Skip to content

fix(ui): thinking indicator never clears on a failed task - #408

Merged
arjun-scale merged 1 commit into
mainfrom
fix/ui-thinking-indicator-stuck-after-rpc-error
Aug 25, 2026
Merged

fix(ui): thinking indicator never clears on a failed task#408
arjun-scale merged 1 commit into
mainfrom
fix/ui-thinking-indicator-stuck-after-rpc-error

Conversation

@arjun-scale

@arjun-scale arjun-scale commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Problem

Opening a task whose turn failed shows "Thinking ..." forever. The error toast fires, but the thread still reads as though the agent were working. It happens in two ways:

  • the task fails during the current session, and
  • a previously-failed task is opened or reloaded, with no client-local error state at all.
Screen.Recording.2026-08-24.at.2.48.31.PM.mov

Cause

shouldShowThinkingForLastPair decided purely from this client's in-session RPC state and the message list. On a cold load neither mentions the failure: rpcStatus starts 'idle', the subscription's first onMessagesChange writes 'success', and a failed turn leaves a user message with no agent message — so the check fell into its "waiting for first response" branch and returned true indefinitely.

The UI already knew the task had failed; the indicator never consulted it.

Fix

Consult the task's own status, the authoritative signal available in both cases:

// Only a running task can be working on a reply.
if (isTaskEnded(task?.status)) return false;

prompt-input.tsx already made the same RUNNING comparison to decide whether sending is allowed, so the rule is extracted to isTaskEnded in lib/task-utils.ts and shared rather than spelled two ways. Comparing against RUNNING also covers every settled status — including DELETED — without enumerating them.

Testing

components/task-messages/task-messages.test.tsx renders the cold-load shape that was broken: a user message, no reply, and rpcStatus: 'success' as the subscription leaves it. Asserts the indicator shows on RUNNING and hides on every ended status. Removing the fix fails all five hide cases.

isTaskEnded is unit-tested for running, ended, and unknown statuses.

Also verified manually against a live agent locally whose turns fail — the indicator clears both when the task fails in-session and on a cold reload.

97 tests pass. npm run typecheck, eslint, and prettier --check clean.

🤖 Generated with Claude Code

Greptile Summary

The PR centralizes task-ended detection and uses authoritative task status to clear the thinking indicator after terminal outcomes.

  • Adds shared isTaskEnded handling to the message view and prompt input.
  • Adds coverage for running and terminal task statuses.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure remains within the eligible follow-up review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
agentex-ui/lib/task-utils.ts Adds the shared task-ended predicate used by task workspace components.
agentex-ui/components/task-messages/task-messages.tsx Uses authoritative task status to suppress the thinking indicator once a task has ended.
agentex-ui/components/primary-content/prompt-input.tsx Replaces its inline status comparison with the shared task-ended helper.
agentex-ui/components/task-messages/task-messages.test.tsx Covers thinking-indicator behavior for running and terminal cold-loaded tasks.
agentex-ui/lib/task-utils.test.ts Adds unit coverage for known, terminal, and unavailable task statuses.

Reviews (2): Last reviewed commit: "fix(ui): thinking indicator never clears..." | Re-trigger Greptile

Context used (3)

@arjun-scale
arjun-scale requested a review from a team as a code owner August 24, 2026 21:50
@arjun-scale
arjun-scale marked this pull request as draft August 24, 2026 22:01
@arjun-scale arjun-scale changed the title fix(ui): thinking indicator never clears after an agent RPC error fix(ui): thinking indicator never clears on a failed task Aug 25, 2026
@arjun-scale
arjun-scale force-pushed the fix/ui-thinking-indicator-stuck-after-rpc-error branch 4 times, most recently from b8ae784 to c95fdda Compare August 25, 2026 01:39
Opening a task whose turn failed showed "Thinking ..." forever. The error
toast fired, but the thread still read as though the agent were working, and
reloading the page reproduced it every time.

`shouldShowThinkingForLastPair` decided purely from this client's in-session
RPC state and the message list, and on a cold load neither mentions the
failure: no send mutation runs, so `rpcStatus` starts 'idle'; the task
subscription's first `onMessagesChange` writes 'success'; and a failed turn
leaves a user message with no agent message, so the check fell into its
"waiting for first response" branch and returned true indefinitely.

The task's own status is the only failure signal available on a cold load,
so consult it. Only a running task can be working on a reply, which covers
every settled status without enumerating them.

prompt-input already made the same RUNNING comparison to decide whether
sending is allowed, so extract `isTaskEnded` and share it rather than
keeping two spellings of one rule.

Covered by a rendering test that reproduces the cold-load shape — a user
message, no reply, rpcStatus 'success' as the subscription leaves it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@arjun-scale
arjun-scale force-pushed the fix/ui-thinking-indicator-stuck-after-rpc-error branch from c95fdda to db2c4fb Compare August 25, 2026 01:44
@arjun-scale
arjun-scale marked this pull request as ready for review August 25, 2026 16:45
@arjun-scale

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Merging

@arjun-scale
arjun-scale merged commit ef3a237 into main Aug 25, 2026
17 checks passed
@arjun-scale
arjun-scale deleted the fix/ui-thinking-indicator-stuck-after-rpc-error branch August 25, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants