Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): show queued state on messages sent while a turn is running #7582

Closedspiky02plateau(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/7582/headopened View on GitHub

Sending a message while a turn is still running queues it server side, but the web timeline renders it as an ordinary bubble. Nothing shows it has not started yet, so it reads as dropped until the next turn suddenly picks it up. Mobile already derives and shows this state in its thread list; the web timeline had nothing.

The obvious key, turnId === null, does not work: the decider persists every user message with a null turnId by design, and the actual linkage (pending_message_id on the turn) never reaches the wire. So the row derivation in MessagesTimeline.logic.ts mirrors what mobile's hasQueuedTurnStart does instead: a user message strictly newer than every timestamp of the still unsettled latest turn is queued. The message that started the turn shares its createdAt with the turn's requestedAt, so it compares equal and stays unmarked. When a turn adopts the queued message, that turn becomes the latest turn with a matching requestedAt, and the flag clears on its own with no client bookkeeping.

Rendering is one line in MessagesTimeline.tsx: a muted "Queued" label under the bubble, reusing the timeline's existing micro label style (text-secondary-label text-[11px], same as the "Worked for" rows). It deliberately sits outside the hover-only footer, since anything in there is invisible at rest. The queued flag is included in isRowUnchanged so the memoized row actually re-renders when adoption clears it.

Verification

In apps/web:

  • vp test run src/components/chat/MessagesTimeline.logic.test.ts src/components/chat/MessagesTimeline.test.tsx: 2 files, 51 passed, including the two new cases (mid-turn message is flagged, the turn starter is not)
  • tsgo --noEmit: clean
  • vp lint and vp fmt --check on the touched files: clean

Screenshots

Same seeded thread, identical crop. "Refactor the settings panel" started the running turn; "Also add tests for the edge cases" was sent mid-turn.

Before:

before

After:

after

Change made by Claude Opus via Claude Code.


Note

Low Risk UI-only timeline derivation and labeling with no auth or persistence changes; behavior is covered by new unit tests.

Overview Adds a visible “Queued” state for user messages that land in the timeline while another turn is still unsettled, matching mobile’s hasQueuedTurnStart heuristic instead of relying on turnId === null.

Row derivation in MessagesTimeline.logic.ts now pulls requestedAt on latestTurn, compares each user message’s createdAt against the unsettled latest turn’s timestamps, and sets a queued flag on message rows (cleared automatically when a new turn adopts the message via matching requestedAt). Stable row memoization includes queued so adoption updates re-render.

MessagesTimeline.tsx renders a muted “Queued” label under the user bubble (outside hover-only chrome). Tests add requestedAt fixtures and cover mid-turn queuing vs turn-starter and settled-turn cases.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 278660e12b2248475320b87856edec0b8299ba30. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Show queued state on user messages sent while a turn is running

  • Adds a queued boolean field to MessagesTimelineRow message variants, computed in MessagesTimeline.logic.ts via a new isQueuedUserMessage function that checks whether the message was created after all timestamps on the current unsettled turn.
  • The queued flag clears automatically once a new turn adopts the message (matched via requestedAt).
  • Renders a "Queued" label beneath the user message bubble in MessagesTimeline.tsx when the flag is set.
  • Extends TimelineLatestTurn to require requestedAt, and updates isRowUnchanged to diff the new queued field so the virtualized list re-renders on state changes.
📊 Macroscope summarized 278660e. 2 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

    1. Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: de28aa73-cc6f-4147-9f6e-0676fa26bc6c

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review

      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.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. @@ -316,0 +318,21 @@
      318+/**
      319+ * A user message sent while a turn was already running. The server persists
      320+ * it right away and queues the turn start, so it lands in the timeline with
      321+ * no work of its own and nothing to show that it has not begun.
      322+ *
      323+ * Detected the same way the thread list does it (`hasQueuedTurnStart`):
      324+ * strictly newer than every timestamp on the turn that is still unsettled.
      325+ * Adoption clears this on its own — the adopting turn becomes the latest
      326+ * turn and its `requestedAt` matches the message, so the comparison flips
      327+ * without any client-side bookkeeping.
      328+ */
      329+function isQueuedUserMessage(message: ChatMessage, unsettledTurn: TimelineLatestTurn | null) {
      330+ if (unsettledTurn === null || message.role !== "user") {
      331+ return false;
      332+ }
      333+ const sentAt = Date.parse(message.createdAt);
      334+ if (Number.isNaN(sentAt)) {
      335+ return false;
      336+ }
      337+ return [unsettledTurn.requestedAt, unsettledTurn.startedAt, unsettledTurn.completedAt].every(
      338+ (candidate) => candidate == null || Date.parse(candidate) < sentAt,
      macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      🟡 Medium chat/MessagesTimeline.logic.ts:337

      isQueuedUserMessage permanently labels a user message as queued when turn adoption fails or stale data contains a message newer than the unsettled turn timestamps, even after that message is more than two minutes old. Add the same two-minute age bound used by hasQueuedTurnStart before applying the timestamp comparison.

      -  return [unsettledTurn.requestedAt, unsettledTurn.startedAt, unsettledTurn.completedAt].every(
      +  return sentAt >= Date.now() - 2 * 60 * 1000 &&
      +    [unsettledTurn.requestedAt, unsettledTurn.startedAt, unsettledTurn.completedAt].every(
      🤖 Copy this AI Prompt to have your agent fix this:
      In file @apps/web/src/components/chat/MessagesTimeline.logic.ts around lines 337-338:
      
      `isQueuedUserMessage` permanently labels a user message as queued when turn adoption fails or stale data contains a message newer than the unsettled turn timestamps, even after that message is more than two minutes old. Add the same two-minute age bound used by `hasQueuedTurnStart` before applying the timestamp comparison.

      Deliberately not bounded, and I think the bound would be wrong here. hasQueuedTurnStart needs its grace window because it fires even with turn === null: it infers queued state from a bare latestUserMessageAt, so without an age cap a stale timestamp reads as queued forever. This derivation has the opposite shape: it requires a live unsettled turn as its precondition and clears on every turn transition. Adoption makes requestedAt equal to the message's createdAt, a later turn makes the message older than requestedAt, and settlement nulls the unsettled turn. An age bound would hide the label on any turn longer than two minutes while the message is genuinely still waiting, which is the common case for agent turns. Mechanically the suggested diff also puts Date.now() inside a pure derivation that only re-runs on state changes, so the two-minute cutoff would not take effect when it elapses anyway. The residual case (a turn stuck running forever because a server died without settling it) leaves the label up, but at that point the label is stating the truth: the message was never adopted.

      Sorry, I'm unable to act on this request because you do not have permissions within this repository.

    4. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This UI state change adds a 'queued' indicator for messages sent while a turn is running. The unresolved Medium-severity finding about missing a 2-minute timeout bound (matching existing logic in hasQueuedTurnStart) needs to be addressed, and the author is not an established contributor to these files.

      Not approved because:

      • 1 blocking correctness issue found at or above your repo's Minimum Blocking Severity
      Adjust the Minimum Blocking Severity for this repo — including turning it Off — in [Settings](https://app.macroscope.com/pingdotgg/settings#Repos). You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. closing this version as part of a pr cleanup at the request of @StiensWout.

      the queued label is inferred from message and turn timestamps rather than authoritative delivery state. those timestamps cannot reliably distinguish queued, delivered, or failed messages. a replacement should expose the relevant server state and derive the label from it rather than extend the heuristic.

      thanks for the contribution. if you disagree with this decision, you are welcome to open a new pr, link back to this one, and explain how your proposal addresses these concerns or why a different approach is warranted.

Sign in to join this conversation.