The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): dedupe live stream row by text-extension, not exact match
chelsealong2494b95929bf
diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.ts b/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.tsindex 24566c3bcf1..cff86b5d944 100644--- a/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.ts+++ b/apps/desktop/src/app/session/hooks/use-session-actions/utils.test.ts@@ -1965,6 +1965,35 @@ describe('removeRepresentedLocalLiveProjection', () => {expect(remaining.map(message => message.id)).toEqual(['user-old-optimistic', 'assistant-complete', 'user-racing'])})+ it('removes a local stream row whose text has advanced past the activation snapshot', () => {+ const previous = [+ msg('user-current', 'user', 'current prompt'),+ msg('assistant-stream-current', 'assistant', 'partial answer and more', { pending: true })+ ]++ const projection = runningProjection('current prompt')++ const remaining = removeRepresentedLocalLiveProjection(previous, projection)++ expect(remaining).toEqual([])+ })++ it('removes a local stream row whose text lags behind the activation snapshot', () => {+ const previous = [+ msg('user-current', 'user', 'current prompt'),+ msg('assistant-stream-current', 'assistant', 'partial', { pending: true })+ ]++ const projection = {+ ...runningProjection('current prompt'),+ inflight: { user: 'current prompt', assistant: 'partial answer', streaming: true }+ }++ const remaining = removeRepresentedLocalLiveProjection(previous, projection)++ expect(remaining).toEqual([])+ })+it('preserves an ambiguous text-identical local race prompt without a matching stream boundary', () => {const previous = [msg('runtime-assistant', 'assistant', 'finished answer'),diff --git a/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts b/apps/desktop/src/app/session/hooks/use-session-actions/utils.tsindex ba9df03045d..668b1fce7b7 100644--- a/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts+++ b/apps/desktop/src/app/session/hooks/use-session-actions/utils.ts@@ -1412,12 +1412,22 @@ export function removeRepresentedLocalLiveProjection(const assistantIndex = inflightUserIndex + 1const assistant = previousMessages[assistantIndex]+ const localAssistant = assistant ? normalizedMessageText(assistant) : ''++ // The activation snapshot and this local row are read at different times+ // while the turn keeps streaming in the background, so neither is+ // guaranteed to be textually identical to the other even though both+ // represent the same running reply — one is simply further along.+ const assistantTextRepresented =+ localAssistant === inflightAssistant ||+ isStrictAnswerTextExtension(localAssistant, inflightAssistant) ||+ isStrictAnswerTextExtension(inflightAssistant, localAssistant)const assistantMatches =inflightUserIndex >= openTailStart &&assistant?.role === 'assistant' &&assistant.id.startsWith('assistant-stream-') &&- normalizedMessageText(assistant) === inflightAssistant+ assistantTextRepresentedif (!assistantMatches) {return previousMessages