fix(client): per-thread agent status so concurrent threads each render their own stop button#47
Closed
yourbuddyconner wants to merge 1 commit into
Closed
fix(client): per-thread agent status so concurrent threads each render their own stop button#47yourbuddyconner wants to merge 1 commit into
yourbuddyconner wants to merge 1 commit into
Conversation
…r their own stop button After PR #46 the stop button correctly aborted only the active thread, but switching to a still-running parallel thread showed no stop button. Root cause: the chat state stored a single global agentStatus, so whichever thread emitted the most recent agentStatus event clobbered every other thread's busy indicator — and the abort handler optimistically cleared that single field session-wide. Track agent status per-thread: - ChatState now carries threadStatuses: Record<threadId, {status, detail}>. - The agentStatus WebSocket handler updates threadStatuses[msg.threadId] alongside the legacy global fields. - The abort handler clears only the targeted thread's slot when scoped to ('thread', channelId); other threads' busy indicators stay intact. - chat-container derives activeThreadStatus from threadStatuses[ activeThreadId] (with a fallback to the legacy agentStatus for sessions whose first event predates this map), and computes isAgentActive / isAgentThinkingInThread from that. MessageList now receives the thread- scoped status rather than the global one. Net effect: clicking Stop on thread A leaves thread B's stop button visible while thread B is still running.
|
Preview deployment: https://pr-47.dev-valet-turnkey-client.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #46. After scoping the runner abort to the active thread, the Stop button still disappeared when the user switched to a still-running parallel thread. Two layers of session-wide front-end state were leaking across threads.
What was wrong
ChatState.agentStatusis a single value — whichever thread emitted the most recentagentStatusWS message overwrote every other thread's status. So if thread B'sthinkingarrived a beat earlier than thread A'stool_calling, switching to A would show the wrong (or no) state.abort()optimistically cleared that global field session-wide — even when scoped to a specific thread, the client setisAgentThinking=false, agentStatus=idleeverywhere. The Stop button keys offisAgentActive(derived fromagentStatus), so it disappeared on every thread until the runner happened to emit a status update for the still-running thread.Fix shape
ChatState.threadStatuses: Record<threadId, { status, detail }>. TheagentStatusWS handler updatesthreadStatuses[msg.threadId]alongside the existing global fields (kept for back-compat).abort('thread', threadId)only mutates that thread's slot; other threads' status entries stay intact. Session-wideabort()(no scope) still clears the global indicator.chat-containerderivesactiveThreadStatusfromthreadStatuses[activeThreadId](with a fallback to the legacy global value for sessions whose first event predates this map), and computesisAgentActive/isAgentThinkingInThreadfrom that.MessageListreceives the thread-scoped status instead of the global one.Test plan