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

+1 -11
View File
@@ -1,6 +1,6 @@
import { describe, it, expect, afterEach } from 'vitest'
import { stubMatchMedia } from '@/test/test-utils'
import { getFocusedElement, hasOpenOverlay, isFinePointer, restoreOverlayFocus } from './overlayFocus'
import { getFocusedElement, hasOpenOverlay, restoreOverlayFocus } from './overlayFocus'
import { PROMPT_INPUT_SELECTOR, isPromptInput, isTextEntryElement } from './domTargets'
function createElement<K extends keyof HTMLElementTagNameMap>(
@@ -26,16 +26,6 @@ describe('getFocusedElement', () => {
})
})
describe('isFinePointer', () => {
it('reflects the fine pointer media query', () => {
stubMatchMedia(true)
expect(isFinePointer()).toBe(true)
stubMatchMedia(false)
expect(isFinePointer()).toBe(false)
})
})
describe('restoreOverlayFocus', () => {
it('focuses the chat prompt on desktop when focus was on a button', () => {
stubMatchMedia(true)
+1 -4
View File
@@ -12,10 +12,7 @@ export function getFocusedElement(): HTMLElement | null {
: null
}
/**
* Reports whether the current device uses a fine pointer, such as a mouse or trackpad.
*/
export function isFinePointer(): boolean {
function isFinePointer(): boolean {
return (
typeof window !== 'undefined' &&
typeof window.matchMedia === 'function' &&
+10 -1
View File
@@ -1,5 +1,14 @@
import { describe, it, expect } from 'vitest'
import { buildPinnedSessionKeys } from './sessionKey'
import { buildPinnedSessionKeys, getSessionKey } from './sessionKey'
import type { Session } from '@/api/types'
describe('getSessionKey', () => {
it('combines the session directory and id', () => {
const session = { id: 'ses_1', location: { directory: '/w/a' } } as Session
expect(getSessionKey(session)).toBe('/w/a:ses_1')
})
})
describe('buildPinnedSessionKeys', () => {
it('builds a session key for each pin', () => {
+6
View File
@@ -1,7 +1,13 @@
import type { Session } from '@/api/types'
export function buildSessionKey(directory: string | undefined, id: string): string {
return `${directory ?? ''}:${id}`
}
export function getSessionKey(session: Pick<Session, 'id' | 'location'>): string {
return buildSessionKey(session.location.directory, session.id)
}
export function buildPinnedSessionKeys(
pins: ReadonlyArray<{ directory: string; sessionId: string }>,
): Set<string> {