Repository navigation
fix(source-control): preserve section collapse state - #9405
Conversation
Walkthrough
Priority: Merge Risk:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/right-sidebar/SourceControl.virtual-file-list.test.tsx (1)
371-375: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the remounted header exists before clicking it. The first lookup already does this; the remounted one should mirror it so a missing/renamed "Changes" header fails here instead of turning the click into a silent no-op.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: f801338f-5e27-43ce-8712-bf87e4f44ba8
📒 Files selected for processing (4)
src/renderer/src/components/right-sidebar/SourceControl.tsxsrc/renderer/src/components/right-sidebar/SourceControl.virtual-file-list.test.tsxsrc/renderer/src/components/right-sidebar/source-control-section-collapse-state.test.tsxsrc/renderer/src/components/right-sidebar/source-control-section-collapse-state.ts
|
Taking a look! |
Adapt just-zzp's stablyai#9405 fix to the current panel modules and existing bounded map, with runtime/host/occupant isolation. Part of stablyai#9403; Session History remains separate. Co-authored-by: just-zzp <264744947+just-zzp@users.noreply.github.com>
…ker/bug-9405-source-control-collapse
Narrow the remount fix to the existing per-worktree reset: a bounded renderer-session map keyed by activeWorktreeId restores section disclosure after the panel unmounts, while a worktree switch still never inherits another worktree's view.
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:
9b42cd73-1097-40c7-b667-61730ff7a8f0
Files selected for processing: 3-
src/renderer/src/components/right-sidebar/SourceControl.virtual-file-list.test.tsxsrc/renderer/src/components/right-sidebar/source-control/panel/use-panel-view-state.test.tsxsrc/renderer/src/components/right-sidebar/source-control/panel/use-panel-view-state.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.
-
| } | ||
|
|
||
| // Why: the panel unmounts on sidebar tab switch; retain per-worktree disclosure for this renderer session. | ||
| const collapsedSectionsByWorktree = new BoundedMap<string, Set<string>>({ maxEntries: 512 }) |
There was a problem hiding this comment.
🎯 Functional Correctness |
🔎 Supported by static analysis
-
🏁 Script executed:
sed -n '1,180p' src/renderer/src/components/right-sidebar/source-control/panel/use-panel-view-state.ts sed -n '1,220p' src/renderer/src/components/right-sidebar/source-control/panel/use-panel-state.ts rg -n 'activeWorktreeInstanceId|useSourceControlPanelViewState|worktreeId' src/renderer/src/components/right-sidebar/source-control/panel
Repository: stablyai/orca
Length of output: 11878
🏁 Script executed:
set -o pipefail printf '%s\n' '--- identity references ---' rg -n -F --glob '*.{ts,tsx}' -e 'activeWorktreeInstanceId' -e 'executionHost' -e 'ownerId' -e 'owner' -e 'worktreeInstanceId' -e 'instanceId' src/renderer/src/components/right-sidebar/source-control src/renderer/src | head -n 240 printf '%s\n' '--- context declaration and related types ---' rg -n -F --glob '*.{ts,tsx}' -e 'useSourceControlWorktreeContext' -e 'SourceControlWorktreeContext' -e 'activeWorktreeInstanceId' src/renderer/src/components/right-sidebar/source-control src/renderer/src/store src/shared | head -n 240 printf '%s\n' '--- replacement and locator references ---' rg -n -F --glob '*.{ts,tsx}' -e 'worktree replacement' -e 'replaceWorktree' -e 'recreated' -e 'locator' -e 'worktreeInstance' -e 'executionHostId' src/renderer/src src/shared | head -n 300 printf '%s\n' '--- relevant diff ---' git diff --find-renames 92ccacd7373147a07cd26ab81ac296b5b102912a 39dd7a464a6876c3d119fcf5f0ada414be7f639e -- src/renderer/src/components/right-sidebar/source-control/panel/use-panel-view-state.ts src/renderer/src/components/right-sidebar/source-control/panel/use-panel-state.ts
Repository: stablyai/orca
Length of output: 41439
🏁 Script executed:
set -o pipefail printf '%s\n' '--- source-control worktree context ---' sed -n '1,280p' src/renderer/src/components/right-sidebar/source-control/listing/use-worktree-context.ts printf '%s\n' '--- context imports and worktree types ---' rg -n -F --glob '*.ts' --glob '*.tsx' -e 'instanceId?:' -e 'instanceId:' -e 'interface Worktree' -e 'type Worktree' -e 'executionHostId' src/shared src/renderer/src/store src/renderer/src/lib src/renderer/src/components/right-sidebar/source-control/listing | head -n 320 printf '%s\n' '--- exact instance-id definitions and consumers ---' rg -n -F --glob '*.ts' --glob '*.tsx' -e 'activeWorktree?.instanceId' -e 'instanceId' src/renderer/src/components/right-sidebar/source-control/listing src/renderer/src/store/slices src/shared | head -n 320 printf '%s\n' '--- locator and identity helpers ---' rg -n -i --glob '*.ts' --glob '*.tsx' 'host.?qualified|qualified.?locator|locator.*fallback|fallback.*locator|worktree.*locator|locator.*worktree|worktree.*identity|identity.*worktree' src | head -n 320 printf '%s\n' '--- tests for the changed hook and replacement behavior ---' sed -n '1,260p' src/renderer/src/components/right-sidebar/source-control/panel/use-panel-view-state.test.tsx rg -n -i --glob '*.{ts,tsx}' 'recreat|replace.*worktree|worktree.*replace|same.*worktree.*host|same.*id.*host|instanceId' src/renderer/src/components/right-sidebar/source-control src/renderer/src/store | head -n 320
Repository: stablyai/orca
Length of output: 45661
🏁 Script executed:
set -o pipefail printf '%s\n' '--- worktree declarations ---' rg -n -U --glob '*.ts' --glob '*.tsx' 'export (interface|type) Worktree|interface Worktree|type Worktree\\s*=' src | head -n 80 printf '%s\n' '--- instance ID lifecycle ---' rg -n -F --glob '*.ts' --glob '*.tsx' -e 'instanceId: crypto' -e 'instanceId: random' -e 'instanceId: uuid' -e 'instanceId: generate' -e 'instanceId ??' -e 'instanceId ||' -e 'worktree.instanceId' -e 'instanceId = ' src/shared src/renderer/src/store src/main | head -n 240 printf '%s\n' '--- same-ID host tests ---' sed -n '1,150p' src/renderer/src/store/slices/worktree-catalog-reconciliation.test.ts sed -n '210,270p' src/renderer/src/store/slices/purge-stale-runtime-host-state.test.ts sed -n '200,250p' src/renderer/src/store/slices/worktree-listing-branch-switch.test.ts printf '%s\n' '--- worktree ID construction and recreation comments ---' rg -n -i --glob '*.ts' --glob '*.tsx' 'recreated at the same path|worktree ids are recycled|id.*repo.*path|repo.*path.*id|new.*instance' src/shared src/renderer/src/store src/main | head -n 240 printf '%s\n' '--- disclosure/fallback terms in full repository ---' rg -n -i --glob '*.ts' --glob '*.tsx' 'collapsedSectionsByWorktree|host-qualified locator|locator fallback|occupant metadata|checkout occupant|section disclosure|disclosure state' . | head -n 240
Repository: stablyai/orca
Length of output: 41753
🏁 Script executed:
set -o pipefail printf '%s\n' '--- checkout identity contract ---' sed -n '1,220p' src/shared/worktree/identity.ts printf '%s\n' '--- persisted locator aliases ---' sed -n '55,125p' src/shared/persisted-state-types.ts rg -n -F --glob '*.ts' --glob '*.tsx' -e 'Host-qualified locator aliases' -e 'worktreeLocatorAliases' -e 'locatorAliases' -e 'canonical identity keys' src | head -n 160 printf '%s\n' '--- alias declarations and consumers ---' rg -n -i --glob '*.ts' --glob '*.tsx' 'locator.*alias|alias.*locator|canonical.*identity|identity.*key' src/shared src/renderer/src/store src/renderer/src/lib | head -n 240 printf '%s\n' '--- worktree ID and host construction ---' rg -n -F --glob '*.ts' --glob '*.tsx' -e 'repo.id}::' -e 'repoId}::' -e 'hostId:' -e 'id: worktreeId' -e 'worktreeId = ' src/main src/shared src/renderer/src/store | head -n 260 printf '%s\n' '--- exact source-control owner key patterns ---' sed -n '35,75p' src/renderer/src/components/right-sidebar/source-control/sync/use-git-history.ts sed -n '145,180p' src/renderer/src/components/right-sidebar/source-control/sync/use-git-history.ts sed -n '1,140p' src/renderer/src/components/right-sidebar/source-control/worktree-git-owner-target.ts
Repository: stablyai/orca
Length of output: 41649
🏁 Script executed:
set -o pipefail printf '%s\n' '--- canonical identity consumers ---' rg -n -F --glob '*.ts' --glob '*.tsx' -e 'canonicalWorktreeIdentity' -e 'createWorktreeIdentity' -e 'WorktreeIdentityRef' -e 'worktreeIdentityAliases' src printf '%s\n' '--- identity helper modules ---' find src/shared/worktree -maxdepth 2 -type f -print | sort for f in src/shared/worktree/id.ts src/shared/sidebar-list/workspace-rows.ts src/shared/sidebar-list/paired-server-rows.ts; do if test -f "$f"; then printf '%s\n' "--- $f ---" sed -n '1,240p' "$f" fi done printf '%s\n' '--- active worktree host and type evidence ---' rg -n -F --glob '*.ts' --glob '*.tsx' -e 'activeWorktree.hostId' -e 'activeWorktree?.hostId' -e 'hostId: activeWorktree' -e 'Pick<Worktree' src/renderer/src src/shared | head -n 220 printf '%s\n' '--- worktree model imports ---' rg -n -F --glob '*.ts' --glob '*.tsx' -e 'from.*types' -e 'from.*models' src/shared | grep -E 'Worktree|worktree' | head -n 120
Repository: stablyai/orca
Length of output: 41930
🏁 Script executed:
set -o pipefail printf '%s\n' '--- host-qualified identity contract ---' sed -n '1,180p' src/shared/worktree/host-qualified-identity.ts printf '%s\n' '--- active worktree host and execution-host alias ---' sed -n '1,140p' src/renderer/src/lib/worktree-execution-host-alias.ts sed -n '285,315p' src/shared/execution-host.ts printf '%s\n' '--- canonical alias projection ---' sed -n '1,125p' src/main/persistence/loading-store/worktree-meta-alias-projection.ts sed -n '1,125p' src/main/persistence/loading-store/worktree-identity-metadata.ts
Repository: stablyai/orca
Length of output: 17183
Key disclosure state by checkout occupant and execution host.
activeWorktreeId is only a repoId::path locator. It is not host-qualified. The hook must key state by the canonical occupant identity: the active worktree’s execution host and activeWorktreeInstanceId. Use composeWorktreeHostIdentity(executionHostId, activeWorktreeId) only when instance metadata is unavailable. Use the same key for the cache lookup, write, and switch comparison.
A recreated checkout receives a new durable instance ID, but the current hook ignores it. A same-ID checkout on another host also shares the current key. The host-qualified fallback matches the repository contract for legacy rows, but it cannot distinguish two occupants that both lack instance metadata on the same host.
|
Maintainer follow-up (39dd7a4): merged main and narrowed the fix. Retained section disclosure is now a bounded (512) renderer-session map keyed by |
Collapsing a Source Control section (e.g. Changes) was lost after visiting Explorer or Checks, because the right sidebar unmounts
<SourceControl/>on tab switch. Section disclosure now survives those remounts for the current worktree in this renderer session.Part of #9403. Agent Session History is tracked separately in #9419, so this PR does not close the combined issue.
Scope:
use-panel-view-state.tskeeps a module-levelBoundedMap(max 512 entries) of collapsed sections keyed byactiveWorktreeId, the same key as the existing per-worktree reset. On mount and on worktree switch the reset reads that worktree's retained sections (or the defaults, including collapsed Commits); toggles write back.Original work by @just-zzp; narrowed by maintainers to the existing worktree key.
Tests:
SourceControl.virtual-file-list.test.tsxremount regression anduse-panel-view-state.test.tsx(remount retention + no cross-worktree leak) fail on main and pass here.