Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/sdk-typescript/src/daemon/ui/transcript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ function handleStateResyncRequired(
appendStatusBlock(
state,
'error',
`State resync required: ${formatMissedRange(event.lastDeliveredId, event.earliestAvailableId)}. Reload the session to recover.`,
`State resync required: ${formatMissedRange(event.lastDeliveredId, event.earliestAvailableId)}.`,
event,
);
}
Expand Down
31 changes: 27 additions & 4 deletions packages/webui/src/daemon/session/DaemonSessionProvider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1934,7 +1934,7 @@ describe('DaemonSessionProvider', () => {
]);
});

it('clears awaitingResync on replay_complete after ring-evicted resync', async () => {
it('resets store on ring-evicted resync so replay events rebuild transcript', async () => {
const liveDelivered = createDeferred<void>();
const session = createMockSession({
lastEventId: 10,
Expand All @@ -1950,13 +1950,24 @@ describe('DaemonSessionProvider', () => {
earliestAvailableId: 12,
},
};
yield {
id: 12,
v: 1,
type: 'session_update',
data: {
update: {
sessionUpdate: 'agent_message_chunk',
content: { type: 'text', text: 'replayed history' },
},
},
};
yield {
v: 1,
type: 'replay_complete',
data: { replayedCount: 0 },
data: { replayedCount: 1 },
};
yield {
id: 12,
id: 13,
v: 1,
type: 'session_update',
data: {
Expand Down Expand Up @@ -1997,12 +2008,24 @@ describe('DaemonSessionProvider', () => {
expect(awaitingResync).toBe(false);
expect(blocks).toEqual(
expect.arrayContaining([
expect.objectContaining({
kind: 'assistant',
text: 'replayed history',
}),
expect.objectContaining({
kind: 'assistant',
text: 'live after replay',
}),
]),
);
expect(blocks).not.toEqual(
expect.arrayContaining([
expect.objectContaining({
kind: 'error',
text: expect.stringContaining('State resync required'),
}),
]),
);
});

it('clears ring-evicted awaitingResync on same-session reattach', async () => {
Expand Down Expand Up @@ -2078,7 +2101,7 @@ describe('DaemonSessionProvider', () => {
await firstStreamDone.promise;
await flushPromises();
});
expect(blocks).toEqual(
expect(blocks).not.toEqual(
expect.arrayContaining([
expect.objectContaining({
kind: 'error',
Expand Down
3 changes: 1 addition & 2 deletions packages/webui/src/daemon/session/DaemonSessionProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,11 @@ export function DaemonSessionProvider({
: undefined;
setPromptStatus('idle');
clearPassiveAssistantDoneTimer(passiveAssistantDoneTimerRef);
store.reset();
if (reason === 'epoch_reset') {
store.reset();
activeSession.setLastEventId(0);
} else if (reason !== 'ring_evicted') {
resyncRequested = true;
store.reset();
session = undefined;
sessionRef.current = undefined;
setConnection((current) => ({
Expand Down