Skip to content

Commit 93338ab

Browse files
fix(mobile): show branch label in repo quick switch sheet so worktrees are distinguishable (#346)
1 parent 68d586f commit 93338ab

2 files changed

Lines changed: 64 additions & 3 deletions

File tree

‎frontend/src/components/navigation/RepoQuickSwitchSheet.test.tsx‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,53 @@ describe('RepoQuickSwitchSheet', () => {
110110
})
111111
})
112112

113+
it('distinguishes worktrees of the same repo by branch', async () => {
114+
vi.mocked(listRepos).mockResolvedValue([
115+
{
116+
id: 1,
117+
repoUrl: 'https://github.com/test/repo1.git',
118+
localPath: '/path/to/repo1',
119+
sourcePath: null,
120+
currentBranch: 'main',
121+
isLocal: false,
122+
createdAt: new Date().toISOString(),
123+
updatedAt: new Date().toISOString(),
124+
},
125+
{
126+
id: 2,
127+
repoUrl: 'https://github.com/test/repo1.git',
128+
localPath: '/path/to/repo1/.worktrees/feature-a',
129+
sourcePath: null,
130+
currentBranch: 'feature-a',
131+
isWorktree: true,
132+
isLocal: false,
133+
createdAt: new Date().toISOString(),
134+
updatedAt: new Date().toISOString(),
135+
},
136+
{
137+
id: 3,
138+
repoUrl: 'https://github.com/test/repo1.git',
139+
localPath: '/path/to/repo1/.worktrees/feature-b',
140+
sourcePath: null,
141+
currentBranch: 'feature-b',
142+
isWorktree: true,
143+
isLocal: false,
144+
createdAt: new Date().toISOString(),
145+
updatedAt: new Date().toISOString(),
146+
},
147+
])
148+
const handleClose = vi.fn()
149+
render(
150+
<RepoQuickSwitchSheet isOpen onClose={handleClose} />,
151+
{ wrapper: createWrapper() },
152+
)
153+
await waitFor(() => {
154+
expect(screen.getAllByText('repo1')).toHaveLength(3)
155+
expect(screen.getByText('feature-a')).toBeInTheDocument()
156+
expect(screen.getByText('feature-b')).toBeInTheDocument()
157+
})
158+
})
159+
113160
it('does not show assistant as a repo option', async () => {
114161
vi.mocked(listRepos).mockResolvedValue([
115162
{

‎frontend/src/components/navigation/RepoQuickSwitchSheet.tsx‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Button } from '@/components/ui/button'
88
import { cn, getRepoDisplayName } from '@/lib/utils'
99
import { listRepos } from '@/api/repos'
1010
import { AddRepoDialog } from '@/components/repo/AddRepoDialog'
11-
import { FolderGit2, Check, Plus } from 'lucide-react'
11+
import { FolderGit2, Check, Plus, GitBranch } from 'lucide-react'
1212
import { useUrlParams } from '@/hooks/useUrlParams'
1313
import { ASSISTANT_REPO_ID } from '@opencode-manager/shared/utils'
1414
import { getAssistantPath, isAssistantPath } from '@/lib/navigation'
@@ -123,6 +123,7 @@ export function RepoQuickSwitchSheet({ isOpen, onClose }: RepoQuickSwitchSheetPr
123123
<div className="flex flex-col gap-2">
124124
{filteredRepos.map((repo) => {
125125
const isActive = repo.id === activeRepoId
126+
const branchToDisplay = repo.currentBranch || repo.branch
126127
return (
127128
<button
128129
key={repo.id}
@@ -146,8 +147,21 @@ export function RepoQuickSwitchSheet({ isOpen, onClose }: RepoQuickSwitchSheetPr
146147
<FolderGit2 className="h-4 w-4" />
147148
</div>
148149
</div>
149-
<div className="flex-1 min-w-0 font-medium text-sm text-foreground truncate">
150-
{getRepoDisplayName(repo)}
150+
<div className="flex-1 min-w-0">
151+
<div className="font-medium text-sm text-foreground truncate">
152+
{getRepoDisplayName(repo)}
153+
</div>
154+
{branchToDisplay && (
155+
<div
156+
className={cn(
157+
'flex items-center gap-1 text-xs',
158+
repo.isWorktree ? 'text-purple-400' : 'text-muted-foreground',
159+
)}
160+
>
161+
<GitBranch className="h-3 w-3 shrink-0" />
162+
<span className="truncate">{branchToDisplay}</span>
163+
</div>
164+
)}
151165
</div>
152166
{isActive && <Check className="h-4 w-4 text-primary flex-shrink-0" />}
153167
</button>

0 commit comments

Comments
 (0)