From 270fe916e5ee7a8e82f08318109001d82f5b4593 Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Wed, 18 Nov 2026 16:32:34 -0500 Subject: [PATCH 1/2] qt: a tab's label reads Core's thread references off the GUI loop _refresh_thread_config read source.references() on the loop as a tab opened; the frame probe caught it holding the loop 104 ms on the desktop (several times that on the phone), the tab-opening stall Tristan sees. Compose access, status and mentions were already off it. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3 --- src/toad/qt/window.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/toad/qt/window.py b/src/toad/qt/window.py index 85089ba7c..b78f68a72 100644 --- a/src/toad/qt/window.py +++ b/src/toad/qt/window.py @@ -1316,7 +1316,10 @@ async def _refresh_thread_config(self) -> None: """Read compose access, status, label and mentions — facts that change when thread config changes (ThreadsObserved), not on every bus message.""" source = self.app.source() - label = self.conversation.label(source.references()) + # The label reads Core's thread references: off the GUI loop, as compose access is. + # Read on the loop it held a tab's opening for 104 ms on the desktop (frame probe). + references = await asyncio.to_thread(source.references) + label = self.conversation.label(references) self.on_composer("label", lambda composer: composer.labelled(label)) compose = await asyncio.to_thread(self.conversation.compose_access, source.core) await self.refresh_composer(compose) From 0ae57208227464ea0289c00f408a377e2264fe04 Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Wed, 18 Nov 2026 16:40:52 -0500 Subject: [PATCH 2/2] composer: one size for every box button, one line centred in the box, and its own surfaces in both frontends - Every button beside the input joins the row through add_box_button, which sizes the whole row: one height (the box's one-line height), the widest one's width, a small gap. Attach was added after the row was sized, so it was shorter, lower and touching Send. - The editor is exactly its lines' height; the box's touch room is split evenly above and below, so one line (and the glyph) sits centred as in Textual, and a longer message grows. - The shared PromptComposer declares queue_tone (TurnBandColour) and input_tone (InputToneColour, ui-theme#35): Textual's PromptContainer, QueueSummary and DeliveryControls paint them through TonePaint, Qt's composer frame and queue/delivery lines through the same declarations, so the input, its band and the prompt area are distinct surfaces. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3 --- src/toad/client/prompt_composer.py | 6 ++- src/toad/qt/composer.py | 68 ++++++++++++++++++++++-------- src/toad/widgets/prompt.py | 10 ++++- 3 files changed, 64 insertions(+), 20 deletions(-) diff --git a/src/toad/client/prompt_composer.py b/src/toad/client/prompt_composer.py index c52a82580..d54cd9100 100644 --- a/src/toad/client/prompt_composer.py +++ b/src/toad/client/prompt_composer.py @@ -13,7 +13,7 @@ from agent_comms.messaging.message_files import FileUpload from metaclass_registry import AbstractHooksMeta -from ui_theme.scheme import PromptToneColour, ThemeColour +from ui_theme.scheme import InputToneColour, PromptToneColour, ThemeColour, TurnBandColour from toad.client.input_decision import InputDecision from toad.setting_declarations import EachOpenWidget @@ -56,6 +56,10 @@ class PromptComposer(metaclass=AbstractHooksMeta): pushes the history further.""" # The surface the composer's area is painted on, a tier off the transcript above it. area_tone: ClassVar[type[ThemeColour]] = PromptToneColour + # The delivery and queue lines' band over that area, and the field typed into, a tier off + # both: each interactive part of the composer is its own surface, in both frontends. + queue_tone: ClassVar[type[ThemeColour]] = TurnBandColour + input_tone: ClassVar[type[ThemeColour]] = InputToneColour @property @abstractmethod diff --git a/src/toad/qt/composer.py b/src/toad/qt/composer.py index 2b27b30ca..514d1a58c 100644 --- a/src/toad/qt/composer.py +++ b/src/toad/qt/composer.py @@ -343,7 +343,11 @@ def __init__(self, host: ComposerHost, renderer: QtLineRenderer, placeholder: st renderer.themed(self, self.paint_colours) # Textual's QueueSummary + DeliveryControls, reading the shared submissions owner. self.submitting = QtQueueSummary(self) + self.submitting.setObjectName("composer-queue") self.delivery_controls = QtDeliveryControls(self) + self.delivery_controls.setObjectName("composer-delivery") + for line in (self.submitting, self.delivery_controls): + line.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True) # Textual's `QueueHint`: the info bar's held count while the delivery preview is off, # before the status line as Textual composes it. self.held = QtQueueHint(self) @@ -357,8 +361,9 @@ def __init__(self, host: ComposerHost, renderer: QtLineRenderer, placeholder: st # button beside the box is the box's one-line height, pinned to its bottom # (`fit_buttons`). self.frame_row = frame_row = QHBoxLayout() + frame_row.setSpacing(UiGap.normal) frame_row.addWidget(self.frame, 1) - frame_row.addWidget(self.send_button, 0, Qt.AlignmentFlag.AlignBottom) + self.add_box_button(self.send_button) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) @@ -395,9 +400,14 @@ def cells(spacing): return spacing.left * cell, spacing.top * line, spacing.right * cell, spacing.bottom * line self.frame_row.setContentsMargins(*cells(box.frame_margin)) - self.frame.layout().setContentsMargins(*cells(box.frame_padding)) + # The box's touch room sits evenly above and below the text, so one line is centred in + # the box as Textual's prompt is; the editor itself is exactly its lines' height. + left, top, right, bottom = cells(box.frame_padding) + room = self.TOUCH_ROOM // 2 + self.frame.layout().setContentsMargins(left, top + room, right, bottom + room) left, top, right, bottom = cells(box.label_padding) - self.glyph.setContentsMargins(left, top, right, bottom) + # The glyph's text sits on the editor's first line, below the document's own margin. + self.glyph.setContentsMargins(left, top + self.document_margin(), right, bottom) self.focus_changed(self.editor.hasFocus()) self.fit_buttons() @@ -408,16 +418,28 @@ def one_line_box_height(self) -> int: border = 2 if self.settings.ui.input.box.bordered else 0 return self.editor_height(1) + padding.top() + padding.bottom() + border + def add_box_button(self, button: QPushButton) -> None: + """The one way a button joins the box's row (Send, and any a composer adds, Attach + first): placed before Send, bottom-aligned, and the whole row sized again, so a button + added after the composer was built is sized like the rest (Attach was not, 2026-11-18).""" + # Send is added first and stays last; every later button goes before it. + self.frame_row.insertWidget(self.frame_row.count() - len(self.box_buttons), + button, 0, Qt.AlignmentFlag.AlignBottom) + self.box_buttons = (*self.box_buttons[:-1], button, *self.box_buttons[-1:]) \ + if self.box_buttons else (button,) + self.fit_buttons() + + box_buttons: tuple[QPushButton, ...] = () + def fit_buttons(self) -> None: - """Every button in the box's row (send, and any a composer adds beside it) is the - box's one-line height and at least as wide as tall: level with a one-line box, and - pinned to the bottom of a taller one (each is added bottom-aligned).""" + """Every button in the box's row is one size: the box's one-line height, and the + widest one's width (at least as wide as tall), level with a one-line box and pinned to + the bottom of a taller one.""" height = self.one_line_box_height() - for index in range(self.frame_row.count()): - button = self.frame_row.itemAt(index).widget() - if button is not None and button is not self.frame: - button.setFixedHeight(height) - button.setMinimumWidth(height) + buttons = self.box_buttons + width = max((height, *(button.sizeHint().width() for button in buttons))) + for button in buttons: + button.setFixedSize(width, height) def update_prompt(self) -> None: """A leading symbol or the placeholder setting changed: draw both again.""" @@ -435,7 +457,12 @@ def submissions(self) -> BusSubmissions: def paint_colours(self) -> None: """The area's tone, the muted placeholder, the offer list, the glyph and the frame's border, under the renderer's current scheme.""" - self.setStyleSheet(f"#composer {{ background: {self.renderer.theme(self.area_tone)} }}") + # The area, the band its delivery and queue lines sit on, and the field typed into: the + # shared composer's three tones (Textual paints the same ones through TonePaint). + queue = self.renderer.theme(self.queue_tone) + self.setStyleSheet( + f"#composer {{ background: {self.renderer.theme(self.area_tone)} }}" + f" #composer-queue, #composer-delivery {{ background: {queue} }}") palette = self.editor.palette() palette.setColor(QPalette.ColorRole.PlaceholderText, QColor(self.renderer.colour(MutedRole))) self.editor.setPalette(palette) @@ -447,10 +474,11 @@ def focus_changed(self, focused: bool) -> None: """The frame's border follows focus (Textual's `PromptContainer.border`), and the badge shows the editing mode only while focused.""" colour = self.renderer.theme(PrimaryColour if focused else MutedColour) + field = self.renderer.theme(self.input_tone) self.renderer.apply_sheet(self.frame, - f"#prompt-frame {{ border: 1px solid {colour}; border-radius: 2px }}" + f"#prompt-frame {{ background: {field}; border: 1px solid {colour}; border-radius: 2px }}" if self.settings.ui.input.box.bordered - else "#prompt-frame { border: none }") + else f"#prompt-frame {{ background: {field}; border: none }}") self.info_bar.badge.present_editing_mode(self.editor.editing_mode, focused) def refresh_editing_mode(self) -> None: @@ -485,9 +513,15 @@ def fit_height(self) -> None: Qt.ScrollBarPolicy.ScrollBarAsNeeded if typed > 5 else Qt.ScrollBarPolicy.ScrollBarAlwaysOff) self.editor.setFixedHeight(self.editor_height(lines)) + TOUCH_ROOM: ClassVar[int] = 16 + """Room the box adds around its text for a finger, split evenly above and below.""" + + def document_margin(self) -> int: + return round(self.editor.document().documentMargin()) + def editor_height(self, lines: int) -> int: - """The editor's height showing `lines` lines.""" - return self.editor.fontMetrics().lineSpacing() * lines + 24 + """The editor's height showing `lines` lines: the lines and the document's margins.""" + return self.editor.fontMetrics().lineSpacing() * lines + 2 * self.document_margin() @property def text(self) -> str: @@ -673,7 +707,7 @@ def __init__(self, host: ComposerHost, renderer: QtLineRenderer, placeholder: st self.attach_button = QPushButton(AttachFileAction.title, self) self.attach_button.setFocusPolicy(Qt.FocusPolicy.NoFocus) # tapping keeps the keyboard up self.attach_button.clicked.connect(self.attach_file) - self.frame_row.insertWidget(1, self.attach_button, 0, Qt.AlignmentFlag.AlignBottom) + self.add_box_button(self.attach_button) self.attached_row = QWidget(self) chips = QHBoxLayout(self.attached_row) chips.setContentsMargins(UiGap.frame, 0, UiGap.frame, 0) diff --git a/src/toad/widgets/prompt.py b/src/toad/widgets/prompt.py index f10f5c8ab..a86b34fec 100644 --- a/src/toad/widgets/prompt.py +++ b/src/toad/widgets/prompt.py @@ -241,10 +241,12 @@ class QueueSummary( MutedText, StartsHidden, AutoHeight, + TonePaint, Label, can_focus=True, ): """Shows queued messages and opens their delivery status when selected.""" + tone = PromptComposer.queue_tone def apply_native_layout(self) -> None: @@ -265,7 +267,8 @@ def activate(self) -> None: self.query_ancestor(Prompt).conversation.open_queue_menu() -class DeliveryControls(QueueDeliveryControls, ComposedWhenShown, StartsHidden, OneRow, containers.HorizontalGroup): +class DeliveryControls(TonePaint, QueueDeliveryControls, ComposedWhenShown, StartsHidden, OneRow, containers.HorizontalGroup): + tone = PromptComposer.queue_tone """Shown while Enter queues behind a running turn; `QueueDeliveryControls` owns its text.""" def shown_children(self) -> tuple[Widget, ...]: @@ -348,7 +351,10 @@ def render(self): return self.query_ancestor(Prompt).label_glyph() -class PromptContainer(SettingsReader, FocusWithinView, containers.HorizontalGroup): +class PromptContainer(TonePaint, SettingsReader, FocusWithinView, containers.HorizontalGroup): + # The field typed into: the composer's input tone, a tier off the prompt and its band. + tone = PromptComposer.input_tone + @property def margin(self): return self.settings.ui.input.box.frame_margin