diff --git a/src/renderer/src/components/activity/activity-search-query.test.tsx b/src/renderer/src/components/activity/activity-search-query.test.tsx index c03d0be3d8b..99f8d361653 100644 --- a/src/renderer/src/components/activity/activity-search-query.test.tsx +++ b/src/renderer/src/components/activity/activity-search-query.test.tsx @@ -68,16 +68,25 @@ function options(query: string): Parameters[0] { } describe('Activity search query in the real hook', () => { - it('excludes acknowledged rows from an unread search', () => { + it('keeps live rows but excludes acknowledged finished rows from an unread search', () => { const panes = installThreads(12) + const entries = useAppStore.getState().agentStatusByPaneKey useAppStore.setState({ + agentStatusByPaneKey: Object.fromEntries( + panes.map((paneKey, index) => [ + paneKey, + index === 0 ? entries[paneKey] : { ...entries[paneKey], state: 'done' as const } + ]) + ), acknowledgedAgentsByPaneKey: Object.fromEntries(panes.map((paneKey) => [paneKey, 100_000])) }) const activity = renderHook(() => useAgentPaneThreads({ ...options(' PROJECT ☃ '), readFilter: 'unread' }) ) expect(activity.result.current.allThreads).toHaveLength(12) - expect(activity.result.current.visibleThreads).toEqual([]) + expect(activity.result.current.visibleThreads.map((thread) => thread.paneKey)).toEqual([ + panes[0] + ]) }) it('keeps selection, child classification and scoped row order', () => { diff --git a/src/renderer/src/components/activity/use-agent-pane-threads.ts b/src/renderer/src/components/activity/use-agent-pane-threads.ts index e32bb3c9ec2..98651a5cfc7 100644 --- a/src/renderer/src/components/activity/use-agent-pane-threads.ts +++ b/src/renderer/src/components/activity/use-agent-pane-threads.ts @@ -221,10 +221,11 @@ export function useAgentPaneThreads(args: { const matchesSearchQuery = normalizedQuery === null ? null : createActivityThreadSearchMatcher(normalizedQuery) return scopeVisibleThreads.filter((thread) => { - // Why: keep the just-selected thread visible after auto-mark-read flips it to read, else unread-only mode makes the clicked row vanish from the list. + // Why: unread-only must not hide live agents (a read agent can be running again) or the just-selected row that auto-mark-read flipped to read. if ( readFilter === 'unread' && !thread.unread && + thread.currentAgentState === null && thread.paneKey !== effectiveSelectedPaneKey ) { return false