fix(canvas-chat): clear stale 'Failed to send' banner when the agent replies (core#2697) #2736
Reference in New Issue
Block a user
Delete Branch "fix/chat-clear-stale-error-on-reply"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug (CTO screenshot, JRS)
The red "Failed to send — agent may be unreachable" banner stayed up while the agent was visibly working (thinking indicator at
●●● 37s, live tool feed streaming). Contradictory UI.Root cause
The agent's turn hit a real context-overflow 400 (
token limit 262144, requested 262158) which set the banner; the runtime auto-healed (reset session + retried). The retry's reply then arrived — butonAgentMessage/onSendCompletereleased the send guards and never cleared the error state, so the stale "unreachable" banner persisted over a reachable, replying agent.Fix
A reply landing (push
AGENT_MESSAGE) or a poll-mode send-complete proves reachability → both callbacks now clear both error sources (setError(null)+clearSendError()).Tests
New
ChatTab.errorClearOnReply.test.tsxcaptures ChatTab's socket callbacks and assertsonAgentMessage+onSendCompleteclear the error. Full ChatTab suite green (358 pass).Note (separate, not a regression)
The underlying trigger — the SEO agent's session exceeding the model's 256K context — is handled by the runtime's existing auto-heal (session reset + retry), and the user-facing remedy is the New session button (#2700, shipped). This PR only fixes the misleading banner.
🤖 Generated with Claude Code
APPROVED: reviewed #2736 at head
59792d9b.The fix is correctly tied to proof of agent reachability: both onAgentMessage and poll-mode onSendComplete clear the local error plus the useChatSend error, so a stale 'Failed to send / agent may be unreachable' banner is removed once the agent actually replies or completes. This does not change send failure detection itself, and it does not mask a still-failing send path before a reachability callback arrives.
The new ChatTab.errorClearOnReply test captures the real socket callbacks and covers both AGENT_MESSAGE and onSendComplete. Required CI is green, including Canvas (Next.js) and CI / all-required. /sop-ack
/sop-ack
APPROVED (post-merge verification; PR was already merged when I fetched it). Head
59792d9b93a419dbca8698a0f16563c1dcf6827b.5-axis review: the fix clears the stale banner only from the real reachability callbacks,
onAgentMessageandonSendComplete. Those callbacks are reached when a reply lands over socket or poll-mode completes, so a pre-reply send failure remains visible until the agent actually proves reachability. Failure detection is not weakened: the send error still comes fromuseChatSend, the UI still recordssetError(...)on actual send failures, and this patch does not clear errors on input changes, retry start, mount, or arbitrary state transitions.Coverage is targeted:
ChatTab.errorClearOnReply.test.tsxmocksuseChatSend, captures the realuseChatSocketcallbacks, and assertsclearErroris called for bothonAgentMessageandonSendComplete. Required CI history for this head shows Canvas Next.js andCI / all-requiredgreen; the PR is already merged./sop-ack