diff --git a/web/src/components/AssistantChat/HappyThread.tsx b/web/src/components/AssistantChat/HappyThread.tsx
index 918e7e52..130648bb 100644
--- a/web/src/components/AssistantChat/HappyThread.tsx
+++ b/web/src/components/AssistantChat/HappyThread.tsx
@@ -29,6 +29,7 @@ import { useSessionHeaderMetadata } from '@/hooks/useSessionHeaderMetadata'
import { useMachines } from '@/hooks/queries/useMachines'
import { useMachineLabels } from '@/hooks/useMachineLabels'
import { resolveSessionHeaderMachineLabel } from '@/components/SessionHeader'
+import { getSessionProjectLabel, getSessionProjectPath } from '@/lib/sessionProjectLabel'
import { formatRelativeTime } from '@/lib/relativeTime'
import { formatSessionHeaderTimestamp } from '@/lib/sessionHeaderTimestamp'
import { getShareTurnReasoningLabel, selectShareTurnMetadata } from '@/lib/shareTurnMetadata'
@@ -572,6 +573,8 @@ export function HappyThread(props: {
const agentFlavor = props.session.metadata?.flavor ?? null
const agentLabel = agentFlavor?.trim() || null
const machineLabel = resolveSessionHeaderMachineLabel(props.session, machineLabelsById)
+ const projectPath = getSessionProjectPath(props.session.metadata)
+ const projectLabel = projectPath ? getSessionProjectLabel(projectPath) : null
const modelLabel = getSessionModelLabel(props.session)
const reasoningLabel = getShareTurnReasoningLabel(
agentFlavor,
@@ -589,6 +592,9 @@ export function HappyThread(props: {
return selectShareTurnMetadata(headerMetadata, {
agent: agentLabel ? { text: agentLabel, flavor: agentFlavor } : undefined,
+ project: projectLabel ? {
+ text: `${headerMetadata.showLabels ? `${t('session.item.project')}: ` : ''}${projectLabel}`,
+ } : undefined,
machine: machineLabel ? {
text: `${headerMetadata.showLabels ? `${t('session.item.machine')}: ` : ''}${machineLabel}`,
} : undefined,
diff --git a/web/src/components/SessionHeader.test.tsx b/web/src/components/SessionHeader.test.tsx
index a78780af..5fcb2541 100644
--- a/web/src/components/SessionHeader.test.tsx
+++ b/web/src/components/SessionHeader.test.tsx
@@ -321,6 +321,32 @@ describe('SessionHeader', () => {
expect(screen.getByTestId('session-header-age')).toHaveTextContent(/5m ago|5分钟前/)
})
+ it('shows the project label from the worktree base path separately from its branch', () => {
+ renderHeader(baseSession({
+ metadata: {
+ flavor: 'cursor',
+ path: '/home/user/coding/hapi-worktrees/fix-resume',
+ host: 'machine',
+ worktree: {
+ basePath: '/home/user/coding/hapi',
+ branch: 'fix/resume',
+ name: 'fix-resume',
+ worktreePath: '/home/user/coding/hapi-worktrees/fix-resume'
+ }
+ }
+ }))
+
+ expect(screen.getByTestId('session-header-project')).toHaveTextContent('project: coding/hapi')
+ expect(screen.getByText('worktree: fix/resume')).toBeInTheDocument()
+ })
+
+ it('hides the project label when its display setting is disabled', () => {
+ localStorage.setItem('hapi-session-header-metadata', JSON.stringify({ project: false }))
+ renderHeader(baseSession({ metadata: { flavor: 'cursor', path: '/home/user/coding/hapi', host: 'machine' } }))
+
+ expect(screen.queryByTestId('session-header-project')).not.toBeInTheDocument()
+ })
+
it('advances relative age on the minute tick without a session prop change', () => {
vi.useFakeTimers()
const now = new Date('2026-07-29T16:00:00.000Z')
diff --git a/web/src/components/SessionHeader.tsx b/web/src/components/SessionHeader.tsx
index 693ed9d7..1c2c4793 100644
--- a/web/src/components/SessionHeader.tsx
+++ b/web/src/components/SessionHeader.tsx
@@ -19,6 +19,7 @@ import { useTranslation } from '@/lib/use-translation'
import { AgentFlavorIcon } from '@/components/AgentFlavorIcon'
import { isFastServiceTier } from '@/components/AssistantChat/codexFastMode'
import { getSessionTitle } from '@/lib/sessionTitle'
+import { getSessionProjectLabel, getSessionProjectPath } from '@/lib/sessionProjectLabel'
import { useToast } from '@/lib/toast-context'
import { queryKeys } from '@/lib/query-keys'
import { markCodexSessionsImported } from '@/lib/codexImportedSessions'
@@ -161,6 +162,8 @@ export function SessionHeader(props: {
const { addToast } = useToast()
const { session, api, onSessionDeleted, onSessionReopened } = props
const title = useMemo(() => getSessionTitle(session), [session])
+ const projectPath = getSessionProjectPath(session.metadata)
+ const projectLabel = projectPath ? getSessionProjectLabel(projectPath) : null
const worktreeBranch = session.metadata?.worktree?.branch?.trim() || null
const { preferences: headerMetadata } = useSessionHeaderMetadata()
const modelLabel = getSessionModelLabel(session)
@@ -204,6 +207,7 @@ export function SessionHeader(props: {
)
const ageAbsolute = ageLabel ? formatAbsoluteDateTime(lastActiveAt) : null
const mobileSecondary = selectMobileSessionHeaderSecondary({
+ project: headerMetadata.project && projectLabel !== null,
model: headerMetadata.model && modelLabel !== null,
reasoning: headerMetadata.reasoning && reasoningLabel !== null,
machine: headerMetadata.machine && machineLabel !== null,
@@ -409,6 +413,7 @@ export function SessionHeader(props: {
{agentLabel}
) : null}
+ {mobileSecondary === 'project' && projectLabel ? {headerMetadata.showLabels ? `${t('session.item.project')}: ` : ''}{projectLabel} : null}
{mobileSecondary === 'model' && modelLabel ? {headerMetadata.showLabels ? `${t(modelLabel.key)}: ` : ''}{modelLabel.value}{isModelChanging ? : null} : null}
{mobileSecondary === 'reasoning' && reasoningLabel ? {reasoningLabel} : null}
{mobileSecondary === 'machine' && machineLabel ? {headerMetadata.showLabels ? `${t('session.item.machine')}: ` : ''}{machineLabel} : null}
@@ -426,6 +431,11 @@ export function SessionHeader(props: {
{agentLabel}
) : null}
+ {headerMetadata.project && projectLabel ? (
+
+ {headerMetadata.showLabels ? `${t('session.item.project')}: ` : ''}{projectLabel}
+
+ ) : null}
{headerMetadata.machine && machineLabel ? (
{headerMetadata.showLabels ? `${t('session.item.machine')}: ` : ''}{machineLabel}
diff --git a/web/src/components/SessionList.tsx b/web/src/components/SessionList.tsx
index 28171c69..ca52edfd 100644
--- a/web/src/components/SessionList.tsx
+++ b/web/src/components/SessionList.tsx
@@ -107,6 +107,7 @@ import { formatReopenError } from '@/lib/reopenError'
import { resolveCursorReopenGate } from '@/lib/sessionResume'
import { getSessionTitle, hasSessionTitleSignal } from '@/lib/sessionTitle'
import { getWorktreeSessionLabel } from '@/lib/sessionWorktreeLabel'
+import { getSessionProjectLabel, getSessionProjectPath } from '@/lib/sessionProjectLabel'
import { retargetSharePendingTransfer } from '@/lib/sharePendingState'
import type { Machine } from '@/types/api'
import { getMachinePlatform, presentMachineHealth } from '@/lib/machineHealth'
@@ -118,7 +119,6 @@ import { SessionRowSummary } from '@/components/SessionRowSummary'
import { Spinner } from '@/components/Spinner'
import { transferComposerDraftThenNavigate } from '@/lib/composer-draft-transfer'
import { useToast } from '@/lib/toast-context'
-import { getPathDisplayName } from '@/utils/path'
import {
shedToolbarSlots,
toolbarActionBudget,
@@ -433,7 +433,7 @@ export function groupSessionsByDirectory(sessions: SessionSummary[], fixedOrder
const groups = new Map()
sessions.forEach(session => {
- const path = session.metadata?.worktree?.basePath ?? session.metadata?.path ?? 'Other'
+ const path = getSessionProjectPath(session.metadata) ?? 'Other'
const machineId = session.metadata?.machineId ?? null
const key = `${machineId ?? UNKNOWN_MACHINE_ID}::${path}`
if (!groups.has(key)) {
@@ -468,7 +468,7 @@ export function groupSessionsByDirectory(sessions: SessionSummary[], fixedOrder
)
const hasActiveSession = group.sessions.some(s => s.active)
const hasPinnedSession = group.sessions.some(s => s.pinned)
- const displayName = getPathDisplayName(group.directory)
+ const displayName = getSessionProjectLabel(group.directory)
return {
key,
@@ -1873,7 +1873,7 @@ export function SessionList(props: {
selected={s.id === selectedSessionId}
showDetailedStatus={showDetailedStatus}
inRunningSection
- projectLabel={getPathDisplayName(s.metadata?.worktree?.basePath ?? s.metadata?.path ?? 'Other')}
+ projectLabel={getSessionProjectLabel(getSessionProjectPath(s.metadata) ?? 'Other')}
machineLabel={resolveMachineLabel(s.metadata?.machineId ?? null)}
lastSeenVersion={lastSeenVersion}
/>
@@ -2548,7 +2548,7 @@ export function SessionList(props: {
selected={s.id === selectedSessionId}
showDetailedStatus={showDetailedStatus}
inRunningSection
- projectLabel={getPathDisplayName(s.metadata?.worktree?.basePath ?? s.metadata?.path ?? 'Other')}
+ projectLabel={getSessionProjectLabel(getSessionProjectPath(s.metadata) ?? 'Other')}
machineLabel={resolveMachineLabel(s.metadata?.machineId ?? null)}
lastSeenVersion={lastSeenVersion}
/>
diff --git a/web/src/hooks/useSessionHeaderMetadata.test.ts b/web/src/hooks/useSessionHeaderMetadata.test.ts
index 7265c1c6..329138c2 100644
--- a/web/src/hooks/useSessionHeaderMetadata.test.ts
+++ b/web/src/hooks/useSessionHeaderMetadata.test.ts
@@ -9,6 +9,7 @@ describe('parseSessionHeaderMetadata', () => {
expect(DEFAULT_SESSION_HEADER_METADATA).toMatchObject({
showLabels: true,
agent: true,
+ project: true,
model: true,
reasoning: true,
fastMode: true,
diff --git a/web/src/hooks/useSessionHeaderMetadata.ts b/web/src/hooks/useSessionHeaderMetadata.ts
index 15b8a47e..a14c9efd 100644
--- a/web/src/hooks/useSessionHeaderMetadata.ts
+++ b/web/src/hooks/useSessionHeaderMetadata.ts
@@ -3,6 +3,7 @@ import { useCallback, useEffect, useState } from 'react'
export type SessionHeaderMetadataKey =
| 'showLabels'
| 'agent'
+ | 'project'
| 'model'
| 'reasoning'
| 'fastMode'
@@ -17,6 +18,7 @@ export type SessionHeaderMetadataPreferences = Record {
+ it('prioritizes the project label when it is available', () => {
+ expect(selectMobileSessionHeaderSecondary({ project: true, machine: true })).toBe('project')
+ })
+
it('follows the upstream-first display order', () => {
expect(selectMobileSessionHeaderSecondary({ machine: true, model: true, updatedAt: true })).toBe('machine')
expect(selectMobileSessionHeaderSecondary({ model: true, updatedAt: true, worktree: true })).toBe('model')
diff --git a/web/src/lib/sessionHeaderMobileMetadata.ts b/web/src/lib/sessionHeaderMobileMetadata.ts
index fa3ed553..06cae907 100644
--- a/web/src/lib/sessionHeaderMobileMetadata.ts
+++ b/web/src/lib/sessionHeaderMobileMetadata.ts
@@ -1,4 +1,5 @@
export type SessionHeaderSecondaryMetadataKey =
+ | 'project'
| 'model'
| 'reasoning'
| 'machine'
@@ -9,6 +10,7 @@ export type SessionHeaderSecondaryMetadataKey =
| 'fastMode'
const MOBILE_SECONDARY_PRIORITY: ReadonlyArray = [
+ 'project',
'machine',
'lastActive',
'model',
diff --git a/web/src/lib/sessionProjectLabel.test.ts b/web/src/lib/sessionProjectLabel.test.ts
new file mode 100644
index 00000000..d37dcf85
--- /dev/null
+++ b/web/src/lib/sessionProjectLabel.test.ts
@@ -0,0 +1,31 @@
+import { describe, expect, it } from 'vitest'
+import { getSessionProjectLabel, getSessionProjectPath } from './sessionProjectLabel'
+
+describe('session project labels', () => {
+ it('uses the repository path for worktree sessions', () => {
+ expect(getSessionProjectPath({
+ path: '/work/hapi-worktrees/fix-resume',
+ worktree: { basePath: '/work/hapi' },
+ })).toBe('/work/hapi')
+ expect(getSessionProjectLabel('/work/hapi')).toBe('work/hapi')
+ })
+
+ it('formats nested POSIX and Windows paths like the sidebar', () => {
+ expect(getSessionProjectLabel('/home/user/coding/hapi')).toBe('coding/hapi')
+ expect(getSessionProjectLabel('C:\\work\\hapi')).toBe('work/hapi')
+ expect(getSessionProjectLabel('hapi')).toBe('hapi')
+ })
+
+ it('falls back to the session path and hides blank paths', () => {
+ expect(getSessionProjectPath({ path: '/repo' })).toBe('/repo')
+ expect(getSessionProjectPath({ path: ' ' })).toBeNull()
+ expect(getSessionProjectPath(null)).toBeNull()
+ })
+
+ it('does not treat a worktree with no base path as a simple session', () => {
+ expect(getSessionProjectPath({
+ path: '/work/hapi-worktrees/fix-resume',
+ worktree: { basePath: ' ' },
+ })).toBeNull()
+ })
+})
diff --git a/web/src/lib/sessionProjectLabel.ts b/web/src/lib/sessionProjectLabel.ts
new file mode 100644
index 00000000..64453ca2
--- /dev/null
+++ b/web/src/lib/sessionProjectLabel.ts
@@ -0,0 +1,21 @@
+import { getPathDisplayName } from '@/utils/path'
+
+export type SessionProjectMetadata = {
+ path?: string | null
+ worktree?: {
+ basePath?: string | null
+ } | null
+}
+
+/** Use the repository path for worktrees and the session path otherwise. */
+export function getSessionProjectPath(metadata: SessionProjectMetadata | null | undefined): string | null {
+ if (metadata?.worktree) {
+ return metadata.worktree.basePath?.trim() || null
+ }
+ return metadata?.path?.trim() || null
+}
+
+/** Match the compact project labels used by the session sidebar. */
+export function getSessionProjectLabel(directory: string): string {
+ return getPathDisplayName(directory)
+}
diff --git a/web/src/lib/shareTurnMetadata.test.ts b/web/src/lib/shareTurnMetadata.test.ts
index 4918476e..85ef1780 100644
--- a/web/src/lib/shareTurnMetadata.test.ts
+++ b/web/src/lib/shareTurnMetadata.test.ts
@@ -5,6 +5,7 @@ import { getShareTurnReasoningLabel, selectShareTurnMetadata } from './shareTurn
describe('selectShareTurnMetadata', () => {
const available = {
agent: { text: 'codex', flavor: 'codex' },
+ project: { text: 'Project: coding/hapi' },
machine: { text: 'Machine: workstation' },
lastActive: { text: '2 minutes ago' },
model: { text: 'Model: gpt-5.6-sol' },
@@ -17,7 +18,7 @@ describe('selectShareTurnMetadata', () => {
it('uses the desktop session-header order and default visibility', () => {
expect(selectShareTurnMetadata(DEFAULT_SESSION_HEADER_METADATA, available).map((item) => item.key)).toEqual([
- 'agent', 'machine', 'lastActive', 'model', 'reasoning', 'fastMode', 'worktree',
+ 'agent', 'project', 'machine', 'lastActive', 'model', 'reasoning', 'fastMode', 'worktree',
])
})
diff --git a/web/src/lib/shareTurnMetadata.ts b/web/src/lib/shareTurnMetadata.ts
index 59a0577a..bb698e9d 100644
--- a/web/src/lib/shareTurnMetadata.ts
+++ b/web/src/lib/shareTurnMetadata.ts
@@ -21,6 +21,7 @@ export function getShareTurnReasoningLabel(
const SESSION_HEADER_METADATA_ORDER: ReadonlyArray = [
'agent',
+ 'project',
'machine',
'lastActive',
'model',
diff --git a/web/src/routes/settings/display.tsx b/web/src/routes/settings/display.tsx
index fca9a7ca..d25ad79e 100644
--- a/web/src/routes/settings/display.tsx
+++ b/web/src/routes/settings/display.tsx
@@ -148,6 +148,7 @@ export default function SettingsDisplayPage() {
const sessionHeaderOptions: ReadonlyArray<{ key: SessionHeaderMetadataKey; labelKey: string }> = [
{ key: 'showLabels', labelKey: 'settings.display.sessionHeader.showLabels' },
{ key: 'agent', labelKey: 'settings.display.sessionHeader.agent' },
+ { key: 'project', labelKey: 'settings.display.sessionHeader.project' },
{ key: 'machine', labelKey: 'settings.display.sessionHeader.machine' },
{ key: 'lastActive', labelKey: 'settings.display.sessionHeader.lastActive' },
{ key: 'model', labelKey: 'settings.display.sessionHeader.model' },
diff --git a/web/src/routes/settings/index.test.tsx b/web/src/routes/settings/index.test.tsx
index 5c0addda..1f067ab7 100644
--- a/web/src/routes/settings/index.test.tsx
+++ b/web/src/routes/settings/index.test.tsx
@@ -103,6 +103,7 @@ vi.mock('@/hooks/useSessionHeaderMetadata', () => ({
preferences: {
showLabels: true,
agent: true,
+ project: true,
model: true,
reasoning: true,
fastMode: true,
@@ -296,6 +297,7 @@ describe('responsive settings pages', () => {
fireEvent.click(appBadgeToggle)
expect(setAppBadgeEnabled).toHaveBeenCalledWith(true)
expect(screen.getByRole('checkbox', { name: 'Show field labels' })).toBeChecked()
+ expect(screen.getByRole('checkbox', { name: 'Project' })).toBeChecked()
expect(screen.getByRole('checkbox', { name: 'Reasoning effort' })).toBeChecked()
expect(screen.getByRole('checkbox', { name: 'Machine' })).toBeChecked()
expect(screen.getByRole('checkbox', { name: 'Active time' })).toBeChecked()