Skip to content

P0 mac: Export PDF works with unsaved edits (and says why when it can't); autosave saves every edited file - #776

Merged
d-q222 merged 4 commits into
mainfrom
integration/2026-09-17-export-incident
Sep 17, 2026
Merged

d-q222 merged 4 commits into
mainfrom
integration/2026-09-17-export-incident

Conversation

@d-q222

@d-q222 d-q222 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

P0: Export PDF fails silently with unsaved edits, and autosave doesn't save

The owner reported: "if the file is unsaved, it doesn't export … Export works fine if (all) files are saved, otherwise the export fails silently. Also, the autosave isn't working."

Export: root cause (reproduced by a failing test first)

  • The default worker is flashtex-render, and the app requests display-list-v2-delta. After an edit, the preview frame is rebuilt from a display_list_delta.
  • exportListURL() treated every unwindowed frame as a complete list. It wrote the raw delta line to a file and handed it to flashtex-pdf-exact, which refused it with error: type "display_list_delta" is not display_list.
  • That refusal only reached the status line. A guard … else { return } in exportPDF() returned with no message at all.

Fix:

  • A delta-built frame now goes through the existing whole-document re-render, the path windowed frames already use. It renders the current buffers, so what you see is what you export, and nothing is saved.
  • Every export failure now raises an alert as well as setting the status line.
  • The shipped .app bundles flashtex-render next to the executable, and locateRenderPipeline finds it there.

Autosave: root causes

  1. Other project files never autosaved: the scheduler required the active tab to be the entry document.
  2. Switching tabs within 2 s dropped the pending save.
  3. An edit in one document cancelled another document's pending save.

Fix: any edit re-arms one shared timer. When it fires, every dirty, file-backed document is saved through the same conflict-checked path ⌘S uses. It never opens a panel. A file changed on disk is still refused.

Verification (combined tree 81960ff4)

  • swift build --build-tests: clean.
  • New tests: ExportUnsavedBufferTests (fails before the fix with the exit-1 delta refusal) and 3 new AutosaveTests (2 fail before the fix). All pass after.
  • Filtered run against real flashtex-pdf-exact and flashtex-render, covering Autosave, Export, ExportSession, PrintController, PDFExport, DisplayListDelta, ProjectDocuments, DocumentKinds and EditorPreferences: 111 tests, 0 failures.
  • Full Mac suite under /tmp/ftgate.lock, with preview-controller and compiler binaries set so the helper-route tests run: results to follow in a comment.

Attribution

  • Export fix: Claude Opus 5 subagent of daniel-parent (faf0a997).
  • Autosave fix: Claude Opus 5 subagent of daniel-parent (1d5bc616).
  • Integration and review: daniel-parent (Commander).

🤖 Generated with Claude Code

https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz

d-q222 and others added 4 commits September 16, 2026 19:32
…ntry

Owner report: "the autosave isn't working." Autosave was scoped to the
entry document while it is active:

- scheduleAutosave/performAutosave guarded activePath == entryPath, so
  project members (chapters opened from the sidebar) never autosaved;
- performAutosave re-checked activePath when the timer fired, so switching
  tabs within the 2 s debounce silently dropped the entry's pending save;
- an edit in any other document cancelled the pending work item before
  the guard returned, dropping the entry's save as well.

The shared timer now saves every dirty document when it fires, each
through its existing conflict-checked save (saveTex's write for the entry
via new saveEntryTex, controllerSave when the controller routes the file,
project.saveDocument/saveDocumentNow for members). No panels; a document
with an outstanding conflict is skipped; untitled buffers are never
touched. flushPendingAutosave now runs only a scheduled save, so tests go
through the same schedule path typing does.

Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…ncident

Autosave saves every dirty, file-backed document through the conflict-checked
save path; switching tabs or editing another document no longer drops a pending
save.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent (Commander)
Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…res alert

Export of a document with unsaved edits failed: after the first full frame,
every edit's preview arrives as a display_list_delta that the app reconstructs
in memory, but exportListURL() handed the raw delta line to flashtex-pdf-exact,
which refuses it (`type "display_list_delta" is not display_list`). The refusal
only reached the status line, so the export looked silent.

- exportListURL(): a frame whose live line is a delta is re-rendered whole
  from the current buffers through the render pipeline, like a windowed frame.
- exportPDFRefusal(): refuses delta frames with a clear reason when no render
  pipeline is available.
- exportPDF(): every refusal/failure (including the previously silent guard)
  sets the status line and shows an alert.
- ExportUnsavedBufferTests: real flashtex-render + flashtex-pdf-exact, saved
  export, unsaved entry and member edits, asserts the delta shape and the
  unsaved text in the PDF.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent subagent
Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
…ncident

Export PDF with unsaved edits: a preview frame rebuilt from a display_list_delta
is re-rendered as a whole document from the current buffers instead of handing
the raw delta line to flashtex-pdf-exact (which refused it). Export failures now
raise an alert as well as the status line.

Implementation-Agent: claude-opus-5 subagent of daniel-parent
Commit-Executor: daniel-parent (Commander)
Co-authored-by: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_012c9XLkHjePPGBuarrmE2mz
@d-q222
d-q222 merged commit 81960ff into main Sep 17, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant