feat(web): show project in session header (#1635)

* feat(web): show project in session header

* fix(web): hide unknown worktree project paths
This commit is contained in:
SSU-WEI HUANG
2026-10-28 12:14:04 +08:00
committed by GitHub
parent 8b5cde7e44
commit 3f4bd9afea
16 changed files with 118 additions and 6 deletions
+31
View File
@@ -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()
})
})