diff --git a/src/renderer/src/components/native-chat/use-structured-agent-session.test.tsx b/src/renderer/src/components/native-chat/use-structured-agent-session.test.tsx index 210586801d9..6a4c2687209 100644 --- a/src/renderer/src/components/native-chat/use-structured-agent-session.test.tsx +++ b/src/renderer/src/components/native-chat/use-structured-agent-session.test.tsx @@ -49,13 +49,15 @@ vi.mock('./use-structured-agent-session-outbox', () => ({ }) })) -import type { AgentJournalSubmission } from '../../../../shared/agent-session-journal-types' +import type { + AgentJournalRenderItem, + AgentJournalSubmission +} from '../../../../shared/agent-session-journal-types' import { applyNativeChatSessionOptionSettingsMutation, resolveStructuredLaunchSeedOptions } from '../../../../shared/native-chat-session-option-defaults' import type { PersistedNativeChatSessionOptions } from '../../../../shared/native-chat-session-options' -import type { AgentJournalRenderItem } from '../../../../shared/agent-session-journal-types' import { useStructuredAgentSession } from './use-structured-agent-session' /** Replay every host mutation in order, exactly as the runtime does. */ @@ -598,8 +600,11 @@ describe('turn timing', () => { ) expect(result.current.isWorking).toBe(true) expect(result.current.workingStartedAt).toBe(50_000 - 300) + // t2 is still running, so the host has no duration for it: an explicit null + // that outranks whatever this client clocked locally. expect([...result.current.settledTurns]).toEqual([ - ['u1', { startedAt: 9_000_000, workedSeconds: 4 }] + ['u1', { startedAt: 9_000_000, workedSeconds: 4 }], + ['u2', null] ]) vi.setSystemTime(80_000) rerender() diff --git a/src/shared/structured-agent-session-reducer.ts b/src/shared/structured-agent-session-reducer.ts index 333951d76e9..15a2ad34608 100644 --- a/src/shared/structured-agent-session-reducer.ts +++ b/src/shared/structured-agent-session-reducer.ts @@ -3,14 +3,13 @@ import type { AgentJournalRenderItem, AgentJournalSubmission } from './agent-session-journal-types' -import { - agentSessionBackgroundTasksEqual, - type AgentSessionBackgroundTaskState, - type AgentSessionSlashCommand, - type AgentSessionHandoffStatus, - type AgentSessionHistoryPage, - type AgentSessionSubscribeEvent, - type AgentSessionTurnActivity +import type { + AgentSessionBackgroundTaskState, + AgentSessionSlashCommand, + AgentSessionHandoffStatus, + AgentSessionHistoryPage, + AgentSessionSubscribeEvent, + AgentSessionTurnActivity } from './agent-session-wire' import { backgroundTaskStatesEqual } from './agent-session-background-task-state-equality' import { agentJournalSubmissionKey } from './agent-session-journal-item-key' diff --git a/src/shared/structured-agent-session-turn-timing-retention.test.ts b/src/shared/structured-agent-session-turn-timing-retention.test.ts index 7b08e3ad691..bb8fbb10238 100644 --- a/src/shared/structured-agent-session-turn-timing-retention.test.ts +++ b/src/shared/structured-agent-session-turn-timing-retention.test.ts @@ -73,7 +73,7 @@ function loadedHistory() { for (const first of [129, 65, 1]) { state = reduceStructuredAgentSession(state, { type: 'older-page', - requestedEpoch: 'epoch', + requestedCursor: { epoch: 'epoch', sequence: Number.MAX_SAFE_INTEGER }, page: page(Array.from({ length: 64 }, (_, index) => index + first)) }) } @@ -84,7 +84,7 @@ describe('durable turn attribution across paginated history', () => { it('keeps an older page duration after the recent submission budget fills', () => { const state = reduceStructuredAgentSession(loadedHistory(), { type: 'older-page', - requestedEpoch: 'epoch', + requestedCursor: { epoch: 'epoch', sequence: Number.MAX_SAFE_INTEGER }, page: page([0]) }) expect( @@ -125,7 +125,7 @@ describe('durable turn attribution across paginated history', () => { it('drops an old alias once rewind removes its user item', () => { const loaded = reduceStructuredAgentSession(loadedHistory(), { type: 'older-page', - requestedEpoch: 'epoch', + requestedCursor: { epoch: 'epoch', sequence: Number.MAX_SAFE_INTEGER }, page: page([0]) }) const removed = reduceStructuredAgentSession(loaded, {