Skip to content

Qt: share Gap/Divider document cache between block_row and header_document + inline cold Divider prep - #2321

Merged
trissim merged 1 commit into
mainfrom
fix/qt-shared-header-doc-cache
Nov 27, 2026
Merged

trissim merged 1 commit into
mainfrom
fix/qt-shared-header-doc-cache

Conversation

@trissim

@trissim trissim commented Nov 27, 2026 •

Copy link
Copy Markdown

Summary

Eliminate redundant QTextDocument layout + setHtml allocations when scrolling past message boundaries in QtHistoryWindow:

  1. Shared standalone block cache key (src/toad/client/line_blocks.py, src/toad/qt/history.py):
    • Added LineBlock.standalone_cache_key(row_key, index, shared_key) (default (row_key, index)) and SharedStandaloneBlock(LineBlock) inherited by both Divider and Gap (one declaration, zero duplicated overrides).
    • HistoryRowDelegate.block_row keys leading blocks through blocks[index].standalone_cache_key(key, index, lambda header: self.header_key(header, font, width)).
    • Every Gap() across all messages at a given (font, width) now shares ONE cached QTextDocument instead of allocating a fresh QTextDocument per crossed message, and every leading Divider measured by block_row hits the exact cached QTextDocument reused by QtStickyHeader.draw_pinned -> header_document (1 setHtml/layout instead of 2).
  2. Inline cold Divider preparation (src/toad/qt/history.py):
    • HistoryRowDelegate.header_document prepares a cold Divider (renders_inline=True) directly on the warm QtLineRenderer when missing from _prepared (e.g. immediately after resize/theme switch) instead of waiting on a RenderProcessPool round-trip.

Verification

  • Focused pytest (test_android_perf_ux_arrivals.py, test_history_preparation_runway.py, test_android_resync_lazy_load_catchup.py): 51 passed in 0.63s (including new test_block_row_and_pinned_header_share_one_cached_document_and_prepare_inline).
  • tools/qt_inherit_ratchet.py: 0 / 0 / 0 / 0 / 0.
  • tools/shadow_check.py: 0.
  • tools/guarded_imports.py: 0.
  • REL_IMPORTS=0.

@trissim
trissim merged commit 872aba8 into main Nov 27, 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