fix: stop working timer when turn completes despite stale session status#1348
fix: stop working timer when turn completes despite stale session status#1348rdoupe wants to merge 4 commits intopingdotgg:mainfrom
Conversation
The isWorking flag was computed before pendingUserInputs, so it never accounted for the agent being in a paused state waiting for user input. This caused the "Working for Xm Xs" timer to keep counting indefinitely even after the agent had asked a question and was no longer actively running. Fixes pingdotgg#1069, closes pingdotgg#1335 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Two locations showed stale "Working" state after the agent finished: 1. ChatView.tsx - "Working for Xm Xs" timer in the main chat 2. Sidebar.logic.ts - "Working" pill on thread list items Root cause: both checked only session.status === "running", but the server can lag in transitioning that status even after the latest turn has a completedAt timestamp. Also, neither checked for pending user inputs, so the timer kept running when the agent was blocked waiting for the user to answer a question. Fix: suppress "working" state when latestTurn.completedAt is set (turn is done regardless of server status lag), or when there are pending user inputs (agent is waiting, not working). Fixes pingdotgg#1069, closes pingdotgg#1335 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The server lifecycle guard (shouldApplyThreadLifecycle) can reject turn.completed events, leaving session.status stuck on "running" and activeTurnId permanently stale. Since completedAt is set through an independent path (thread.turn.diff.complete), it reliably indicates turn completion regardless of session status lag. Extract turnDone variable and add comments explaining the root cause. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Just made a PR related to this as well. Below is message from Claude: Interesting — PR #1348 is a different Their fix is a workaround (frontend Both fixes are complementary — theirs |
feel free to snag all or part of this if you want. found out this version doesn't actually start the Working text correctly in the chat or the sidebar. working on it again, lets see what else I find. |
|
I've confirmed through human testing the backend only fix in #1364 is working correctly to my taste. I'm going to close this issue. |
What Changed
Two locations showed a stale "Working" state after the agent finished responding:
ChatView.tsx— "Working for Xm Xs" timer in the main chat areaSidebar.logic.ts— "Working" pill on thread list itemsRoot Cause
The server's
shouldApplyThreadLifecycleguard inProviderRuntimeIngestion.tscan rejectturn.completedevents when turn IDs don't match. When this happens:session.statusstays stuck on"running"indefinitelysession.activeTurnIdbecomes permanently staleHowever,
latestTurn.completedAtis set through a separate, independent path (thread.turn.diff.complete) that bypasses this guard — so the frontend has a reliable signal that the turn is done.Fix
Use
completedAton the latest turn as the reliable completion signal, rather than depending solely onsession.status:This also correctly suppresses the working indicator when the agent is blocked waiting for user input (
pendingUserInputs.length > 0), since that check was already present.Checklist
Fixes #1069, closes #1335