Repository navigation
fix(editor): keep a pinned duplicate open and ignore unknown ids in setActiveFile - #28063
SamuelAdigos wants to merge 1 commit into
Conversation
…etActiveFile closeFile's duplicate sweep closed clean same-owner records even when their tab was pinned; skip those like dirty and drafted records. setActiveFile made an id with no open file the global active file; return without changes instead.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Severity of issue fixed: Low Merge Risk: ⚪ Minimal · up to The reviewed selection and pinned-tab guards have no remaining actionable risk identified in the inspected call paths. Pre-merge checks ·
|
Samuel Vila (@SamuelAdigos) independently submitted both editor guards and regression tests in #28063 before #28120 was opened. The narrower implementation landed in #28120; this follow-up records credit for his earlier contribution. Co-authored-by: Samuel Vila <[email protected]>
|
Thanks, @SamuelAdigos, for the earlier implementation and regression tests. Your PR was opened before #28120 and independently covered both guards. Both fixes have now landed through #28120. We selected that smaller patch after reproducing the regressions, exercising the editor close flow in hidden Electron, and passing 693 related tests. I've added you as a co-author in a follow-up attribution commit: f118137. This explicitly records credit for your earlier contribution; the original merged commit is unchanged. Closing this PR as superseded. Thank you for the investigation and regression coverage. |
ELI5
Two small editor fixes. Closing a tab no longer also closes a pinned tab for the same file, and asking the editor to select a file that isn't open no longer leaves the selection pointing at nothing.
What Changed
Before:
setActiveFilewith an id that has no open file made it the globalactiveFileId.After:
closeFileskips records whose editor tab is pinned, next to the existing dirty and draft exclusions.setActiveFilereturns without changes when no open file has the id. Because the file is now always known, its fallbacks to the active workspace are gone.Why
Pinning a tab is an explicit "keep this open", so a cleanup sweep should respect it the same way it respects unsaved work. A selection that points at no open file is what lets stale tab and pane ids (recent-tab cycling →
activateCyclableTab→setActiveFile) leak into the global state. Every caller passes the entity id of an editor-family tab, and all of those are backed by anOpenFile, so the guard blocks no real selection.Linked Issue
Fixes #27985
Visual Proof
N/A: store-level fix. Reproducing it needs duplicate records from older builds, and the new store tests cover that state.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
editor-close-document-siblings.test.ts: a pinned clean duplicate and its tab survive closing the other record.active-selection-owner-scoping.test.ts:setActiveFile('stale-file-id')leavesactiveFileIdandactiveFileIdByWorktreeunchanged.Both fail before the fix.
pnpm test src/rendererpasses (4730 files), as dopnpm tc:web,pnpm run check:code-quality:changed, and oxlint and oxfmt on the changed files. macOS only.AI Disclosure
Claude Code helped investigate and write the change; I reviewed and tested it.
Review
Duplicate records themselves stay out of scope, as the issue asks (#21121).
Agent skill upstream boundary
Notes
Renderer store only: no IPC, wire, SSH, mobile or platform impact.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)