Skip to content

fix: keep subagent spinner and footer live while a subagent runs#3604

Draft
MattPua wants to merge 2 commits into
mainfrom
posthog-code/restore-subagent-wait-indicator
Draft

fix: keep subagent spinner and footer live while a subagent runs#3604
MattPua wants to merge 2 commits into
mainfrom
posthog-code/restore-subagent-wait-indicator

Conversation

@MattPua

@MattPua MattPua commented Jul 20, 2026

Copy link
Copy Markdown
Member

Problem

When a sub-agent (Task/Agent tool call) is running, the conversation UI sometimes looked done while the sub-agent was still working. Two faces:

  1. The sub-agent row's spinner stopped once the parent turn completed (or once the spawn tool call settled), even though the sub-agent kept running.
  2. The footer's "Generating…" indicator stopped for the same reason.

This affects both the Claude and Codex adapters.

Changes

Derive live state from the sub-agent's own nested child tool calls instead of the parent turn's turnComplete / the spawn's own status:

  • SubagentToolView keeps its spinner while any child tool call is non-terminal, even after the parent turn completes.
  • New-thread ToolGroup / chip summary stay "Using" while a sub-agent in the group has active children.
  • Both footers (legacy ConversationView and ChatThreadFooter) keep the generating indicator alive via a new conversationHasActiveSubagent helper.

Display-only: the prompt-lifecycle gates (message queue / steer) still read the raw isPromptPending, so a follow-up message sends rather than queuing while a detached sub-agent finishes.

Also restores Codex's wait collab-agent event ("Waiting for subagents" row) that PR #3522 had hidden alongside closeAgent; closeAgent stays hidden as lifecycle noise.

How did you test this?

  • New unit tests in buildConversationItems.test.ts for conversationHasActiveSubagent (active child, detached sub-agent after turn end, clears on settle, ignores non-subagent).
  • New SubagentToolView.test.tsx asserting the spinner stays up while a child is in_progress with turnComplete=true, and clears when settled.
  • pnpm --filter @posthog/ui exec vitest run src/features/sessions/ (467 passing)
  • pnpm --filter agent exec vitest run src/adapters/codex-app-server/mapping.test.ts (39 passing)
  • pnpm --filter @posthog/ui typecheck, biome lint on changed files

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

@trunk-io

trunk-io Bot commented Jul 20, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 880a27a.

MattPua added 2 commits July 20, 2026 16:47
PR #3522 hid both `wait` and `closeAgent` collab-agent events. `wait`
("Waiting for subagents") is the visible state that the main thread is
blocked on a running subagent; dropping it made the conversation look
done while a subagent was still working. Keep `closeAgent` hidden as
lifecycle noise but restore `wait` so the in-progress spinner shows.

Generated-By: PostHog Code
Task-Id: 515f2e33-762c-412a-8a2d-a217bbace052
A subagent (Task/Agent tool call) keeps running after the parent turn
ends or after the spawn tool call settles, but the conversation UI
derived "loading" from the parent turn's turnComplete and the spawn's
own status, so the spinner and the footer's generating indicator
stopped mid-subagent, making the conversation look done.

Derive live state from the subagent's own nested child tool calls:
- SubagentToolView keeps its spinner while any child is non-terminal,
  even after the parent turn completes.
- The new-thread ToolGroup / chip summary stay "Using" while a
  subagent in the group has active children.
- Both footers (legacy ConversationView and ChatThreadFooter) keep the
  generating indicator alive via conversationHasActiveSubagent.

Display-only: the prompt-lifecycle gates (queue/steer) still read the
raw isPromptPending, so a follow-up message sends rather than queuing
while a detached subagent finishes. Works for both Claude and Codex.

Generated-By: PostHog Code
Task-Id: 515f2e33-762c-412a-8a2d-a217bbace052
@MattPua
MattPua force-pushed the posthog-code/restore-subagent-wait-indicator branch from 406ead5 to 880a27a Compare July 20, 2026 20:54
@MattPua MattPua changed the title fix: restore Codex subagent waiting indicator fix: keep subagent spinner and footer live while a subagent runs Jul 20, 2026
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.

1 participant