Skip to content

qt arrivals: rows rise in place and the reader glides; the queue strip opens and closes its height - #2110

Merged
trissim merged 3 commits into
mainfrom
fork-qt-arrival-polish
Nov 18, 2026
Merged

trissim merged 3 commits into
mainfrom
fork-qt-arrival-polish

Conversation

@trissim

@trissim trissim commented Nov 18, 2026 •

Copy link
Copy Markdown

Tristan on the phone: messages "snap in … sometimes come in, come out, come back in", and the queue "pops in, pops out" on send.

What was wrong, measured

tools/qt_drive.py arrival sends three messages from the composer while a scratch sender (agent-comms send --from scratch-live-pipeline) posts three into #scratch (or TARGET=scratch-live-pipeline). It logs every row-model update by key and text, which rows were drawn plain, the queue rows and viewport height every 16 ms, the scroll position while following, and each arrival-handling call's wall and CPU time.

  • In → out → in. No row was ever removed and re-added, and the draft and live handoffs never left a frame with neither row. The flicker was inside the row. A sent message's receipt answers several times just after it lands (Unchecked → Checked → EmptyChecked). Each answer is a new preparation key, and until its rich text was prepared the delegate drew the row as plain text at another height, then snapped back. Every arriving row was also first drawn plain, because Qt prepared nothing before publishing.
  • Snap. Rows arrived in one frame, with no ARRIVAL effect, and a following reader jumped their full height: up to 109 px per send on a thread, 1566 px on main at phone throttle.
  • Queue pop. At phone width the queue summary wrapped between 2 and 3 lines as its text alternated ("Submitting (1): …" / "Delivery (4 visible messages): …"). The history reflowed 360↔377 px in one frame on every send, and on main it hid and re-showed (hide at 1.49 s, show at 1.98 s).

