M3.9: closing a modified project asks to save it first; the modified mark follows undo
- Quit and the window's close button, File ▸ New Project, Open Project, Open Recent, Close
Project, the demo project and a Home template show Save / Don't Save / Cancel when the
project has unsaved changes (Save asks for a path when untitled; cancelling that keeps the
project open). File ▸ Revert asks to discard. Before, all of them dropped unsaved work
without asking.
- The window title shows the project's path and `*` while it is modified.
- The modified mark follows undo: the session keeps the snapshot it last opened or saved
(`Session::saved_project`), so undoing, jumping in the History panel or rolling back a batch
to the saved state clears it.
- An edit that changes nothing (a value set to what it already is) records no undo step and
doesn't mark the project modified (`Project::same_content`, comparing untouched comps by
pointer).
- Agents' `engine.execute` / MCP calls are never asked; `ui.menu.invoke` shows the prompt like a
click (automation ids `dialog.unsaved.save` / `dontSave` / `revert` / `cancel`), and the
control channel's `app.quit {force: true}` skips it.
- Docs: architecture, agents, control protocol, parity.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
10644a83aa
commit
e0ed28f55d
@@ -298,6 +298,9 @@ pub struct Session {
|
||||
pub history: History,
|
||||
pub revision: u64,
|
||||
pub saved_revision: u64,
|
||||
/// The project as last opened or saved: the project is unmodified while it is this very
|
||||
/// snapshot, so undoing back to the saved state clears the modified mark.
|
||||
pub saved_project: Arc<Project>,
|
||||
pub path: Option<String>,
|
||||
pub state: EditorState,
|
||||
pub services: Arc<dyn Services>,
|
||||
@@ -417,8 +420,10 @@ pub type PluginLoader = fn(&[u8], &str) -> std::result::Result<Value, String>;
|
||||
|
||||
impl Default for Session {
|
||||
fn default() -> Self {
|
||||
let project = Arc::new(Project::default());
|
||||
Session {
|
||||
project: Arc::new(Project::default()),
|
||||
saved_project: project.clone(),
|
||||
project,
|
||||
history: History::default(),
|
||||
revision: 0,
|
||||
saved_revision: 0,
|
||||
@@ -541,6 +546,11 @@ impl Session {
|
||||
self.roto_pending.push(r);
|
||||
}
|
||||
}
|
||||
// Nothing changed (a value set to what it already was): no undo step, not modified.
|
||||
if p.same_content(&before) {
|
||||
self.state = st;
|
||||
return Ok(r);
|
||||
}
|
||||
let same = merge.is_some() && merge.map(str::to_string) == self.history.merge_key;
|
||||
if !same {
|
||||
// Undone steps aren't lost: they stay in the History panel as a branch.
|
||||
@@ -558,6 +568,10 @@ impl Session {
|
||||
|
||||
pub fn bump(&mut self) {
|
||||
self.revision += 1;
|
||||
// Back at the saved state (undo, redo, a history jump or a rolled-back batch).
|
||||
if Arc::ptr_eq(&self.project, &self.saved_project) {
|
||||
self.saved_revision = self.revision;
|
||||
}
|
||||
if self.disk_cache.is_some() {
|
||||
self.layer_cache.set_disk_salt(effectcraft_render::disk_cache::footage_salt(&self.project));
|
||||
}
|
||||
@@ -611,6 +625,12 @@ impl Session {
|
||||
self.revision != self.saved_revision
|
||||
}
|
||||
|
||||
/// The project as it is now is the saved one (after opening or saving it).
|
||||
pub fn mark_saved(&mut self) {
|
||||
self.saved_project = self.project.clone();
|
||||
self.saved_revision = self.revision;
|
||||
}
|
||||
|
||||
pub fn active_comp(&self) -> Option<&Comp> {
|
||||
self.project.comp(self.state.active_comp?)
|
||||
}
|
||||
@@ -840,7 +860,7 @@ impl Session {
|
||||
self.state = EditorState { snapping: true, view_layout: 1, ..Default::default() };
|
||||
self.path = path;
|
||||
self.bump();
|
||||
self.saved_revision = self.revision;
|
||||
self.mark_saved();
|
||||
let first = self.project.comps().next().map(|(id, _)| *id);
|
||||
if let Some(c) = first {
|
||||
self.open_comp(c);
|
||||
|
||||
Reference in New Issue
Block a user