The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): hydrate pending clarify args on re-arm
Hukla73688014f787
diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsx b/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsxindex 3e6d426c6ed..bf7d1a2cdd5 100644--- a/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsx+++ b/apps/desktop/src/app/session/hooks/use-message-stream/clarify-hydration.test.tsx@@ -166,6 +166,40 @@ describe('clarify request stream hydration', () => {expect(stream.state().streamId).toBe('assistant-codex')})+ it('hydrates an already-pending sparse clarify row from the live request', () => {+ mountStream()++ seedHydratedMessages([+ { id: 'user-1', role: 'user', parts: [{ type: 'text', text: 'help me choose' }] },+ {+ id: 'assistant-pending',+ role: 'assistant',+ pending: true,+ parts: [+ {+ type: 'tool-call',+ toolCallId: 'call-provider',+ toolName: 'clarify',+ args: {},+ argsText: '{}'+ }+ ]+ }+ ])++ clarifyRequest({ choices: ['Approve', 'Reject'], question: 'Continue?', request_id: 'req-pending' })++ const messages = stream.state().messages+ const part = clarifyParts()[0]+ expect(messages).toHaveLength(2)+ expect(messages[1]).toMatchObject({ id: 'assistant-pending', pending: true })+ expect(part).toMatchObject({+ toolCallId: 'call-provider',+ args: { choices: ['Approve', 'Reject'], question: 'Continue?' }+ })+ expect(stream.state().streamId).toBe('assistant-pending')+ })+it('keeps a hydrated DeepSeek text-plus-clarify row in its original position', () => {mountStream()diff --git a/apps/desktop/src/lib/chat-messages/tool-parts.ts b/apps/desktop/src/lib/chat-messages/tool-parts.tsindex 466d88e2380..9ff115368da 100644--- a/apps/desktop/src/lib/chat-messages/tool-parts.ts+++ b/apps/desktop/src/lib/chat-messages/tool-parts.ts@@ -611,24 +611,28 @@ export function restorePendingBlockingToolCall(if (location) {const message = messages[location.messageIndex]const part = message.parts[location.partIndex]- // A correlated row that settle sealed (stop, lost completion) is live- // again: drop the seal so the card renders as pending, not as history.- const sealed = part.type === 'tool-call' && part.completedAt !== undefined && part.result === undefined- if (message.pending && !sealed) {+ if (part.type !== 'tool-call') {return { messages, streamId: message.id }}- const next = [...messages]+ // A correlated row that settle sealed (stop, lost completion) is live+ // again: drop the seal so the card renders as pending, not as history.+ // A sparse hydrated projection may already be marked pending while still+ // lacking the authoritative clarify.request args, so re-arm in place and+ // merge the live payload into that provider-authored part, preserving its+ // tool-call id and transcript position.+ const { completedAt: _completedAt, ...unsealed } = part+ const args = toolArgs(clarifyPayload, part.args)+ const parts = [...message.parts]+ parts[location.partIndex] = {+ ...unsealed,+ args: args as never,+ argsText: JSON.stringify(args)+ } as ChatMessagePart- if (sealed) {- const { completedAt: _completedAt, ...unsealed } = part- const parts = [...message.parts]- parts[location.partIndex] = unsealed as ChatMessagePart- next[location.messageIndex] = { ...message, parts, pending: true }- } else {- next[location.messageIndex] = { ...message, pending: true }- }+ const next = [...messages]+ next[location.messageIndex] = { ...message, parts, pending: true }return { messages: next, streamId: message.id }}