mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix(web): keep session preview fold while searching (#1183)
Searching the session list forced every directory group to expand all sessions (expanded: isFiltering) and hid the Show more button, so the user's per-group preview fold was ignored during filtering. Stop overriding the preview state while filtering and keep the Show more / Show less control available. Fixes #1068
This commit is contained in:
@@ -7,7 +7,10 @@ import { I18nProvider } from '@/lib/i18n-context'
|
||||
import { ToastProvider } from '@/lib/toast-context'
|
||||
import { SessionList } from './SessionList'
|
||||
|
||||
afterEach(() => cleanup())
|
||||
afterEach(() => {
|
||||
cleanup()
|
||||
localStorage.removeItem('hapi-session-preview-limit')
|
||||
})
|
||||
|
||||
function makeSession(overrides: Partial<SessionSummary> & { id: string }): SessionSummary {
|
||||
return {
|
||||
@@ -225,7 +228,7 @@ describe('SessionList action menu parity', () => {
|
||||
})
|
||||
|
||||
describe('SessionList collapse behavior', () => {
|
||||
function renderSessionList(sessions: SessionSummary[], selectedSessionId = 'session-running') {
|
||||
function renderSessionList(sessions: SessionSummary[], selectedSessionId: string | null = 'session-running') {
|
||||
return (
|
||||
<QueryClientProvider client={new QueryClient({
|
||||
defaultOptions: {
|
||||
@@ -346,4 +349,32 @@ describe('SessionList collapse behavior', () => {
|
||||
expect(firstPanel?.getAttribute('data-open')).toBe('true')
|
||||
})
|
||||
})
|
||||
|
||||
it('keeps the configured session preview fold while searching', () => {
|
||||
localStorage.setItem('hapi-session-preview-limit', '2')
|
||||
const sessions = Array.from({ length: 4 }, (_, index) => makeSession({
|
||||
id: `matching-${index + 1}`,
|
||||
updatedAt: 100 - index,
|
||||
metadata: {
|
||||
path: '/work/hapi',
|
||||
name: `Matching task ${index + 1}`,
|
||||
flavor: 'codex',
|
||||
},
|
||||
}))
|
||||
|
||||
render(renderSessionList(sessions, null))
|
||||
fireEvent.change(screen.getByPlaceholderText('Search sessions…'), {
|
||||
target: { value: 'Matching task' },
|
||||
})
|
||||
|
||||
expect(screen.getByRole('button', { name: /Matching task 1/ })).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: /Matching task 2/ })).toBeInTheDocument()
|
||||
expect(screen.queryByRole('button', { name: /Matching task 3/ })).toBeNull()
|
||||
expect(screen.queryByRole('button', { name: /Matching task 4/ })).toBeNull()
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Show 2 more' }))
|
||||
|
||||
expect(screen.getByRole('button', { name: /Matching task 3/ })).toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: /Matching task 4/ })).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1150,7 +1150,6 @@ export function SessionList(props: {
|
||||
return getVisibleSessionPreview(
|
||||
group.sessions,
|
||||
{
|
||||
expanded: isFiltering,
|
||||
selectedSessionId,
|
||||
limit: getGroupVisibleCount(group)
|
||||
}
|
||||
@@ -1341,7 +1340,7 @@ export function SessionList(props: {
|
||||
showDetailedStatus={showDetailedStatus}
|
||||
/>
|
||||
))}
|
||||
{!isFiltering && group.sessions.length > sessionPreviewLimit && (hiddenSessionCount > 0 || canCollapseSessions) ? (
|
||||
{group.sessions.length > sessionPreviewLimit && (hiddenSessionCount > 0 || canCollapseSessions) ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => hiddenSessionCount > 0
|
||||
|
||||
Reference in New Issue
Block a user