Repository navigation
Conflict review shows the file's live unsaved text from any workspace (read-only) - #31990
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
Co-Authored-By: Claude <[email protected]>
A dirty view with no draft no longer pushes disk text into the shared model; merge and deleted-banner joins mirror the record; web-session sync honours detached views. Co-Authored-By: Claude <[email protected]>
…ompt closes, restore merges - Rich Markdown, notebook and CSV commits also edit the record's models no editor shows, as one undoable edit; a save moves every loaded view's panel text to the written disk text, so a stale dirty check can't mark the record clean over unsaved edits. - A detached pair rejoins once one side is clean (save, Discard, reload) or the partner closes: the clean side attaches, a dirty side wins with its own baseline, so its next save is refused and the banner shows on every view. Rejoin runs on the next microtask, after the caller has finished settling the record; doing it mid-settle let the settle clear the adopted draft. - A dirty record whose last view a no-prompt removal closed is kept with its draft and model; reopening the file joins it, it never autosaves, and dismissing the removal notice drops it. - Restored identical drafts merge; divergent ones detach with their own models and timers. Co-Authored-By: Claude <[email protected]>
…e a record through its writable view Adds save-queue and store tests for rename and owner-resolution re-keys carrying a conflict, a read-only sibling joining a dirty record, retired-runtime quarantine, runtime-in-SSH identity, the reconnect writer, restart once per record, and a 200-tab index. Fix: restart picked a record's first dirty view, so a read-only view listed first refused the whole restart; it now picks the record's first view that may autosave. Co-Authored-By: Claude <[email protected]>
… save events - A no-prompt removal's keep request rides in the write that closes the tabs (editorBufferKeepRequest, consumed by the record middleware), so a removal closing tabs over several writes keeps every dirty record it closes. - Kept records carry their removal notice's token; dismissing a notice, or failing to show it, releases only that notice's records. - A divergent dirty view reopening a kept record stays detached on its own model; a rename onto a kept record's path drops the kept record. - Each rich/notebook/CSV commit into a retained model is its own undo step. - The saved event names the record's views, so the panel updates them even when the saving tab closed mid-save. - A queued save compares the discard epoch of the record it was queued under. - Typing no longer runs the rejoin check; only clearing a side's draft does. Co-Authored-By: Claude <[email protected]>
…r-switch-g3 # Conflicts: # src/renderer/src/components/editor/editor-model-owner.test.ts # src/renderer/src/components/editor/editor-model-owner.ts # src/renderer/src/components/editor/editor-save-queue-records.test.ts # src/renderer/src/store/editor-buffer-record-lifecycle.ts # src/renderer/src/store/slices/editor/buffers/editor-buffer-join.ts # src/renderer/src/store/slices/editor/buffers/editor-buffer-mirrored-dirty.test.ts # src/renderer/src/store/slices/editor/buffers/editor-buffer-record.ts # src/renderer/src/store/slices/editor/buffers/editor-buffer-views.ts
…, read-only and live The overview of a conflict review now reads each file through any open view of its shared buffer record (this workspace's first), so it shows the record's current unsaved text and model and follows typing in another workspace. It stays read-only and is never a view itself: it loads as that view would and never pushes text. With no view open it still shows disk text. Co-Authored-By: Claude <[email protected]>
…ever acts as it - The overview's load reruns when the view it reads through opens, closes, re-keys, detaches or rejoins in any workspace, so it no longer sticks on "Loading...". - Retry reloads through the borrowed view's own workspace, and the editor resolves through that workspace, so this workspace never re-owns the other's tab. - Overview editors are passive mirrors: they don't move the borrowed tab's cursor line or take a reveal meant for it. - This workspace's own tab (even a detached one with its own edits) wins over another workspace's view. - The panel's draft selector re-resolves when tabs or record views change, not only when drafts do; overview lookups are memoized per tabs/views/routes, and the stand-in cache evicts least recently used entries instead of clearing. Co-Authored-By: Claude <[email protected]>
…r-switch-g4 # Conflicts: # src/renderer/src/runtime/web-session-tabs-sync/apply-final-patch.ts # src/renderer/src/store/editor-buffer-record-lifecycle.test.ts # src/renderer/src/store/editor-buffer-record-lifecycle.ts # src/renderer/src/store/slices/editor/buffers/editor-buffer-identity-cache.ts # src/renderer/src/store/slices/editor/buffers/editor-buffer-mirrored-dirty.test.ts # src/renderer/src/store/slices/editor/buffers/editor-buffer-reconcile-write.ts # src/renderer/src/store/slices/editor/buffers/editor-buffer-reconcile.ts # src/renderer/src/store/slices/editor/buffers/editor-buffer-record.ts
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ 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:
6779b139-186f-415d-9464-0744e428f4bf
📒 Files selected for processing: 20
src/renderer/src/components/editor/EditorConflictReviewSurface.live-record.test.tsxsrc/renderer/src/components/editor/EditorConflictReviewSurface.tsxsrc/renderer/src/components/editor/MonacoEditor.tsxsrc/renderer/src/components/editor/editor-panel-draft-selector.test.tssrc/renderer/src/components/editor/editor-panel-draft-selector.tssrc/renderer/src/components/editor/monaco-editor-mount-params.tssrc/renderer/src/components/editor/use-monaco-editor-mount.cursor-owner.test.tsxsrc/renderer/src/components/editor/use-monaco-editor-mount.tssrc/renderer/src/components/editor/useEditorPanelActiveTabContentLoad.overview.test.tsxsrc/renderer/src/components/editor/useEditorPanelActiveTabContentLoad.tssrc/renderer/src/components/editor/useEditorPanelContentState.test.tsxsrc/renderer/src/components/editor/useEditorPanelContentState.tssrc/renderer/src/components/editor/useEditorPanelFloatingTabContentState.test.tsxsrc/renderer/src/components/editor/useEditorPanelHostUnresolvedContentState.test.tsxsrc/renderer/src/components/editor/useEditorPanelRemoteSiblingContentState.test.tsxsrc/renderer/src/components/editor/useEditorPanelVisibilityContentState.test.tsxsrc/renderer/src/store/slices/editor/buffers/editor-buffer-conflict-overview.test.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-conflict-overview.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-identity-cache.tssrc/renderer/src/store/slices/editor/file-ids/editor-file-ids.ts
💤 Files with no reviewable changes: 2
- src/renderer/src/components/editor/useEditorPanelContentState.ts
- src/renderer/src/store/slices/editor/file-ids/editor-file-ids.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.
| let previousDrafts: AppState['editorDrafts'] | null = null | ||
| let previousOpenFiles: EditorDraftState['openFiles'] | null = null | ||
| let previousViews: EditorDraftState['editorBufferViews'] | null = null | ||
| let previousSelection = EMPTY_EDITOR_PANEL_DRAFTS | ||
|
|
||
| return (state) => { | ||
| // Why: every Zustand write reruns the selector. The slice identity guard | ||
| // keeps unrelated terminal/status traffic allocation-free. | ||
| if (previousDrafts === state.editorDrafts) { | ||
| // keeps unrelated terminal/status traffic allocation-free; overview ids | ||
| // also move with the tabs and record views they resolve through. | ||
| if ( | ||
| previousDrafts === state.editorDrafts && | ||
| (overviewPaths.length === 0 || | ||
| (previousOpenFiles === state.openFiles && previousViews === state.editorBufferViews)) | ||
| ) { | ||
| return previousSelection | ||
| } | ||
| previousDrafts = state.editorDrafts | ||
| previousOpenFiles = state.openFiles | ||
| previousViews = state.editorBufferViews | ||
|
|
||
| const ids = selectedFileIds(state) | ||
| const changed = ids.some((fileId) => { | ||
| const draft = state.editorDrafts[fileId] | ||
| return ( | ||
| draft !== previousSelection[fileId] || | ||
| (draft === undefined && Object.hasOwn(previousSelection, fileId)) | ||
| ) | ||
| }) | ||
| const idSet = new Set(ids) | ||
| const changed = | ||
| ids.some((fileId) => { | ||
| const draft = state.editorDrafts[fileId] | ||
| return ( | ||
| draft !== previousSelection[fileId] || | ||
| (draft === undefined && Object.hasOwn(previousSelection, fileId)) | ||
| ) | ||
| }) || Object.keys(previousSelection).some((fileId) => !idSet.has(fileId)) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,130p' src/renderer/src/components/editor/editor-panel-draft-selector.ts
sed -n '1,135p' src/renderer/src/store/slices/editor/buffers/editor-buffer-conflict-overview.ts
sed -n '20,85p' src/renderer/src/store/slices/editor/buffers/editor-buffer-identity-cache.tsRepository: stablyai/orca
Length of output: 9506
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- route inputs and declarations ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'EDITOR_BUFFER_ROUTE_INPUT_KEYS' -e 'EditorBufferRouteState' -e 'editorBufferRouteInputsChanged' src/ || true
printf '%s\n' '--- route input key names ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'runtimeEnvironments' -e 'editorBufferIdentityRevision' -e 'editorBufferIdentityOf' src/renderer/src/store src/renderer/src/components/editor || true
printf '%s\n' '--- conflict overview selector/callers ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'createEditorPanelDraftSelector' -e 'conflictOverviewView(' -e 'conflictOverviewViewsKey' src/renderer/src || true
printf '%s\n' '--- candidate changed-file diff ---'
git diff --no-ext-diff --unified=40 885cd6ff44f115dab642839c3b19549ef55335a2 -- src/renderer/src/components/editor/editor-panel-draft-selector.ts src/renderer/src/store/slices/editor/buffers/editor-buffer-identity-cache.ts src/renderer/src/store/slices/editor/buffers/editor-buffer-conflict-overview.tsRepository: stablyai/orca
Length of output: 41604
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- route state and identity implementation ---'
sed -n '1,240p' src/renderer/src/lib/worktree-operation-route.ts
sed -n '1,240p' src/renderer/src/store/slices/editor/buffers/editor-buffer-identity.ts
printf '%s\n' '--- identity action and lifecycle implementations ---'
sed -n '1,280p' src/renderer/src/store/slices/editor/actions/editor-buffer-identity-actions.ts
sed -n '1,260p' src/renderer/src/store/editor-buffer-record-lifecycle.ts
printf '%s\n' '--- direct route-input writes ---'
rg -n -U --glob '*.ts' --glob '*.tsx' '(set\\(|setState\\(|\\.setState\\().{0,500}(repos|worktreesByRepo|detectedWorktreesByRepo|folderWorkspaces|projectGroups|restoredRuntimeHostIdByWorkspaceSessionKey|runtimeEnvironmentCatalogHydrated|removedRuntimeEnvironmentIds|runtimeEnvironments|settings|editorBufferIdentityRevision)' src/renderer/src/store src/renderer/src/components || trueRepository: stablyai/orca
Length of output: 25281
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- route-input writes by key ---'
for key in repos worktreesByRepo detectedWorktreesByRepo folderWorkspaces projectGroups restoredRuntimeHostIdByWorkspaceSessionKey runtimeEnvironmentCatalogHydrated removedRuntimeEnvironmentIds runtimeEnvironments settings editorBufferIdentityRevision; do
printf '%s\n' "### $key"
rg -n -F --glob '*.ts' --glob '*.tsx' -- "$key:" src/renderer/src/store src/renderer/src/components src/renderer/src/hooks || true
done
printf '%s\n' '--- route update APIs and state setters ---'
rg -n -F --glob '*.ts' --glob '*.tsx' -e 'setRuntimeEnvironmentCatalogHydrated' -e 'runtimeEnvironmentCatalogHydrated' -e 'reconcileEditorBufferIdentities' -e 'setRepos' -e 'setWorktrees' src/renderer/src/store src/renderer/src/components src/renderer/src/hooks || true
printf '%s\n' '--- conflict overview tests ---'
sed -n '1,180p' src/renderer/src/store/slices/editor/buffers/editor-buffer-conflict-overview.test.ts
printf '%s\n' '--- draft selector tests ---'
sed -n '1,230p' src/renderer/src/components/editor/editor-panel-draft-selector.test.ts
printf '%s\n' '--- relevant lifecycle/reconcile tests ---'
rg -n -F --glob '*test.ts' --glob '*test.tsx' -e 'route' -e 'identityRevision' -e 'reconcileEditorBufferIdentities' src/renderer/src/store/slices/editor/buffers src/renderer/src/components/editor | head -200 || trueRepository: stablyai/orca
Length of output: 45665
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- production writes: hydration and identity revision ---'
rg -n -F --glob '*.ts' --glob '*.tsx' --glob '!*.test.ts' --glob '!*.test.tsx' --glob '!*.spec.ts' --glob '!*.spec.tsx' \
-e 'runtimeEnvironmentCatalogHydrated:' -e 'editorBufferIdentityRevision:' -e 'reconcileEditorBufferIdentities(' \
src/renderer/src || true
printf '%s\n' '--- production writes: route object fields ---'
rg -n -F --glob '*.ts' --glob '*.tsx' --glob '!*.test.ts' --glob '!*.test.tsx' --glob '!*.spec.ts' --glob '!*.spec.tsx' \
-e 'worktreesByRepo:' -e 'detectedWorktreesByRepo:' -e 'folderWorkspaces:' -e 'projectGroups:' \
-e 'restoredRuntimeHostIdByWorkspaceSessionKey:' -e 'removedRuntimeEnvironmentIds:' -e 'runtimeEnvironments:' -e 'settings:' \
src/renderer/src/store src/renderer/src/hooks || true
printf '%s\n' '--- route re-key test block ---'
sed -n '1,245p' src/renderer/src/store/slices/editor/buffers/editor-buffer-reconcile-identity.test.ts
printf '%s\n' '--- shared-record route test block ---'
sed -n '280,360p' src/renderer/src/components/editor/editor-save-queue-shared-records.test.tsRepository: stablyai/orca
Length of output: 44772
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- editor model owner ---'
sed -n '1,260p' src/renderer/src/components/editor/editor-model-owner.ts
printf '%s\n' '--- runtime catalog hydration transition ---'
sed -n '1,190p' src/renderer/src/store/slices/runtime-status.ts
printf '%s\n' '--- view rekey implementation ---'
rg -n -F --glob '*.ts' -e 'function reconcileEditorBufferRecords' -e 'editorBufferViews' -e 'viewMirrors' src/renderer/src/store/slices/editor/buffers/editor-buffer-reconcile.ts src/renderer/src/store/slices/editor/buffers/editor-buffer-reconcile-write.ts src/renderer/src/store/slices/editor/buffers/editor-buffer-views.ts
sed -n '1,300p' src/renderer/src/store/slices/editor/buffers/editor-buffer-reconcile.ts
sed -n '1,260p' src/renderer/src/store/slices/editor/buffers/editor-buffer-reconcile-write.tsRepository: stablyai/orca
Length of output: 28716
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- numbered selector and owner blocks ---'
nl -ba src/renderer/src/components/editor/editor-panel-draft-selector.ts | sed -n '24,82p'
nl -ba src/renderer/src/components/editor/editor-model-owner.ts | sed -n '8,54p'
printf '%s\n' '--- numbered route resolver entry and route-state types ---'
rg -n -F -- 'export function resolveWorktreeOperationRoute' src/renderer/src/lib/worktree-operation-route.ts
nl -ba src/renderer/src/lib/worktree-operation-route.ts | sed -n '220,390p'
printf '%s\n' '--- numbered lifecycle route guard and state write ---'
nl -ba src/renderer/src/store/editor-buffer-record-lifecycle.ts | sed -n '45,110p'
nl -ba src/renderer/src/store/editor-buffer-record-lifecycle.ts | sed -n '180,214p'
printf '%s\n' '--- numbered reachable route writers ---'
nl -ba src/renderer/src/store/slices/runtime-status.ts | sed -n '104,148p'
nl -ba src/renderer/src/store/slices/worktrees/listing/fetched-worktree-merge.ts | sed -n '205,292p'Repository: stablyai/orca
Length of output: 23647
🏁 Script executed:
set -o pipefail
rg -n -F -- 'function resolveExplicitWorktreeOperationRouteResult' src/renderer/src/lib
rg -n -F -- 'runtimeOwnerEnvironmentId' src/renderer/src/lib src/renderer/src/store/slices/worktrees | head -40Repository: stablyai/orca
Length of output: 5559
🏁 Script executed:
nl -ba src/renderer/src/lib/worktree-operation-catalog-route.ts | sed -n '1,105p'Repository: stablyai/orca
Length of output: 4653
🏁 Script executed:
nl -ba src/renderer/src/lib/worktree-owner-route.ts | sed -n '1,180p'Repository: stablyai/orca
Length of output: 3614
Include the route epoch in the overview draft selector guard.
A worktree owner update can change conflictOverviewView from one explicit-runtime tab to another while editorDrafts, openFiles, and editorBufferViews keep the same references. The selector then returns previousSelection without resolving the new view, so the overview can display the previous tab’s draft.
Suggested fix
import {
conflictOverviewView,
type ConflictOverviewState
} from '@/store/slices/editor/buffers/editor-buffer-conflict-overview'
+import { editorBufferRouteEpochOf } from '@/store/slices/editor/buffers/editor-buffer-identity-cache'
@@
let previousDrafts: AppState['editorDrafts'] | null = null
let previousOpenFiles: EditorDraftState['openFiles'] | null = null
let previousViews: EditorDraftState['editorBufferViews'] | null = null
+ let previousRouteEpoch: object | null = null
let previousSelection = EMPTY_EDITOR_PANEL_DRAFTS
return (state) => {
+ const routeEpoch = overviewPaths.length === 0 ? null : editorBufferRouteEpochOf(state)
// Why: every Zustand write reruns the selector. The slice identity guard
@@
previousDrafts === state.editorDrafts &&
(overviewPaths.length === 0 ||
- (previousOpenFiles === state.openFiles && previousViews === state.editorBufferViews))
+ (previousOpenFiles === state.openFiles &&
+ previousViews === state.editorBufferViews &&
+ previousRouteEpoch === routeEpoch))
@@
previousDrafts = state.editorDrafts
previousOpenFiles = state.openFiles
previousViews = state.editorBufferViews
+ previousRouteEpoch = routeEpoch…orkspace (read-only) (stablyai#31990)" This reverts commit 8556d11 for the release ad hoc build only. stablyai#31990 builds on stablyai#31974, which is reverted next.
ELI5
When a file has a conflict (it changed on disk while you had unsaved edits), the conflict-review overview shows your side. It used to show the text from one tab in the same workspace, or the disk text if the file was only open in another workspace. Now it shows the file's current unsaved text from whichever tab holds it — read-only, and updating live as you type there.
What Changed
Why
Last step of moving to one editor buffer per file (after #31974). With tabs of a file sharing one record, the overview can show exactly the text that Overwrite/Reload would act on, which is what the conflict decision needs.
Linked Issue
Follow-up to #31974.
Visual Proof
N/A: the overview looks the same; it now shows the shared unsaved text instead of one tab's or disk text. Covered by tests against a real two-workspace store.
Testing
pnpm tc, ratchets,check:code-quality:changed, oxfmt pass; editor/store/hooks/runtime/sidebar suites pass.Known gaps: a file whose last tab closed with unsaved text kept for recovery shows disk text here; if every tab of the file is mirrored from an older remote host, the overview uses the previous same-workspace behaviour.
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
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)