Skip to content

fix(viewer): no overlapping saves, Ctrl+S saves wherever the focus is - #459

Merged
AndyScherzinger merged 2 commits into
mainfrom
fix/viewer-save-hotkey
Oct 27, 2026
Merged

AndyScherzinger merged 2 commits into
mainfrom
fix/viewer-save-hotkey

Conversation

@AndyScherzinger

Copy link
Copy Markdown
Member

Two save fixes in the editor, taken from the analysis of #259 (thanks @stephancordes for the diagnosis).

  • No overlapping saves. Autosave runs every 10 seconds next to the save button and Ctrl+S. When two saves overlapped, the second request still carried the old mtime and failed with "The file you are working on was updated in the meantime", although nobody else had touched the file. A save requested while one is running now waits and runs afterwards, so a pending close still gets its answer. The map is marked unchanged when the request goes out and changed again if it fails, so edits made during a save are no longer lost.
  • Ctrl+S wherever the focus is. Inside the editor, Ctrl+S is now handled in the capture phase (the editor's own key handlers could swallow it) and checks event.key instead of the deprecated event.which. With the focus outside the editor iframe, for example on the viewer header, Ctrl+S opened the browser's save dialog; the viewer element now catches it while it is shown and asks the editor to save.

Unlike #259, the parent-side handler doesn't pull a logger into the init script, which runs on every page.

Checked: unit tests (117 passing, 3 new for the viewer element's Ctrl+S), lint, production build. Not yet tested on a live instance.

The 0.1.x backport follows in a separate PR, with the Ctrl+S handling adapted to the Vue component used there.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (N/A)

Autosave runs every 10 seconds next to the save button and Ctrl+S. When
two saves overlapped, the second request still carried the old mtime and
failed with "The file you are working on was updated in the meantime",
although nobody else had touched the file.

A save requested while one is running now waits for it and runs
afterwards, so edits made in between are saved as well and a pending
close still gets its answer. The map is marked unchanged when the
request goes out and changed again when it fails, so edits made during
a save are no longer lost.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Inside the editor, Ctrl+S was handled in the bubble phase, where the
editor's own key handlers could swallow it first. It is now handled in
the capture phase and checks event.key instead of the deprecated
event.which.

With the focus outside the editor iframe, for example on the viewer's
header, Ctrl+S opened the browser's save dialog. The viewer element now
catches it while it is shown and asks the editor to save.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
@AndyScherzinger AndyScherzinger added this to the v0.2.0 milestone Oct 27, 2026
@AndyScherzinger AndyScherzinger added bug Something isn't working AI assisted This PR contains AI-assisted commits 3. to review labels Oct 27, 2026
@AndyScherzinger
AndyScherzinger merged commit 50b27e8 into main Oct 27, 2026
8 checks passed
@AndyScherzinger
AndyScherzinger deleted the fix/viewer-save-hotkey branch October 27, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review AI assisted This PR contains AI-assisted commits bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant