From 4e4c2c1956d3a602e2f0dd12ba4e17e3a3786edc Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sat, 7 Nov 2026 17:20:49 -0800 Subject: [PATCH] fix(activity): keep live agents visible when showing unread only A running agent's thread is read unless it carries an older unread event, so the unread-only filter hid agents that were working again. Exempt live threads (currentAgentState non-null) alongside the selected-row exemption. --- .../activity/activity-search-query.test.tsx | 13 +++++++++++-- .../components/activity/use-agent-pane-threads.ts | 3 ++- 2 files changed, 13 insertions(+), 3 deletions(-) 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