Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: A message queued behind a running turn pushes the "Working for…" header below it #19736

Closedkaovilai(GitHub profile, opens in a new tab) opened this issue 3 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Start a turn that runs for a while (several tool calls).
  2. While it is still running, send a follow-up with the Queue behavior, so it shows the "Queued" marker.
  3. Look at the live thread before the queued message's own turn starts.

Expected behavior

The "Working for …" header stays with the turn that is actually running, directly under the message that started it. The queued message sits after that turn's output and header, since it has not started yet.

Actual behavior

The queued message is rendered with the "Queued" marker, and the "Working for …" header is rendered below it. The running turn's output appears above the queued message while the header that belongs to it appears underneath, so the output and the header look disconnected. The live tool row can also drop out, and a "thinking" row shows at the end of the thread instead.

Cause

In apps/web/src/components/chat/MessagesTimeline.logic.ts, timelineEntryStartsResponse treats every user message other than steer and promoted_queued_to_steer as the start of a new response, including inputIntent === "queued_turn". lastResponseBoundaryIndex then returns the queued message, so activeTurnHeaderIndex points after it and the working header is placed below it. The queued message's runId is not the running run, so it should not move the header.

Impact

Cosmetic issue

Version or commit

upstream main, the logic is unchanged as of 9a01524f3f

Environment

Desktop app, any provider

  • #14566: a message queued during /compact renders above the compaction row (same area, different trigger)
  • #15279: steered messages render below "Worked for" (same function, different symptom)

Note

Responses generated with Claude (model: Claude Sonnet 5.5)

  1. I have a small fix for this, tested locally but not opened as a PR. I'll open one if a maintainer wants it.

    lastResponseBoundaryIndex now skips a queued_turn message whose runId is not the running run, so the "Working for …" header stays under the message that started the active turn. Once the queued run starts, its runId matches and it becomes the boundary as before.

    --- a/apps/web/src/components/chat/MessagesTimeline.logic.ts
    +++ b/apps/web/src/components/chat/MessagesTimeline.logic.ts
    @@ -893,8 +893,22 @@
    -function lastResponseBoundaryIndex(timelineEntries: ReadonlyArray<TimelineEntry>): number {
    -  return timelineEntries.findLastIndex(timelineEntryStartsResponse);
    +function lastResponseBoundaryIndex(
    +  timelineEntries: ReadonlyArray<TimelineEntry>,
    +  runningRunId: RunId | null = null,
    +): number {
    +  return timelineEntries.findLastIndex(
    +    (entry) =>
    +      timelineEntryStartsResponse(entry) &&
    +      // A queued message waits behind the running turn; the active turn's
    +      // header must stay above it until its own run starts.
    +      !(
    +        runningRunId !== null &&
    +        entry.kind === "message" &&
    +        entry.message.inputIntent === "queued_turn" &&
    +        entry.message.runId !== runningRunId
    +      ),
    +  );
     }
    @@ -912,7 +926,10 @@
    -  const latestResponseBoundaryIndex = lastResponseBoundaryIndex(input.timelineEntries);
    +  const latestResponseBoundaryIndex = lastResponseBoundaryIndex(
    +    input.timelineEntries,
    +    input.unsettledRunId,
    +  );
    @@ -1410,7 +1427,7 @@
    -    ? lastResponseBoundaryIndex(timelineEntries) + 1
    +    ? lastResponseBoundaryIndex(timelineEntries, input.runningRunId ?? null) + 1

    A regression test in MessagesTimeline.logic.test.ts covers it: a running turn plus a queued message yields message, working, message, thinking. All 766 tests in src/components/chat pass.

    Known gap: the live tool row can still drop out while a queued message is at the tail, because the trailing run of tool entries is broken by the message. A "thinking" row shows instead. That is not addressed here.

    Note

    Responses generated with Claude (model: Claude Sonnet 5.5)

  2. Note

    Grok responding on behalf of Julius.

    Confirmed on main (9a01524f3f). This is a bug in the active-turn header placement, not intended behavior.

    In apps/web/src/components/chat/MessagesTimeline.logic.ts, timelineEntryStartsResponse excludes only steer and promoted_queued_to_steer. A queued_turn user message therefore counts as a response boundary as soon as it shows up in the timeline. activeTurnHeaderIndex is computed as lastResponseBoundaryIndex(timelineEntries) + 1, so while the earlier turn is still running, the "Working for…" header lands below the queued message instead of under the prompt that started the run.

    This isn't a duplicate. #15279 is about steers and Worked for ordering, and #14566 was the /compact queue case. Both touch the same function, so a fix should keep those cases working.

    Workaround: none needed. It's cosmetic, and the layout corrects itself once the queued turn starts.

    The idea in your follow-up looks reasonable: skip a queued_turn boundary whose runId isn't the unsettled run. A PR with a test in MessagesTimeline.logic.test.ts is welcome.

  3. juliusmarminge added labelsaccepted

  4. juliusmarminge added labelsbug

  5. juliusmarminge added labelsvia-triage

  6. juliusmarminge added labelsneeds more info

  7. juliusmarminge removed labelsneeds more info

  8. Already addressed on current main by de34391427: queued prompts stay in the queue control until their run starts, rather than becoming timeline response boundaries.

    Verified the real web app on Linux at a46f80ee28, using GPT-6-Astra with three sequential sleep tool calls. Queued one follow-up, then a second, and reloaded during the running turn. In each case, “Working for…” stayed under the original prompt and the running tool row remained above the queue.

    Current main: active header and running tool above two queued follow-ups

    Closing as already fixed.

  9. juliusmarminge closed this

Sign in to join this conversation.