Repository navigation
qt views: the composer is built just after the history first paints - #2124
Merged
Merged
Conversation
Opening a second channel at a phone's speed held the loop for one long stall, and 335 ms of the 491 ms (probed) was ConversationView's constructor: 170 ms of it the composer (channel_prompt: ComposerEditor, place_input_box, focus_changed, paint_colours). Rows are measured in the relayouts after it. QtConversation.reserve_composer is the one owner for every view kind: - the composer's place in the layout holds a ComposerPlaceholder, as tall as that view kind's composer last asked to be (composer_heights, its sizeHint), else an estimate from its parts (the editor's line and padding over the info bar's line); - the composer is built just after the history viewport's first Paint (an event filter, then a zero timer), replacing the placeholder in place; - a tap or focus on the placeholder builds it at once and hands it the focus, so typing never waits; a view never shown (a restored background tab) builds none until it is; - what the composer is told before it exists goes through on_composer: now once it is built, else at the mount, the latest of each kind (label, status, commands, hold, receipt, mention candidates), so nothing piles up while a view is hidden; - close_core_events forgets a composer not built yet. ConversationView and the thread views (QtThreadView, so mailbox and ACP) reserve it the same way; the thread view's one-tick QTimer mount goes, and so does its own copy of the "Composer mount failed" handling. The question under the composer keeps its place. On Android the composer stays out of the first frame's EGL setup, as before. Measured placeholder vs built height (Pixel 8a profile): 60 px / 60 px for the channel, DM and mailbox views. tools/qt_drive.py (tools only): FRAME_TIME_OPEN also times the composer's mount, the delegate's new_document / final_document and the history's fragment_height / block_row, and prints each composer's placeholder height beside its built one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is the second-channel open, at the view owner. A Qt view now builds its composer just after its history first paints, instead of inside its constructor. It goes with PyQT-reactive#65, where a layout lays out only the rows near the reader.
Why the view, not only
sizeHint. On the live bus, at phone speed (probed, py-spy), the second channel's worst stall was the target open itself: 491 ms,task=SessionRequestApply. 335 ms of that wasConversationView's constructor, and 170 ms of that was the composer (channel_prompt:ComposerEditor,place_input_box,focus_changed,paint_colours). Row measurement happened in the relayouts after it, as separate stalls.QtConversation.reserve_composer, one owner for every view kind:ComposerPlaceholder. It's as tall as that view kind's composer last asked to be (composer_heights, from itssizeHint), or an estimate from the composer's parts before the first one.on_composer(kind, apply). What the composer is told before it exists (label, status, commands, hold, receipt, mention candidates) applies at the mount. Only the latest of each kind is kept, so nothing piles up while a view is hidden.close_core_eventsforgets a composer that hasn't been built yet.ConversationViewandQtThreadView(so mailbox and ACP) both reserve it this way.QTimermount and its copy of the "Composer mount failed" handling are gone.Placeholder vs built height (Pixel 8a profile): 60 px / 60 px for the channel, DM and mailbox views, including the first composer of a run.
I didn't change composer internals or
paint_colours. Lines the other forks will touch:fork-android-file-picker-2): Attach and chips inQtMessageComposer; the attach owner intoad.client.prompt_composer. This PR doesn't touch either. If it adds anything that tells the view's composer something before it exists, that goes throughon_composer.fork-qt-theme-contrast):paint_colours. Untouched here. It runs inside the deferred build now, so it's no longer in the open's stall.tools/qt_drive.py(tools only):FRAME_TIME_OPENalso times the composer's mount, the delegate'snew_document/final_document, and the history'sfragment_height/block_row. It prints each composer's placeholder height beside its built height.Depends on
_row_preparedhook qt arrivals: rows rise in place and the reader glides; the queue strip opens and closes its height #2110 overrides)These arrive with the runtime rebuild: the runtime resolves each library at
main, and the APK bundles the runtime's site-packages. This PR's Toad code runs on the installed libraries too:check.shpasses against the current runtime.Measured (fixed bus, 1 core, unthrottled)
The phone-speed throttle (
systemd-run --user … CPUQuota=45%) needs the host's user systemd manager, which is down since the OOM. The live bus is down with it. So these numbers are from a fixed local bus (150 synthetic messages each on #comms and #scratch, plus the thread scratch-live-pipeline), driven byqt_drive actions --comms-root, pinned to 1 core and unthrottled. They're a relative before/after, not phone speed. 3 valid runs per side, median. (Runs that timed out at "welcome rows" during startup under host load are left out and were rerun.)These are two separate A/Bs, each against its own baseline, and they shouldn't be read across. The same configuration measured differently between the two sessions: the second A/B's "without band" #scratch was 44.8 ms, where the first A/B's "deferred composer" column has 20.1 ms.
1. This PR (#2112's head vs this branch, both with PyQT-reactive#63, without #65), worst stall:
The composer mount is now its own step after the paint: 14–27 ms on this core.
2. PyQT-reactive#65 (this branch, with and without the band):
sizeHintsizeHintsizeHintThe thread's worst stall isn't settled by A/B 1. Its composer was already deferred by one tick before this change. Its runs overlap (33–63 ms against 44–50 ms), and in A/B 2 one thread run stalled 246 ms while its row and relayout timers totalled under 90 ms, so this fixture can't attribute it.
The phone-throttled 3-run medians against the target (second-channel worst stall under 300 ms), and the live-bus reruns, follow once the user manager and the live bus are back.
Gates (once, on this head, a3c1492 over 19058d2)
ComposerPlaceholderis added with its reason (Qt builds a view's widgets in its constructor; Textual mounts them after its first frame).shadow_check: 0.tools/android/check.shwithPYTHONFAULTHANDLER=1: exit 0 on the installed runtime, including qt themes: Qt offers only the schemes it can draw; one failing setting no longer stops a start #2115's shipped run. No fatal or traceback lines.test_window_top_edge::test_wheel_up_through_saved_history_never_moves_forwardcases, which also fail on main when that file runs alone.@in #any and the fixed bus has no candidates there). open path: view settings class set up after startup; rows laid out once; qt_drive waits for sidebar rows #2112's head fails at the same step on the same bus. The live-bus run confirms it once the bus is back.🤖 Generated with Claude Code
https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3