Repository navigation
Offer back unsaved edits when a workspace is removed without a prompt - #31738
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]>
A workspace removed with no dialog (CLI, automations, paired clients, removal outside Orca, listing and runtime-host purges) still closed its editor tabs and dropped their unsaved text. Those removals now flush delayed rich Markdown, CSV and notebook text, then show one toast, "Closed N files with unsaved edits from <workspace>", whose Reopen action reopens each file as an unsaved tab: in its own workspace if it is still open, else the active one, only when that resolves to the same host. The next save is guarded against the disk version the edits came from. Dismissing the toast drops the text and logs it. The captured entries belong to that removal alone. Removals confirmed in a dialog that listed their unsaved files pass unsavedEditsConfirmed through removeWorktree, deleteFolderWorkspace, removeProject, project-group deletion and the purge builders, so they discard without a toast. Folder-workspace and Settings project removals refuse while files are unsaved, so they never reach the toast. Co-Authored-By: Claude <[email protected]>
…oval-dirty-confirm # Conflicts: # src/renderer/src/components/sidebar/HostRemoveDialog.tsx # src/renderer/src/components/sidebar/RemoveFolderDialog.tsx
…worktree-removal-reopen-toast # Conflicts: # src/renderer/src/store/slices/worktrees/session/worktree-slice-lookups.ts # src/renderer/src/store/slices/worktrees/teardown/host-twin-worktree-purge.ts
…oval-reopen-toast # Conflicts: # src/renderer/src/i18n/en-runtime-required.json # src/renderer/src/i18n/locales/en.json # src/renderer/src/i18n/locales/es.json # src/renderer/src/i18n/locales/fr.json # src/renderer/src/i18n/locales/ja.json # src/renderer/src/i18n/locales/ko.json # src/renderer/src/i18n/locales/zh.json
…oval-reopen-toast
…oval-reopen-toast
Preserve recovered text through a missing-file read, retaining previous content and rename state. Cover empty drafts and keep unrelated failures on the existing error path. Co-Authored-By: Claude <[email protected]>
Create collision-safe recovered files in the active workspace using the existing untitled flow. Capture delayed edits across host twins as one removal, match stale-host flushes to purge selection, honor host-qualified confirmations during announcements, and release retained toast text. Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Claude <[email protected]>
…ce recovery A removal dialog now records the exact text it listed when the user confirms. Every purge path (worktrees:changed, announcements, removal teardown, runtime host retirement, repo removal, nested children) skips a closed file only while its text still equals that snapshot, so edits made after confirming are offered back instead of dropped. - One flushAllPendingEditorBuffers() before each purge replaces per-id flushing and the getState threading; idle CSV cells stay open. - Captures merge into one toast per microtask, deduped by file id; the per-call options, scope ref-counting and announcement wrapper are gone. - Capture reads a shared model's live text, else any sharing tab's draft. - Recovery writes through a guarded write that only fills the empty file it created, moves to the next name on conflict, and never deletes it. - Reopen resolves the destination path from the provenance owner host. Co-Authored-By: Claude <[email protected]>
…sh only closing panes - No lingering allowlist: a dialog's confirm returns a snapshot that rides the confirmed removal (removeWorktree, removeProject, project groups, SSH host clear) to its own teardown capture. Every other purge path offers unsaved text back, even if it races a confirmed delete. - The pre-purge flush covers only the closing files and views sharing their records, and flushes every pane registered for them, so split rich and notebook panes all commit while other workspaces' CSV cells keep editing. - Listing announcements flush the files they will remove before the purge. - Capture reads a model's text only while it is attached to an editor; otherwise it prefers the drafts. Co-Authored-By: Claude <[email protected]>
… tab closes A pending cell over the table size limit fails commit(), so the closing flush now falls back to the view's preserve hook, which writes the cell through the same limit-free serialization the unmount path uses. Recovery then captures the typed text instead of an older draft. 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 6 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
ELI5
When a workspace disappears without Orca being able to ask first — removed from the command line, by an automation or a paired device, by git outside Orca, or because its remote host went away — any unsaved edits in its open files used to vanish. Now Orca catches them and shows "Closed N files with unsaved edits from " with a Reopen button, which puts the text back in a new file so nothing is lost.
What Changed
<name> (recovered)<ext>file (or(recovered 2), …) in the active workspace and opens it. It never overwrites an existing file and never writes to the original path. If no workspace is open, the toast keeps the text so you can retry.Why
Follow-up to #31641, which warns before deletions that can show a dialog. Removals that can't prompt now keep the text recoverable instead of dropping it. Writing a new file, rather than reattaching the text to the original path or another tab, avoids writing to the wrong file or host and needs no new editor mode.
Linked Issue
Follow-up to #31641.
Visual Proof
The toast after a worktree was removed outside Orca with an unsaved file open:
After Reopen, the recovered text in a new file:
Testing
pnpm tc, changed-code quality gate, oxfmt, oxlint and localization checks pass.Known limitations: on older remote hosts, writing the recovered file isn't fully atomic against another writer at the same moment; the recovered file lands in the active workspace, which may be a different repository.
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 recovered text is held in memory only until the toast is dismissed.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)