Skip to content

qt: a CLI's newest item shows when Core publishes it, not when its next one arrives - #2125

Merged
trissim merged 2 commits into
mainfrom
qt-cli-sync-probe
Nov 18, 2026
Merged

trissim merged 2 commits into
mainfrom
qt-cli-sync-probe

Conversation

@trissim

@trissim trissim commented Nov 18, 2026

Copy link
Copy Markdown

What was wrong

A Claude Code session's DM view in the Qt app ran 4–33 s behind the CLI. Measured against this session's own CLI on the live bus with the new cli_sync drive. The drive times each marker token in four places: the CLI's JSONL, the bus store (draft and finished rows, read-only), a direct Core read every second, and the Qt view's rows.

marker CLI file store (finished) Core read Qt view
4-a1 (before) 146.25 146.31 146.80 151.20
5-a1 (after) 412.75 412.76 413.13 412.95
5-a2 (after) 417.20 417.28 418.13 417.86

Before the fix, the bus had the item within 0.1 s, the observation services were idle (py-spy dump), and the Qt view only showed the item once the CLI wrote its next one.

Cause: the Qt window followed only CoordinationObserved. That event fires for thread-status changes, and CLI drafts and finished items never change status (StatusView's own docstring says so). So a CLI thread's view re-read its transcript only when some unrelated status change happened to come along. The TUI already follows ExternalTranscriptChanged.

Change

Both toolkits route ExternalTranscriptChanged through one owner, SourcedConversation.external_transcript_changed (the shared parent of Textual's Conversation and QtConversation), which asks the view's operational sources to read.

  • Textual: the presentation now calls it on its widget. The behaviour is the same, because widget.operational_sources is presentation.sources.
  • Qt: the window subscribes to the event and tells every open view, shown or parked, as the TUI does. The Qt Page base answers with nothing to read.

New drive scenarios

  • cli_sync: CLI transcript vs Qt rows vs direct Core reads, with a frame recording.
  • peer_profile: ask a tailnet peer for a UI profile, as the bus picker does.
  • idle: this process's CPU per thread while following a bus untouched, plus the sidebar wave's repaint count.

Gates (on 6dd4c36)

  • Ratchet: 11/11, 0, bare 21/21, parallel copies 0. shadow_check: 0.
  • Live-bus drives, each on its own config and state: arrival, history, participants, composer, tabs and frame all exit 0. Composer's one error notice is its deliberate send to #composer-drive-missing.
  • check.sh with PYTHONFAULTHANDLER=1: exit 0, no fatal or traceback lines. The real toad.json was not written.

Not run

tests/textual/test_parked_session_tab_arrives_progressively.py covers the Textual path. It can't run in any local test env: they fail on import because textual.actions.StyleAction is missing from the Textual checkout. The Textual change swaps sources.external_transcript_changed(widget) for widget.external_transcript_changed(), which resolves to the same call.

Still in the lag (not this PR)

Claude Code itself writes a message's JSONL line up to about 9 s after the message's own timestamp, while a following tool call runs. No client can show the item before that write.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

trissim and others added 2 commits November 18, 2026 09:56
…xt one arrives

The Qt window followed only `CoordinationObserved`, which CLI drafts and finished items
never change (they feed no thread status), so a CLI thread's view re-read its transcript
only when some status change happened by. Measured on the live bus against this
session's own CLI (tools/qt_drive.py cli_sync): an item reached Core in under 0.1 s and
stayed off the Qt view for 4-33 s, until the CLI wrote its next item. The TUI already
follows `ExternalTranscriptChanged`.

Both toolkits now route that event through one owner, `SourcedConversation.
external_transcript_changed`, which asks the view's operational sources to read: the
Textual presentation calls it on its widget, and the Qt window calls it on every open
view (shown or parked); a page without a transcript answers with nothing to read.
After: 0.2 s and 0.6 s from Core's store to the Qt view, ahead of a direct Core read.

Drive scenarios added: `cli_sync` (CLI transcript vs Qt rows vs direct Core reads, with a
frame recording), `peer_profile` (ask a tailnet peer for a UI profile as the bus picker
does) and `idle` (this process's CPU per thread while following a bus untouched).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…ed its band

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
@trissim
trissim merged commit 8e2f741 into main Nov 18, 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