Repository navigation
fix(sidebar): draw a project group once when two hosts publish it under one id #30128
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
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
2cfee82
fix(sidebar): draw a project group once when two hosts publish it und…
nwparker c3e9153
fix(cmd-j): search a same-id project group by the copy the sidebar shows
nwparker b6febe8
fix(sidebar): reveal a same-id project group through the copy the sid…
nwparker 27b7d10
fix(sidebar): reveal a folder workspace through the group parents the…
nwparker 2874fbb
fix(sidebar): reveal from the host-filtered groups the rows were buil…
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
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
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
125 changes: 125 additions & 0 deletions
125
src/renderer/src/components/sidebar/worktree-list-groups-same-id-host-groups.test.ts
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,125 @@ | ||
| /** | ||
| * #30045: moving a project to a managed server copies its project group to the server under the | ||
| * same id, and the desktop keeps its own copy. The sidebar must still draw that group once. | ||
| */ | ||
| import { describe, expect, it } from 'vitest' | ||
| import { buildRows } from './worktree-list/grouping/build-rows.test-fixture' | ||
| import { repo, worktree } from './worktree-list-groups-test-fixtures' | ||
| import { getRenderRowKey } from './worktree-list/listing/render-row' | ||
| import { getSidebarRowRevealAncestorKeys } from './worktree-list/navigation/reveal-ancestors' | ||
| import { getProjectGroupOccurrencePaths } from '../../../../shared/sidebar-list/project-group-sections' | ||
| import type { ProjectGroup } from '../../../../shared/project-group-types' | ||
| import type { Repo } from '../../../../shared/repo-types' | ||
| import type { Worktree } from '../../../../shared/worktree/types' | ||
| import type { ExecutionHostId } from '../../../../shared/execution-host' | ||
|
|
||
| const REMOTE_HOST: ExecutionHostId = 'runtime:env-b' | ||
|
|
||
| function group(executionHostId: ExecutionHostId, overrides: Partial<ProjectGroup> = {}) { | ||
| return { | ||
| id: 'group-shared', | ||
| name: 'Platform', | ||
| parentPath: null, | ||
| executionHostId, | ||
| parentGroupId: null, | ||
| createdFrom: 'manual', | ||
| tabOrder: 0, | ||
| isCollapsed: false, | ||
| color: null, | ||
| createdAt: 1, | ||
| updatedAt: 1, | ||
| ...overrides | ||
| } satisfies ProjectGroup | ||
| } | ||
|
|
||
| const groupedRepo: Repo = { ...repo, projectGroupId: 'group-shared' } | ||
| const localWorktree: Worktree = { | ||
| ...worktree, | ||
| id: 'wt-local', | ||
| hostId: 'local' | ||
| } | ||
| const remoteWorktree: Worktree = { | ||
| ...worktree, | ||
| id: 'wt-remote', | ||
| hostId: REMOTE_HOST | ||
| } | ||
|
|
||
| function rowsFor(projectGroups: readonly ProjectGroup[], collapsed = new Set<string>()) { | ||
| const worktrees = [localWorktree, remoteWorktree] | ||
| return buildRows( | ||
| 'repo', | ||
| worktrees, | ||
| new Map([[groupedRepo.id, groupedRepo]]), | ||
| null, | ||
| collapsed, | ||
| undefined, | ||
| undefined, | ||
| undefined, | ||
| {}, | ||
| new Map(worktrees.map((entry) => [entry.id, entry])), | ||
| false, | ||
| undefined, | ||
| projectGroups | ||
| ) | ||
| } | ||
|
|
||
| describe('a project group both hosts publish under one id', () => { | ||
| it('draws one header holding the project, not a second empty one', () => { | ||
| const rows = rowsFor([group('local'), group(REMOTE_HOST, { name: 'Renamed on server' })]) | ||
|
|
||
| const groupHeaders = rows.filter((row) => row.type === 'header' && row.projectGroup) | ||
| expect(groupHeaders).toHaveLength(1) | ||
| // The same copy every id-keyed lookup (and Cmd+J) resolves to. | ||
| expect(groupHeaders[0]).toMatchObject({ | ||
| key: 'project-group:group-shared', | ||
| label: 'Renamed on server', | ||
| count: 1 | ||
| }) | ||
| expect(rows.filter((row) => row.type === 'item')).toHaveLength(2) | ||
| }) | ||
|
|
||
| it('gives every rendered row a distinct key', () => { | ||
| const keys = rowsFor([group('local'), group(REMOTE_HOST)]).map(getRenderRowKey) | ||
|
|
||
| expect(new Set(keys).size).toBe(keys.length) | ||
| }) | ||
|
|
||
| it('keeps a same-id child group nested once under its parent', () => { | ||
| const parent = (hostId: ExecutionHostId) => group(hostId, { id: 'parent', name: 'Parent' }) | ||
| const child = (hostId: ExecutionHostId) => group(hostId, { parentGroupId: 'parent' }) | ||
|
|
||
| const rows = rowsFor([parent('local'), child('local'), parent(REMOTE_HOST), child(REMOTE_HOST)]) | ||
|
|
||
| expect( | ||
| rows.flatMap((row) => | ||
| row.type === 'header' && row.projectGroup ? [[row.key, row.projectGroupDepth]] : [] | ||
| ) | ||
| ).toEqual([ | ||
| ['project-group:parent', 0], | ||
| ['project-group:group-shared', 1] | ||
| ]) | ||
| }) | ||
|
|
||
| it('reveals the drawn copy when the copies have different parents', () => { | ||
| const groups = [ | ||
| group('local'), | ||
| group(REMOTE_HOST, { id: 'parent', name: 'Parent' }), | ||
| group(REMOTE_HOST, { parentGroupId: 'parent' }) | ||
| ] | ||
|
|
||
| const collapsedParentRows = rowsFor(groups, new Set(['project-group:parent'])) | ||
| expect( | ||
| collapsedParentRows.filter((row) => row.type === 'header').map((row) => row.key) | ||
| ).toEqual(['project-group:parent']) | ||
| expect( | ||
| getSidebarRowRevealAncestorKeys({ | ||
| rowKey: 'project-group:group-shared', | ||
| repoMap: new Map(), | ||
| projectGroups: groups | ||
| }) | ||
| ).toEqual(['project-group:parent']) | ||
| expect(getProjectGroupOccurrencePaths(groups).get('group-shared')?.parent?.key).toBe( | ||
| 'project-group:parent' | ||
| ) | ||
| }) | ||
| }) |
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
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
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
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
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
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
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 | 🟠 Major | 🏗️ Heavy lift
Keep conflicting host trees from hiding grouped projects.
If same-ID copies from two hosts interleave, selecting the last copy of each ID can create a parent cycle. For example, local
Ais a root and localBis its child, while remoteBis a root and remoteAis its child. In the order[local A, remote B, remote A, local B], this loop selectsA → B → A. Neither group reaches the root traversal at Line 132. The fallback at Lines 137-139 then skips their grouped repos because both IDs exist. Resolve conflicting parents or detect cycles before building the tree so those projects remain visible.