Repository navigation
Close prompt, Discard, save flush and restart save each decided in one place per buffer record (phase 1b-2, no behaviour change) - #31313
Merged
Conversation
Adds `editorBufferIdentityOf`, not consumed yet: [environment, host, pairing root, path key] with exact case, normalized Windows separators and drive letter, WSL alias folding only for a local Windows client, SSH keyed with its runtime environment, and a detached record id for retired hosts. Splits `resolveEditorModelOwner` out of the owner-key function; the owner key is unchanged. Co-Authored-By: Claude <[email protected]>
…hase 1b-1 review) - A folded WSL alias is a tagged tuple, so a real `\\wsl\<distro>` share can't collide with it. - `//` is ambiguous between POSIX and UNC, so it folds only for a known-Windows (local) host; drive and `\\` paths still fold separators and the drive letter on any host. - A proven UNC path folds its server name, matching the Monaco URI authority today. - SSH identity includes the target's endpoint incarnation: a target id edited to point at another machine gets a new key, a reconnect keeps it; an unknown endpoint never shares. - Documents the live pairing resolution and per-event retirement ids. Co-Authored-By: Claude <[email protected]>
…ified host path flavor - The SSH endpoint is the one the tab captured at open, passed in by the caller; a live lookup would match an old tab to whatever machine the target id names now. Missing means never share. - Remote hosts accept a verified path flavor (`windows` | `posix` | `unknown`), so a Windows host's `//SERVER/share` folds like `\\SERVER\share`, as the Monaco URI authority does today. Co-Authored-By: Claude <[email protected]>
…nd save keys through the buffer view index (phase 1b-2) No behaviour change. Each tab still has its own record; this adds the indirection the sharing switch will change instead of call sites: - editorBufferIdOf / editorBufferViews, maintained by the record middleware with openFiles - the invariant now covers the index, records without views, and drafts across a record's views - writeEditorBuffer, setEditorDraft and clearEditorDraft(s) write every view of the record - needsSavePromptOnClose at every close site, discardEditorBuffer, record-wide pending flush, restartSaveTargets, and injected save-queue keys (queue = model URI, timer/generation = record) Parity tests check each entry point against the old per-tab expression across a fixture matrix. Co-Authored-By: Claude <[email protected]>
…order, cheaper draft checks (phase 1b-2 review) - Lookups take a required EditorBufferViewIndex; tests pass an explicit empty index. - needsSavePromptOnClose drops the batch set: every site asks against current state as it processes each view, so a record's last open view prompts once in any order. - Drafts-only writes check draft agreement only; the index rebuild is skipped when no tab joined, left or moved record. - Artifact upload flushes through the record; the per-tab flush/has functions are gone. - Membership and adoption read record ids from the index; drop the save-key injection and the test-only useTerminalSaveDialog migration. Co-Authored-By: Claude <[email protected]>
Contributor
|
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 7 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Jinwoo-H
added a commit
that referenced
this pull request
Oct 21, 2026
#31313 renamed a flush call inside the removed renderer Markdown bridge; the bridge stays deleted.
7 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
Today each editor tab decides on its own whether closing it should ask "save changes?", what Discard clears, which unsaved text gets flushed before a save, and which tabs get saved on restart. The next steps let tabs that show the same file share one record of unsaved edits, and then those decisions have to be made per file, not per tab. This PR routes all of them through one place each, keyed by the tab's record. Every tab still has its own record, so nothing changes for users.
What Changed
buffers/editor-buffer-views.ts):editorBufferIdOf(tab → record) andeditorBufferViews(record → tabs), kept in the store and updated in the same write asopenFiles. Rebuilt only when a tab joins, leaves or moves record.needsSavePromptOnClose— "the record is dirty and this is its last open tab", asked against current state as each tab closes (close queue, single and bulk closes, workspace tab close).discardEditorBuffer.flushPendingEditorBuffer/hasPendingEditorBufferChange(save queue, autosave, restart save, mobile bridge, artifact upload). The per-tab flush functions are removed.restartSaveTargets(one dirty tab per record).Why
Step 1b-2 of moving to one editor buffer per file. Landing these entry points first, with today's answers, means the later switch to shared records changes one function per decision instead of ~10 scattered per-tab loops. The lookup is stored rather than derived because in the switch a record's id will also depend on route data and on which side had unsaved edits when two tabs joined, which can't be rebuilt from the tab list.
Linked Issue
Follow-up to #31272.
Visual Proof
N/A: no behaviour change.
Testing
Existing editor, store, hooks, runtime and lib suites pass unchanged: 4,978 files / 44,385 tests.
New tests: the lookup across open/re-key/close; per-tab answers for the close prompt, restart targets, queue keys and flush on main's sharing cases (same file in two workspaces, clean tab, diff tab); closing a record's tabs in either order prompts only on the last; the dev check throws on a draft-only write that splits a record.
pnpm tc,check:e2e-typecheck-ratchet,check:code-quality:changed,oxfmt --checkpass.Reviewed by GPT and Opus; their fixes (required lookup, close-order handling, cheaper keystroke checks, artifact upload, simplifications) are applied, and a GPT re-review found nothing further.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
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. Window close and
beforeunloadpaths are untouched.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)