From 8ba41f2afa41fb8bd413dcd88782e9291f07d3a1 Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Wed, 18 Nov 2026 04:30:57 -0500 Subject: [PATCH] theme: the composer's area and the open tab take their tones from the shared roles Qt's composer drew on the page's own colour, so it read as part of the transcript, while Textual's prompt sits on PromptToneColour. The composer's area tone is now one declaration on the shared PromptComposer (`area_tone`); Textual's Prompt points its TonePaint at it and Qt's Composer paints its area with it. The open tab is raised a tier off the tab bar in both frontends (ui_theme's SelectedTabToneColour). Qt had drawn it darker than the other tabs; the TUI had marked it only by the underline. Needs ui-theme's tier derivation (TIER_GAP, SelectedTabToneColour) and pyqt-reactive's tab_bg / selected_tab_bg roles, so it merges after both and a runtime rebuild. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3 --- src/toad/client/prompt_composer.py | 4 ++++ src/toad/qt/composer.py | 8 ++++++-- src/toad/widgets/prompt.py | 5 +++-- src/toad/widgets/session_tabs.py | 11 +++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/toad/client/prompt_composer.py b/src/toad/client/prompt_composer.py index ae6c2209a..fa803e5ca 100644 --- a/src/toad/client/prompt_composer.py +++ b/src/toad/client/prompt_composer.py @@ -9,8 +9,10 @@ from __future__ import annotations from abc import abstractmethod +from typing import ClassVar from metaclass_registry import AbstractHooksMeta +from ui_theme.scheme import PromptToneColour, ThemeColour from toad.client.input_decision import InputAccepted, InputDecision from toad.setting_declarations import EachOpenWidget @@ -36,6 +38,8 @@ class PromptComposer(metaclass=AbstractHooksMeta): """A conversation's composer: its submission owner, queue and leading glyph.""" submissions: object | None + # The surface the composer's area is painted on, a tier off the transcript above it. + area_tone: ClassVar[type[ThemeColour]] = PromptToneColour @property @abstractmethod diff --git a/src/toad/qt/composer.py b/src/toad/qt/composer.py index ee5dd3c2b..0fddca236 100644 --- a/src/toad/qt/composer.py +++ b/src/toad/qt/composer.py @@ -308,6 +308,9 @@ class Composer(PromptSettingEffects, PromptComposer, MentionEditor, SubmitsContr def __init__(self, host: ComposerHost, renderer: QtLineRenderer, placeholder: str) -> None: super().__init__() self.host, self.renderer = host, renderer + # The composer's area is its own surface (`area_tone`), as Textual's prompt area is. + self.setObjectName("composer") + self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True) self.given_placeholder = placeholder self.mention_candidates: tuple[MentionCandidate, ...] = () self.commands: list[SlashCommand] = [] @@ -398,8 +401,9 @@ def submissions(self) -> BusSubmissions: return self.host.submissions def paint_colours(self) -> None: - """The muted placeholder, the offer list, the glyph and the frame's border, under the - renderer's current scheme.""" + """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)} }}") palette = self.editor.palette() palette.setColor(QPalette.ColorRole.PlaceholderText, QColor(self.renderer.colour(MutedRole))) self.editor.setPalette(palette) diff --git a/src/toad/widgets/prompt.py b/src/toad/widgets/prompt.py index 68ed33bce..205cde657 100644 --- a/src/toad/widgets/prompt.py +++ b/src/toad/widgets/prompt.py @@ -38,7 +38,7 @@ from textual.widgets import Label, OptionList, TextArea from textual.widgets.option_list import Option, OptionListComponent from textual.widgets.text_area import Selection, TextAreaComponent -from ui_theme.scheme import ErrorColour, MutedColour, PrimaryColour, PromptToneColour, SecondaryColour +from ui_theme.scheme import ErrorColour, MutedColour, PrimaryColour, SecondaryColour from toad import messages from toad.clipboard_image import PastesClipboard, read_clipboard, save_clipboard_png @@ -715,7 +715,8 @@ class Prompt(NativeMethodKeys, HiddenActions, DismissibleControl, PromptSettingE containers.VerticalGroup, ToadNode, PromptComposer, actions=(PromptFrameAction,)): """The Textual composer; `PromptComposer` owns its submissions, queue, glyph and draft decisions, shared with Qt's `Composer`.""" - tone = PromptToneColour + # `TonePaint` comes first in the bases, so its `tone` would hide the composer's own. + tone = PromptComposer.area_tone TEXT_AREA_CLASS = PromptTextArea diff --git a/src/toad/widgets/session_tabs.py b/src/toad/widgets/session_tabs.py index 5af0d7ddd..2901b543f 100644 --- a/src/toad/widgets/session_tabs.py +++ b/src/toad/widgets/session_tabs.py @@ -29,6 +29,7 @@ ForegroundColour, HeaderToneColour, MutedColour, + SelectedTabToneColour, ) from toad.core import events as core_events @@ -52,6 +53,16 @@ class SessionLabel(WidgetView, PrimaryActivation, ViewLabel, ChangingText, widge def current(self) -> bool: return self.mode_name == self.app.selected_mode + # TonePaint declares a class tone; the open tab is raised a tier off the bar, the rest sit on it. + @property + def tone(self): # type: ignore[override] + return SelectedTabToneColour if self.current else None + + def paint_current(self) -> None: + """The tab opened or closed: its tone is part of its cached paint.""" + self.refresh_paint() + super().paint_current() + @property def paint_text_style(self): return RichStyle(dim=not self.mouse_hover)