fix(sessions): address PR #403 review findings

- fetch picker sessions only while the dialog is open
- list all-projects sessions with one request per page
- block infinite-scroll paging while a search is pending
- memoize picker rows with stable callbacks
- remove deleted sessions from list caches instead of refetching
- keep the repo tab when the open session is deleted
- reuse useSessionSearch in the sidebar session tree
- drop dead activeSessionID/isActive and share delete, session-key and repo-map helpers
- move usePersistentBoolean to its own hook
This commit is contained in:
Chris Scott committed 2026-10-08 14:36:26 -04:00
1 parent 85288d6393
commit 2d14972fad
24 files changed
+814 -412

No files matched your search

+26
View File
@@ -98,6 +98,32 @@ describe('OpenCode facade', () => {
expect(page.nextCursor).toBeUndefined()
})
it('omits the directory when listing sessions across all directories', async () => {
fetchMock.mockResolvedValue(
jsonResponse({ data: [sessionInfo('ses_1', '/repo')], cursor: { next: 'cursor_next' } }),
)
const page = await listSessionPage({ limit: 25, order: 'desc' })
expect(lastRequest().url).toBe(
'http://localhost/api/opencode/api/session?limit=25&order=desc&parentID=null',
)
expect(lastRequest().init.method).toBe('GET')
expect(page.items).toEqual([sessionInfo('ses_1', '/repo')])
expect(page.nextCursor).toBe('cursor_next')
})
it('omits the directory on an all-directories continuation page', async () => {
fetchMock.mockResolvedValue(jsonResponse({ data: [], cursor: {} }))
await listSessionPage({ cursor: 'cursor_1' })
expect(lastRequest().url).toBe(
'http://localhost/api/opencode/api/session?parentID=null&cursor=cursor_1',
)
expect(lastRequest().init.method).toBe('GET')
})
it('reads a single session from the V2 session route', async () => {
fetchMock.mockResolvedValue(jsonResponse({ data: sessionInfo('ses_1', '/repo') }))
+2 -2
View File
@@ -37,7 +37,7 @@ export interface SessionPage {
}
export interface SessionPageInput {
directory: string
directory?: string
limit?: number
order?: 'asc' | 'desc'
search?: string
@@ -93,7 +93,7 @@ function buildPromptFields(input: PromptFields) {
export async function listSessionPage(input: SessionPageInput): Promise<SessionPage> {
const { data, cursor } = await callOpenCode((api) =>
api.session.list({
directory: input.directory,
...(input.directory === undefined ? {} : { directory: input.directory }),
parentID: 'null',
limit: input.limit,
order: input.order,