Repository navigation
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · 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:
0b158f52-f095-4779-a014-f28844958bd4
📒 Files selected for processing: 36
src/renderer/src/components/editor/MonacoEditor.tsxsrc/renderer/src/components/editor/closed-editor-tab-controller.tssrc/renderer/src/components/editor/discard-editor-file-changes.tssrc/renderer/src/components/editor/editor-autosave-controller-test-fixture.tssrc/renderer/src/components/editor/editor-autosave-controller.test.tssrc/renderer/src/components/editor/editor-autosave-state-projections.tssrc/renderer/src/components/editor/editor-model-host-isolation.test.tssrc/renderer/src/components/editor/editor-model-owner.tssrc/renderer/src/components/editor/editor-model-uri-language-service.test.tssrc/renderer/src/components/editor/editor-model-uri.test.tssrc/renderer/src/components/editor/editor-model-uri.tssrc/renderer/src/components/editor/editor-restart-save-handlers.tssrc/renderer/src/components/editor/editor-save-queue.tssrc/renderer/src/components/editor/use-editor-buffer-content-sync.test.tsxsrc/renderer/src/components/editor/use-editor-buffer-content-sync.tssrc/renderer/src/components/editor/useEditorPanelContentState.tssrc/renderer/src/components/tab-group/workspace-tab-close-commands.tssrc/renderer/src/components/terminal/useTerminalSaveDialog.tssrc/renderer/src/components/use-terminal-bulk-close-actions.tssrc/renderer/src/components/use-terminal-editor-close-queue.tssrc/renderer/src/runtime/web-session-tabs-sync/apply-preparation-browser.tssrc/renderer/src/runtime/web-session-tabs-sync/state.tssrc/renderer/src/store/editor-buffer-record-lifecycle.test.tssrc/renderer/src/store/editor-buffer-record-lifecycle.tssrc/renderer/src/store/slices/editor/actions/editor-draft-state.tssrc/renderer/src/store/slices/editor/actions/hydrated-editor-session-state.tssrc/renderer/src/store/slices/editor/actions/open-file-state.tssrc/renderer/src/store/slices/editor/actions/rekey-open-files-action.tssrc/renderer/src/store/slices/editor/actions/restored-editor-owner-transition.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-close-rule.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-record.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-sharing.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-sharing.tssrc/renderer/src/store/slices/editor/types/editor-files-slice.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| if (patch && shared) { | ||
| recordId = newId | ||
| for (let n = 1; recordId in editorBuffers; n += 1) { | ||
| recordId = `${newId}#${n}` | ||
| } | ||
| } | ||
| recordIdByFileId[newId] = recordId | ||
| editorBuffers[recordId] = { ...record, ...editorBuffers[recordId], ...patch } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
rg -nP -C8 'setRestoredEditorOwnerMigrationPending\s*[:=(]' src/renderer/src/store
rg -nP -C3 'pendingOwnerMigration' src/renderer/src/store/slices/editor/actionsRepository: stablyai/orca
Length of output: 22219
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- editor-buffer-record.ts ---'
cat src/renderer/src/store/slices/editor/buffers/editor-buffer-record.ts
printf '%s\n' '--- transition caller ---'
sed -n '170,250p' src/renderer/src/store/slices/editor/actions/restored-editor-owner-transition.ts
printf '%s\n' '--- rekey callers and reconciliation references ---'
rg -n -C 12 -F -e 'rekeyEditorBuffers(' -e 'findSharedRecord' -e 'joinPauses' src/renderer/src/store/slices/editor
printf '%s\n' '--- owner migration and shared-buffer tests ---'
rg -n -C 15 -F -e 'shared' -e 'pendingOwnerMigration' src/renderer/src/store/slices/editor/actions/restored-editor-owner* src/renderer/src/store/editor-buffer-record-lifecycle.test.tsRepository: stablyai/orca
Length of output: 42028
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- editor-buffer-sharing.ts ---'
nl -ba src/renderer/src/store/slices/editor/buffers/editor-buffer-sharing.ts | sed -n '1,280p'
printf '%s\n' '--- owner action after transition construction ---'
nl -ba src/renderer/src/store/slices/editor/actions/restored-editor-owner.ts | sed -n '1,180p'
printf '%s\n' '--- transition application and buffer-sharing reconciliation callers ---'
rg -n -C 14 -F -e 'withEditorBufferRecords' -e 'reconcileEditorBuffers' -e 'reconcileEditorBuffer' -e 'editorBufferSharing' src/renderer/src/store/slices/editor src/renderer/src/storeRepository: stablyai/orca
Length of output: 41761
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- pending-owner save and autosave checks ---'
rg -n -C 12 -F -e 'This file is still restoring its workspace owner' -e 'isAutosaveSuspendedForFile' -e 'pendingOwnerMigration' src/renderer/src/store --glob '*.ts'Repository: stablyai/orca
Length of output: 34824
Clear pendingOwnerMigration on the shared record.
When two tabs share a record, pendingOwnerMigration is mirrored to both tabs. During owner reparenting, the clear is passed as a patch to rekeyEditorBuffers. That function splits the migrated tab from the shared record and applies the clear only to the new record. The sibling record keeps pendingOwnerMigration: true.
Reconciliation can then rejoin the tabs and restore the flag because joinPauses merges pendingOwnerMigration with logical OR. If the tabs remain separate, the sibling still retains the save-blocking flag.
Update rekeyEditorBuffers so a patch that clears pendingOwnerMigration updates the shared record instead of splitting it. Keep the split for patches that add a per-tab pause. Add a sharing test that opens two shared tabs, sets the migration flag, reparents one tab, and asserts that both tabs can save.
24dc595 to
bc9fec2
Compare
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:
b6bf1500-22c4-4e00-b570-0b7215942137
📒 Files selected for processing: 10
src/renderer/src/components/editor/discard-editor-file-changes.tssrc/renderer/src/components/editor/editor-save-queue.tssrc/renderer/src/components/use-terminal-editor-close-dialog-actions.tssrc/renderer/src/components/use-terminal-editor-close-queue.tssrc/renderer/src/store/slices/editor/actions/open-file-mutations.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-close-rule.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-record.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-sharing.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-sharing.tssrc/renderer/src/store/slices/editor/tabs/workspace-editor-item.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| const view = nextState.openFiles.find( | ||
| (openFile) => editorBufferIdOf(nextState, openFile.id) === recordId | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Pick a view that can save when a save finishes.
When a save finishes, view is the first open tab in openFiles that uses the record. Read-only tabs share the record. The test "a read-only tab mounting beside a dirty writable tab shows the edits" covers this case.
Suppose a read-only tab of the file opened before the writable tab. Then view is the read-only tab. nextState.markFileDirty(view.id, false) does nothing, because markFileDirty returns early for readOnly/csvPreviewOnly tabs (open-file-mutations.ts lines 77-80). The record keeps isDirty: true, even though disk now holds contentToSave and the draft is cleared. The writable tab still shows unsaved changes. Closing it asks to save again. Saving again ends the same way, so the flag never clears.
Use the tab that started the save if it is still open. Otherwise, use a tab that can save.
🐛 Proposed fix
--- "a/src/renderer/src/components/editor/editor-save-queue.ts"
+++ "b/src/renderer/src/components/editor/editor-save-queue.ts"
@@ -161,9 +161,16 @@
// Why the record: the tab that started the save may have closed while another still shows the file.
const nextState = store.getState()
- const view = nextState.openFiles.find(
- (openFile) => editorBufferIdOf(nextState, openFile.id) === recordId
- )
+ const sameRecord = (openFile: OpenFile): boolean =>
+ editorBufferIdOf(nextState, openFile.id) === recordId
+ const view =
+ nextState.openFiles.find((openFile) => openFile.id === file.id && sameRecord(openFile)) ??
+ nextState.openFiles.find(
+ (openFile) =>
+ sameRecord(openFile) &&
+ openFile.readOnly !== true &&
+ openFile.csvPreviewOnly !== true
+ )
if (!view) {
return
}📝 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.
| const view = nextState.openFiles.find( | |
| (openFile) => editorBufferIdOf(nextState, openFile.id) === recordId | |
| ) | |
| const sameRecord = (openFile: OpenFile): boolean => | |
| editorBufferIdOf(nextState, openFile.id) === recordId | |
| const view = | |
| nextState.openFiles.find((openFile) => openFile.id === file.id && sameRecord(openFile)) ?? | |
| nextState.openFiles.find( | |
| (openFile) => | |
| sameRecord(openFile) && | |
| openFile.readOnly !== true && | |
| openFile.csvPreviewOnly !== true | |
| ) |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
c7be69b0-7f06-4194-94e9-f80db0a13fe1
📒 Files selected for processing: 11
src/renderer/src/components/editor/editor-save-queue.tssrc/renderer/src/components/editor/use-editor-buffer-content-sync.test.tsxsrc/renderer/src/components/editor/use-editor-buffer-content-sync.tssrc/renderer/src/components/editor/useEditorPanelContentState.tssrc/renderer/src/store/editor-buffer-record-lifecycle.tssrc/renderer/src/store/slices/editor/actions/open-file-action.tssrc/renderer/src/store/slices/editor/actions/open-file-mutations.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-preview.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-sharing.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-sharing.tssrc/renderer/src/store/slices/tabs/tabs-create-actions.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
Phase 1b part one: edit tabs of one physical file (host + normalized, exact-case path; retired runtime pairings quarantined) map to one record with one save queue and autosave timer. Only the last tab that can save prompts on close. Dirty+dirty joins stay separate with their own model. Reuses the URI shape, close rule and cache sync from #30714.
…ce a dirty shared preview - Save completion reconciles through the captured record and a surviving tab, so a closed initiating tab can't clear a sibling's newer draft. - A preview tab sharing unsaved edits is promoted, and preview replacement skips dirty tabs. - Quit prompts the first queued tab of a file and closes its queued siblings only after that decision, so Cancel keeps them open.
…reads safe - A preview opening onto a dirty file opens as a kept tab; preview replacement never drops a tab whose file is dirty. - Records of one file kept apart for differing drafts never autosave. - A queued save whose fallback a newer write covered doesn't write it. - Newer text for a record supersedes other panels' in-flight reads. - Clearing dirty works from any tab, and save completion prefers a writable tab; the sharing reconcile no longer writes tab layout.
…ush delayed edits on close - Newer text fills a tab whose superseded first read would leave it loading. - Drafts kept apart only block autosave while they start from the same disk version; a save marks the other records changed-on-disk instead. - Closing or tearing down a tab that shares its file flushes its delayed editor text into the shared draft first.
… kept-apart records - One read-freshness counter per buffer record: a read publishes only if no newer read, save or reload of the file started since it began. - Saves queue per physical file; a record whose disk version predates another record's write is marked changed-on-disk instead of writing. - A clean kept-apart record rejoins its file when both start from the same disk version. - Close flushes delayed editor text before the close rule decides.
…joins with the kept draft
bb0ae79 to
1192553
Compare
…esult, clean-only rejoin - Delete the renderer write ledger. A record kept apart from another record of its file saves through the guarded write with its disk baseline; a refusal (or an older host that can't compare) returns blocked-stale and shows the banner. Other records keep today's path. - queueSave resolves written | blocked-stale | skipped; save-and-close, Cmd+S and restart-save act on it, closing or reporting saved only when written. - A save during Keep My Edits' baseline read waits for it. - Kept-apart records rejoin only when both are clean, keeping the newest disk version; a clean side never adopts another side's draft.
…-first reload, O(n) sharing - Overwrite consent is captured when a save is requested; a conflict raised while it waited never drops its host precondition. - Disk reads publish to the file's record, so a closed panel's read still reaches the others; freshness is keyed by physical file and bumped by reads, writes, Keep and rejoin. - Reload on a kept-apart tab reads first, then drops the draft; a read older than the other side's write is dropped. - Save-and-close, Cmd+S and restart-save treat anything but written as not saved; a save superseded mid-write still rebaselines. - Same-file lookups are indexed by identity key (2000 tabs < 50 ms).
…y drafts - Remove kept-apart records, their guarded writes, conflict grouping and rejoin. Two different drafts of one file (only from an older session) keep the most recently active tab's; the other is kept in the session as a recovered draft with a Compare / Copy / Dismiss toast (capped at 20 drafts and 2 MB; optional field older builds ignore). - Reads: one freshness counter per record, results publish through any surviving tab of the record, a superseded read with nothing shown retries up to 3 times then shows the load error, and Keep's baseline read never supersedes content reads. - Reload from Disk is main's again.
There was a problem hiding this comment.
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
5f4b9d36-71df-485d-8f56-4c1cba4ca391
📒 Files selected for processing: 48
src/main/orca-profiles/profile-project-session-field-disposition.tssrc/main/persistence/restoring-sessions/session-worktree-ownership.tssrc/renderer/src/App.tsxsrc/renderer/src/components/editor/ExternalFileChangeBanner.test.tsxsrc/renderer/src/components/editor/ExternalFileChangeBanner.tsxsrc/renderer/src/components/editor/RecoveredEditorDraftCompareDialog.tsxsrc/renderer/src/components/editor/RecoveredEditorDraftsNotice.test.tsxsrc/renderer/src/components/editor/RecoveredEditorDraftsNotice.tsxsrc/renderer/src/components/editor/editor-autosave-controller-test-fixture.tssrc/renderer/src/components/editor/editor-autosave-controller.tssrc/renderer/src/components/editor/editor-clean-tab-disk-baseline.tssrc/renderer/src/components/editor/editor-restart-save-handlers.tssrc/renderer/src/components/editor/editor-save-queue.tssrc/renderer/src/components/editor/editor-tab-disk-read.tssrc/renderer/src/components/editor/use-editor-buffer-content-sync.test.tsxsrc/renderer/src/components/editor/use-editor-buffer-content-sync.tssrc/renderer/src/components/editor/use-superseded-file-read-retry.tssrc/renderer/src/components/editor/useEditorPanelContentState.tssrc/renderer/src/components/editor/useEditorPanelFileContentLoader.tssrc/renderer/src/components/editor/useEditorPanelVisibilityContentState.test.tsxsrc/renderer/src/lib/workspace-session-browser-history.test.tssrc/renderer/src/lib/workspace-session-editor-drafts.test.tssrc/renderer/src/lib/workspace-session-editor-files.tssrc/renderer/src/lib/workspace-session-liveness.test.tssrc/renderer/src/lib/workspace-session-patch.tssrc/renderer/src/lib/workspace-session-relevant-fields.test.tssrc/renderer/src/lib/workspace-session.tssrc/renderer/src/store/editor-buffer-record-lifecycle.tssrc/renderer/src/store/slices/editor/actions/hydrated-editor-session-state.tssrc/renderer/src/store/slices/editor/actions/open-file-state.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-identity.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-read-freshness.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-read-freshness.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-record.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-sharing-scale.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-sharing.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-sharing.tssrc/renderer/src/store/slices/editor/buffers/recovered-editor-drafts.test.tssrc/renderer/src/store/slices/editor/buffers/recovered-editor-drafts.tssrc/renderer/src/store/slices/editor/types/editor-files-slice.tssrc/shared/workspace-layout/workspace-layout-beside.tssrc/shared/workspace-layout/workspace-layout-fact-locations.test.tssrc/shared/workspace-session-editor-schema.tssrc/shared/workspace-session-host-field-ownership.tssrc/shared/workspace-session-schema-field-coverage.test.tssrc/shared/workspace-session-schema.tssrc/shared/workspace-session-state-types.tssrc/shared/wsl-move/wsl-move-dispositions.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| if (!isCurrentRead()) { | ||
| retryIfSuperseded() |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
set -eu
printf '%s\n' '--- changed file diff ---'
git diff --unified=80 bfdf16b2530adf8e90939f5374eed4dc47ba1ad1 9250fe67b951394cb09a19164c64c959b6154873 -- src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts
printf '%s\n' '--- target file ---'
nl -ba src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts | sed -n '1,380p'
printf '%s\n' '--- freshness/read symbol references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'beginEditorBufferFileRead' -e 'isEditorBufferReadCurrent' -e 'inFlightFileReads' -e 'tracksFileRead' -e 'publishEditorBufferContent' -e 'retryIfSuperseded' src/renderer/src
printf '%s\n' '--- relevant freshness files ---'
rg --files src/renderer/src | rg 'editor-buffer-read-freshness|editor-buffer|file-content|FileContent'Repository: stablyai/orca
Length of output: 39505
🏁 Script executed:
git diff --unified=60 bfdf16b2530adf8e90939f5374eed4dc47ba1ad1 9250fe67b951394cb09a19164c64c959b6154873 -- src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts; nl -ba src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts | sed -n '1,360p'; rg -n -F --glob '*.ts' --glob '*.tsx' -e 'beginEditorBufferFileRead' -e 'isEditorBufferReadCurrent' -e 'inFlightFileReads' -e 'tracksFileRead' -e 'publishEditorBufferContent' -e 'retryIfSuperseded' src/renderer/src; rg --files src/renderer/src | rg 'editor-buffer-read-freshness|editor-buffer|file-content|FileContent'Repository: stablyai/orca
Length of output: 37466
🏁 Script executed:
git diff --unified=60 bfdf16b2530adf8e90939f5374eed4dc47ba1ad1 9250fe67b951394cb09a19164c64c959b6154873 -- src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts
nl -ba src/renderer/src/components/editor/useEditorPanelFileContentLoader.ts | sed -n '1,360p'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'beginEditorBufferFileRead' -e 'isEditorBufferReadCurrent' -e 'inFlightFileReads' -e 'tracksFileRead' -e 'publishEditorBufferContent' -e 'retryIfSuperseded' src/renderer/src
rg --files src/renderer/src | rg 'editor-buffer-read-freshness|editor-buffer|file-content|FileContent'Repository: stablyai/orca
Length of output: 37466
🏁 Script executed:
set -eu
for f in \
src/renderer/src/store/slices/editor/buffers/editor-buffer-read-freshness.ts \
src/renderer/src/components/editor/use-superseded-file-read-retry.ts \
src/renderer/src/components/editor/use-editor-buffer-content-sync.ts \
src/renderer/src/store/slices/editor/buffers/editor-buffer-record.ts \
src/renderer/src/store/slices/editor/buffers/editor-buffer-identity.ts \
src/renderer/src/components/editor/editor-tab-disk-read.ts
do
printf '\n--- %s ---\n' "$f"
nl -ba "$f"
done
printf '\n--- focused retry/sync/loader tests ---\n'
rg -n -F --glob '*.test.ts' --glob '*.test.tsx' \
-e 'supersed' -e 'same file' -e 'same record' -e 'simult' -e 'read' \
src/renderer/src/components/editor src/renderer/src/store/slices/editor/buffers \
| head -240
printf '\n--- loader hook call sites and content ref wiring ---\n'
rg -n -F --glob '*.ts' --glob '*.tsx' \
-e 'useEditorPanelFileContentLoader(' \
-e 'fileContentsRef:' \
-e 'fileContentsRef' \
src/renderer/src/components/editor src/renderer/srcRepository: stablyai/orca
Length of output: 41596
🏁 Script executed:
set -eu
for f in src/renderer/src/store/slices/editor/buffers/editor-buffer-read-freshness.ts src/renderer/src/components/editor/use-superseded-file-read-retry.ts src/renderer/src/components/editor/use-editor-buffer-content-sync.ts src/renderer/src/store/slices/editor/buffers/editor-buffer-record.ts src/renderer/src/store/slices/editor/buffers/editor-buffer-identity.ts src/renderer/src/components/editor/editor-tab-disk-read.ts; do
printf '\n--- %s ---\n' "$f"
nl -ba "$f"
done
printf '\n--- focused tests and call sites ---\n'
rg -n -F --glob '*.test.ts' --glob '*.test.tsx' -e 'supersed' -e 'same file' -e 'same record' -e 'simult' -e 'read' src/renderer/src/components/editor src/renderer/src/store/slices/editor/buffers | head -240
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'useEditorPanelFileContentLoader(' -e 'fileContentsRef:' -e 'fileContentsRef' src/renderer/src/components/editor src/renderer/srcRepository: stablyai/orca
Length of output: 41708
Prevent superseded shared reads from cancelling each other.
When two panels start the same record read together, the first continuation can retry synchronously and invalidate the second continuation before it publishes. Both continuations can then retry in turn until the retry cap reports The file kept changing while it was loading.
Coordinate retries at the record level. A superseded continuation must not start a new read while another subscriber to the shared read can still publish its result. Preserve retries for invalidations or failed newer reads. Add a regression test with two panels that start the same read together and assert that both receive the content without exhausting the retry cap.
| export function isSameRecoveredEditorDraft( | ||
| a: RecoveredEditorDraft, | ||
| b: RecoveredEditorDraft | ||
| ): boolean { | ||
| return ( | ||
| a.filePath === b.filePath && a.worktreeId === b.worktreeId && a.recoveredAt === b.recoveredAt | ||
| ) | ||
| } |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Confirm how dismissal uses the predicate.
rg -nP -C6 'isSameRecoveredEditorDraft|dismissRecoveredEditorDraft' src/renderer/src/storeRepository: stablyai/orca
Length of output: 6976
🏁 Script executed:
#!/bin/bash
set -o pipefail
printf '%s\n' '--- declarations and references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'RecoveredEditorDraft' -e 'reconcileEditorBufferSharing' -e 'recoveredAt' -e 'modelKey' -e 'key=' src/renderer/src | head -n 240
printf '%s\n' '--- relevant file excerpts ---'
for f in \
src/renderer/src/store/slices/editor/buffers/recovered-editor-drafts.ts \
src/renderer/src/store/slices/editor/types/editor-files-slice.ts \
src/renderer/src/store/slices/editor/actions/open-file-state.ts \
src/renderer/src/store/slices/editor/actions/reconcile-editor-buffer-sharing.ts \
src/renderer/src/components/editor/RecoveredEditorDraftsNotice.tsx \
src/renderer/src/components/editor/RecoveredEditorDraftCompareDialog.tsx; do
if [ -f "$f" ]; then
echo "### $f"
nl -ba "$f" | sed -n '1,240p'
fi
done
printf '%s\n' '--- schema/session references ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'recoveredEditorDrafts' -e 'recovered-editor-drafts' src | head -n 180Repository: stablyai/orca
Length of output: 41763
🏁 Script executed:
#!/bin/bash
set -o pipefail
for f in \
src/renderer/src/store/slices/editor/buffers/editor-buffer-sharing.ts \
src/renderer/src/store/editor-buffer-record-lifecycle.ts \
src/shared/workspace-session-state-types.ts \
src/shared/workspace-session-editor-schema.ts; do
echo "### $f"
nl -ba "$f" | sed -n '1,290p'
done
printf '%s\n' '--- now bindings and relevant tests ---'
rg -n -C5 -F --glob '*.ts' -e 'now: Date.now' -e 'now: () => Date.now' -e 'now:' -e 'recoveredAt:' src/renderer/src/store src/shared | head -n 260Repository: stablyai/orca
Length of output: 42199
Give each recovered draft a stable identity.
When multiple divergent tabs join in one reconciliation pass, reconcileEditorBufferSharing can create multiple recovered drafts for the same file. Each draft receives Date.now(), so consecutive calls can return the same millisecond value. isSameRecoveredEditorDraft and the UI keys then treat those drafts as identical. One Dismiss action can remove both drafts, and the losing draft is no longer available after reconciliation.
Add a stable id to RecoveredEditorDraft, persist it in the schema, and mint it for each recovered draft. Assign IDs to legacy drafts during hydration. Use the ID for isSameRecoveredEditorDraft, the React key in RecoveredEditorDraftsNotice.tsx, and the modelKey in RecoveredEditorDraftCompareDialog.tsx. Comparing draft text is not sufficient because identical drafts can still collide.
…clears, panel-owned read invalidation, recovered-draft notice fixes - Save-and-close rechecks the record after writing and keeps the tab if a sibling typed while it saved. - A rekey patch applies to the whole record, so clearing an owner migration pause clears it for every tab of the file. - Invalidating a tab supersedes only the panel's own read, and only while it is still the file's newest. - Compare reads SSH files through their connection. - Recovered drafts: always persisted (empty included) and not copied into host partitions; over-cap drafts stay for this launch and say so; the newest-visited workspace's draft wins; unique ids with the workspace shown; drafts recovered later show the notice again.
…es supersede older reads, stamp the surviving tab, keep live tails apart - Joins track which tab's draft a record carries, and each recovered draft gets a unique id, so three different drafts are all kept and credited to their own workspace. - An external change supersedes every read of the file that started before it, so an older read can't clear the reload it caused. - A read landing after its tab closed publishes to, and stamps the baseline of, a surviving tab. - Live log tails are excluded from the shared read broadcast. - Save-and-close reports its outcome; a save that landed while a sibling kept the tab dirty closes the dialog without an error. - Dismissing a recovered draft re-applies the size cap.
…its, notebook cells rebase, failed reads reach every panel - A record's draft owner is carried with it, so a losing draft is credited to the workspace it came from even when the first tab had none. - Quitting flushes every queued tab's delayed edits before the first prompt; a save that a sibling keeps dirty asks again while quitting, and never runs the tab's close reaction. - Notebook cell edits apply onto the file's shared text by cell, and focus leaving the notebook commits them. - The newest read of a file failing reaches every panel showing it. - Id-less recovered drafts (an older build rewrote the session) are told apart by their text.
…eral tabs flush - Flushing a file's tabs applies whole-document serializers (rich markdown) in edit order; the newest wins and the text any earlier one produced is kept as a recovered draft for its own workspace. - A CSV tab's pending cell applies onto the file's shared text by cell when another tab committed first, instead of over it. - Every flush path (save, quiesce, hot exit, quit, close, teardown) goes through the one record flush.
|
Parking this as a draft. The safety it was building toward (a save never silently overwrites a disk change it hasn't seen) will land first as host-checked saves per tab (#30417), which doesn't need tabs to share a buffer. This branch stays as the starting point for sharing one buffer per file once rich markdown, notebook and CSV views move onto the shared record, so they stop keeping their own whole-document copies. |
ELI5
When the same file is open in two workspaces (or twice in one), Orca now keeps one shared copy of its unsaved state. Typing in one tab shows up as unsaved in the other. Saving from either one saves the file once and clears both. Closing one of them doesn't ask you to save or throw the edits away while another tab still shows them.
This is Phase 1b, part one, of moving to one editor buffer per file: tabs showing the same file share one buffer.
What Changed
Before: two tabs showing the same file already shared one text model, but each tab kept its own unsaved draft, dirty flag, disk version, changed-on-disk mark, autosave pauses, save queue and autosave timer. So:
After:
local, an SSH target keyed by its runtime namespace and target id, or a runtime environment.\\wsl$and\\wsl.localhost). Case is kept exactly, so paths that differ only in case stay apart.written,blocked-stale(kept for guarded saves) orskipped. Save-and-close, Cmd+S and restart-save close a tab or report it saved only when the text was written. A save superseded mid-write still records the disk version it wrote./.orca-owner/<hash>/folder instead of the URL fragment. This keeps the file name last, so the TypeScript service still recognises.tsxfiles and resolves imports between files on the same host. Both WSL spellings now give one address.Dirty state is still main's content compare. That changes in 1c.
Why
The shared-model bug kept coming back across several review rounds because each tab held its own copy of the file's state. One record per file removes the duplication, so there's nothing left to fall out of sync. Sharing ships together with the per-record save queue, the single autosave timer and the last-view close rule. Without them, one workspace's autosave or "Don't Save" could still overwrite or discard another workspace's edits.
Alternatives considered:
Part two should follow soon (Phase 1b part two):
applyTextwith delayed commits fenced by version, the pending-text slot, and flushing a sibling's pending text before another tab writes.Linked Issue
N/A (internal refactor, Phase 1b of the editor buffer plan)
Visual Proof
N/A: no new UI. The behaviour change is which tabs share unsaved state and which close prompts appear. Automated tests cover it.
Testing
New tests:
The 1a store invariant (records equal the open tabs, and every mirror equals its record) is updated for shared records and still runs after every store write in dev and test builds. Ran the renderer store, editor, lib, runtime, terminal, tab-group, right-sidebar, app-shell and hooks suites, plus
pnpm tc,oxlintandoxfmton the changed files.AI Disclosure
Review
Agent skill upstream boundary
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)