diff --git a/desktop/src/components/shared/ProjectContextChip.test.tsx b/desktop/src/components/shared/ProjectContextChip.test.tsx index d5ff758c..68be5c39 100644 --- a/desktop/src/components/shared/ProjectContextChip.test.tsx +++ b/desktop/src/components/shared/ProjectContextChip.test.tsx @@ -4,7 +4,7 @@ import '@testing-library/jest-dom' import { ProjectContextChip } from './ProjectContextChip' describe('ProjectContextChip', () => { - it('keeps the source project label and adds worktree identity', () => { + it('shows only the source project label and worktree marker for isolated worktrees', () => { render( { ) expect(screen.getByText('OpenCutSkill')).toBeInTheDocument() - expect(screen.getByText('main')).toBeInTheDocument() expect(screen.getByText('worktree')).toBeInTheDocument() - expect(screen.getByText('desktop-main-54a09f85')).toBeInTheDocument() + expect(screen.queryByText('main')).not.toBeInTheDocument() + expect(screen.queryByText('desktop-main-54a09f85')).not.toBeInTheDocument() }) it('does not show worktree details for a normal checkout', () => { diff --git a/desktop/src/components/shared/ProjectContextChip.tsx b/desktop/src/components/shared/ProjectContextChip.tsx index 1cc58a5a..8eb4a708 100644 --- a/desktop/src/components/shared/ProjectContextChip.tsx +++ b/desktop/src/components/shared/ProjectContextChip.tsx @@ -26,6 +26,7 @@ export function ProjectContextChip({ const labelRoot = isWorktree ? (sourceWorkDir || workDir) : workDir const label = branch ? (repoName || basename(labelRoot)) : (basename(labelRoot) || repoName || '') const worktreeName = worktreeSlug || basename(worktreePath) || 'isolated' + const showBranch = !!branch && !isWorktree const title = [ label, branch ? `branch: ${branch}` : null, @@ -43,7 +44,7 @@ export function ProjectContextChip({ compact ? 'gap-1.5 px-3 py-1.5 text-xs' : 'gap-2 px-4 py-2 text-sm' }`} > - {branch ? ( + {showBranch ? ( @@ -51,7 +52,7 @@ export function ProjectContextChip({ folder )} {label} - {branch ? ( + {showBranch ? ( <> | {branch} @@ -63,7 +64,6 @@ export function ProjectContextChip({ worktree - {worktreeName} ) : null} diff --git a/src/server/__tests__/sessions.test.ts b/src/server/__tests__/sessions.test.ts index f5cf545a..dc259673 100644 --- a/src/server/__tests__/sessions.test.ts +++ b/src/server/__tests__/sessions.test.ts @@ -2026,11 +2026,11 @@ describe('Sessions API', () => { } }) - it('GET /api/sessions/:id/git-info should include isolated worktree identity', async () => { + it('GET /api/sessions/:id/git-info should keep the visible launch branch while including isolated worktree identity', async () => { const workDir = await createCleanGitRepo(tmpDir) const { sessionId } = await sessionService.createSession( workDir, - { branch: 'main', worktree: true }, + { branch: 'feature/rail', worktree: true }, ) const launchInfo = await sessionService.getSessionLaunchInfo(sessionId) const repository = launchInfo?.repository @@ -2038,7 +2038,7 @@ describe('Sessions API', () => { expect(repository?.worktreeBranch).toBeTruthy() const activeWorktree = repository!.worktreePath! - git(workDir, 'worktree', 'add', '-b', repository!.worktreeBranch!, activeWorktree, 'main') + git(workDir, 'worktree', 'add', '-b', repository!.worktreeBranch!, activeWorktree, 'feature/rail') const sessionsMap = (conversationService as any).sessions as Map sessionsMap.set(sessionId, { workDir: activeWorktree }) @@ -2058,7 +2058,7 @@ describe('Sessions API', () => { branch: string | null } | null } - expect(body.branch).toBe(repository!.worktreeBranch) + expect(body.branch).toBe('feature/rail') expect(body.workDir).toBe(activeWorktree) expect(body.worktree).toEqual({ enabled: true, @@ -2103,7 +2103,7 @@ describe('Sessions API', () => { branch: string | null } | null } - expect(body.branch).toBe('worktree-desktop-main-12345678') + expect(body.branch).toBe('main') expect(body.workDir).toBe(activeWorktree) expect(body.worktree).toEqual({ enabled: true, @@ -2157,7 +2157,7 @@ describe('Sessions API', () => { branch: string | null } | null } - expect(body.branch).toBe('worktree-desktop-main-12345678') + expect(body.branch).toBe('main') expect(body.worktree).toMatchObject({ path: activeWorktree, plannedPath: activeWorktree, diff --git a/src/server/api/sessions.ts b/src/server/api/sessions.ts index e404d1fe..b71acc4e 100644 --- a/src/server/api/sessions.ts +++ b/src/server/api/sessions.ts @@ -670,9 +670,11 @@ async function getGitInfo(sessionId: string): Promise { sameResolvedPath(workDir, worktree.path) || sameResolvedPath(workDir, worktree.plannedPath) ) - const branch = materializedWorktree - ? (gitBranch || worktree.branch || sessionBranch) - : (sessionBranch || gitBranch) + const branch = sessionBranch || ( + materializedWorktree + ? (worktree.branch || gitBranch) + : gitBranch + ) // Get repo name from remote or directory let repoName = ''