Repository navigation
List unsaved files before deleting a workspace, and refuse removals that would lose them silently - #31641
Conversation
…ses them Removing a workspace closed its editor tabs and threw away unsaved text without a word, including with "Don't ask again" on. Removal confirms now list the files whose unsaved edits the removal discards: the tabs the purge itself would close (host twins included), kept only when no view sharing their model or record stays open. Editable unstaged diff tabs count; delayed rich Markdown, CSV and notebook text is flushed first. - Delete Workspace dialog: the list sits with the git-change warnings. While it is non-empty the dialog no longer starts focus on Delete, and "Don't ask again" no longer skips the dialog. - The same list in Remove Project, SSH workspace forget/reconnect-and- delete, SSH host removal with its workspaces, nested-worktree deletion (rows matched by path containment under the parent) and project-group deletion with its contained projects. - Removals with no dialog whose files stay on disk refuse instead, with "Save or close N unsaved files in <name> first": folder-workspace delete (card action, context menu, hovered shortcut, through one shared helper) and Settings > Remove Project. Force retries with no list of their own (the failure toast's Force Delete / Delete Anyway, Space's Force button) re-check at that moment and refuse the same way. A folder-workspace delete that leaves a same-id folder on another host closes no tabs, so it is not refused. Removal confirms touched here render on the security surface. Removals with no prompt (CLI, automations, paired clients) behave as before; a follow-up offers their text back. Known limitation: the list is decided by the tabs a removal closes, not by paths; a symlink into a deleted folder is not resolved on the host. Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 15 minutes. View limit details
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
98e7b160-9674-4f52-b2ec-3041d62cc833
📒 Files selected for processing: 35
src/renderer/src/components/editor/removal-unsaved-editor-files.test.tssrc/renderer/src/components/editor/removal-unsaved-editor-files.tssrc/renderer/src/components/settings/use-settings-store-model.tssrc/renderer/src/components/sidebar/DeleteNestedWorktreesDialog.test.tsxsrc/renderer/src/components/sidebar/DeleteNestedWorktreesDialog.tsxsrc/renderer/src/components/sidebar/DeleteWorktreeDialog.tsxsrc/renderer/src/components/sidebar/DeleteWorktreeDialog.unsaved-edits.test.tsxsrc/renderer/src/components/sidebar/ForgetSshWorkspaceDialog.tsxsrc/renderer/src/components/sidebar/HostRemoveDialog.tsxsrc/renderer/src/components/sidebar/ProjectGroupDeleteDialog.tsxsrc/renderer/src/components/sidebar/RemovalUnsavedFilesNotice.tsxsrc/renderer/src/components/sidebar/RemoveFolderDialog.tsxsrc/renderer/src/components/sidebar/delete-worktree-flow.test.tssrc/renderer/src/components/sidebar/delete-worktree-flow.tssrc/renderer/src/components/sidebar/folder-workspace-delete.test.tssrc/renderer/src/components/sidebar/folder-workspace-delete.tssrc/renderer/src/components/sidebar/hovered-workspace-delete.test.tssrc/renderer/src/components/sidebar/hovered-workspace-delete.tssrc/renderer/src/components/sidebar/removal-unsaved-files.tssrc/renderer/src/components/sidebar/run-worktree-delete-with-toast.tssrc/renderer/src/components/sidebar/use-delete-worktree-dialog-targets.tssrc/renderer/src/components/sidebar/use-worktree-card-controller.tssrc/renderer/src/components/sidebar/use-worktree-card-workspace-actions.tssrc/renderer/src/components/sidebar/worktree-context-menu-delete-intent.tssrc/renderer/src/components/sidebar/worktree-list/rows/ProjectGroupDialogs.tsxsrc/renderer/src/components/sidebar/worktree-list/rows/use-project-group-dialogs.tssrc/renderer/src/components/status-bar/use-workspace-space-manager-panel.tssrc/renderer/src/i18n/en-runtime-required.jsonsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/store/slices/worktrees/teardown/worktree-purge-closed-files.ts
💤 Files with no reviewable changes: 1
- src/renderer/src/components/sidebar/use-worktree-card-controller.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.
| export function flushRemovalPendingEdits(state: AppState, fileIds: Iterable<string>): void { | ||
| try { | ||
| for (const fileId of fileIds) { | ||
| flushPendingEditorBuffer(state, fileId) | ||
| } | ||
| } catch (error) { | ||
| // Why: a view's flush failing must not block the removal that asked. | ||
| console.error('[editor] flushing pending edits before a removal failed', error) | ||
| } | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Move the try/catch inside the loop so one failing flush does not skip the remaining files.
The try wraps the whole for loop. If flushPendingEditorBuffer throws for one file, the loop stops. The delayed views of the later file ids are never committed to editorDrafts or isDirty. lastViewUnsavedFiles then does not list those files. A removal dialog can omit them, and the skip-confirm and block paths can allow the removal. The user loses the edits without a warning.
The comment says one failing flush "must not block the removal". The test name says "keeps going". Both imply that the remaining flushes still run.
🐛 Proposed fix
--- "a/src/renderer/src/components/editor/removal-unsaved-editor-files.ts"
+++ "b/src/renderer/src/components/editor/removal-unsaved-editor-files.ts"
@@ -34,16 +34,16 @@
}
/** Commits text delayed views (rich Markdown, CSV, notebook) still hold for these tabs. */
export function flushRemovalPendingEdits(state: AppState, fileIds: Iterable<string>): void {
- try {
- for (const fileId of fileIds) {
+ for (const fileId of fileIds) {
+ try {
flushPendingEditorBuffer(state, fileId)
+ } catch (error) {
+ // Why: a view's flush failing must not block the removal that asked, nor skip other files.
+ console.error('[editor] flushing pending edits before a removal failed', error)
}
- } catch (error) {
- // Why: a view's flush failing must not block the removal that asked.
- console.error('[editor] flushing pending edits before a removal failed', error)
}
}
/** Unsaved files a removal of `targets` would close, after flushing their delayed views. */
export function collectRemovalUnsavedFiles(Add a test with two registered flushes where the first throws. Assert that the second flush still runs.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| export function flushRemovalPendingEdits(state: AppState, fileIds: Iterable<string>): void { | |
| try { | |
| for (const fileId of fileIds) { | |
| flushPendingEditorBuffer(state, fileId) | |
| } | |
| } catch (error) { | |
| // Why: a view's flush failing must not block the removal that asked. | |
| console.error('[editor] flushing pending edits before a removal failed', error) | |
| } | |
| } | |
| export function flushRemovalPendingEdits(state: AppState, fileIds: Iterable<string>): void { | |
| for (const fileId of fileIds) { | |
| try { | |
| flushPendingEditorBuffer(state, fileId) | |
| } catch (error) { | |
| // Why: a view's flush failing must not block the removal that asked, nor skip other files. | |
| console.error('[editor] flushing pending edits before a removal failed', error) | |
| } | |
| } | |
| } |
…oval-dirty-confirm # Conflicts: # src/renderer/src/components/sidebar/HostRemoveDialog.tsx # src/renderer/src/components/sidebar/RemoveFolderDialog.tsx
ELI5
Deleting a workspace could silently throw away unsaved edits in files that were only open in that workspace. Now Orca lists those files before you delete, and refuses (with "Save or close N unsaved files first") where the files would otherwise be lost without any dialog.
What Changed
Removals that can't show anything (CLI, automations, paired clients) are unchanged here; a follow-up handles them.
Why
Listing the files in the dialog the user already sees, and refusing elsewhere, is the smallest change that stops silent loss. An earlier version added a separate step with a Save button; it was larger and had a cancel-during-save bug, so Save was dropped — the user cancels, saves, and retries.
Linked Issue
N/A (maintainer).
Visual Proof
Before — Delete Workspace with an unsaved file open (no warning):
After — the same dialog lists the unsaved file:
After — deleting a folder workspace with an unsaved file is refused:
Testing
pnpm tc,oxlint,oxfmt --check,check:code-quality:changed(design system), localization checks pass.Known limitation: a symlink pointing into a deleted folder isn't resolved on the host.
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
No wire or persisted-state change. The Forget SSH workspace dialog now uses the standard dialog padding.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)