mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
fix(activity): keep live agents visible in unread filter (#40016)
* 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. * fix(activity): exclude unavailable agents from live filter * fix(activity): retain unavailable identity in live snapshots * test(activity): retain live agent badge after acknowledgment
This commit is contained in:
@@ -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, {
|
||||
|
||||
@@ -68,16 +68,75 @@ function options(query: string): Parameters<typeof useAgentPaneThreads>[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<ReturnType<typeof useAgentPaneThreads>, 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', () => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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}`.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(<SidebarAgentsList {...props} active />)
|
||||
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(<SidebarAgentsList {...props} active={false} />)
|
||||
expect(badgeTarget.textContent).toBe('0')
|
||||
expect(badgeTarget.textContent).toBe('1')
|
||||
act(() => useAppStore.setState({ agentStatusByPaneKey: {} }))
|
||||
view.rerender(<SidebarAgentsList {...props} query="" readFilter="all" active={false} />)
|
||||
expect(badgeTarget.textContent).toBe('0')
|
||||
|
||||
Reference in New Issue
Block a user