Repository navigation
fix(source-control): preserve section collapse state #9405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
nwparker
merged 6 commits into
stablyai:main
from
just-zzp:fix/source-control-section-collapse-state
Oct 24, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ef298d7
fix(source-control): preserve section collapse state
just-zzp 8c3bf6a
test(source-control): strengthen remount regression
just-zzp c92dafa
fix(source-control): preserve section disclosure across panel remounts
nwparker d83e92c
Merge remote-tracking branch 'origin/review-9405-original' into nwpar…
nwparker 78d8e59
Merge remote-tracking branch 'origin/main' into fix9405
nwparker 39dd7a4
fix(source-control): key retained disclosure by active worktree id
nwparker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
63 changes: 63 additions & 0 deletions
63
src/renderer/src/components/right-sidebar/source-control/panel/use-panel-view-state.test.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // @vitest-environment happy-dom | ||
|
|
||
| import { act } from 'react' | ||
| import { createRoot, type Root } from 'react-dom/client' | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { useSourceControlPanelViewState } from './use-panel-view-state' | ||
|
|
||
| let container: HTMLDivElement | ||
| let root: Root | ||
| let toggle: (section: string) => void = () => {} | ||
| let collapsed = new Set<string>() | ||
|
|
||
| function Probe({ worktreeId }: { worktreeId: string | null }) { | ||
| const viewState = useSourceControlPanelViewState({ | ||
| activeWorktreeId: worktreeId, | ||
| settings: null, | ||
| updateSettings: vi.fn() | ||
| }) | ||
| toggle = viewState.toggleSection | ||
| collapsed = viewState.collapsedSections | ||
| return null | ||
| } | ||
|
|
||
| function render(worktreeId: string | null): void { | ||
| act(() => root.render(<Probe worktreeId={worktreeId} />)) | ||
| } | ||
|
|
||
| function remount(worktreeId: string | null): void { | ||
| act(() => root.unmount()) | ||
| root = createRoot(container) | ||
| render(worktreeId) | ||
| } | ||
|
|
||
| beforeEach(() => { | ||
| globalThis.IS_REACT_ACT_ENVIRONMENT = true | ||
| container = document.createElement('div') | ||
| root = createRoot(container) | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| act(() => root.unmount()) | ||
| }) | ||
|
|
||
| describe('useSourceControlPanelViewState section disclosure', () => { | ||
| it('keeps a worktree choice across remount without leaking it to another worktree', () => { | ||
| render('wt-a') | ||
| act(() => toggle('unstaged')) | ||
| act(() => toggle('history')) | ||
| expect([...collapsed].sort()).toEqual(['unstaged']) | ||
|
|
||
| remount('wt-a') | ||
| expect([...collapsed].sort()).toEqual(['unstaged']) | ||
|
|
||
| render('wt-b') | ||
| expect([...collapsed].sort()).toEqual(['history']) | ||
|
|
||
| remount('wt-b') | ||
| expect([...collapsed].sort()).toEqual(['history']) | ||
|
|
||
| render('wt-a') | ||
| expect([...collapsed].sort()).toEqual(['unstaged']) | ||
| }) | ||
| }) |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness |
Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: stablyai/orca
Length of output: 11878
🏁 Script executed:
Repository: stablyai/orca
Length of output: 41439
🏁 Script executed:
Repository: stablyai/orca
Length of output: 45661
🏁 Script executed:
Repository: stablyai/orca
Length of output: 41753
🏁 Script executed:
Repository: stablyai/orca
Length of output: 41649
🏁 Script executed:
Repository: stablyai/orca
Length of output: 41930
🏁 Script executed:
Repository: stablyai/orca
Length of output: 17183
Key disclosure state by checkout occupant and execution host.
activeWorktreeIdis only arepoId::pathlocator. It is not host-qualified. The hook must key state by the canonical occupant identity: the active worktree’s execution host andactiveWorktreeInstanceId. UsecomposeWorktreeHostIdentity(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.