diff --git a/src/toad/client/history.py b/src/toad/client/history.py index f7a493003..c3c91d16c 100644 --- a/src/toad/client/history.py +++ b/src/toad/client/history.py @@ -157,7 +157,7 @@ async def read_changes(self) -> bool: def prepare_viewport(self) -> None: super().prepare_viewport() - if self.can_draw_on_screen: + if self.can_draw_on_screen and not self.window.scroll_in_motion: self.mark_visible() self.follow_message_style() @@ -183,7 +183,10 @@ async def restyle(self, style) -> None: def mark_visible_after_paint(self) -> None: """Try marking read again once the frontend has painted its next frame, coalesced so - painting many rows in one scroll frame schedules one callback instead of N.""" + painting many rows in one scroll frame schedules one callback instead of N. Defers + while the window is actively scrolling; settle flushes `prepare_viewport()` once.""" + if self.window.scroll_in_motion: + return if not self._read_mark_scheduled: self._read_mark_scheduled = True self.call_after_refresh(self._run_scheduled_mark_visible) @@ -218,7 +221,7 @@ def read_fragments(self) -> tuple[EvidencedFragment, ...]: return tuple(self._painted_reads.values()) def read_visible(self) -> PaintedRead: - if not self.is_attached: + if not self.is_attached or self.window.scroll_in_motion: return NothingToRead() if not any(fragment.evidence is not None for fragment in self.read_fragments()): return NothingToRead() diff --git a/src/toad/client/history_notifications.py b/src/toad/client/history_notifications.py index 9380a8a7e..b14fbb832 100644 --- a/src/toad/client/history_notifications.py +++ b/src/toad/client/history_notifications.py @@ -62,6 +62,8 @@ def check_notifications_after_refresh(self) -> None: def check_notifications(self) -> None: fragments = self.notification_targets() if self.can_draw_on_screen else () + if any(target.notifications_deferred for target in fragments): + return references = tuple(dict.fromkeys( reference for fragment in fragments for reference in fragment.notification_references)) # The connection still showing a read for this view is checked too: a hide stops the @@ -181,9 +183,15 @@ def rows_published(self) -> None: self.notification_view.checked_references = None self.notification_view.check_notifications_after_refresh() + @property + def notifications_deferred(self) -> bool: + """Defer notification re-subscription while the window is actively scrolling.""" + return self.window.scroll_in_motion + def prepare_viewport(self) -> None: super().prepare_viewport() - self.notification_view.check_notifications() + if not self.notifications_deferred: + self.notification_view.check_notifications() def check_visible_notifications(self) -> None: self.notification_view.check_notifications_after_refresh() diff --git a/src/toad/client/history_pager.py b/src/toad/client/history_pager.py index d0e220f61..b42b42fe8 100644 --- a/src/toad/client/history_pager.py +++ b/src/toad/client/history_pager.py @@ -181,6 +181,11 @@ class PagingWindow(ReaderWindow): arrival_burst: ArrivalBurst = NO_BURST """The messages that last arrived together at the end the reader follows.""" + @property + def scroll_in_motion(self) -> bool: + """Whether an active drag, fling, or unsettled scroll burst is moving this window.""" + return False + def arrivals_followed(self, arrivals: tuple[HistoryFragment, ...]) -> None: """`arrivals` were published at the followed end: they join the burst while the reader follows it, or while the burst is still arriving (Textual stops following where it diff --git a/src/toad/history_jump.py b/src/toad/history_jump.py index 26addff64..4960ed0ea 100644 --- a/src/toad/history_jump.py +++ b/src/toad/history_jump.py @@ -143,7 +143,7 @@ def record_reader_scroll(self, delta: float) -> None: self.rejoin_reached_tail() -class ReaderWindow(JumpsToLatest): +class PagedReader(JumpsToLatest): """A history window the reader keys move: a page either way, or back to the latest (`reader_actions`). Textual's `HistoryWindow` and Qt's `QtHistoryWindow` both list it.""" diff --git a/src/toad/qt/activity.py b/src/toad/qt/activity.py index 8e65ea8a8..5fd2b2145 100644 --- a/src/toad/qt/activity.py +++ b/src/toad/qt/activity.py @@ -12,7 +12,7 @@ from PySide6.QtGui import QColor, QLinearGradient, QPainter from PySide6.QtWidgets import QVBoxLayout, QWidget from pyqt_reactive.widgets.fitted_text import ElidedLine -from ui_theme.clock import Animation, AnimationClock +from ui_theme.clock import Animation from ui_theme.effects import ACTIVITY_SWEEP, Ribbon from ui_theme.scheme import BackgroundColour @@ -23,7 +23,7 @@ from toad.qt.lines import QtLineRenderer from toad.status_thread import ObservedActivity from toad.qt.metrics import UiGap -from toad.qt.widget_animation import WidgetAnimation +from toad.qt.widget_animation import QtAnimationClock, WidgetAnimation class ActivitySweep(SweepEffect, WidgetAnimation, QWidget): @@ -36,7 +36,7 @@ class ActivitySweep(SweepEffect, WidgetAnimation, QWidget): backing store continuously. """ - def __init__(self, renderer: QtLineRenderer, clock: AnimationClock) -> None: + def __init__(self, renderer: QtLineRenderer, clock: QtAnimationClock) -> None: super().__init__() self.renderer = renderer self.working = False @@ -74,6 +74,10 @@ def repaint(self) -> None: """A shared clock tick invalidates this strip; Qt schedules its native paint.""" self.update() + @property + def animation_visible(self) -> bool: + return super().animation_visible and not self.clock.scrolling + def paintEvent(self, event) -> None: # type: ignore[override] painter = QPainter(self) background, bg_qcolor, stops_map = self._scheme_colours() diff --git a/src/toad/qt/history.py b/src/toad/qt/history.py index 26af640a5..8cd04ec13 100644 --- a/src/toad/qt/history.py +++ b/src/toad/qt/history.py @@ -76,7 +76,7 @@ FragmentLocation, FragmentPosition, ReaderPage, ReaderPosition, RowPosition, TailPosition, UnloadedFragment, ) -from toad.history_jump import FollowsTail, JumpsToLatest, ReaderWindow +from toad.history_jump import FollowsTail, JumpsToLatest, PagedReader from toad.no_worker import NoTask from toad.qt.live_turn import QtLiveBlock from toad.qt.workspace_frame import QtWorkspaceHosted @@ -1204,13 +1204,6 @@ class QtHistoryNotifications(OneHistoryNotifications): notification_work = NoTask() _notifications_timer: QTimer | None = None - def check_notifications(self) -> None: - """Defer notification re-subscription while a finger is actively dragging or flinging - QScroller; `QtHistoryWindow._on_scroller_state` flushes the instant motion settles.""" - if self.message_history.window.actively_scrolling: - return - super().check_notifications() - def report_queue_evidence(self) -> None: """New queue evidence repaints the composer's queue rows, as Textual's `Conversation.queue_evidence_changed` does through its submissions. Skip scheduling @@ -1534,7 +1527,7 @@ def show_jump(self, shown: bool) -> None: self.setVisible(shown) -class QtHistoryWindow(AnimatesArrivals, ReaderPlacement, ShowsLatestJumpBar, FollowsTail, ReaderWindow, +class QtHistoryWindow(AnimatesArrivals, ReaderPlacement, ShowsLatestJumpBar, FollowsTail, PagedReader, QtWorkspaceHosted, VirtualRowCanvas, PagingWindow, TogglesFragmentShown, PinsMessageHeader, SettingsReading): """The reader window of one Qt conversation: prefix-sum virtual rows of the history's @@ -1665,6 +1658,7 @@ def repaint_arrival_keys(self, keys: tuple[object, ...]) -> None: def _on_widget_destroyed(self, *_args) -> None: self.stop_arrival_motion() + self.animation_clock.set_scrolling(self, False) async def acquire_links(self, app) -> None: """The names this conversation's bodies link through; redraw rows only if links changed.""" @@ -2200,6 +2194,8 @@ def showEvent(self, event) -> None: # type: ignore[override] def hideEvent(self, event) -> None: # type: ignore[override] super().hideEvent(event) self.actively_scrolling = False + self._settle_timer.stop() + self._sync_clock_scrolling() def resizeEvent(self, event) -> None: # type: ignore[override] """A window that follows the latest message stays on it when its height changes: the @@ -2317,10 +2313,18 @@ def reveal_head_at(self, point: QPoint) -> bool: return False return self.start_head_reveal(self.scroll_y + top) + @property + def scroll_in_motion(self) -> bool: + """Whether a finger drag/fling or an unsettled scroll burst is moving the viewport.""" + return self.actively_scrolling or self._settle_timer.isActive() + + def _sync_clock_scrolling(self) -> None: + self.animation_clock.set_scrolling(self, self.scroll_in_motion) + def _on_scroller_state(self, state) -> None: """A finger taking the rows stops a head reveal; a press that stops a fling is - remembered, so its release is not read as a tap on a row. Notification checks wait - until the drag/fling settles instead of firing hundreds of Core subscriptions mid-fling.""" + remembered, so its release is not read as a tap on a row. Notification checks, + read-marking, and decorative chrome animations wait until motion settles.""" scrolling = state in (QScroller.State.Dragging, QScroller.State.Scrolling) was_scrolling = self.actively_scrolling self.actively_scrolling = scrolling @@ -2334,8 +2338,15 @@ def _on_scroller_state(self, state) -> None: self._overshoot = 0.0 self._travel_origin = 0.0 if was_scrolling and not scrolling: - for history in tuple(self.histories): - history.notification_view.check_notifications_after_refresh() + if self._settle_timer.isActive(): + self._settle_timer.stop() + self._sync_clock_scrolling() + self._settle() + else: + self._sync_clock_scrolling() + self.request_preparation() + else: + self._sync_clock_scrolling() _travel_origin = 0.0 """How far layout has moved the reader since the finger now scrolling them came down. @@ -2451,6 +2462,7 @@ def _schedule_settle(self) -> None: self._last_scroll_at = monotonic() if not self._settle_timer.isActive(): self._settle_timer.start(int(self.lookahead.idle_seconds * 1000)) + self._sync_clock_scrolling() def _on_settle_timer(self) -> None: if self.widget_gone: @@ -2459,6 +2471,7 @@ def _on_settle_timer(self) -> None: if remaining_ms > 15: self._settle_timer.start(remaining_ms) return + self._sync_clock_scrolling() self._settle() def after_source_presented(self, callback, *arguments) -> None: diff --git a/src/toad/qt/name_wave.py b/src/toad/qt/name_wave.py index c5c214125..e45d33005 100644 --- a/src/toad/qt/name_wave.py +++ b/src/toad/qt/name_wave.py @@ -325,7 +325,7 @@ def wave_visible(self) -> bool: @property def animation_visible(self) -> bool: - return self.wave_visible() + return self.wave_visible() and not self.wave_clock().scrolling def wave_running(self) -> bool: return self.animation is not None @@ -431,7 +431,7 @@ def __init__(self, bar: QtSessionTabBar) -> None: @property def animation_visible(self) -> bool: - return self.bar.isVisible() + return self.bar.isVisible() and not self.bar.clock.scrolling def marquee_running(self) -> bool: return self.animation is not None diff --git a/src/toad/qt/widget_animation.py b/src/toad/qt/widget_animation.py index 10cb66055..afbf5722f 100644 --- a/src/toad/qt/widget_animation.py +++ b/src/toad/qt/widget_animation.py @@ -17,6 +17,35 @@ from ui_theme.clock import AnimationClock +class QtAnimationClock(AnimationClock): + """Qt's shared animation clock: tracks scrolling history windows so infinite decorative + chrome effects (name waves, tab marquees, activity sweeps) yield while scrolling without + stalling finite transitions (arrivals, fades, tab open/close) or expanding Android's + backing-store dirty bounding box to a full-screen GPU upload.""" + + def __init__(self, schedule, *, enabled: bool = True, frame_interval: float = 1 / 60, + now=None) -> None: + if now is None: + super().__init__(schedule, enabled=enabled, frame_interval=frame_interval) + else: + super().__init__(schedule, now=now, enabled=enabled, frame_interval=frame_interval) + self._scrolling_owners: set[int] = set() + + @property + def scrolling(self) -> bool: + return bool(self._scrolling_owners) + + def set_scrolling(self, owner: object, active: bool) -> None: + was = self.scrolling + oid = id(owner) + if active: + self._scrolling_owners.add(oid) + else: + self._scrolling_owners.discard(oid) + if self.scrolling != was: + self.refresh() + + def frame_interval(screen: QScreen | None) -> float: """Seconds between the frames `screen` shows: one over its refresh rate (a Pixel 8a's 120 Hz), or 60 Hz where it reports none (offscreen, some remote displays). Motion ticks at it diff --git a/src/toad/qt/window.py b/src/toad/qt/window.py index f8c505ab2..432f90851 100644 --- a/src/toad/qt/window.py +++ b/src/toad/qt/window.py @@ -57,7 +57,6 @@ from toad.qt.mailbox_view import QtMailboxView from toad.qt.opening_view import QtOpeningSessionView from toad.qt.tap_flash import QtPushButton, QtTextButton -from ui_theme.clock import AnimationClock from ui_theme.scheme import ( AlternateRowToneColour, ColourScheme, @@ -74,7 +73,7 @@ from toad.app_core import CorePrewarm from toad.client.application import ACTIVE_PRESENCE, ApplicationPresence, ClientApplication from toad.qt.workspace_frame import QtWorkspaceFrame, QtWorkspaceHosted -from toad.qt.widget_animation import frame_interval +from toad.qt.widget_animation import QtAnimationClock, frame_interval from toad.workspace_frame import WorkspaceFrame from toad.client.session_scope import NoConversationView from toad.client.application_actions import ApplicationAction, MenuActionRun, NewSessionAction, NewSessionControl @@ -1764,7 +1763,7 @@ def __init__(self, connection: CoreConnection, project: Checkout, self._animations_paused = False self._layout_pending = False self._presence: ApplicationPresence = ACTIVE_PRESENCE - self.animation_clock = AnimationClock(self._schedule_animation, enabled=animations_enabled()) + self.animation_clock = QtAnimationClock(self._schedule_animation, enabled=animations_enabled()) # Notices and the work the reader waits on float over the pages, never in their layout. self.float_layer = QtFloatLayer( self.theme.color_scheme, self.renderer, self.animation_clock, self) diff --git a/src/toad/reader_actions.py b/src/toad/reader_actions.py index 049117093..00ce22358 100644 --- a/src/toad/reader_actions.py +++ b/src/toad/reader_actions.py @@ -16,14 +16,14 @@ from textual.document._editing import VimMode -from toad.history_jump import ReaderWindow +from toad.history_jump import PagedReader from toad.widget_actions import Action class ReaderAction(Action, affix="Action"): """Vim reader keys every history window answers.""" - context_capability = ReaderWindow + context_capability = PagedReader class PageDownAction(ReaderAction, declared_name="reader_page_down"): diff --git a/src/toad/transcript_publication.py b/src/toad/transcript_publication.py index 77d1d4a54..a33b35a0e 100644 --- a/src/toad/transcript_publication.py +++ b/src/toad/transcript_publication.py @@ -63,7 +63,7 @@ from toad.core.link_context_changed import CoreEventStream from toad.core.projection import MroProjection from toad.core.source_events import TranscriptCoverage as CoverageEvent -from toad.history_jump import ReaderWindow +from toad.history_jump import PagedReader from toad.live_output import LiveOutput from toad.client.resource_release import AsyncResourceRelease, ResourceRelease from toad.client.session_scope import SessionOrigin, SessionScope @@ -1196,7 +1196,7 @@ def retire_presentations( if any(candidate.display for candidate in candidates): # Their rows leave the window now; the reader stays on theirs. - contents.query_ancestor(ReaderWindow).keep_reader() + contents.query_ancestor(PagedReader).keep_reader() for candidate in candidates: candidate.display = False retirement = asyncio.create_task( diff --git a/src/toad/widgets/history_anchor.py b/src/toad/widgets/history_anchor.py index ff3870be2..1e74626a4 100644 --- a/src/toad/widgets/history_anchor.py +++ b/src/toad/widgets/history_anchor.py @@ -22,7 +22,7 @@ from toad.block_navigation import ConversationBlock from toad.arrivals import AnimatesArrivals -from toad.history_jump import FollowsTail, JumpsToLatest, ReaderWindow +from toad.history_jump import FollowsTail, JumpsToLatest, PagedReader from toad.core.projection import MroProjection from toad.no_worker import NO_TIMER, NoTimer from toad.workspace_frame import WorkspaceHosted @@ -57,7 +57,7 @@ class HistoryWindow(FollowsTail, NativeMethodKeys, WorkspaceHosted, MroProjection[tuple[MessageRowOwner, ...]], - AnimatesArrivals, ReaderPlacement, ReaderWindow, VerticalScroll, PagingWindow, + AnimatesArrivals, ReaderPlacement, PagedReader, VerticalScroll, PagingWindow, actions=(ReaderAction,)): """A document owns reader intent and ends its pointer-scroll route. diff --git a/tests/model/test_android_perf_ux_arrivals.py b/tests/model/test_android_perf_ux_arrivals.py index f52c21927..7323a1ffa 100644 --- a/tests/model/test_android_perf_ux_arrivals.py +++ b/tests/model/test_android_perf_ux_arrivals.py @@ -377,15 +377,16 @@ def test_scroll_perf_optimizations_cache_overlays_and_keep_animations_live(monke from PySide6.QtWidgets import QListView from toad.markdown_links import ReferenceContext from toad.qt.activity import ActivitySweep + from toad.qt.widget_animation import QtAnimationClock scheduled: list[float | None] = [] - clock = AnimationClock(scheduled.append) + clock = QtAnimationClock(scheduled.append) scheme = current_scheme(os.environ) concrete = [c for c in ReferenceContext.__subclasses__() if not inspect.isabstract(c)][0] renderer = QtLineRenderer(scheme, LinkContext(Path("."), concrete()), DiffSettings()) - # 1. Ambient animations (tab waves and ActivitySweep loading spinner) stay live and are never - # paused while scrolling. + # 1. Decorative chrome animations (tab waves and ActivitySweep) run when idle and yield + # while a viewport is actively scrolling, resuming cleanly on settle. bar = QtSessionTabBar(clock, QColor("#ff00ff"), QColor("#ffffff")) bar.show_tabs([("#comms", "comms")]) bar.show() @@ -394,6 +395,12 @@ def test_scroll_perf_optimizations_cache_overlays_and_keep_animations_live(monke sweep = ActivitySweep(renderer, clock) sweep.show() assert sweep.animation_visible is True + clock.set_scrolling(bar, True) + assert wave.animation_visible is False + assert sweep.animation_visible is False + clock.set_scrolling(bar, False) + assert wave.animation_visible is True + assert sweep.animation_visible is True sweep.deleteLater() # 2. QtJumpBar caches its rendered pill QPixmap across repeated paints. @@ -444,6 +451,7 @@ def test_failed_observation_notifications_do_not_crash_on_resume() -> None: class FakeHistory: can_draw_on_screen = True + notifications_deferred = False notification_references = (MessageReference(seq=1, message_id="1-abc"),) def notification_identity_for(self, wanted): @@ -1318,7 +1326,8 @@ def test_wave4_virtual_row_canvas_direct_value_and_tab_chrome_cache(monkeypatch) task.accept_result.assert_called_once_with("ready") # 3. QtSessionTabBar caches busy-tab QSS chrome QImage across wave frames. - clock = AnimationClock(lambda _interval: None, now=lambda: 0.5) + from toad.qt.widget_animation import QtAnimationClock + clock = QtAnimationClock(lambda _interval: None, now=lambda: 0.5) bar = QtSessionTabBar(clock, QColor("#ff00ff"), QColor("#ffffff")) bar.show_tabs([("#comms", "comms")]) bar.follow_tabs((SimpleNamespace(mode_name="comms", busy=True),)) @@ -3046,7 +3055,8 @@ def test_compact_marquee_tabs_and_multifile_pickers(monkeypatch, tmp_path) -> No # 1. Compact tabs: short tabs stay tight; 3 long tabs fit inside a 300 px Android strip; # marquee runs ONLY while overflowing and advances offset after the pause. now = [0.0] - clock = AnimationClock(lambda _dt: None, now=lambda: now[0]) + from toad.qt.widget_animation import QtAnimationClock + clock = QtAnimationClock(lambda _dt: None, now=lambda: now[0]) strip = QScrollArea() bar = QtSessionTabBar(clock, QColor("#ff00ff"), QColor("#ffffff"), QColor("#aaaaaa")) bar.setTabsClosable(True) diff --git a/tests/model/test_mobile_chrome_polish_and_suspend.py b/tests/model/test_mobile_chrome_polish_and_suspend.py index 3e6982876..5e298f154 100644 --- a/tests/model/test_mobile_chrome_polish_and_suspend.py +++ b/tests/model/test_mobile_chrome_polish_and_suspend.py @@ -250,3 +250,131 @@ def test_wire_view_skips_rpc_storm_on_pure_activity_or_read_ticks(): reg_change = replace(base, catalog=(rev(3),)) assert WireView._conversation_stores_changed(seen, reg_change) assert reg_change.changed_since(RegistrationsView(), base) + + +def test_scroll_in_motion_defers_notifications_reads_style_and_decorative_clock(): + """Active scroll motion defers notification WS re-subscriptions, painted read-mark RPCs, + lazy message_style reads, and infinite decorative chrome animations until settle, without + duplicate `ReaderWindow` names in either frontend's MRO.""" + from types import SimpleNamespace + from PySide6.QtGui import QColor + from PySide6.QtWidgets import QApplication + from agent_comms.messaging.message_reference import MessageReference + from agent_comms.messaging.read_basis import NoDisplaySelection + from toad.client.history import ReadMarkedHistory + from toad.client.history_notifications import OneHistoryNotifications, SourceNotifications + from toad.client.history_pager import PagingWindow + from toad.client.history_reads import NothingToRead + from toad.history_jump import PagedReader + from toad.qt.history import QtHistoryWindow + from toad.qt.name_wave import QtSessionTabBar, QtTabWave + from toad.qt.widget_animation import QtAnimationClock + from toad.widgets.history_anchor import HistoryWindow + + # No duplicate ReaderWindow name in either frontend MRO (IDEN-2). + for cls in (QtHistoryWindow, HistoryWindow): + names = [c.__name__ for c in cls.__mro__] + assert names.count("ReaderWindow") == 1 + assert issubclass(cls, PagedReader) + assert issubclass(cls, PagingWindow) + + # Scroll-motion deferral on SourceNotifications + ReadMarkedHistory. + class _FakeWindow(PagingWindow): + def __init__(self) -> None: + self._moving = True + + @property + def scroll_in_motion(self) -> bool: + return self._moving + + win = _FakeWindow() + subscribed: list[tuple] = [] + marked: list[str] = [] + styled: list[str] = [] + scheduled: list[object] = [] + + class _FakeHistory(SourceNotifications, ReadMarkedHistory): + can_draw_on_screen = True + is_attached = True + window = win + notification_references = (MessageReference(seq=1, message_id="1-abc"),) + + def __init__(self, view) -> None: + self.notification_view = view + self._painted_reads = {"k": SimpleNamespace(evidence="proof")} + self._read_mark_scheduled = False + self.page_source = SimpleNamespace(painted_read=lambda _h: SimpleNamespace(start=lambda _m: marked.append("read"))) + + def notification_identity_for(self, _wanted): + return NoDisplaySelection() + + def read_running(self) -> bool: + return False + + def call_after_refresh(self, cb, *args) -> None: + scheduled.append((cb, args)) + + def follow_message_style(self) -> None: + styled.append("style") + + class _FakeView(OneHistoryNotifications): + def __init__(self) -> None: + self.app = SimpleNamespace(coordination_access=SimpleNamespace(shows_notifications=lambda _v: False)) + self.message_history = _FakeHistory(self) + + def subscribe_notifications(self, references) -> bool: + subscribed.append(tuple(references)) + return True + + def report_queue_evidence(self) -> None: + pass + + def run_notification_work(self, work) -> None: + pass + + def check_notifications_after_refresh(self) -> None: + pass + + view = _FakeView() + hist = view.message_history + + # While scrolling: notifications, read-marks, after-paint schedule, and style lookup all defer. + view.check_notifications() + hist.mark_visible_after_paint() + assert isinstance(hist.read_visible(), NothingToRead) + assert subscribed == [] + assert marked == [] + assert scheduled == [] + assert styled == [] + + # Once scroll settles: notifications, read-marks, and style flush cleanly. + win._moving = False + view.check_notifications() + hist.mark_visible() + hist.mark_visible_after_paint() + assert len(subscribed) == 1 + assert marked == ["read"] + assert len(scheduled) == 1 + + # QtAnimationClock pauses decorative chrome targets while scrolling and resumes on settle. + _app = QApplication.instance() or QApplication([]) + intervals: list[float | None] = [] + clock = QtAnimationClock(intervals.append) + bar = QtSessionTabBar(clock, QColor("#ff8800"), QColor("#eeeeee")) + bar.show() + wave = QtTabWave(bar, "t1") + wave.start_wave() + assert wave.animation_visible is True + assert bar.marquee.animation_visible is True + owner = object() + clock.set_scrolling(owner, True) + assert clock.scrolling is True + assert wave.animation_visible is False + assert bar.marquee.animation_visible is False + assert intervals[-1] is None + clock.set_scrolling(owner, False) + assert clock.scrolling is False + assert wave.animation_visible is True + assert intervals[-1] is not None + wave.stop_wave() + bar.deleteLater() diff --git a/tests/model/test_qt_channel_activity_sidebar.py b/tests/model/test_qt_channel_activity_sidebar.py index 632b4ae3b..1578381de 100644 --- a/tests/model/test_qt_channel_activity_sidebar.py +++ b/tests/model/test_qt_channel_activity_sidebar.py @@ -3,11 +3,13 @@ from __future__ import annotations import os +from pathlib import Path from types import SimpleNamespace from weakref import WeakSet from agent_comms.display_order import LastActivityThreadSort from agent_comms.messaging.channel_targets import ChannelTarget +from agent_comms.messaging.display_references import ProjectReferences from agent_comms.registry.thread_identity import RecordedThreadIncarnation from agent_comms.registry.thread_model import UndeclaredModel from agent_comms.registry.thread_presentation import IdleThreadPresentationStatus, WorkingThreadPresentationStatus @@ -19,6 +21,9 @@ from toad.client.conversation import ChannelConversation from toad.client.sidebar_state import Current +from toad.markdown_links import LinkContext +from toad.patch import DiffSettings +from toad.qt.lines import QtLineRenderer from toad.qt.theme import offered_schemes from toad.qt.widget_animation import QtAnimationClock from toad.qt.window import ( @@ -76,6 +81,7 @@ def test_channel_activity_sidebar_reuses_sidebar_tree_for_selected_channel(monke } class _Observed: + root = Path("/tmp/test-bus") sidebar = sidebar_model def show_sidebar(self, view) -> None: @@ -93,21 +99,15 @@ def show_sidebar(self, view) -> None: scheme = next(iter(offered_schemes(os.environ).values())) color_scheme = ColorScheme() - - class _Renderer: - def themed(self, _widget, apply_fn) -> None: - apply_fn() - - def theme(self, colour_type) -> str: - return colour_type.rgb(scheme).hex + renderer = QtLineRenderer(scheme, LinkContext(Path("."), ProjectReferences()), DiffSettings()) opened: list[object] = [] window = SimpleNamespace( - renderer=_Renderer(), + renderer=renderer, theme=SimpleNamespace(color_scheme=color_scheme), settings=SimpleNamespace(sidebar=SimpleNamespace(unread_counts=ShownUnreadCount)), thread_actions=SimpleNamespace(pending={}), - animation_clock=QtAnimationClock(lambda _interval, _cb: lambda: None), + animation_clock=QtAnimationClock(lambda _interval: None), coordination_access=access, open_row=lambda row: opened.append(row), ) diff --git a/tests/textual/test_name_wave_repaint.py b/tests/textual/test_name_wave_repaint.py index aac7ef551..15e40fe57 100644 --- a/tests/textual/test_name_wave_repaint.py +++ b/tests/textual/test_name_wave_repaint.py @@ -35,9 +35,9 @@ class RecordedTabBar: """What a tab title's wave asks of its bar: the band's cells, and to paint its tab.""" def __init__(self, spans: list[tuple[int, int]]) -> None: - from ui_theme.clock import AnimationClock + from toad.qt.widget_animation import QtAnimationClock - self.clock = AnimationClock(lambda interval: None) + self.clock = QtAnimationClock(lambda interval: None) self.spans = iter(spans) self.repainted: list[str] = [] @@ -162,9 +162,9 @@ def paint_accent_xs() -> list[int]: assert len(delegate._row_images[id(kept_item_row)][1]) == before_variants + 1 from toad.qt.name_wave import QtSessionTabBar - from ui_theme.clock import AnimationClock + from toad.qt.widget_animation import QtAnimationClock - bar = QtSessionTabBar(AnimationClock(lambda _dt, _cb: None), accent, QColor("#eeeeee")) + bar = QtSessionTabBar(QtAnimationClock(lambda _dt: None), accent, QColor("#eeeeee")) try: layout = bar.bold_line("toad-qt", 120) assert layout.cacheEnabled() is True