mirror of
https://github.com/storytold/figcraft.git
synced 2026-12-04 19:41:51 -05:00
9087f616d3
* perf: eliminate UI-thread freezes on save, recovery, MCP render, and Local Share * Background save runs file.save's own checks, one save at a time - file.save and the background save share one prepare/write/commit path: branch tabs are synced first, unknown params, another tab holding the file and the overwrite check refuse as file.save does, and a save under a new name leaves the tab saved. - One save at a time: an MCP file.save waits for the save in flight and Save chosen again saves once more after it; a panicking worker ends the save with an error instead of blocking every later one. - The worker writes under the roots the frame ran in (an agent's shortcut). - Only Save in the menu and its shortcut write in the background; other callers (library publish) still save before they go on. - Recovery: a new copy of a document waits for its dropped copy's cleanup, which would otherwise remove it. * Saving again saves the tab it was chosen in; ui.render draws the selection - Save chosen while a save is written is kept per tab and runs for that tab once the write is committed, not for whichever tab is in front by then. - ui.render on a worker picks its layers as file.export does (the ids given, else the selection, else the page): file.export's choice is now one engine function, export_ids, used by both. * Save chosen again keeps the file access roots it was chosen under A Save queued behind the save in flight remembers the roots of the frame that chose it (an agent's shortcut) and runs inside them, not the app's. * Recheck the file right before a save replaces it; recovery cleanup survives a failed spawn - A save remembers its own file's state on disk when its checks passed and refuses to replace it if another app changed it while the new file was written (the background save can take a while). - A dropped recovery copy's cleanup is a guard: if its helper thread can't start, it runs on the calling thread instead of leaving the copy behind. * A revert or a discarding close stops a background save from replacing the file A background save holds a gate while it replaces the file; file.revert and file.close (once it is closing) shut the gates of the tab's saves first, so a save still being written no longer puts back the edits the tab went back on. A save replacing the file at that moment finishes before the revert reads it. --------- Co-authored-by: Jeremy <jeremy8776@googlemail.com>