Repository navigation
fix(plugins): hand over pending custom-editor edits before closing or reloading - #37278
Conversation
Findings
|
There was a problem hiding this comment.
Actionable comments posted: 2

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
a1a8dbfe-cc9d-4077-bd48-b2e3a6b25210
Files selected for processing: 10-
src/renderer/src/components/editor/PluginCustomEditorFrame.test.tsxsrc/renderer/src/components/editor/PluginCustomEditorFrame.tsxsrc/renderer/src/components/editor/editor-pending-flush.test.tssrc/renderer/src/components/editor/editor-pending-flush.tssrc/renderer/src/components/editor/plugin-custom-editor-host.test.tssrc/renderer/src/components/editor/plugin-custom-editor-host.tssrc/renderer/src/components/editor/use-custom-editor-reload-flush.tssrc/renderer/src/components/tab-group/workspace-tab-close-commands.tssrc/renderer/src/components/use-terminal-bulk-close-actions.tssrc/renderer/src/components/use-terminal-editor-close-queue.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
-
| close(false) | ||
| return | ||
| } | ||
| void Promise.all([...flushes].map((flush) => flush().catch(() => false))).then(() => close(true)) |
There was a problem hiding this comment.
Do not close a clean file after a failed frame flush.
If a frame has an unsent debounced edit and does not answer editor.flush, the flush returns false on timeout. This callback discards that result. The subsequent dirty check can see a clean buffer and close the frame without a prompt, losing the edit. Pass the failure to close callers so they can keep the affected file open or obtain explicit confirmation. (raw.githubusercontent.com)
| const latest = useAppStore.getState() | ||
| if (needsSavePromptOnClose(latest, fileId)) { |
There was a problem hiding this comment.
Recheck pinned status after the flush.
If the user pins the file while its frame flush is pending, the earlier pinned check no longer describes the file’s state. This callback still closes the newly pinned file. Recheck isPinnedActiveEditorTab against latest before the dirty check or closeFile. (raw.githubusercontent.com)
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ddd63c01-f644-459d-89b1-87df82e9e2b8
Files selected for processing: 10-
src/renderer/src/components/editor/EditorPanel.custom-editor-flush.test.tsxsrc/renderer/src/components/editor/EditorPanel.tsxsrc/renderer/src/components/editor/PluginCustomEditorFrame.test.tsxsrc/renderer/src/components/editor/editor-pending-flush.test.tssrc/renderer/src/components/editor/editor-pending-flush.tssrc/renderer/src/components/sidebar/RemovalUnsavedFilesNotice.tsxsrc/renderer/src/components/tab-group/workspace-tab-close-commands.tssrc/renderer/src/components/use-terminal-bulk-close-actions.tssrc/renderer/src/components/use-terminal-editor-close-queue.tssrc/renderer/src/components/use-terminal-window-lifecycle.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
-
Closing a custom-editor tab or reloading its frame tore the frame down without asking for edits still in its debounce window. Close paths now send editor.flush (bounded by the existing 1 s deadline) and run the dirty check once it settles; a reload keeps the old document mounted until its flush settles. Read-only, windowless and dead frames settle at once.
… close and removal list Switching the view toggle away from a custom editor unmounted its frame without a flush; it now switches once the frame's flush settles. Window close/quit flushes mounted frames before its dirty check, and the worktree-removal unsaved list asks frames to flush so it lists their edits. Renames closeAfterEditorFramesFlush to runAfterEditorFramesFlush.
… unframed tabs at once
c2c6653 to
9419401
Compare
ELI5
Plugin editors (such as Excalidraw) usually wait a moment after you stop typing or drawing before sending the change to Orca. If you closed the tab, or the plugin reloaded, inside that moment, the last change was thrown away. Now Orca asks the editor for anything unsent first.
What Changed
Why
Reusing the save path's existing flush means one mechanism, one deadline, and no new message between Orca and the plugin, so older plugins benefit without changes. Alternatives considered: relying on the page's own
pagehide(not awaited, so unreliable) or a new close message (needs every plugin to adopt it).Linked Issue
N/A (maintainer).
Visual Proof
N/A: no visible change; the behaviour is that an edit made just before closing now reaches the unsaved-changes prompt. Covered by component tests that mount the editor frame.
Testing
pnpm testover editor, tab-group, terminal and workspace-tab code: 995 files, 8991 tests pass.pnpm tcpasses except a pre-existing error on main fixed by fix(sidebar): point hovercard fixture at the moved jump-palette fixtures #37276.Risk
Level: Medium. Closing a tab that shows a plugin editor is now asynchronous, up to 1 s if the plugin never answers; a second click meanwhile queues a harmless second close. Not covered: when removing a worktree skips its confirm dialog, that check is synchronous and does not wait for plugin editors (the dialog's unsaved-files list does). Plain revert.
Agent skill upstream boundary
Checklist
N/Afor visuals with reason