Skip to content

Cut tab-bar paint enum overhead and disable Android composer auto-focus on tab switch - #2347

Merged
trissim merged 1 commit into
mainfrom
fix/tab-bar-paint-frame-budget
Nov 28, 2026
Merged

trissim merged 1 commit into
mainfrom
fix/tab-bar-paint-frame-budget

Conversation

@trissim

@trissim trissim commented Nov 28, 2026

Copy link
Copy Markdown

Summary

  1. Eliminated enum.py per-frame overhead in QtSessionTabBar.paintEvent (39.9 -> 0.8 Python calls/frame in shipped_run.py, 50× reduction):

    • Keyed _tab_chrome on pure integers/booleans (tab_w, tab_h, selected, hovered, pos_tag, adj_selected, dpr) and constructed QStyleOptionTab only on chrome cache miss (eliminating 84/87 Python enum.py calls per warm frame).
    • Pre-computed marquee offsets once per clock tick in QtTabMarquee.repaint() (painted_offsets) instead of calling animation.frame() inside paintEvent.
    • Tightened tools/frame_work_baseline.json (name_wave.QtNameWaveDelegate.paint: 37.7 -> 26.9).
  2. Stopped Android tab switches from auto-focusing the composer & popping the soft keyboard:

    • Declared auto_focus_composer: ClassVar[bool] = True on Platform (src/toad/client/platform.py), overridden to False on AndroidPlatform.
    • Switched ComposerPlaceholder (src/toad/qt/conversation.py) and ComposerEditor (src/toad/qt/composer.py) to Qt.FocusPolicy.ClickFocus when not host.auto_focus_composer so QStackedWidget.setCurrentWidget never transfers focus into the input box.
    • Gated ComposerPlaceholder.focusInEvent and ComposerEditor.focusInEvent IME show on Qt.FocusReason.MouseFocusReason (explicit tap on composer or placeholder still raises the keyboard immediately).
    • Cleared focus on pooled composer release (release_pooled_composer) and cleared focus + hid IME on tab switch (QtWorkspaceViews.select / swap_page) when not host.auto_focus_composer.

Verification

  • REL_IMPORTS=0
  • tools/qt_inherit_ratchet.py: 0 / 0 / 0 / 0 / 0 (Qt-only: 47)
  • Focused pytest (test_android_perf_ux_arrivals.py, test_name_wave_repaint.py): 49 passed in 0.99s
  • tools/android/check.sh (full shipped-app check + shipped_run.py + frame_work gate): ALL_CHECKS_PASSED (QtSessionTabBar.paintEvent: 0.8 Python calls/frame; QtNameWaveDelegate.paint: 25.6 vs baseline 26.9).

@trissim
trissim merged commit 6622143 into main Nov 28, 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