fix(mobile): show branch label in repo quick switch sheet so worktrees are distinguishable (#346)

This commit is contained in:
Chris Scott authored and GitHub committed 2026-09-01 22:16:04 -04:00
1 parent 68d586f183
commit 93338abbdb
2 files changed
+64 -3

No files matched your search

@@ -110,6 +110,53 @@ describe('RepoQuickSwitchSheet', () => {
})
})
it('distinguishes worktrees of the same repo by branch', async () => {
vi.mocked(listRepos).mockResolvedValue([
{
id: 1,
repoUrl: 'https://github.com/test/repo1.git',
localPath: '/path/to/repo1',
sourcePath: null,
currentBranch: 'main',
isLocal: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
},
{
id: 2,
repoUrl: 'https://github.com/test/repo1.git',
localPath: '/path/to/repo1/.worktrees/feature-a',
sourcePath: null,
currentBranch: 'feature-a',
isWorktree: true,
isLocal: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
},
{
id: 3,
repoUrl: 'https://github.com/test/repo1.git',
localPath: '/path/to/repo1/.worktrees/feature-b',
sourcePath: null,
currentBranch: 'feature-b',
isWorktree: true,
isLocal: false,
createdAt: new Date().toISOString(),
updatedAt: new Date().toISOString(),
},
])
const handleClose = vi.fn()
render(
<RepoQuickSwitchSheet isOpen onClose={handleClose} />,
{ wrapper: createWrapper() },
)
await waitFor(() => {
expect(screen.getAllByText('repo1')).toHaveLength(3)
expect(screen.getByText('feature-a')).toBeInTheDocument()
expect(screen.getByText('feature-b')).toBeInTheDocument()
})
})
it('does not show assistant as a repo option', async () => {
vi.mocked(listRepos).mockResolvedValue([
{
@@ -8,7 +8,7 @@ import { Button } from '@/components/ui/button'
import { cn, getRepoDisplayName } from '@/lib/utils'
import { listRepos } from '@/api/repos'
import { AddRepoDialog } from '@/components/repo/AddRepoDialog'
import { FolderGit2, Check, Plus } from 'lucide-react'
import { FolderGit2, Check, Plus, GitBranch } from 'lucide-react'
import { useUrlParams } from '@/hooks/useUrlParams'
import { ASSISTANT_REPO_ID } from '@opencode-manager/shared/utils'
import { getAssistantPath, isAssistantPath } from '@/lib/navigation'
@@ -123,6 +123,7 @@ export function RepoQuickSwitchSheet({ isOpen, onClose }: RepoQuickSwitchSheetPr
<div className="flex flex-col gap-2">
{filteredRepos.map((repo) => {
const isActive = repo.id === activeRepoId
const branchToDisplay = repo.currentBranch || repo.branch
return (
<button
key={repo.id}
@@ -146,8 +147,21 @@ export function RepoQuickSwitchSheet({ isOpen, onClose }: RepoQuickSwitchSheetPr
<FolderGit2 className="h-4 w-4" />
</div>
</div>
<div className="flex-1 min-w-0 font-medium text-sm text-foreground truncate">
{getRepoDisplayName(repo)}
<div className="flex-1 min-w-0">
<div className="font-medium text-sm text-foreground truncate">
{getRepoDisplayName(repo)}
</div>
{branchToDisplay && (
<div
className={cn(
'flex items-center gap-1 text-xs',
repo.isWorktree ? 'text-purple-400' : 'text-muted-foreground',
)}
>
<GitBranch className="h-3 w-3 shrink-0" />
<span className="truncate">{branchToDisplay}</span>
</div>
)}
</div>
{isActive && <Check className="h-4 w-4 text-primary flex-shrink-0" />}
</button>