From efb8e3d6667e9561dc5daa288763da28ebb766c7 Mon Sep 17 00:00:00 2001 From: PuFGGs Date: Sun, 8 Nov 2026 20:19:48 +0000 Subject: [PATCH 1/3] M9: a file joined on a server that keeps it asks for no save A tab in a live session counted every edit, everyone's, as unsaved, so closing a tab joined on figcraft-server or quitting asked to save a copy on this computer. The server already keeps the file: once it confirmed every edit (no batch pending or deferred, the tab's document the synced one), the tab is marked saved. --- crates/engine/src/lib.rs | 2 + crates/engine/src/server_kept_tests.rs | 89 ++++++++++++++++++++++++ crates/engine/src/sharing/live/events.rs | 1 + crates/engine/src/sharing/live/sync.rs | 21 ++++++ docs/server.md | 8 +++ 5 files changed, 121 insertions(+) create mode 100644 crates/engine/src/server_kept_tests.rs diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 6f77e514f..274af5bab 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -606,6 +606,8 @@ mod selection_behaviour_tests; #[cfg(test)] mod selection_depth_tests; #[cfg(test)] +mod server_kept_tests; +#[cfg(test)] mod shape_handles_tests; #[cfg(test)] mod shapebuilder_strokes_tests; diff --git a/crates/engine/src/server_kept_tests.rs b/crates/engine/src/server_kept_tests.rs new file mode 100644 index 000000000..78c304775 --- /dev/null +++ b/crates/engine/src/server_kept_tests.rs @@ -0,0 +1,89 @@ +//! A file joined on a server that keeps it has nothing to save on this computer once the server +//! confirmed all of it: no "Unsaved changes" question when its tab closes or the app quits. + +use std::sync::{Arc, Mutex}; + +use figcraft_collab::message::{ClientMsg, HostInfo, ServerMsg}; +use figcraft_collab::{Client, Limits, Outgoing, Server}; +use figcraft_doc::Document; +use serde_json::json; + +use crate::Session; +use crate::live::{Event, Role}; +use crate::live_tests::{Script, info, peer, push, relay, session}; + +/// You joined "Team file" on a server as a guest: the session, its server and your client id. +fn joined() -> (Session, Arc>, Server, u32) { + let (mut s, script) = session(); + let mut doc = Document::new("Team file"); + doc.repair(); + let mut server = Server::new(doc, "", Limits::default()); + let ClientMsg::Hello(h) = Client::hello("f", "", "Me", "") else { panic!("no hello") }; + let (me, outs) = server.join(h).unwrap(); + let Some(Outgoing::To(_, w)) = outs.into_iter().find(|o| matches!(o, Outgoing::To(_, ServerMsg::Welcome { .. }))) else { panic!("no welcome") }; + s.execute("collab.join", &json!({"link": "figcraft://join?host=a:1&file=f&token=t"})).unwrap(); + push(&script, vec![Event::Welcome { info: info(Role::Guest, me), peers: vec![peer(1, "Hana")] }, Event::Sync(w)]); + s.live_poll(); + assert_eq!(s.doc().unwrap().name, "Team file"); + (s, script, server, me) +} + +/// Draw a rectangle and let the server confirm it. +fn edit_and_confirm(s: &mut Session, script: &Arc>, server: &mut Server, me: u32) { + s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap(); + s.live_sync(); + assert!(s.ds().unwrap().is_dirty(), "an edit the server hasn't confirmed is unsaved"); + push(script, relay(script, server, me)); + s.live_poll(); +} + +#[test] +fn a_file_the_server_keeps_has_nothing_to_save_once_confirmed() { + let (mut s, script, mut server, me) = joined(); + push(&script, vec![Event::Hosting(HostInfo::default())]); + s.live_poll(); + assert!(!s.ds().unwrap().is_dirty(), "joining a kept file asks for no save"); + edit_and_confirm(&mut s, &script, &mut server, me); + assert!(!s.ds().unwrap().is_dirty(), "the server has every edit"); + // Someone else's edit is on the server too. + let ClientMsg::Hello(h) = Client::hello("f", "", "Ada", "") else { panic!("no hello") }; + let (ada, outs) = server.join(h).unwrap(); + let Some(Outgoing::To(_, w)) = outs.into_iter().find(|o| matches!(o, Outgoing::To(_, ServerMsg::Welcome { .. }))) else { panic!("no welcome") }; + let mut other = Client::join(w).unwrap(); + let mut doc = other.document().clone(); + doc.name = "Renamed".into(); + let batch = other.edit(&doc).unwrap().unwrap(); + let remote: Vec = + server.receive(ada, batch).into_iter().filter_map(|o| if let Outgoing::All(m) = o { Some(Event::Sync(m)) } else { None }).collect(); + push(&script, remote); + s.live_poll(); + assert_eq!(s.doc().unwrap().name, "Renamed"); + assert!(!s.ds().unwrap().is_dirty()); +} + +#[test] +fn a_session_an_app_hosts_still_asks() { + // No hosting info: an app hosts the session, and nothing keeps the file once it leaves. + let (mut s, script, mut server, me) = joined(); + edit_and_confirm(&mut s, &script, &mut server, me); + assert!(s.ds().unwrap().is_dirty()); +} + +#[test] +fn a_file_that_expires_unopened_still_asks() { + let (mut s, script, mut server, me) = joined(); + push(&script, vec![Event::Hosting(HostInfo { open: true, expires: Some(4_102_444_800), ..HostInfo::default() })]); + s.live_poll(); + edit_and_confirm(&mut s, &script, &mut server, me); + assert!(s.ds().unwrap().is_dirty(), "a public server keeps no backups: keep a copy"); +} + +#[test] +fn a_tab_with_a_file_of_its_own_still_asks() { + let (mut s, script, mut server, me) = joined(); + push(&script, vec![Event::Hosting(HostInfo::default())]); + s.live_poll(); + s.ds_mut().unwrap().path = Some("team.figcraft".into()); + edit_and_confirm(&mut s, &script, &mut server, me); + assert!(s.ds().unwrap().is_dirty(), "the file on this computer is behind"); +} diff --git a/crates/engine/src/sharing/live/events.rs b/crates/engine/src/sharing/live/events.rs index d78568e8e..b52fc3203 100644 --- a/crates/engine/src/sharing/live/events.rs +++ b/crates/engine/src/sharing/live/events.rs @@ -154,6 +154,7 @@ impl Session { for id in self.live.sessions.keys().copied().collect::>() { self.live_deferred(id); self.live_follow_apply(id); + self.live_kept(id); } self.online_recoveries(); true diff --git a/crates/engine/src/sharing/live/sync.rs b/crates/engine/src/sharing/live/sync.rs index cb05f252e..558ff9007 100644 --- a/crates/engine/src/sharing/live/sync.rs +++ b/crates/engine/src/sharing/live/sync.rs @@ -251,6 +251,27 @@ impl Session { live.followed = Some(FollowedView { page: ds.page, cx: ds.view.cx, cy: ds.view.cy, zoom: ds.view.zoom }); } + /// Session `id`'s file is kept by a server that never deletes it, and the server confirmed all + /// of it: a tab with no file of its own on this computer then has nothing to save, so closing + /// it or quitting doesn't ask. Not for a session an app hosts (nothing keeps it once the host + /// leaves), a file that expires unopened (a public server keeps no backups), versions or a + /// local file the tab has (they stay on this computer), or edits the server hasn't confirmed. + pub(super) fn live_kept(&mut self, id: SessionId) { + let Some(live) = self.live.get(id) else { return }; + let kept = live.status == Status::Live && live.hosting.as_ref().is_some_and(|h| h.expires.is_none()); + let confirmed = live.client.as_ref().is_some_and(|c| c.pending() == 0) && live.deferred.is_empty() && live.hold == 0; + let (Some(uid), Some(synced)) = (live.doc_uid, live.synced.clone()) else { return }; + if !kept || !confirmed { + return; + } + if let Some(ds) = self.docs.iter_mut().find(|d| d.uid == uid && d.path.is_none() && d.branch_of.is_none() && !d.versions_changed) + && Arc::ptr_eq(ds.document_itself(), &synced) + && ds.is_dirty() + { + ds.mark_saved(); + } + } + /// Sessions whose tab was closed end (hosts stop hosting, guests leave); the others go on. A /// join still on its way from a closed tab shows on the one in front. pub(super) fn live_closed(&mut self) { diff --git a/docs/server.md b/docs/server.md index 8e97c2174..4133336d5 100644 --- a/docs/server.md +++ b/docs/server.md @@ -222,6 +222,14 @@ comment link's batch only when every change in it touches comment threads. An ap comment links joins with one as a viewer. **Leave session** keeps the file open as your own copy, editable again. +The server keeps the file, so a tab joined there has nothing to save on your computer once the +server has confirmed every edit in it: closing the tab or quitting doesn't ask to save it, and the +tab shows no unsaved mark. It still asks while an edit of yours hasn't reached the server (offline, +say), for a file that expires unopened (a [public server](#running-a-public-server) keeps no +backups: keep a copy of your own), for a tab saved to a file on this computer (that file would be +behind), for versions you made in the tab (they live only on this computer), and in a session a +desktop app hosts on the local network (nothing keeps that file once the host leaves). + ## Team libraries A file on the server can hold a **team library**: its published components, styles and variables, From 7ddc533dd1175eef09529244a408011a737b0a86 Mon Sep 17 00:00:00 2001 From: Mikael Weiss Date: Sat, 28 Nov 2026 10:00:03 -0700 Subject: [PATCH 2/3] fix: keep server-kept tabs clean across previews During a version or text preview, ds.doc is the temporary preview while document_itself() holds the underlying synced document, so mark_saved() recorded the wrong baseline and version.exitPreview re-normalised the restored document off saved_doc. Recording synced directly, skipping re-normalisation on version.exitPreview, and rechecking live_kept in live_sync_in after deferred batches or holds clear keeps confirmed server-kept tabs clean. --- crates/engine/src/server_kept_tests.rs | 124 ++++++++++++++++++++++++- crates/engine/src/session/exec.rs | 7 +- crates/engine/src/sharing/live/sync.rs | 10 +- docs/collaboration-parity.md | 3 +- docs/server.md | 14 +-- 5 files changed, 140 insertions(+), 18 deletions(-) diff --git a/crates/engine/src/server_kept_tests.rs b/crates/engine/src/server_kept_tests.rs index 78c304775..1f9779078 100644 --- a/crates/engine/src/server_kept_tests.rs +++ b/crates/engine/src/server_kept_tests.rs @@ -9,7 +9,7 @@ use figcraft_doc::Document; use serde_json::json; use crate::Session; -use crate::live::{Event, Role}; +use crate::live::{Event, Role, Status}; use crate::live_tests::{Script, info, peer, push, relay, session}; /// You joined "Team file" on a server as a guest: the session, its server and your client id. @@ -28,10 +28,13 @@ fn joined() -> (Session, Arc>, Server, u32) { (s, script, server, me) } -/// Draw a rectangle and let the server confirm it. +/// Draw a rectangle, confirm it stays dirty across a poll while pending, then let the server confirm it. fn edit_and_confirm(s: &mut Session, script: &Arc>, server: &mut Server, me: u32) { s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap(); s.live_sync(); + // An unrelated event while the batch is still pending must not clear the unsaved mark. + push(script, vec![Event::PeerJoined(peer(1, "Hana"))]); + s.live_poll(); assert!(s.ds().unwrap().is_dirty(), "an edit the server hasn't confirmed is unsaved"); push(script, relay(script, server, me)); s.live_poll(); @@ -70,12 +73,12 @@ fn a_session_an_app_hosts_still_asks() { } #[test] -fn a_file_that_expires_unopened_still_asks() { +fn a_file_with_an_expiry_time_still_asks() { let (mut s, script, mut server, me) = joined(); push(&script, vec![Event::Hosting(HostInfo { open: true, expires: Some(4_102_444_800), ..HostInfo::default() })]); s.live_poll(); edit_and_confirm(&mut s, &script, &mut server, me); - assert!(s.ds().unwrap().is_dirty(), "a public server keeps no backups: keep a copy"); + assert!(s.ds().unwrap().is_dirty(), "a server that expires the file keeps no backups"); } #[test] @@ -87,3 +90,116 @@ fn a_tab_with_a_file_of_its_own_still_asks() { edit_and_confirm(&mut s, &script, &mut server, me); assert!(s.ds().unwrap().is_dirty(), "the file on this computer is behind"); } + +#[test] +fn a_tab_with_changed_versions_still_asks() { + let (mut s, script, mut server, me) = joined(); + push(&script, vec![Event::Hosting(HostInfo::default())]); + s.live_poll(); + s.execute("file.saveVersion", &json!({"name": "Local snapshot"})).unwrap(); + edit_and_confirm(&mut s, &script, &mut server, me); + assert!(s.ds().unwrap().is_dirty(), "versions live only in the local file"); + assert!(s.ds().unwrap().versions_changed); +} + +#[test] +fn a_branch_tab_still_asks() { + let (mut s, script, mut server, me) = joined(); + push(&script, vec![Event::Hosting(HostInfo::default())]); + s.live_poll(); + s.ds_mut().unwrap().branch_of = Some((999, "b1".into())); + edit_and_confirm(&mut s, &script, &mut server, me); + assert!(s.ds().unwrap().is_dirty(), "branch tabs are excluded from live_kept"); +} + +#[test] +fn an_unsynced_local_edit_stays_unsaved_when_polling() { + let (mut s, script, _server, _me) = joined(); + push(&script, vec![Event::Hosting(HostInfo::default())]); + s.live_poll(); + assert!(!s.ds().unwrap().is_dirty()); + // Edit locally without calling live_sync(): pending() is 0, but document_itself() != synced. + s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap(); + push(&script, vec![Event::PeerJoined(peer(1, "Hana"))]); + s.live_poll(); + assert!(s.ds().unwrap().is_dirty(), "local edit not yet sent to the sync client must stay unsaved"); +} + +#[test] +fn confirming_during_a_version_preview_marks_the_document_saved() { + let (mut s, script, mut server, me) = joined(); + s.execute("file.saveVersion", &json!({"name": "Earlier"})).unwrap(); + // Simulate a version already saved before this edit so only the preview baseline is tested. + s.ds_mut().unwrap().versions_changed = false; + // Confirm the edit before hosting info arrives so the tab is still dirty entering the preview. + edit_and_confirm(&mut s, &script, &mut server, me); + assert!(s.ds().unwrap().is_dirty()); + s.execute("version.preview", &json!({"index": 0})).unwrap(); + assert!(s.ds().unwrap().preview.is_some()); + push(&script, vec![Event::Hosting(HostInfo::default())]); + s.live_poll(); + assert!(!s.ds().unwrap().is_dirty(), "confirmed underlying document is saved during a version preview"); + s.execute("version.exitPreview", &json!({})).unwrap(); + assert!(!s.ds().unwrap().is_dirty(), "document stays saved after ending a version preview"); +} + +#[test] +fn confirming_during_a_text_preview_marks_the_document_saved() { + let (mut s, script, mut server, me) = joined(); + let text = s.execute("text.create", &json!({"text": "Preview"})).unwrap()["id"].clone(); + s.live_sync(); + push(&script, relay(&script, &mut server, me)); + s.live_poll(); + assert!(s.ds().unwrap().is_dirty()); + s.execute("text.preview", &json!({"command": "text.style", "params": {"ids": [text], "fontSize": 32}})).unwrap(); + assert!(s.ds().unwrap().text_preview.is_some()); + push(&script, vec![Event::Hosting(HostInfo::default())]); + s.live_poll(); + assert!(!s.ds().unwrap().is_dirty(), "confirmed underlying document is saved during a text preview"); + s.execute("text.endPreview", &json!({})).unwrap(); + assert!(!s.ds().unwrap().is_dirty(), "document stays saved after ending a text preview"); +} + +#[test] +fn a_deferred_confirmation_stays_unsaved_until_applied_after_preview() { + let (mut s, script, mut server, me) = joined(); + push(&script, vec![Event::Hosting(HostInfo::default())]); + s.live_poll(); + let text = s.execute("text.create", &json!({"text": "Deferred"})).unwrap()["id"].clone(); + s.live_sync(); + // Start a text preview before the server echoes the batch so the confirmation is deferred. + s.execute("text.preview", &json!({"command": "text.style", "params": {"ids": [text], "fontSize": 28}})).unwrap(); + push(&script, relay(&script, &mut server, me)); + s.live_poll(); + assert!(s.ds().unwrap().is_dirty(), "deferred confirmation must not clear the unsaved mark yet"); + // Ending the preview lets live_sync() apply the deferred batch with no further network events. + s.execute("text.endPreview", &json!({})).unwrap(); + s.live_sync(); + assert!(!s.ds().unwrap().is_dirty(), "applying the deferred confirmation clears the unsaved mark"); +} + +#[test] +fn a_held_session_stays_unsaved_until_released() { + let (mut s, script, mut server, me) = joined(); + let uid = s.ds().unwrap().uid; + edit_and_confirm(&mut s, &script, &mut server, me); + assert!(s.ds().unwrap().is_dirty()); + s.live_hold(uid, true); + push(&script, vec![Event::Hosting(HostInfo::default())]); + s.live_poll(); + assert!(s.ds().unwrap().is_dirty(), "a held session must stay unsaved"); + s.live_hold(uid, false); + s.live_sync(); + assert!(!s.ds().unwrap().is_dirty(), "releasing the hold allows the confirmed tab to become saved"); +} + +#[test] +fn a_disconnected_session_stays_unsaved_even_with_hosting_info() { + let (mut s, script, mut server, me) = joined(); + edit_and_confirm(&mut s, &script, &mut server, me); + assert!(s.ds().unwrap().is_dirty()); + // Hosting info arrives while reconnecting (not Status::Live). + push(&script, vec![Event::Status(Status::Reconnecting { attempt: 1 }), Event::Hosting(HostInfo::default())]); + s.live_poll(); + assert!(s.ds().unwrap().is_dirty(), "a non-live session must stay unsaved"); +} diff --git a/crates/engine/src/session/exec.rs b/crates/engine/src/session/exec.rs index 0e6f899a5..25fa2b6cf 100644 --- a/crates/engine/src/session/exec.rs +++ b/crates/engine/src/session/exec.rs @@ -237,9 +237,10 @@ impl Session { let Some((bdoc, _, _, uid)) = before else { return }; let deletes = spec.id == "edit.delete" || (spec.id == "edit.repeat" && self.last_command.as_ref().is_some_and(|(id, _)| id == "edit.delete")); let Some(ds) = self.docs.iter_mut().find(|d| d.uid == *uid) else { return }; - // Saving may adopt the chosen filename as the document title. The encoded snapshot is - // already final; normalising it again would detach it from the saved baseline. - if !Arc::ptr_eq(&ds.doc, bdoc) && !matches!(spec.id, "file.save" | "file.saveAs") { + // Saving may adopt the chosen filename as the document title, and exiting a version + // preview only restores the already-normalised document; normalising either again would + // detach it from the saved baseline. + if !Arc::ptr_eq(&ds.doc, bdoc) && !matches!(spec.id, "file.save" | "file.saveAs" | "version.exitPreview") { normalize(ds.doc_mut(), bdoc); if deletes { cmd::edit::report_orphaned_instances(result, bdoc, &ds.doc); diff --git a/crates/engine/src/sharing/live/sync.rs b/crates/engine/src/sharing/live/sync.rs index 558ff9007..97d036557 100644 --- a/crates/engine/src/sharing/live/sync.rs +++ b/crates/engine/src/sharing/live/sync.rs @@ -251,11 +251,12 @@ impl Session { live.followed = Some(FollowedView { page: ds.page, cx: ds.view.cx, cy: ds.view.cy, zoom: ds.view.zoom }); } - /// Session `id`'s file is kept by a server that never deletes it, and the server confirmed all + /// Session `id`'s file is kept by a server that never expires it, and the server confirmed all /// of it: a tab with no file of its own on this computer then has nothing to save, so closing /// it or quitting doesn't ask. Not for a session an app hosts (nothing keeps it once the host - /// leaves), a file that expires unopened (a public server keeps no backups), versions or a - /// local file the tab has (they stay on this computer), or edits the server hasn't confirmed. + /// leaves), a file with an expiry time (a public server keeps no backups), a branch tab, + /// versions or a local file the tab has (they stay on this computer), or edits that are + /// unconfirmed, deferred or held. pub(super) fn live_kept(&mut self, id: SessionId) { let Some(live) = self.live.get(id) else { return }; let kept = live.status == Status::Live && live.hosting.as_ref().is_some_and(|h| h.expires.is_none()); @@ -268,7 +269,7 @@ impl Session { && Arc::ptr_eq(ds.document_itself(), &synced) && ds.is_dirty() { - ds.mark_saved(); + ds.saved_doc = synced; } } @@ -318,6 +319,7 @@ impl Session { self.live_branches_sync(uid); } self.live_present(id); + self.live_kept(id); } } diff --git a/docs/collaboration-parity.md b/docs/collaboration-parity.md index 0cc5b37e6..54bc1d687 100644 --- a/docs/collaboration-parity.md +++ b/docs/collaboration-parity.md @@ -1,6 +1,6 @@ # Collaboration parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-28 · **Change:** minor (`wss://` connections also trust the authorities in the operating system's certificate store, so a private authority added there works without `FIGCRAFT_CA_FILE` (#2342); legacy welcomes without a reconnect secret are accepted with their explicit access level, and reconnects re-authenticate with the share link (#2365); a shared file's opening page can be set (`page.setOpening`, Set as opening page in the pages list) and syncs to everyone who joins afterwards (#1817); shared branches sync across live sessions and survive `figcraft-server` restarts, capability-gated on `branches`; numbers unchanged) · **Target:** Figma Design (desktop app 126.10.7); M9: a joined live session reconnects until you leave and says when it is disconnected, and joining it again merges what you did while disconnected; ; a file shared on the local network can be shared to look at only: a view-only code next to the edit code, picked in the Share popover before or while sharing) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-28 · **Change:** minor (a file joined on a server that keeps it no longer shows an unsaved mark or asks to be saved once every edit is confirmed; `wss://` connections also trust the authorities in the operating system's certificate store, so a private authority added there works without `FIGCRAFT_CA_FILE` (#2342); legacy welcomes without a reconnect secret are accepted with their explicit access level, and reconnects re-authenticate with the share link (#2365); a shared file's opening page can be set (`page.setOpening`, Set as opening page in the pages list) and syncs to everyone who joins afterwards (#1817); shared branches sync across live sessions and survive `figcraft-server` restarts, capability-gated on `branches`; numbers unchanged) · **Target:** Figma Design (desktop app 126.10.7); M9: a joined live session reconnects until you leave and says when it is disconnected, and joining it again merges what you did while disconnected; ; a file shared on the local network can be shared to look at only: a view-only code next to the edit code, picked in the Share popover before or while sharing) Figma is multiplayer first; FigCraft is local first. **Ready ~13% (estimated):** comments, version history and branches (review and merge) work inside one file; the real-time collaboration core landed in #103 (sync model, @@ -27,6 +27,7 @@ cursors, selections, text carets, cursor chat and spotlights shown live ([`colla | Date | Change | Summary | |---|---|---| +| 2026-11-28 | minor | M9: a file joined on a server that keeps it (hosting info reports no expiry) has nothing to save on this computer once the server has confirmed every edit and no batch is deferred or held: closing its tab or quitting no longer asks to save it, and the tab shows no unsaved mark. Recording `synced` as the saved baseline preserves the clean state across version and text previews, and `live_sync_in` also rechecks after applying deferred batches or releasing holds. Still asks while an edit is unconfirmed, deferred or held, for a file with an expiry time, on servers older than hosting info, for branch tabs, for a tab saved to a local file or with changed versions, and in an app-hosted session. Tests: `engine::server_kept_tests`. Numbers unchanged. | | 2026-11-28 | minor | #2342: the desktop app and `figcraft-cli` checked a `wss://` server's certificate against the compiled-in public roots and `FIGCRAFT_CA_FILE` only, so a server behind a proxy with a private authority needed that variable on every computer, which a signed desktop app started from the dock or the start menu doesn't see. They now also trust the authorities in the operating system's certificate store, read once per process, so adding the private authority to the computer's trusted certificates is enough. `FIGCRAFT_NO_SYSTEM_ROOTS=1` leaves the store out. Certificates are still always verified; an unknown authority's error names both ways to trust it. Not tested against a real private authority in the store here. | | 2026-11-28 | patch | M9, #2495: Stop sharing failed on a private server for a file shared with the server key typed under Advanced ("that owner token doesn't manage a file of that id here"). Such a file has no owner token, and the key went only with the publish. `collab.share {key}` now keeps the key with the share in this session, in the address as `collab.share {server: "…?key=…"}` would give it, so Stop sharing and sharing again ask as the server's operator. The key is never in a command result. Test: `live_share_tests::stopping_a_file_shared_with_a_separate_key_asks_with_that_key`. Numbers unchanged | | 2026-11-26 | minor | M10, gap 17: shared branches sync across live sessions. Capability-gated on `branches` in `Hello::client_version` (`ServerMsg::Branches` / `Branch`, `ClientMsg::Branch` with `Create`, `Edit`, `UpdateFromMain`, `SetState`), persisted in `SessionState::branches` and the server journal (with fallback decoding for pre-branch `figcraft-server` snapshots). Any editor can open, co-edit, update from main, review, archive and merge another peer's branch (remote merges/archives close open branch tabs on peers and switch back to main); view and comment links are refused; node/entry id spaces, geometry and image entries are validated on every branch mutation; older clients and servers stay compatible (local-only branches). Tests: `collab::branch_tests`, `engine::branch_live_tests`, `figcraft-server::server_tests::shared_branches_sync_and_survive_a_server_restart`, `figcraft-server::disk::tests::decode_snapshot_reads_pre_branch_v1_snapshots`. Numbers unchanged. | diff --git a/docs/server.md b/docs/server.md index 4133336d5..63d19b724 100644 --- a/docs/server.md +++ b/docs/server.md @@ -223,12 +223,14 @@ comment links joins with one as a viewer. **Leave session** keeps the file open editable again. The server keeps the file, so a tab joined there has nothing to save on your computer once the -server has confirmed every edit in it: closing the tab or quitting doesn't ask to save it, and the -tab shows no unsaved mark. It still asks while an edit of yours hasn't reached the server (offline, -say), for a file that expires unopened (a [public server](#running-a-public-server) keeps no -backups: keep a copy of your own), for a tab saved to a file on this computer (that file would be -behind), for versions you made in the tab (they live only on this computer), and in a session a -desktop app hosts on the local network (nothing keeps that file once the host leaves). +server has confirmed every edit in it and no batch is deferred or held (during a preview, gesture +or command group): closing the tab or quitting doesn't ask to save it, and the tab shows no unsaved +mark. It still asks while an edit of yours hasn't reached the server (offline, say) or a batch is +deferred or held, for a file with an expiry time (a [public server](#running-a-public-server) keeps +no backups: keep a copy of your own), for a server older than hosting info (it never reports +whether the file expires), for a tab saved to a file on this computer (that file would be behind), +for branch tabs, for versions you made in the tab (they live only on this computer), and in a +session a desktop app hosts on the local network (nothing keeps that file once the host leaves). ## Team libraries From 5370cfc60269fa2f1318961e1834a08c2634c302 Mon Sep 17 00:00:00 2001 From: Mikael Weiss Date: Sat, 28 Nov 2026 13:17:21 -0700 Subject: [PATCH 3/3] test: isolate unsynced edit guard in live_kept Mutate the document directly via ds_mut() instead of execute() so live_edit() does not run, assert pending() == 0, and verify saved_doc stays unchanged across live_poll(). --- crates/engine/src/server_kept_tests.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/crates/engine/src/server_kept_tests.rs b/crates/engine/src/server_kept_tests.rs index 1f9779078..b41dfbeb3 100644 --- a/crates/engine/src/server_kept_tests.rs +++ b/crates/engine/src/server_kept_tests.rs @@ -114,15 +114,17 @@ fn a_branch_tab_still_asks() { #[test] fn an_unsynced_local_edit_stays_unsaved_when_polling() { - let (mut s, script, _server, _me) = joined(); + let (mut s, script, mut server, me) = joined(); + // Confirm an edit before hosting arrives so saved_doc differs from synced. + edit_and_confirm(&mut s, &script, &mut server, me); + let saved_before = s.ds().unwrap().saved_doc.clone(); + // Mutate the document directly without running live_edit(): pending() stays 0, but document_itself() != synced. + s.ds_mut().unwrap().doc_mut().name = "Local draft".into(); + assert_eq!(s.live().client().unwrap().pending(), 0); push(&script, vec![Event::Hosting(HostInfo::default())]); s.live_poll(); - assert!(!s.ds().unwrap().is_dirty()); - // Edit locally without calling live_sync(): pending() is 0, but document_itself() != synced. - s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap(); - push(&script, vec![Event::PeerJoined(peer(1, "Hana"))]); - s.live_poll(); assert!(s.ds().unwrap().is_dirty(), "local edit not yet sent to the sync client must stay unsaved"); + assert!(Arc::ptr_eq(&s.ds().unwrap().saved_doc, &saved_before), "unsynced local edit must not advance saved_doc"); } #[test]