Changes

  • Styled before drawn (QtConversationHistory.prepare_fragments): the shared pager's preparation hook now formats each shown row at the window's width before it is published.
  • Keep the last look while a new one prepares (HistoryRowDelegate.styled_formatting): a drawn row whose look changes keeps its last prepared formatting until the new one lands, never the plain fallback.
  • Arrival fade (ArrivalFade): Qt runs the TUI's ARRIVAL cascade (NEW_TEXT) on the app's AnimationClock. It starts from repaint(fragments), where Textual's EffectPhase.on_new_arrival starts it, so both publish paths fade: an edge extended under the reader, and show_newest on a thread. Rows committed while a draft or live block stood in for them don't fade, since they replace it in place.
  • Glide to arrivals (ArrivalGlide, motion.FOLLOW_ARRIVAL): a following reader glides from where the end was before the arrived rows, measured from their own heights. The three places Qt follows the end (anchor for FollowTailCommit.restore_reader, check_follow, keep_reader) all defer to the glide through gliding_to_end. A glide never moves up, and a row arriving mid-glide turns it toward the new end. A reader scrolled up is not moved and the shared jump bar shows.
  • Queue rows (RowReveal, motion.ROW_REVEAL): the summary and the delivery controls open and close their height, and the summary follows its wrapped line count, on the clock. A summary that empties and fills again turns around where it is instead of hiding and showing. Show and hide still follow the shared queue_summary / offers_send_now.
  • Motion off: reduced motion (TEXTUAL_ANIMATIONS=none, the clock disabled) lands everything at once.
  • Glyph check (tools/glyph_check.py, run first by tools/android/check.sh): refuses a drawn string literal in src/toad (docstrings excepted) with a code point that defaults to emoji presentation unless U+FE0E follows it. The five the font work named are ⏪ U+23EA, ⏳ U+23F3, ⚡ U+26A1, ⚫ U+26AB and ❓ U+2753. The check covers the whole BMP Emoji_Presentation=Yes set: ⌚ ⌛ ⏩ ⏪ ⏫ ⏬ ⏰ ⏳ ◽ ◾ ☔ ☕ ♈–♓ ♿ ⚓ ⚡ ⚪ ⚫ ⚽ ⚾ ⛄ ⛅ ⛎ ⛔ ⛪ ⛲ ⛳ ⛵ ⛺ ⛽ ✅ ✊ ✋ ✨ ❌ ❎ ❓ ❔ ❕ ❗ ➕ ➖ ➗ ➰ ➿ ⬛ ⬜ ⭐ ⭕. None of them is declared anywhere Toad draws from today (Toad, ui_theme, agent_comms, textual), so there was nothing to append U+FE0E to, and the check finds 0. It keeps any new one from being declared without U+FE0E. Font loading (toad.qt.glyph_fonts, qt fonts: ship the glyph fonts Toad draws with, ahead of emoji (Android tofu and orange symbols) #2105) is untouched.

Evidence

qt_drive.py arrival, Pixel 8a profile, offscreen, live bus, scratch threads only.

main branch
rows removed and re-added / message text shown under two keys 0 0
rows drawn plain before styled (per arriving message) 1 each 0
receipt-status repaint as plain text yes (key dump) 0
largest scroll step while following, #scratch 261–348 px 31 px
largest scroll step while following, thread 109 px per send 23 px
queue hide then show within 1 s hidden 3.1 s → shown 3.3 s (throttled); 1.49 → 1.98 s; 2.4 → 2.61 s none in any run
queue summary height step per 16 ms 17 px in one frame ≤ 5 px
scrolled-up reader's row — stays at -34 px, jump bar shown
loop gaps unthrottled, rebased head (p50/p95/max) #scratch 16 / 22 / 43 ms; thread 16 / 17 / 31 ms
longest loop stall at 45% CPU, first throttled run 503 ms (p95 87) 300 ms (p95 100)
arrival-handling CPU per call at 45% CPU, max rows_changed 12.6 ms, show_pages 5.8 ms rows_changed 3.7 ms, show_pages 3.0 ms

At phone throttle (systemd-run --user --scope -q -p CPUQuota=45%), main's longest stall was 503 ms and the branch's 300 ms in the first run. In that run the sender processes shared the app's quota; with the senders in a scope of their own, each arrival-handling call's own CPU on the branch is at most 3.0 ms (show_pages), 3.7 ms (rows_changed), 0.3 ms (keep_reader) and 0.1 ms (repaint). On main, rows_changed reaches 12.6 ms. Wall gaps of about 200 ms happen on both sides and away from any update (205 ms elsewhere vs 201 ms near updates). They are the quota freezing the whole process under background load: keep_reader, at 0.3 ms of CPU, shows 86 ms of wall. So no stall over 50 ms comes from arrival handling. The background load is the frame-stall lane's.

Gates, run once on the final head (rebased onto 7752071):

  • qt_inherit_ratchet: bare Qt 21/21, parallel copies 0. ArrivalFade is declared Qt-only: it paints the shared cascade frame as QPainter opacity.
  • shadow_check: 0.
  • glyph_check: 0.
  • Arrival runs on this head: thread replies 0/1/2 shown, flicker {}, plain draws {}, no queue hide-then-show. Loop gap max 45 ms on the thread. On #scratch the max was 75 ms, one gap outside arrival handling, whose CPU was at most 4.6 ms per call.
  • tools/android/check.sh (with PYTHONFAULTHANDLER=1): exit 0, through closure, assemble (apk: assemble owns the app folder; leftovers of older builds are removed and excluded #2109's planted leftovers removed), the shipped-app check, and the shipped app run over every view kind and bound key on a scratch bus.

Thread replies

The first thread runs showed only the composer's own sends. The bus explains why: agent-comms history --as scratch-arrival-sender scratch-live-pipeline is empty, and a hand send answers {"error":"Sender 'scratch-arrival-sender' is not registered."}. The scenario's sender was unregistered, and the drive discarded its stderr and exit code. That was a scenario bug, not a Qt history bug. On a thread the other party is the thread itself, so the drive now posts --from scratch-live-pipeline --to user (landed as seq 940 by hand), and a refused post fails the walk.

Rerun on the thread: arrival reply 0/1/2 appear in Qt's thread view at 3.97 s and 4.20 s.

  • No flicker, no plain draws, no queue hide-then-show.
  • Loop gaps p50 16 ms, p95 19 ms, max 62 ms.
  • Arrival-handling CPU at most 4.4 ms per call.
  • The few upward scroll steps match the viewport's bottom edge moving down as the queue summary shrinks (viewport 359 → 394 px). The view stays pinned to the end; the reader is not moved within the content.

Shutdown SIGSEGV: found and fixed here

The shipped app (tools/android/shipped_run.py) exited with SIGSEGV at shutdown, after its last step. faulthandler places it in window._tick_animation → AnimationClock.tick → RowReveal.animation_visible (queue_ui.py:116, self.row.isVisible()), on a queue row whose C++ side was already destroyed. The window's clock timer outlives a conversation's widgets, so the cause is this PR's widget-bound clock targets, not main.

Counts (shipped_run.py only, PYTHONFAULTHANDLER=1 -X faulthandler):

  • Unfixed head, sequential: 2 of 17 crashed (the first check.sh run and the first loop run).
  • Three parallel batches of 15, one each for unfixed, main 3712ef8 and fixed: 0 crashes in all three. The crash is timing-dependent, so these counts alone can't show the fix works.

Deterministic probe: a reveal is running when its row's C++ side is destroyed, then the clock ticks.

  • Unfixed: raises Internal C++ object (QLabel) already deleted from the same frame. At app teardown it reads freed memory instead. In normal use the same path is a tab closing mid-reveal.
  • Fixed: the target is gone from the clock when the row is destroyed, and the ticks pass.

Fix at one owner: toad.qt.widget_animation.WidgetAnimation. Every widget-bound clock target binds its widget once. The widget's destroyed stops the target on the clock, and a destroyed widget is never asked anything. RowReveal, ArrivalGlide and ArrivalFade inherit it. #2100's targets (TabGrowth, TabGhost, PaneSlide, NameWave) move window-lifetime widgets that die with the clock's own timer, so they keep their current base.

Not covered

🤖 Generated with Claude Code

https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

@trissim
trissim force-pushed the fork-qt-arrival-polish branch from 19241a0 to aa0b3ba Compare November 18, 2026 07:43
trissim and others added 3 commits November 18, 2026 03:06
…p opens and closes its height

The phone showed messages snapping in, out and back, and the queue strip popping on every
send. Measured with a new qt_drive `arrival` scenario (scratch threads only):

- A sent row's receipt answers several times just after it lands; each answer is a new
  preparation key, and the delegate drew the row as plain text, at another height, until the
  new look was prepared. The delegate now keeps the row's last prepared look meanwhile, and
  the shared pager's `prepare_fragments` styles rows before they are published.
- Arriving rows run the TUI's ARRIVAL cascade on the app's clock, started from `repaint`
  as Textual starts it, on both publish paths; rows replacing a draft or live block do not.
- A following reader glides to arrivals (motion.FOLLOW_ARRIVAL) from where the end was;
  every Qt follow point defers to the glide.
- The queue summary and delivery controls open, close and follow their wrapped height
  (motion.ROW_REVEAL), turning around instead of hiding and showing again.
- tools/glyph_check.py (first step of tools/android/check.sh) refuses an emoji-default
  code point drawn without U+FE0E.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…post fails the walk

On a thread, the scripted sender was an unregistered identity: the bus refused every post
('Sender ... is not registered') and the drive discarded the error, so the thread run
covered only the composer's own sends. The other party in a thread's view is the thread
itself replying to the user; it now posts as that, and a refused post raises.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
The shipped app exited with SIGSEGV at shutdown (2 of 17 sequential runs), the faulthandler
trace in AnimationClock.tick asking RowReveal.animation_visible -> row.isVisible() on a queue
row whose C++ side was already destroyed: the window's timer outlives a conversation's widgets.
Deterministic probe: a reveal running when its row is destroyed, then a tick: the unfixed
code raises 'Internal C++ object already deleted' from the same frame.

toad.qt.widget_animation.WidgetAnimation owns this for every widget-bound clock target:
the widget's destroyed signal stops the target on the clock, and a destroyed widget is never
asked anything. RowReveal, ArrivalGlide and ArrivalFade inherit it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
@trissim
trissim force-pushed the fork-qt-arrival-polish branch from aa0b3ba to 5798ecc Compare November 18, 2026 08:10
@trissim
trissim merged commit a7eb82a into main Nov 18, 2026
1 of 2 checks passed
trissim added a commit that referenced this pull request Nov 18, 2026
… one is named

The sidebar is a live list, filled from observations that can arrive after the step
that reads it. Scenarios took rows from it with a one-shot next(), which raised
StopIteration whenever the row was not drawn yet (history and composer at
qt_drive.py:649 today, twice, on main as on branches).

Scenario.found(wanted, label, rows) owns every such lookup. It reads the rows
again every tenth of a second, through the loop the scenario's steps run on,
until a 20 s deadline. Past the deadline it raises LookupError naming the missing
row and every row listed. channel_row, thread_row and the new listed_thread wait
through it, and channel_listed goes. Every one-shot next() over sidebar or
thread rows now goes through found, and so does each scenario that took
threads[0], children[0] or thread_rows()[0] from a list that could
still be empty, and #2110's ArrivalScenario, which used channel_listed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
trissim added a commit that referenced this pull request Nov 18, 2026
…ce; qt_drive waits for sidebar rows (#2112)

* open path: the views' settings class is set up after startup; rows measure pending stand-ins

- ObjectConfiguration.prepare_settings_type makes the views' lazy settings class, each
  nested one, and validates one instance, so their annotations resolve once. That is
  class setup the first view the reader opened used to pay (238 ms median at a phone's
  speed on the cold #comms open). ApplicationLifetime.start runs it once the restored
  tabs are up, before the heap settles, in both frontends.
- PreparedOnFill.resolved: pyqt-reactive measures a row's final formatting only; what a
  history row's measurement resolves to may be its pending stand-in, which is estimated
  instead of laid out (pyqt-reactive#63 calls it; an older delegate fills as before).
- qt_drive: FRAME_TIME_OPEN times the open path per action (view configuration, lazy
  types, the row delegate, settings writes and their snapshot and invalidation);
  FRAME_TIME_WRITES logs each settings write with the registered states (tools only).

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

* qt_drive: a sidebar row is waited for, with a deadline, and a missing one is named

The sidebar is a live list, filled from observations that can arrive after the step
that reads it. Scenarios took rows from it with a one-shot next(), which raised
StopIteration whenever the row was not drawn yet (history and composer at
qt_drive.py:649 today, twice, on main as on branches).

Scenario.found(wanted, label, rows) owns every such lookup. It reads the rows
again every tenth of a second, through the loop the scenario's steps run on,
until a 20 s deadline. Past the deadline it raises LookupError naming the missing
row and every row listed. channel_row, thread_row and the new listed_thread wait
through it, and channel_listed goes. Every one-shot next() over sidebar or
thread rows now goes through found, and so does each scenario that took
threads[0], children[0] or thread_rows()[0] from a list that could
still be empty, and #2110's ArrivalScenario, which used channel_listed.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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