feat(frontend): consolidate session picker navigation and remote project loading

This commit is contained in:
Chris Scott committed 2026-10-23 22:35:10 -04:00
1 parent 81fb2d4033
commit 52aeb7780f
42 files changed
+1486 -769

No files matched your search

+47
View File
@@ -20,13 +20,16 @@ import {
listPendingPermissions,
listSessionMessages,
listSessionPage,
projectActivityTimestamp,
readSessionSnapshot,
remoteProjectName,
renameSession,
replyForm,
replyPermission,
runCommand,
runShell,
sendPrompt,
sortProjectsByActivity,
stageRevert,
switchSessionAgent,
switchSessionModel,
@@ -753,3 +756,47 @@ describe('OpenCode facade', () => {
expect(lastRequest().init.method).toBe('DELETE')
})
})
const project = (
id: string,
name: string | undefined,
canonical: string,
time: { created: number; updated: number; active?: number },
) => ({ id, name, canonical, time, sandboxes: [] })
describe('project helpers', () => {
it('prefers the activity time over the update time', () => {
const withActivity = project('p1', 'Active', '/work/active', { created: 1, updated: 10, active: 900 })
expect(projectActivityTimestamp(withActivity)).toBe(900)
})
it('falls back to the update time when the project was never active', () => {
const neverActive = project('p1', 'Idle', '/work/idle', { created: 1, updated: 10, active: 0 })
expect(projectActivityTimestamp(neverActive)).toBe(10)
})
it('orders projects by activity, most recent first, without mutating the input', () => {
const stale = project('p_stale', 'Stale', '/work/stale', { created: 1, updated: 500, active: 100 })
const recent = project('p_recent', 'Recent', '/work/recent', { created: 1, updated: 100, active: 900 })
const middle = project('p_middle', 'Middle', '/work/middle', { created: 1, updated: 700 })
const projects = [stale, recent, middle]
expect(sortProjectsByActivity(projects).map((entry) => entry.id)).toEqual([
'p_recent',
'p_middle',
'p_stale',
])
expect(projects.map((entry) => entry.id)).toEqual(['p_stale', 'p_recent', 'p_middle'])
})
it('names a project from its trimmed title', () => {
expect(remoteProjectName(project('p1', ' Alpha ', '/work/alpha', { created: 1, updated: 2 }))).toBe('Alpha')
})
it('names a project from its directory when it has no title', () => {
expect(remoteProjectName(project('p1', undefined, '/work/beta', { created: 1, updated: 2 }))).toBe('beta')
expect(remoteProjectName(project('p1', ' ', '/work/gamma', { created: 1, updated: 2 }))).toBe('gamma')
})
})