Repository navigation
Conversation
Await debounced and in-flight slide edits through FileOps before save and export. Retain failed commits for retry, guard overlapping saves and stale document completions, and preserve dirty state for edits made during save. Add browser regressions for immediate text/format saves, failures, retries, source replacement, unmount and exports.
pierreneter
reviewed
Nov 18, 2026
pierreneter
left a comment
Member
There was a problem hiding this comment.
Thanks for picking up #18. The lost-edit case itself is fixed, but the commit queue and the save session bring regressions that are worse than the original bug, so I can't merge this as it is. Line numbers are at d98c44e.
Reproduced:
src/react/pptx/PptxEditor.ts:253:commit()now queues a snapshot behind an in-flightsetText, soend()no longer guarantees that the text reaches the worker before the structural op that follows it. With one debounce commit in flight: type more, then delete, move or duplicate a slide. The worker getssetText(A),pptx.slides,setText(B)with the old slide index, so B lands on another slide or throwsNo slide #n. In a collab session the stale index is what gets broadcast.PptxEditor.ts:264: a snapshot that fails stays at the head of the queue and is retried forever. These failures are deterministic (Shape n not found, a collab session inerror), so one failure blocks every later commit, andflush()rejects on every Save, Download, PDF and Print until reload. Before, the failed edit was dropped and Save still worked.src/react/DocViewer.tsx:189: the save session is keyed onopenedandclient, so the live-preview reload of a Markdown / HTML / SVG source counts as a new document.sample.md, Code pane, type, Ctrl+S with anonSaveslower than the 350 ms preview debounce:- dirty is never cleared (
onDirtyChangegives[true], base gives[true, false]); - a rejected
onSaveshows no toast and calls noonError; - the Save button is re-enabled mid-save, so a second click runs
onSavetwice in parallel.
- dirty is never cleared (
DocViewer.tsx:356: the revision is captured before the worker has acknowledged edits that are already posted. XLSX: type a cell, Enter, Ctrl+S before thexlsx.setreply. The saved file contains the edit, but the late reply bumps the revision and the viewer stays dirty. Same for PPTX shape and slide ops.
From reading, not run:
flush()loops onchangedSinceCommit, whichcommit()only clears while a shape is active. I found no UI path into that state today, but if it is reached, Save spins forever on microtasks.- Download original now shares the
savingguard with the host's Save, so each silently cancels the other. - The
catchreturns silently whenever the session is no longer live, which also swallows a realonSaverejection for a document the user has just replaced.
A different shape may be simpler: a pending-work barrier in DocumentClient in front of save and pptx.slide, or committing on each edit as DocxEditor does. That also covers a host that calls client.call('save') itself, which a per-view flush hook does not, and it needs no queue or retry.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Saving immediately after editing slide text could serialize the file before the editor's debounced commit, omitting the latest edit while clearing dirty state. Save now flushes and awaits pending PPTX edits before serialization.
Failed editor commits remain retryable, overlapping saves are guarded, and edits made during a save or in a replacement document retain their dirty state. Original downloads and print/export use the same flush hook.
Fixes #18. This is a standalone fix against
main, separate from the controller formatting feature in #9.Validation with Bun 1.4.4: typecheck, full build, and 540 unit tests passed. Seven save-race browser regressions, ten existing PPTX editing/focus tests, 94 cross-format/menu/permissions/viewer tests, and four source-save compatibility checks passed. The immediate-save regression fails on unchanged
main.