- {cardProps.includes('status') &&
}
+ {cardProps.includes('status') &&
+ (AGENT_DASHBOARD_ENABLED ? (
+
+ {/* Why: make the hover trigger keyboard-focusable so
+ keyboard-only users can open the hover panel (Radix
+ HoverCardTrigger asChild does not promote a
+ non-interactive child to focusable). */}
+
+
+
+
+ ) : (
+
+ ))}
{cardProps.includes('unread') && (
diff --git a/src/renderer/src/components/sidebar/WorktreeCardHelpers.tsx b/src/renderer/src/components/sidebar/WorktreeCardHelpers.tsx
index 0794635e1..46de66e50 100644
--- a/src/renderer/src/components/sidebar/WorktreeCardHelpers.tsx
+++ b/src/renderer/src/components/sidebar/WorktreeCardHelpers.tsx
@@ -5,6 +5,7 @@ import type {
GitConflictOperation,
TerminalTab
} from '../../../../shared/types'
+import type { AgentStatusEntry } from '../../../../shared/agent-status-types'
// ── Pure helper functions ────────────────────────────────────────────
@@ -39,6 +40,7 @@ export const CONFLICT_OPERATION_LABELS: Record(
+ nonArchivedWorktrees.map((w) => [
+ w.id,
+ computeSmartScore(
+ w,
+ currentTabs,
+ repoMap,
+ state.prCache,
+ now,
+ agentStatusForSort,
+ explicitByTabId
+ )
+ ])
+ )
+ : undefined
nonArchivedWorktrees.sort(
- buildWorktreeComparator(sortBy, currentTabs, repoMap, state.prCache, Date.now())
+ buildWorktreeComparator(
+ sortBy,
+ currentTabs,
+ repoMap,
+ state.prCache,
+ now,
+ null,
+ agentStatusForSort,
+ precomputedScores,
+ explicitByTabId
+ )
)
return nonArchivedWorktrees.map((w) => w.id)
// debouncedSortEpoch is an intentional trigger: it's not read inside the
diff --git a/src/renderer/src/components/sidebar/smart-sort.test.ts b/src/renderer/src/components/sidebar/smart-sort.test.ts
index 502090fc5..dc470ce89 100644
--- a/src/renderer/src/components/sidebar/smart-sort.test.ts
+++ b/src/renderer/src/components/sidebar/smart-sort.test.ts
@@ -2,6 +2,7 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import type { Repo, TerminalTab, Worktree } from '../../../../shared/types'
import { buildWorktreeComparator, computeSmartScore, type SmartSortOverride } from './smart-sort'
+import type { AgentStatusEntry } from '../../../../shared/agent-status-types'
const NOW = new Date('2026-03-27T12:00:00.000Z').getTime()
@@ -53,6 +54,21 @@ function makeTab(overrides: Partial = {}): TerminalTab {
}
}
+function makeAgentStatusEntry(
+ overrides: Partial & { paneKey: string }
+): AgentStatusEntry {
+ return {
+ state: overrides.state ?? 'working',
+ prompt: overrides.prompt ?? '',
+ updatedAt: overrides.updatedAt ?? NOW - 30_000,
+ stateStartedAt: overrides.stateStartedAt ?? overrides.updatedAt ?? NOW - 30_000,
+ agentType: overrides.agentType ?? 'codex',
+ paneKey: overrides.paneKey,
+ terminalTitle: overrides.terminalTitle,
+ stateHistory: overrides.stateHistory ?? []
+ }
+}
+
describe('computeSmartScore', () => {
afterEach(() => {
vi.restoreAllMocks()
@@ -158,6 +174,39 @@ describe('computeSmartScore', () => {
computeSmartScore(plain, null, repoMap, {})
)
})
+
+ it('does not let stale explicit status mask a live heuristic permission prompt', () => {
+ const worktree = makeWorktree({ id: 'wt-1' })
+ const tabsByWorktree = {
+ [worktree.id]: [makeTab({ worktreeId: worktree.id, title: 'codex permission needed' })]
+ }
+ const score = computeSmartScore(worktree, tabsByWorktree, repoMap, null, NOW, {
+ 'tab-1:1': makeAgentStatusEntry({
+ paneKey: 'tab-1:1',
+ state: 'done',
+ updatedAt: NOW - 45 * 60_000
+ })
+ })
+
+ expect(score).toBeGreaterThanOrEqual(35)
+ })
+
+ it('does not stack heuristic working on top of fresh explicit done for the same tab', () => {
+ const worktree = makeWorktree({ id: 'wt-1' })
+ const tabsByWorktree = {
+ [worktree.id]: [makeTab({ worktreeId: worktree.id, title: 'codex working' })]
+ }
+
+ expect(
+ computeSmartScore(worktree, tabsByWorktree, repoMap, null, NOW, {
+ 'tab-1:1': makeAgentStatusEntry({
+ paneKey: 'tab-1:1',
+ state: 'done',
+ updatedAt: NOW - 60_000
+ })
+ })
+ ).toBe(12)
+ })
})
describe('buildWorktreeComparator', () => {
diff --git a/src/renderer/src/components/sidebar/smart-sort.ts b/src/renderer/src/components/sidebar/smart-sort.ts
index 6e8e23af4..8200cb357 100644
--- a/src/renderer/src/components/sidebar/smart-sort.ts
+++ b/src/renderer/src/components/sidebar/smart-sort.ts
@@ -1,6 +1,10 @@
-import { detectAgentStatusFromTitle } from '@/lib/agent-status'
+import { detectAgentStatusFromTitle, isExplicitAgentStatusFresh } from '@/lib/agent-status'
import { branchName } from '@/lib/git-utils'
import type { Worktree, Repo, TerminalTab } from '../../../../shared/types'
+import {
+ AGENT_STATUS_STALE_AFTER_MS,
+ type AgentStatusEntry
+} from '../../../../shared/agent-status-types'
type SortBy = 'name' | 'smart' | 'recent' | 'repo'
@@ -11,6 +15,38 @@ export type SmartSortOverride = {
hasRecentPRSignal: boolean
}
+// Why: building this index once at the sort call site reduces the smart-
+// score computation from O(N × E × T) to O(E) build + O(T) lookups per
+// worktree. Before, each worktree's score computation scanned the full
+// agentStatusByPaneKey map, which made the decorate-sort-undecorate
+// precompute pay the scan N times even though the map is global. Entries are
+// keyed by the `tabId` prefix of their paneKey (paneKey format: `${tabId}:…`).
+export function buildExplicitEntriesByTabId(
+ agentStatusByPaneKey: Record | undefined
+): Map {
+ const byTab = new Map()
+ if (!agentStatusByPaneKey) {
+ return byTab
+ }
+ for (const entry of Object.values(agentStatusByPaneKey)) {
+ const colon = entry.paneKey.indexOf(':')
+ // Why: paneKey must be `${tabId}:${paneId}`. Skip malformed entries (no
+ // colon or leading colon) rather than bucketing them under an empty tabId,
+ // where they would never match a real tab and just waste memory.
+ if (colon <= 0) {
+ continue
+ }
+ const tabId = entry.paneKey.slice(0, colon)
+ const bucket = byTab.get(tabId)
+ if (bucket) {
+ bucket.push(entry)
+ } else {
+ byTab.set(tabId, [entry])
+ }
+ }
+ return byTab
+}
+
export function hasRecentPRSignal(
worktree: Worktree,
repoMap: Map,
@@ -35,18 +71,65 @@ function computeSmartScoreFromSignals(
worktree: Worktree,
tabs: TerminalTab[],
hasRecentPR: boolean,
- now: number
+ now: number,
+ agentStatusByPaneKey?: Record,
+ explicitByTabId?: Map
): number {
const liveTabs = tabs.filter((t) => t.ptyId)
let score = 0
- const isRunning = liveTabs.some((t) => detectAgentStatusFromTitle(t.title) === 'working')
+ // Why: explicit agent status (OSC 9999) is authoritative over heuristic title
+ // parsing. Check explicit status first; fall through to heuristics for tabs
+ // that have no explicit status entry.
+ //
+ // Why the index parameter: when the caller precomputes the tabId → entries
+ // index once (via buildExplicitEntriesByTabId) and threads it through, each
+ // worktree does O(T) lookups instead of scanning the full map O(E) times.
+ // This matters because `sortWorktreesSmart` calls this function N times in a
+ // decorate-sort-undecorate pass; without the shared index we'd pay O(N×E×T)
+ // overall. When the index is absent and `agentStatusByPaneKey` is provided
+ // we build it inline to preserve backward compatibility for callers (tests,
+ // palette) that haven't adopted the optimization.
+ const resolvedExplicitByTabId =
+ explicitByTabId ?? buildExplicitEntriesByTabId(agentStatusByPaneKey)
+
+ let hasExplicitWorking = false
+ let hasExplicitBlocked = false
+ let hasHeuristicWorking = false
+ let hasHeuristicBlocked = false
+
+ for (const tab of liveTabs) {
+ const tabExplicitEntries = resolvedExplicitByTabId.get(tab.id) ?? []
+ // Why: compute freshness once per entry instead of recomputing inside each
+ // of the three `.some(...)` passes below. Freshness is a pure function of
+ // (entry, now) so filtering up front is equivalent and cheaper.
+ const freshEntries = tabExplicitEntries.filter((entry) =>
+ isExplicitAgentStatusFresh(entry, now, AGENT_STATUS_STALE_AFTER_MS)
+ )
+
+ if (freshEntries.length > 0) {
+ hasExplicitWorking ||= freshEntries.some((entry) => entry.state === 'working')
+ hasExplicitBlocked ||= freshEntries.some(
+ (entry) => entry.state === 'blocked' || entry.state === 'waiting'
+ )
+ continue
+ }
+
+ const heuristicState = detectAgentStatusFromTitle(tab.title)
+ hasHeuristicWorking ||= heuristicState === 'working'
+ hasHeuristicBlocked ||= heuristicState === 'permission'
+ }
+
+ // Explicit working → +60, same weight as heuristic working
+ // Explicit blocked/waiting → +35, same weight as heuristic permission
+ // Explicit done → no bonus (task complete, no attention needed)
+ const isRunning = hasExplicitWorking || hasHeuristicWorking
if (isRunning) {
score += 60
}
- const needsAttention = liveTabs.some((t) => detectAgentStatusFromTitle(t.title) === 'permission')
+ const needsAttention = hasExplicitBlocked || hasHeuristicBlocked
if (needsAttention) {
score += 35
}
@@ -99,6 +182,21 @@ function getSmartSortCandidate(
/**
* Build a comparator for sorting worktrees based on the current sort mode.
+ *
+ * `precomputedScores` is the decorate-sort-undecorate optimization for the
+ * `smart` mode: callers should compute each worktree's smart score once and
+ * pass the map in, since `Array.prototype.sort` invokes the comparator
+ * O(N log N) times and recomputing the score each call scans the
+ * `agentStatusByPaneKey` map O(N log N × E) times. When omitted, the
+ * comparator falls back to computing scores per-comparison so existing call
+ * sites that haven't adopted the optimization keep working.
+ *
+ * `explicitByTabId` is a secondary optimization: when `precomputedScores` is
+ * absent (fallback path), the comparator still has to call
+ * `computeSmartScoreFromSignals` per comparison. Passing the prebuilt tabId
+ * index avoids rescanning the full `agentStatusByPaneKey` map on every call.
+ * When this index is also absent, the inner function builds one inline per
+ * invocation to preserve backward compatibility.
*/
export function buildWorktreeComparator(
sortBy: SortBy,
@@ -106,8 +204,23 @@ export function buildWorktreeComparator(
repoMap: Map,
prCache: Record | null,
now: number = Date.now(),
- smartSortOverrides: Record | null = null
+ smartSortOverrides: Record | null = null,
+ agentStatusByPaneKey?: Record,
+ precomputedScores?: Map,
+ explicitByTabId?: Map
): (a: Worktree, b: Worktree) => number {
+ // Why: when the caller does not pre-build the tabId index but does provide
+ // the source map, build it ONCE here and close over it. Array.sort invokes
+ // the comparator O(N log N) times in the fallback path (no precomputed
+ // scores), and `computeSmartScoreFromSignals` would otherwise rebuild the
+ // O(E) index on every comparison — re-introducing the O(N log N × E) cost
+ // the precompute was meant to avoid. Only matters for the smart mode; for
+ // other modes we skip construction.
+ const resolvedExplicitByTabId =
+ sortBy === 'smart' && !explicitByTabId && agentStatusByPaneKey
+ ? buildExplicitEntriesByTabId(agentStatusByPaneKey)
+ : explicitByTabId
+
return (a, b) => {
switch (sortBy) {
case 'name':
@@ -127,19 +240,42 @@ export function buildWorktreeComparator(
prCache,
smartSortOverrides
)
+ // Why precomputedScores: the smart-score computation iterates
+ // `agentStatusByPaneKey` (O(E) per call) when no tabId index is
+ // threaded in, and still does O(T) lookups per worktree when one is.
+ // The comparator is invoked O(N log N) times by Array.sort, so without
+ // memoization we pay O(N log N × E) (or O(N log N × T) with the
+ // index). When the caller supplies a precomputed score map we get
+ // O(1) lookups; when it doesn't we preserve the old behavior and pass
+ // the optional `explicitByTabId` index to the inner function so the
+ // fallback path avoids the full-map scan as well. Overrides bypass the
+ // precomputed map because the override intentionally freezes the
+ // candidate's inputs (tabs, hasRecentPRSignal) which may differ from
+ // the live score.
+ const scoreA =
+ precomputedScores && !smartSortOverrides?.[a.id]
+ ? (precomputedScores.get(a.id) ?? 0)
+ : computeSmartScoreFromSignals(
+ smartA.worktree,
+ smartA.tabs,
+ smartA.hasRecentPRSignal,
+ now,
+ agentStatusByPaneKey,
+ resolvedExplicitByTabId
+ )
+ const scoreB =
+ precomputedScores && !smartSortOverrides?.[b.id]
+ ? (precomputedScores.get(b.id) ?? 0)
+ : computeSmartScoreFromSignals(
+ smartB.worktree,
+ smartB.tabs,
+ smartB.hasRecentPRSignal,
+ now,
+ agentStatusByPaneKey,
+ resolvedExplicitByTabId
+ )
return (
- computeSmartScoreFromSignals(
- smartB.worktree,
- smartB.tabs,
- smartB.hasRecentPRSignal,
- now
- ) -
- computeSmartScoreFromSignals(
- smartA.worktree,
- smartA.tabs,
- smartA.hasRecentPRSignal,
- now
- ) ||
+ scoreB - scoreA ||
smartB.worktree.lastActivityAt - smartA.worktree.lastActivityAt ||
a.displayName.localeCompare(b.displayName)
)
@@ -179,7 +315,8 @@ export function sortWorktreesSmart(
worktrees: Worktree[],
tabsByWorktree: Record,
repoMap: Map,
- prCache: Record | null
+ prCache: Record | null,
+ agentStatusByPaneKey?: Record
): Worktree[] {
const hasAnyLivePty = Object.values(tabsByWorktree)
.flat()
@@ -192,8 +329,52 @@ export function sortWorktreesSmart(
)
}
+ // Why precompute: Array.sort calls the comparator O(N log N) times and the
+ // smart-score computation needs to look up explicit-status entries per tab.
+ // We apply two layered optimizations:
+ // 1. Build the `explicitByTabId` index ONCE up front (O(E) work). Without
+ // it, each per-worktree score would scan the full `agentStatusByPaneKey`
+ // map to find matching entries, which is O(N × E × T) across all
+ // worktrees — the same cost the decorate-sort-undecorate pass was
+ // supposed to avoid.
+ // 2. Precompute each worktree's score once (decorate-sort-undecorate) so
+ // the comparator does O(1) map lookups instead of re-scoring per
+ // comparison.
+ // Combined cost: O(E) index build + O(N × T) scoring + O(N log N) sort,
+ // instead of the prior O(N × E × T + N log N).
+ const now = Date.now()
+ const explicitByTabId = buildExplicitEntriesByTabId(agentStatusByPaneKey)
+ const precomputedScores = new Map(
+ worktrees.map((w) => [
+ w.id,
+ computeSmartScore(
+ w,
+ tabsByWorktree,
+ repoMap,
+ prCache,
+ now,
+ agentStatusByPaneKey,
+ explicitByTabId
+ )
+ ])
+ )
+
+ // Why: agentStatusByPaneKey is forwarded so the smart-score comparator can
+ // use explicit agent status (OSC 9999) when ranking worktrees by recency.
+ // `explicitByTabId` is forwarded too so the comparator's fallback path (used
+ // for worktrees covered by smartSortOverrides) avoids rebuilding the index.
return [...worktrees].sort(
- buildWorktreeComparator('smart', tabsByWorktree, repoMap, prCache, Date.now())
+ buildWorktreeComparator(
+ 'smart',
+ tabsByWorktree,
+ repoMap,
+ prCache,
+ now,
+ null,
+ agentStatusByPaneKey,
+ precomputedScores,
+ explicitByTabId
+ )
)
}
@@ -215,7 +396,9 @@ export function computeSmartScore(
tabsByWorktree: Record | null,
repoMap: Map | null,
prCache: Record | null,
- now: number = Date.now()
+ now: number = Date.now(),
+ agentStatusByPaneKey?: Record,
+ explicitByTabId?: Map
): number {
return computeSmartScoreFromSignals(
worktree,
@@ -225,6 +408,8 @@ export function computeSmartScore(
// only while that branch cache entry is still cold so smart sorting stays
// stable on launch without reviving stale PRs after a cache miss resolves.
repoMap ? hasRecentPRSignal(worktree, repoMap, prCache) : worktree.linkedPR !== null,
- now
+ now,
+ agentStatusByPaneKey,
+ explicitByTabId
)
}
diff --git a/src/renderer/src/components/sidebar/visible-worktrees.ts b/src/renderer/src/components/sidebar/visible-worktrees.ts
index 702d5f3dc..145dddc98 100644
--- a/src/renderer/src/components/sidebar/visible-worktrees.ts
+++ b/src/renderer/src/components/sidebar/visible-worktrees.ts
@@ -1,5 +1,6 @@
import type { Worktree, Repo, TerminalTab } from '../../../../shared/types'
import type { AppState } from '@/store/types'
+import { AGENT_DASHBOARD_ENABLED } from '../../../../shared/constants'
import { matchesSearch } from './worktree-list-groups'
import { buildWorktreeComparator, sortWorktreesSmart } from './smart-sort'
import { useAppStore } from '@/store'
@@ -119,10 +120,15 @@ export function getVisibleWorktreeIds(): string[] {
let sortedIds: string[]
+ const agentStatusForSort = AGENT_DASHBOARD_ENABLED ? state.agentStatusByPaneKey : undefined
if (state.sortBy === 'smart') {
- sortedIds = sortWorktreesSmart(allWorktrees, state.tabsByWorktree, repoMap, state.prCache).map(
- (w) => w.id
- )
+ sortedIds = sortWorktreesSmart(
+ allWorktrees,
+ state.tabsByWorktree,
+ repoMap,
+ state.prCache,
+ agentStatusForSort
+ ).map((w) => w.id)
} else {
const sorted = [...allWorktrees].sort(
buildWorktreeComparator(
@@ -130,7 +136,9 @@ export function getVisibleWorktreeIds(): string[] {
state.tabsByWorktree,
repoMap,
state.prCache,
- Date.now()
+ Date.now(),
+ null,
+ agentStatusForSort
)
)
sortedIds = sorted.map((w) => w.id)
diff --git a/src/renderer/src/lib/agent-catalog.tsx b/src/renderer/src/lib/agent-catalog.tsx
index 6a386f91d..c10ea0e0a 100644
--- a/src/renderer/src/lib/agent-catalog.tsx
+++ b/src/renderer/src/lib/agent-catalog.tsx
@@ -255,9 +255,16 @@ export function AgentIcon({
agent,
size = 14
}: {
- agent: TuiAgent
+ agent: TuiAgent | null | undefined
size?: number
}): React.JSX.Element {
+ // Why: render a neutral question-mark glyph when the agent identity is not
+ // yet known. Before, the caller coerced null → 'claude', which caused Codex
+ // panes to briefly show the Claude icon until the first hook callback
+ // arrived.
+ if (!agent) {
+ return
+ }
if (agent === 'claude') {
return
}
diff --git a/src/renderer/src/lib/agent-status.test.ts b/src/renderer/src/lib/agent-status.test.ts
index 4d3da9a25..f42f16098 100644
--- a/src/renderer/src/lib/agent-status.test.ts
+++ b/src/renderer/src/lib/agent-status.test.ts
@@ -560,8 +560,8 @@ describe('mapAgentStatusStateToVisualStatus', () => {
expect(mapAgentStatusStateToVisualStatus('waiting')).toBe('permission')
})
- it("maps 'done' to 'active'", () => {
- expect(mapAgentStatusStateToVisualStatus('done')).toBe('active')
+ it("maps 'done' to 'done'", () => {
+ expect(mapAgentStatusStateToVisualStatus('done')).toBe('done')
})
it('returns a non-empty string for every valid state', () => {
diff --git a/src/renderer/src/lib/agent-status.ts b/src/renderer/src/lib/agent-status.ts
index a8dde5eef..b4d1a37b0 100644
--- a/src/renderer/src/lib/agent-status.ts
+++ b/src/renderer/src/lib/agent-status.ts
@@ -176,7 +176,7 @@ export function isExplicitAgentStatusFresh(
* | working | working | agent actively executing |
* | blocked | permission | agent needs user attention |
* | waiting | permission | agent needs user attention |
- * | done | active | task complete but pane live |
+ * | done | done | task complete but pane live |
*/
export function mapAgentStatusStateToVisualStatus(state: AgentStatusState): WorktreeStatus {
switch (state) {
@@ -186,7 +186,7 @@ export function mapAgentStatusStateToVisualStatus(state: AgentStatusState): Work
case 'waiting':
return 'permission'
case 'done':
- return 'active'
+ return 'done'
}
}
diff --git a/src/renderer/src/lib/worktree-status.ts b/src/renderer/src/lib/worktree-status.ts
index c117f3c61..008966216 100644
--- a/src/renderer/src/lib/worktree-status.ts
+++ b/src/renderer/src/lib/worktree-status.ts
@@ -1,12 +1,13 @@
import { detectAgentStatusFromTitle } from '@/lib/agent-status'
import type { TerminalTab } from '../../../shared/types'
-export type WorktreeStatus = 'active' | 'working' | 'permission' | 'inactive'
+export type WorktreeStatus = 'active' | 'working' | 'permission' | 'done' | 'inactive'
const STATUS_LABELS: Record = {
active: 'Active',
working: 'Working',
permission: 'Needs permission',
+ done: 'Done',
inactive: 'Inactive'
}
diff --git a/src/renderer/src/store/slices/agent-status.test.ts b/src/renderer/src/store/slices/agent-status.test.ts
index 2ab8cf855..33d967065 100644
--- a/src/renderer/src/store/slices/agent-status.test.ts
+++ b/src/renderer/src/store/slices/agent-status.test.ts
@@ -24,7 +24,9 @@ describe('agent status freshness expiry', () => {
vi.setSystemTime(new Date('2026-04-09T12:00:00.000Z'))
const store = createTestStore()
- store.getState().setAgentStatus('tab-1:1', { state: 'working', prompt: 'Fix tests' }, 'codex')
+ store
+ .getState()
+ .setAgentStatus('tab-1:1', { state: 'working', prompt: 'Fix tests', agentType: 'codex' })
// setAgentStatus bumps epoch once synchronously
expect(store.getState().agentStatusEpoch).toBe(1)
@@ -43,7 +45,9 @@ describe('agent status freshness expiry', () => {
vi.setSystemTime(new Date('2026-04-09T12:00:00.000Z'))
const store = createTestStore()
- store.getState().setAgentStatus('tab-1:1', { state: 'working', prompt: 'Fix tests' }, 'codex')
+ store
+ .getState()
+ .setAgentStatus('tab-1:1', { state: 'working', prompt: 'Fix tests', agentType: 'codex' })
// set bumps to 1, remove bumps to 2
store.getState().removeAgentStatus('tab-1:1')
expect(store.getState().agentStatusEpoch).toBe(2)
@@ -68,17 +72,14 @@ describe('agent status tool + assistant fields', () => {
it('writes toolName, toolInput, and lastAssistantMessage straight onto the entry', () => {
vi.useFakeTimers()
const store = createTestStore()
- store.getState().setAgentStatus(
- 'tab-1:1',
- {
- state: 'working',
- prompt: 'Edit the config',
- toolName: 'Edit',
- toolInput: '/src/config.ts',
- lastAssistantMessage: 'Edited config.ts'
- },
- 'claude'
- )
+ store.getState().setAgentStatus('tab-1:1', {
+ state: 'working',
+ prompt: 'Edit the config',
+ agentType: 'claude',
+ toolName: 'Edit',
+ toolInput: '/src/config.ts',
+ lastAssistantMessage: 'Edited config.ts'
+ })
const entry = store.getState().agentStatusByPaneKey['tab-1:1']
expect(entry.toolName).toBe('Edit')
expect(entry.toolInput).toBe('/src/config.ts')
@@ -88,21 +89,20 @@ describe('agent status tool + assistant fields', () => {
it('clears fields to undefined when a later payload omits them', () => {
vi.useFakeTimers()
const store = createTestStore()
- store.getState().setAgentStatus(
- 'tab-1:1',
- {
- state: 'working',
- prompt: 'Edit the config',
- toolName: 'Edit',
- toolInput: '/src/config.ts',
- lastAssistantMessage: 'Edited config.ts'
- },
- 'claude'
- )
+ store.getState().setAgentStatus('tab-1:1', {
+ state: 'working',
+ prompt: 'Edit the config',
+ agentType: 'claude',
+ toolName: 'Edit',
+ toolInput: '/src/config.ts',
+ lastAssistantMessage: 'Edited config.ts'
+ })
// Why: the main-process cache is the source of truth for tool/assistant
// fields — a fresh-turn reset surfaces as undefined on the payload, and
// the store must not fall back to the prior entry's values.
- store.getState().setAgentStatus('tab-1:1', { state: 'working', prompt: 'Next step' }, 'claude')
+ store
+ .getState()
+ .setAgentStatus('tab-1:1', { state: 'working', prompt: 'Next step', agentType: 'claude' })
const entry = store.getState().agentStatusByPaneKey['tab-1:1']
expect(entry.toolName).toBeUndefined()
expect(entry.toolInput).toBeUndefined()
diff --git a/src/renderer/src/store/slices/agent-status.ts b/src/renderer/src/store/slices/agent-status.ts
index ecad99064..4d0df2241 100644
--- a/src/renderer/src/store/slices/agent-status.ts
+++ b/src/renderer/src/store/slices/agent-status.ts
@@ -9,6 +9,7 @@ import {
type ParsedAgentStatusPayload
} from '../../../../shared/agent-status-types'
import type { TerminalTab } from '../../../../shared/types'
+import { isExplicitAgentStatusFresh } from '@/lib/agent-status'
/** Snapshot of a finished (or vanished) agent status entry, kept around so
* the dashboard + sidebar hover can continue showing the completion until the
@@ -209,15 +210,28 @@ export const createAgentStatusSlice: StateCreator