Skip to content

The agent that grows with you

fix(desktop): keep a reasoning-only stream instead of hydrating over it (#118755)

brooklyn!3b5c5cc7fbca
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/index.ts b/apps/desktop/src/app/session/hooks/use-message-stream/index.ts
index 1e65fc3baf4..14d9eaafe3a 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/index.ts
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/index.ts
@@ -892,7 +892,7 @@ export function useMessageStream({
// locally, so the user-tail guard keeps applying there.
(!unresolvedUserTail || !finalText) &&
!(localVisibleText && !finalText) &&
- (state.adoptedRunningTurn || !state.sawAssistantPayload || !finalText)
+ (state.adoptedRunningTurn || !state.sawAssistantPayload)
return {
...state,
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/session-info-side-effects.test.tsx b/apps/desktop/src/app/session/hooks/use-message-stream/session-info-side-effects.test.tsx
index dc76c94a936..dfaf57e365f 100644
--- a/apps/desktop/src/app/session/hooks/use-message-stream/session-info-side-effects.test.tsx
+++ b/apps/desktop/src/app/session/hooks/use-message-stream/session-info-side-effects.test.tsx
@@ -284,6 +284,26 @@ describe('session.info settles an incomplete live turn', () => {
})
describe('empty message.complete after streamed text (#95514)', () => {
+ it('keeps a reasoning-only stream and does not hydrate over it (#118755)', () => {
+ mountStream()
+
+ act(() => stream.handleEvent({ payload: {}, session_id: ACTIVE_SID, type: 'message.start' }))
+ act(() =>
+ stream.handleEvent({
+ payload: { text: 'The answer lives in reasoning.' },
+ session_id: ACTIVE_SID,
+ type: 'reasoning.delta'
+ })
+ )
+ act(() => stream.handleEvent({ payload: { text: '' }, session_id: ACTIVE_SID, type: 'message.complete' }))
+
+ const assistant = stream.state(ACTIVE_SID).messages.find(message => message.role === 'assistant')
+ expect(assistant?.parts.filter(part => part.type === 'reasoning').map(part => part.text)).toEqual([
+ 'The answer lives in reasoning.'
+ ])
+ expect(hydrateFromStoredSession).not.toHaveBeenCalled()
+ })
+
it('keeps streamed text and does not hydrate over it', () => {
mountStream()