Repository navigation
Editor buffers ready for sharing: autosave per record, separate models for detached tabs (no behaviour change) - #31970
Conversation
…oved tabs Delete the pendingDiskBaselineVerification and pendingLiveDiskVerification pause flags. Every editor save is already a guarded write; a refusal raises the changed-on-disk banner, which is what stops autosave until an explicit save. A guarded write now succeeds when disk changed but already holds exactly the text being saved (local/host compare is byte-exact; client-side fallbacks compare decoded text and refuse when it holds U+FFFD), so a restored draft that matches disk goes clean instead of showing a banner. The restore scan only raises the banner early for tabs that arrive dirty; a watch resync no longer re-checks dirty tabs. Co-Authored-By: Claude <[email protected]>
Return a compatible optional no-op result from hosts and client fallbacks, clean the tab, and clear its provisional self-write stamp without rewriting identical bytes. Co-Authored-By: Claude <[email protected]>
…er hosts, flag dirty tabs on resync - Autosave and pre-restart saves refuse when disk text can't be decoded losslessly, so a baseline that decoded to U+FFFD can't authorize overwriting different bytes. - New files.write.identical-noop.v1 capability; for hosts with only the v1 guarded write the client compares first, skips identical saves, then delegates to the host's guarded write. - Watch resync compares dirty tabs against disk and shows the changed-on-disk banner. - Local guarded writes check for identical content before the write-only regular-file probe. Co-Authored-By: Claude <[email protected]>
…false resync banners - Local guarded writes judge losslessness by bytes, so a valid UTF-8 file containing U+FFFD autosaves again. A file that really isn't UTF-8 is refused with its own reason, 'not-utf8' (older clients read it as 'changed'), which pauses autosave for that file with one notice until an explicit save converts it. - A watch resync whose disk read fails leaves dirty tabs alone; the guarded save still catches a real conflict. - Resync and restored-tab checks treat disk holding the tab's own just-written save as an echo. - On hosts with only the v1 guarded write, only automatic saves read the file first; explicit saves go straight to the host's guard. Co-Authored-By: Claude <[email protected]>
…d report disk changes first - The pause is released once no dirty tab of the file remains (close, reload from disk, discard), so a reopened or reloaded file's next autosave asks the host again and notifies. - Client-side precondition checks compare the signature before looking for U+FFFD, so an external rewrite shows the changed-on-disk banner rather than the non-UTF-8 notice. Co-Authored-By: Claude <[email protected]>
…e sharing switch uses First of the stacked sharing-switch PRs (G1). Inert while every record has one view, which is all main produces today; tests drive the shared shape through hand-built view indexes. - Autosave timers are decided per record by its first view that may autosave, so a read-only or preview view of a record no longer cancels the record's timer, and a timer survives the view that scheduled it closing (it resolves a live view of the record when it fires). - A view of a detached record gets its own model owner key, so divergent dirty drafts never share text with the file's other record. - Pure join and rejoin rules: rekey / attach / adopt (dirty wins) / merge (identical dirty) / detach (divergent dirty); a detached pair rejoins only once one side is clean. - Mirrored host tabs: a record's dirty flag is the OR of its host-owned views, since an older host publishes it per tab; the dev invariant tolerates exactly that disagreement. Co-Authored-By: Claude <[email protected]>
…e view for autosave - A merge needs equal drafts, baselines, conflict and owner-migration state; anything else detaches, so a paused record never resumes autosave by joining. A side whose text is still pending (no draft) never counts as identical. - A clean-flagged view that still holds a draft counts as dirty in joins. - The invariant tolerates a clean host-owned view on a dirty record only when another host-owned view of that record reads dirty. - Autosave and restart skip CSV-preview and read-only views when picking the view a record writes through. Co-Authored-By: Claude <[email protected]>
…r-switch-g1-fixes # Conflicts: # src/renderer/src/components/editor/editor-save-queue.ts
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
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:
85a3105a-c003-49ba-a660-958103382d67
📒 Files selected for processing: 16
src/renderer/src/components/editor/editor-autosave-controller.test.tssrc/renderer/src/components/editor/editor-autosave-due-records.tssrc/renderer/src/components/editor/editor-model-owner.test.tssrc/renderer/src/components/editor/editor-model-owner.tssrc/renderer/src/components/editor/editor-save-queue-records.test.tssrc/renderer/src/components/editor/editor-save-queue.tssrc/renderer/src/components/editor/editor-save-writer-view.test.tssrc/renderer/src/components/editor/editor-save-writer-view.tssrc/renderer/src/store/editor-buffer-record-lifecycle.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-identity.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-identity.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-join.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-join.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-mirrored-dirty.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-record.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-views.ts
💤 Files with no reviewable changes: 1
- src/renderer/src/store/slices/editor/buffers/editor-buffer-identity.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.
| if (!isDirtySide(joining)) { | ||
| return 'attach' | ||
| } | ||
| if (!isDirtySide(target)) { | ||
| return 'adopt' |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Preserve pauses when a clean side joins.
A side with isDirty: false, no draft, and pendingOwnerMigration: true takes the clean-side branch. attach or adopt can then discard that side’s migration pause. The same branches can discard externalMutation. Defer the join or retain the relevant state until the pause or conflict is resolved.
| case 'merge': | ||
| return target |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Keep the dirty flag when identical drafts merge.
If the target holds a draft with record.isDirty: false and the joining side holds the same draft with record.isDirty: true, joinOnto selects merge. joinedEditorBuffer returns the clean-flagged target and drops the joining side’s dirty flag. OR the flags in the merged record, or reject this merge until the flags agree.
ELI5
Groundwork for letting every tab that shows the same file share one record of unsaved edits. Nothing changes for users yet: today every tab still has its own record. This makes autosave, the editor model and the join rules ready for sharing, and fixes two autosave problems that would only appear once records are shared.
What Changed
detached:record ids), so their text never mixes with the file's other record.Why
First of the stacked PRs that switch Orca to one editor buffer per file. This part is safe to ship alone because every record still has one view; the next PR (views share one record, plus rich/notebook/CSV writing through the record) lands as one unit.
Linked Issue
Follow-up to #31768.
Visual Proof
N/A: no visible change.
Testing
Per-record autosave (read-only view first, timer surviving the scheduling tab closing), detached model owner keys, join/rejoin rules incl. pending conflicts and drafts not yet serialized, mirrored dirty OR.
pnpm tc,check:code-quality:changed, oxfmt, oxlint pass; editor/store/runtime/hooks/sidebar suites pass.Reviewed by Opus; its findings are applied.
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.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)