1- import { createContext , useCallback , useContext , useEffect , useState , type CSSProperties } from 'react'
1+ import { createContext , useCallback , useContext , useEffect , useMemo , useState , type CSSProperties } from 'react'
22import { useQueryClient } from '@tanstack/react-query'
33import {
44 Navigate ,
@@ -40,6 +40,7 @@ import { usePlatform } from '@/hooks/usePlatform'
4040import { SessionActionMenu } from '@/components/SessionActionMenu'
4141import { ConfirmDialog } from '@/components/ui/ConfirmDialog'
4242import type { GroupDetail } from '@/types/api'
43+ import { filterSessionsBySearch } from '@/lib/session-search'
4344import FilesPage from '@/routes/sessions/files'
4445import FilePage from '@/routes/sessions/file'
4546import PreviewPage from '@/routes/sessions/preview'
@@ -231,6 +232,12 @@ function SessionsPage() {
231232 const { sidebarWidth, isResizing, startSidebarResize } = useSessionSidebarWidth ( )
232233 const { desktopSidebarHidden, setDesktopSidebarHidden, toggleDesktopSidebar } = useSessionSidebarVisibility ( )
233234 const [ mobileSidebarOpen , setMobileSidebarOpen ] = useState ( false )
235+ const [ sessionSearchQuery , setSessionSearchQuery ] = useState ( '' )
236+
237+ const visibleSessions = useMemo (
238+ ( ) => filterSessionsBySearch ( sessions , sessionSearchQuery ) ,
239+ [ sessions , sessionSearchQuery ]
240+ )
234241
235242 const handleRefresh = useCallback ( ( ) => {
236243 void refetch ( )
@@ -244,7 +251,7 @@ function SessionsPage() {
244251 } )
245252 } , [ navigate ] )
246253
247- const projectCount = new Set ( sessions . map ( s => s . metadata ?. worktree ?. basePath ?? s . metadata ?. path ?? 'Other' ) ) . size
254+ const projectCount = new Set ( visibleSessions . map ( s => s . metadata ?. worktree ?. basePath ?? s . metadata ?. path ?? 'Other' ) ) . size
248255 const sessionMatch = matchRoute ( { to : '/sessions/$sessionId' , fuzzy : true } )
249256 const chatRouteMatch = matchRoute ( { to : '/sessions/$sessionId' , fuzzy : false } )
250257 const selectedSessionId = sessionMatch && sessionMatch . sessionId !== 'new' ? sessionMatch . sessionId : null
@@ -325,7 +332,7 @@ function SessionsPage() {
325332 < div className = "flex items-center gap-1" >
326333 < button
327334 type = "button"
328- className = "rounded-md px-2.5 py-1.5 text-xs bg-[var(--app-link )] text-white font-medium"
335+ className = "rounded-md px-2.5 py-1.5 text-xs bg-[var(--app-button )] text-[var(--app-button-text)] font-medium"
329336 >
330337 Sessions
331338 </ button >
@@ -392,9 +399,17 @@ function SessionsPage() {
392399 </ div >
393400 < div className = "mx-auto w-full max-w-content flex items-center justify-between px-3 py-1.5" >
394401 < div className = "text-xs text-[var(--app-hint)]" >
395- { t ( 'sessions.count' , { n : sessions . length , m : projectCount } ) }
402+ { t ( 'sessions.count' , { n : visibleSessions . length , m : projectCount } ) }
396403 </ div >
397404 </ div >
405+ < div className = "mx-auto w-full max-w-content px-3 pb-2" >
406+ < input
407+ value = { sessionSearchQuery }
408+ onChange = { ( e ) => setSessionSearchQuery ( e . target . value ) }
409+ placeholder = { t ( 'sessions.search.placeholder' ) }
410+ className = "w-full rounded-md border border-[var(--app-divider)] bg-[var(--app-secondary-bg)] px-3 py-1.5 text-sm outline-none focus:border-[var(--app-link)]"
411+ />
412+ </ div >
398413 </ div >
399414
400415 < div className = "flex min-h-0 flex-1 flex-col" >
@@ -405,7 +420,7 @@ function SessionsPage() {
405420 ) : null }
406421 < div className = "min-h-0 flex-1" >
407422 < SessionList
408- sessions = { sessions }
423+ sessions = { visibleSessions }
409424 selectedSessionId = { selectedSessionId }
410425 onSelect = { selectSession }
411426 onNewSession = { openNewSession }
@@ -886,7 +901,7 @@ function GroupsLayout() {
886901 </ button >
887902 < button
888903 type = "button"
889- className = "rounded-md px-2.5 py-1.5 text-xs bg-[var(--app-link )] text-white font-medium"
904+ className = "rounded-md px-2.5 py-1.5 text-xs bg-[var(--app-button )] text-[var(--app-button-text)] font-medium"
890905 >
891906 Groups
892907 </ button >
0 commit comments