diff --git a/src/renderer/src/components/activity/activity-event-build-cache.ts b/src/renderer/src/components/activity/activity-event-build-cache.ts index 8dfe2f9f6dd..9193f3b4ade 100644 --- a/src/renderer/src/components/activity/activity-event-build-cache.ts +++ b/src/renderer/src/components/activity/activity-event-build-cache.ts @@ -110,7 +110,8 @@ export function resolvePaneBuild( repo: request.repo, entry: rowEntry, tab: request.tab, - agentType: request.agentType + agentType: request.agentType, + migrationUnsupportedPtyId: request.migrationUnsupportedPtyId } cache?.panes.set(request.cacheKey, { 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..25df53dc89c 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,75 @@ 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('hides acknowledged unavailable rows unless selected in the unread filter', () => { + const [livePane, unavailablePane] = installThreads(2) + const entries = useAppStore.getState().agentStatusByPaneKey + useAppStore.setState({ + agentStatusByPaneKey: { [livePane]: entries[livePane] }, + migrationUnsupportedByPtyId: { + 'pty-tab-1': { + ptyId: 'pty-tab-1', + paneKey: unavailablePane, + reason: 'legacy-numeric-pane-key', + source: 'local', + updatedAt: 99_000 + } + }, + acknowledgedAgentsByPaneKey: { [livePane]: 100_000, [unavailablePane]: 100_000 } + }) + const activity = renderHook, string | null>( + (selectedPaneKey: string | null) => + useAgentPaneThreads({ ...options(''), readFilter: 'unread', selectedPaneKey }), + { initialProps: null } + ) + expect(activity.result.current.visibleThreads.map((thread) => thread.paneKey)).toEqual([ + 'tab-0:11111111-1111-4111-8111-111111111111' + ]) + activity.rerender(unavailablePane) + expect( + activity.result.current.visibleThreads.map((thread) => thread.paneKey).toSorted() + ).toEqual([ + 'tab-0:11111111-1111-4111-8111-111111111111', + 'tab-1:11111111-1111-4111-8111-111111111111' + ]) + act(() => useAppStore.setState({ activityClearedAtByPaneKey: { [unavailablePane]: 99_000 } })) + activity.rerender(null) + expect(activity.result.current.visibleThreads.map((thread) => thread.paneKey)).toEqual([ + 'tab-0:11111111-1111-4111-8111-111111111111' + ]) + act(() => + useAppStore.setState({ + activityClearedAtByPaneKey: {}, + acknowledgedAgentsByPaneKey: { [livePane]: 100_000 } + }) + ) + expect( + activity.result.current.visibleThreads.map((thread) => thread.paneKey).toSorted() + ).toEqual([ + 'tab-0:11111111-1111-4111-8111-111111111111', + 'tab-1:11111111-1111-4111-8111-111111111111' + ]) }) it('keeps selection, child classification and scoped row order', () => { diff --git a/src/renderer/src/components/activity/activity-thread-builder.ts b/src/renderer/src/components/activity/activity-thread-builder.ts index 6ebf0d702d8..473820dac4d 100644 --- a/src/renderer/src/components/activity/activity-thread-builder.ts +++ b/src/renderer/src/components/activity/activity-thread-builder.ts @@ -130,6 +130,7 @@ export function buildAgentPaneThreads( latestTimestamp: liveAgent.timestamp, latestEvent: null, events: [], + migrationUnsupportedPtyId: liveAgent.migrationUnsupportedPtyId, unread: false }) continue @@ -142,6 +143,7 @@ export function buildAgentPaneThreads( existing.agentType = liveAgent.agentType existing.currentAgentState = liveAgent.state existing.currentAgentEntry = liveAgent.entry + existing.migrationUnsupportedPtyId ??= liveAgent.migrationUnsupportedPtyId existing.responsePreview = statusPreviewForEntry( liveAgent.entry, liveAgent.entry.state, diff --git a/src/renderer/src/components/activity/activity-thread-types.ts b/src/renderer/src/components/activity/activity-thread-types.ts index b6ba66cdb29..f336ad375b0 100644 --- a/src/renderer/src/components/activity/activity-thread-types.ts +++ b/src/renderer/src/components/activity/activity-thread-types.ts @@ -40,6 +40,7 @@ export type ActivityLiveAgentSnapshot = { entry: AgentStatusEntry tab: TerminalTab agentType: AgentType + migrationUnsupportedPtyId?: string } // Why: keyed per agent pane (tab + leaf id), not per workspace, so the list shows one row per agent; paneKey is `${tabId}:${leafId}`. 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..66406c57320 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. + // Keep live agents and the selected row visible after marking read; migration blocks are unavailable. if ( readFilter === 'unread' && !thread.unread && + (thread.currentAgentState === null || thread.migrationUnsupportedPtyId !== undefined) && thread.paneKey !== effectiveSelectedPaneKey ) { return false diff --git a/src/renderer/src/components/sidebar/SidebarAgentsList.test.tsx b/src/renderer/src/components/sidebar/SidebarAgentsList.test.tsx index 9131ad41bae..edb6f091d95 100644 --- a/src/renderer/src/components/sidebar/SidebarAgentsList.test.tsx +++ b/src/renderer/src/components/sidebar/SidebarAgentsList.test.tsx @@ -126,7 +126,7 @@ it('keeps filtered live badge counts across sidebar modes and excludes retained expect(badgeTarget.textContent).toBe('0') }) -it('preserves historical search, unread filtering and migration blocks in badge-only mode', () => { +it('preserves historical search, live badges and migration blocks in badge-only mode', () => { vi.spyOn(Date, 'now').mockReturnValue(10_000) const tab = makeTab() useAppStore.setState({ @@ -164,9 +164,9 @@ it('preserves historical search, unread filtering and migration blocks in badge- view.rerender() expect(badgeTarget.textContent).toBe('1') act(() => useAppStore.setState({ acknowledgedAgentsByPaneKey: { [PANE_KEY]: 2_000 } })) - expect(badgeTarget.textContent).toBe('0') + expect(badgeTarget.textContent).toBe('1') view.rerender() - expect(badgeTarget.textContent).toBe('0') + expect(badgeTarget.textContent).toBe('1') act(() => useAppStore.setState({ agentStatusByPaneKey: {} })) view.rerender() expect(badgeTarget.textContent).toBe('0')