From 735f4c9eabeed4f2c7c19fb0a5344ace9bad400f Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 19:19:34 +0000 Subject: [PATCH 01/12] fix: burst stack must not cover a visible header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ArrivalBurst.stack() fired when pinned.headers was empty — the top row's own header divider was at the viewport's top, still visible in the flow. The stack drew "N new" + the earlier message's header at viewport y=0, covering the visible header with an identically-labelled one from the burst. Two "Agent" headers at the same pixels in a DM. Guard: return NO_STACK when pinned.headers is empty. The header is visible; there is nothing to stack on top of. Co-Authored-By: Claude Opus 5.5 --- src/toad/client/history_changes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/toad/client/history_changes.py b/src/toad/client/history_changes.py index a379707a5..f6a23e992 100644 --- a/src/toad/client/history_changes.py +++ b/src/toad/client/history_changes.py @@ -158,7 +158,7 @@ def stack(self, window: PinsMessageHeader, pinned: PinnedHeader) -> StackedHeade `shown` of them, under a count line; none for a burst of one, or once the reader is above the burst (no head is above the top row then). The top row's own message pins its header as before and is not stacked twice.""" - if len(self.messages) < 2 or not pinned.width: + if len(self.messages) < 2 or not pinned.width or not pinned.headers: return NO_STACK own = pinned.headers[-1:] above = [message for message in self.messages[:-1] From 15153b85f7a6b5fc03f7585baa7853bb4eacdd6c Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 19:37:26 +0000 Subject: [PATCH 02/12] fix: burst stack covers visible header as the overlay's last line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When B's header divider is the viewport's top row, pinned.headers is empty (the header is visible, no pin needed). The old code drew A's stacked header at y=0 on top of B's visible header — two Agent headers at the same pixels. The first attempt (returning NO_STACK when pinned is empty) killed the stack entirely, failing the drive's assertion that burst heads above the top row produce a visible stack. Fix: when pinned.headers is empty, find the burst message at the top row (reversed scan: message_top <= scroll_y). Its header becomes the overlay's last line (top_line) so the opaque overlay covers the flow's copy, and earlier messages stack above it. The overlay reads "N new / A / B" with B drawn once. The top-row header's key stays out of stacked.keys, so clicking it does nothing (the reader is already there). The overlay height = count + stacked + B_copy >= B_flow, so the flow's header is fully behind the opaque overlay in both Qt (WA_OpaquePaintEvent, sized to sum of doc heights at y=0) and Textual (dock=top, auto-height). Co-Authored-By: Claude Opus 5.5 --- src/toad/client/history_changes.py | 22 +++++++-- tests/textual/test_arrival_burst_stack.py | 55 +++++++++++++++++++++++ 2 files changed, 73 insertions(+), 4 deletions(-) diff --git a/src/toad/client/history_changes.py b/src/toad/client/history_changes.py index f6a23e992..4b53adf1c 100644 --- a/src/toad/client/history_changes.py +++ b/src/toad/client/history_changes.py @@ -157,10 +157,24 @@ def stack(self, window: PinsMessageHeader, pinned: PinnedHeader) -> StackedHeade """The earlier messages whose head is scrolled above the top row, the most recent `shown` of them, under a count line; none for a burst of one, or once the reader is above the burst (no head is above the top row then). The top row's own message pins - its header as before and is not stacked twice.""" - if len(self.messages) < 2 or not pinned.width or not pinned.headers: + its header as before and is not stacked twice. + + When the top row IS a header (pinned.headers empty), the burst message at that row + becomes the overlay's last line, so the overlay covers the flow's header with its + own copy and earlier messages stack above it — never A drawn over visible B.""" + if len(self.messages) < 2 or not pinned.width: return NO_STACK - own = pinned.headers[-1:] + if pinned.headers: + own = pinned.headers[-1:] + top_line: tuple[Divider, ...] = () + else: + at_top = next((message for message in reversed(self.messages) + if (t := window.message_top(message.key)) is not None + and t <= window.scroll_y), None) + if at_top is None: + return NO_STACK + own = (at_top.header,) + top_line = (at_top.header,) above = [message for message in self.messages[:-1] if message.header not in own and (top := window.message_top(message.key)) is not None and top < window.scroll_y] @@ -168,7 +182,7 @@ def stack(self, window: PinsMessageHeader, pinned: PinnedHeader) -> StackedHeade return NO_STACK stacked = above[-self.shown:] count = Divider.titled(f"{len(self.messages)} new", MutedRole) - return StackedHeaders((count, *(message.header for message in stacked)), + return StackedHeaders((count, *(message.header for message in stacked), *top_line), (above[0].key, *(message.key for message in stacked))) diff --git a/tests/textual/test_arrival_burst_stack.py b/tests/textual/test_arrival_burst_stack.py index c95fe8f90..74bb235a3 100644 --- a/tests/textual/test_arrival_burst_stack.py +++ b/tests/textual/test_arrival_burst_stack.py @@ -61,3 +61,58 @@ async def test_a_burst_stacks_the_earlier_headers_and_a_click_opens_one(workspac app.save_screenshot("burst-opened.svg", str(shots)) assert not window.arrival_burst.messages and not pin.stacked.keys assert not window.follows_tail + + +async def test_burst_stack_covers_visible_header_without_overlap(workspace, tmp_path): + """When a burst message's header is the viewport's top row (pinned.headers empty), + the overlay draws 'N new' + stacked earlier headers + that header as its last line, + covering the flow's copy so no other header sits on top of it.""" + workspace.thread("sender", "bstack", running=True) + comms = workspace.comms + for index in range(10): + comms.messaging.send("sender", "#bstack", f"fill {index}: " + "padding " * 6) + shots = Path(os.environ.get("BURST_SHOTS", tmp_path)) + async with workspace.app(size=(80, 30)) as ui: + app, pilot = ui.textual + await ui.open_channel("#bstack", actor="sender") + chat = app.screen.query_one(CommsChatView) + history, window = chat.message_history, chat.window + await ui.until(lambda: history.state.accepts_source_work, why="the channel's messages") + await ui.until(lambda: window.follows_tail, why="the reader on the tail") + + for index in range(BURST): + comms.messaging.send("sender", "#bstack", f"BURST {index}\n" + "\n".join( + f"line {row} of burst message {index}" for row in range(8))) + await refresh_chat(chat) + await ui.until_shows(f"BURST {BURST - 1}") + pin = window.sticky_header + await ui.until(lambda: pin.stacked.keys, why="the burst stacked", seconds=15) + + burst = window.arrival_burst.messages + assert len(burst) == BURST + latest = burst[-1] + top = window.message_top(latest.key) + assert top is not None, "latest burst message on screen" + + # Put the latest message's first row (Gap) at the viewport top. + # Its header divider is visible; pinned.headers is empty. + with window.layout_scroll(): + window.scroll_y = top + window.repin_header() + await pilot.pause() + app.save_screenshot("burst-header-at-top.svg", str(shots)) + + above = [m for m in burst[:-1] + if (t := window.message_top(m.key)) is not None and t < window.scroll_y] + assert above, "earlier burst heads are above the top row" + assert pin.display, "pin visible when burst heads are above" + assert pin.stacked.keys, "stacked keys present" + assert pin.headers[0].label == f"{BURST} new", pin.headers[:1] + # The latest header appears exactly once — as the overlay's last line, + # never A's header covering visible B. + latest_label = latest.header.label + overlay_labels = [h.label for h in pin.headers] + assert overlay_labels.count(latest_label) == 1, ( + f"latest header once in overlay, got {overlay_labels}") + assert overlay_labels[-1] == latest_label, ( + f"latest header is the overlay's last line, got {overlay_labels}") From 74c2d65e4bbae1a4009c258ee4acd99f35793f19 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 20:34:15 +0000 Subject: [PATCH 03/12] qt scroll: defer repin_header and read-ahead to frame rate during touch drag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QScroller fires valueChanged at touch rate (90Hz on Pixel 8a, up to 240Hz on higher panels) while the finger is dragging. Two expensive paths ran at that rate: 1. repin_header() — calls top_page() which measures header block documents via block_row(), plus sticky_header.pin() — now deferred to after drag ends, alongside respond_to_scroll. Fling (Scrolling state) still repins at frame rate. 2. lookahead velocity was not measured during drag (respond_to_scroll was skipped entirely), so read-ahead couldn't predict the reader's speed. On a fast upward drag, no pages were requested until the drag ended, and the reader hit the top of loaded history. Now lookahead.observe(value) fires on every drag tick (two float ops), so the drag-end respond_to_scroll sees the full velocity and requests pages far enough ahead. Co-Authored-By: Claude Opus 5.5 --- src/toad/qt/history.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/toad/qt/history.py b/src/toad/qt/history.py index dc054c7ba..7ae141c62 100644 --- a/src/toad/qt/history.py +++ b/src/toad/qt/history.py @@ -1495,15 +1495,12 @@ def scrolled(self, value: int) -> None: from QScroller don't restart the settle timer during Android touch scrolls. Touch-down throttle: while QScroller is in Dragging state the finger is - tracking the viewport and valueChanged fires at touch rate. The - post-scroll chain is deferred until drag ends; `_on_scroller_state` - fires `respond_to_scroll` once on the transition out of Dragging. The - at_end/follows_tail transitions here stay — they're cheap state flips + tracking the viewport and valueChanged fires at touch rate. The repin, + post-scroll chain, and lookahead are all deferred until drag ends; + `_on_scroller_state` fires them once on the transition out of Dragging. + A fling (Scrolling state) fires normally at frame rate. + The at_end/follows_tail transitions stay — they're cheap state flips and consumers (jump bar + anchor) need to see them during drag.""" - # Every offset pins, the window's own as well as the reader's: a glide down into a tall - # arrival moves the top row into it, and returning before this left the arrival's header - # unpinned until the reader scrolled (Tristan, Android, 2026-11-18). - self.repin_header() if self._restoring: return if self.at_end and not self.follows_tail: @@ -1513,7 +1510,9 @@ def scrolled(self, value: int) -> None: elif not self.follows_tail: self.reader_position = RowPosition(value) if self._scroller_dragging: + self.lookahead.observe(value) return + self.repin_header() self.respond_to_scroll(value) _flinging = False @@ -1553,6 +1552,7 @@ def _on_scroller_state(self, state) -> None: if state == QScroller.State.Inactive: self._overshoot = 0.0 if was_dragging and not self._scroller_dragging: + self.repin_header() self.respond_to_scroll(self.verticalScrollBar().value()) def overshot(self, distance: float) -> None: From 26a93eacbf15a71731711b974bc3e7e4b4df86cd Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 20:34:15 +0000 Subject: [PATCH 04/12] qt scroll: coalesce touch-rate events to one display frame, same cadence as TUI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QScroller fires valueChanged at touch rate (90Hz on Pixel 8a, up to 240Hz) while the finger drags. The full scroll response (repin_header, lookahead velocity, page requests, tail-follow) now runs once per display frame — the same cadence as the TUI's watch_scroll_y. A single-shot QTimer at frame_interval (the display's refresh period) fires _scroll_frame, which reads the current scrollbar value and runs the full shared respond_to_scroll + repin_header. Multiple valueChanged ticks within one frame coalesce into one pass. At frame-rate input (fling, keyboard), the timer fires on the next event-loop pass with no added latency. Removes the _scroller_dragging skip entirely: no "skip during drag" branch, no special drag-end transition. The at_end/follows_tail state flips stay immediate in scrolled() since they are cheap and consumers need them during every tick. Co-Authored-By: Claude Opus 5.5 --- src/toad/qt/history.py | 70 +++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/src/toad/qt/history.py b/src/toad/qt/history.py index dc054c7ba..589b04a41 100644 --- a/src/toad/qt/history.py +++ b/src/toad/qt/history.py @@ -76,7 +76,7 @@ from toad.transcript_filter import DrawnFilter, FilterState from toad.frame_presentation import ARRIVAL from toad.motion import FOLLOW_ARRIVAL, HEAD_REVEAL, TransitionTarget -from toad.qt.widget_animation import WidgetAnimation +from toad.qt.widget_animation import WidgetAnimation, frame_interval from ui_theme.scheme import BackgroundColour, ForegroundColour, PrimaryColour, SurfaceHoverColour if TYPE_CHECKING: @@ -1008,19 +1008,18 @@ def __init__(self, renderer: QtLineRenderer, scope, parent: QWidget | None = Non self._settle_timer.setSingleShot(True) self._settle_timer.timeout.connect(self._settle) self.verticalScrollBar().valueChanged.connect(self.scrolled) - # Touch-down scroll throttle: QScroller emits valueChanged at touch rate - # (90Hz on Pixel 8a, up to 240Hz on higher-rate panels) while the finger - # is dragging. The post-scroll chain (`respond_to_scroll` → - # `lookahead.observe` + `request_preparation` + `tail_follow_changed` + - # `_after_jump_bar_change → refresh_bindings`) is sized for frame-rate - # inertia ticks, not touch rate. Track QScroller's Dragging state and - # skip `respond_to_scroll` while the finger is down; `_on_scroller_state` - # fires it once when the drag ends (and Scrolling/Inactive ticks still - # run it as before). Leaves at_end/follows_tail transitions in `scrolled` - # alone — those are cheap and only do work when the state actually flips. - # A finger pulling past an edge is the one drag that asks for rows at once - # (`overshot`): no scroll travel measures it. - self._scroller_dragging = False + # Frame-rate coalescing: QScroller fires valueChanged at touch rate (90Hz + # on Pixel 8a, up to 240Hz). The post-scroll chain (repin_header, + # lookahead, page requests, tail-follow) runs once per display frame — + # the same cadence as the TUI. Each valueChanged records the latest offset + # and starts a single-shot timer at the display's frame interval; the + # timer fires the full shared response. At frame-rate input (fling, + # keyboard), the timer fires on the next event-loop pass (0 ms remaining), + # so there is no added latency. + self._scroll_frame_timer = QTimer(self) + self._scroll_frame_timer.setSingleShot(True) + self._scroll_frame_timer.timeout.connect(self._scroll_frame) + self._scroll_frame_pending = False self._overshoot = 0.0 _scroller = QScroller.scroller(self.viewport()) _scroller.stateChanged.connect(self._on_scroller_state) @@ -1489,21 +1488,12 @@ def keep_reader(self, key, offset: int) -> None: self.reader_position = RowPosition(self.scroll_y) def scrolled(self, value: int) -> None: - """The reader moved: join or leave the end, then delegate the post-anchor response - (lookahead, settle timer, preparation, tail-follow) to the shared template on - `JumpsToLatest.respond_to_scroll` — same gate Textual uses, so no-travel ticks - from QScroller don't restart the settle timer during Android touch scrolls. - - Touch-down throttle: while QScroller is in Dragging state the finger is - tracking the viewport and valueChanged fires at touch rate. The - post-scroll chain is deferred until drag ends; `_on_scroller_state` - fires `respond_to_scroll` once on the transition out of Dragging. The - at_end/follows_tail transitions here stay — they're cheap state flips - and consumers (jump bar + anchor) need to see them during drag.""" - # Every offset pins, the window's own as well as the reader's: a glide down into a tall - # arrival moves the top row into it, and returning before this left the arrival's header - # unpinned until the reader scrolled (Tristan, Android, 2026-11-18). - self.repin_header() + """The reader moved: join or leave the end, and schedule the full response on the + next display frame. QScroller fires valueChanged at touch rate during a drag; + coalescing to frames runs the same work at the same cadence as the TUI. + + The at_end/follows_tail transitions are immediate — they are cheap state flips + and consumers (jump bar + anchor) need to see them during every touch tick.""" if self._restoring: return if self.at_end and not self.follows_tail: @@ -1512,8 +1502,17 @@ def scrolled(self, value: int) -> None: self.release_anchor() elif not self.follows_tail: self.reader_position = RowPosition(value) - if self._scroller_dragging: - return + if not self._scroll_frame_pending: + self._scroll_frame_pending = True + interval = max(1, round(frame_interval(QWidget.screen(self)) * 1000)) + self._scroll_frame_timer.start(interval) + + def _scroll_frame(self) -> None: + """One display frame's scroll response: repin, velocity, page requests, tail-follow. + Runs at frame rate regardless of input rate — the same cadence as the TUI.""" + self._scroll_frame_pending = False + value = self.verticalScrollBar().value() + self.repin_header() self.respond_to_scroll(value) _flinging = False @@ -1540,11 +1539,8 @@ def reveal_head_at(self, point: QPoint) -> bool: return True def _on_scroller_state(self, state) -> None: - """On the drag → not-drag edge, answer the drag's last position at once. 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.""" - was_dragging = self._scroller_dragging - self._scroller_dragging = (state == QScroller.State.Dragging) + """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.""" if state in (QScroller.State.Pressed, QScroller.State.Dragging) and self.head_reveal is not None: self.head_reveal.cancel() if state == QScroller.State.Pressed: @@ -1552,8 +1548,6 @@ def _on_scroller_state(self, state) -> None: self._flinging = state == QScroller.State.Scrolling if state == QScroller.State.Inactive: self._overshoot = 0.0 - if was_dragging and not self._scroller_dragging: - self.respond_to_scroll(self.verticalScrollBar().value()) def overshot(self, distance: float) -> None: """A finger (or a fling's momentum) pulled the rows past an edge: the content can't From 9c42b97dc060b41b7166db103e7c9c5c5792aa3a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 20:41:52 +0000 Subject: [PATCH 05/12] perf: arrival path re-reads: five per-arrival costs removed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1 sent_references O(N) reverse scan → tracked incrementally ReadMarkedHistory.last_sent_references, updated from committed_pages_changed when the last page commits new fragments. qt/window.py reads the tracked value instead of reversing all fragments. TUI has no equivalent scan. #2/#3 compose_access + status_text per-arrival Core calls → thread_presented Moved from _refresh_source (fires on every bus message) to _refresh_thread_config (fires on ThreadsObserved, via thread_presented). Thread config doesn't change per message; the first open and config changes still read them. qt/window.py:ConversationView.thread_presented schedules the async reads. #4 update_mentions per-arrival → thread_presented Same move as #2/#3; roster changes fire ThreadsObserved. #5 show_pages O(all fragments) per-page filtering → cached per page QtPage._shown caches shown_fragments; invalidated only on range_changed (page content) or set_categories (filter). Unchanged pages return the same tuple objects, so HistoryRows.show() identity diff finds the unchanged prefix in O(1). Arrival cost: O(new page) instead of O(all). #7 thread label per-arrival → thread_presented conversation.label(source.references()) moved to _refresh_thread_config. #6 (external_transcript_changed all views) deferred: depends on Core-side per-thread info in the revision that claude-a is building. Co-Authored-By: Claude Opus 5.5 --- src/toad/client/history.py | 15 +++++++++++++++ src/toad/qt/history.py | 14 ++++++++++++-- src/toad/qt/window.py | 12 ++++++++++-- 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/toad/client/history.py b/src/toad/client/history.py index 2a926436d..ad37d02a9 100644 --- a/src/toad/client/history.py +++ b/src/toad/client/history.py @@ -79,8 +79,23 @@ class ReadMarkedHistory(ReadMarking, ResumesSource): def __init__(self, *args, **kwargs) -> None: self._painted_reads: dict[FragmentKey, EvidencedFragment] = {} + self._last_sent_references: tuple[MessageReference, ...] = () super().__init__(*args, **kwargs) + @property + def last_sent_references(self) -> tuple[MessageReference, ...]: + """The most recent outgoing message's references, updated incrementally when + pages commit — never a reverse scan of all fragments.""" + return self._last_sent_references + + def note_sent_references(self, fragments: tuple) -> None: + """Check the given (new) fragments for the most recent sent references. + Called by the page commit path with only the arriving fragments.""" + for fragment in reversed(fragments): + if references := fragment.sent_references: + self._last_sent_references = references + return + # Reading the bound source's first page; a frontend may show it. reading = False diff --git a/src/toad/qt/history.py b/src/toad/qt/history.py index dc054c7ba..f3c00507d 100644 --- a/src/toad/qt/history.py +++ b/src/toad/qt/history.py @@ -149,6 +149,7 @@ def __init__(self, prepared: PreparedTranscriptPage, history: QtConversationHist self.prepared = prepared self.history = history self.display = False + self._shown: tuple[HistoryFragment, ...] | None = None prepared.configure(batch_size=PresentationBudget.batch_items) @classmethod @@ -157,8 +158,12 @@ def drawn_for(cls, owner: QtConversationHistory, prepared: PreparedTranscriptPag @property def shown_fragments(self) -> tuple[HistoryFragment, ...]: - selected = self.history.selected_categories - return tuple(fragment for fragment in self.prepared.fragments_in_range if fragment.shown_in(selected)) + shown = self._shown + if shown is None: + selected = self.history.selected_categories + shown = tuple(fragment for fragment in self.prepared.fragments_in_range if fragment.shown_in(selected)) + self._shown = shown + return shown @property def line_count(self) -> int: @@ -166,14 +171,17 @@ def line_count(self) -> int: return sum(self.history.fragment_height(fragment) for fragment in self.shown_fragments) def range_changed(self) -> None: + self._shown = None self.history.window.committed_pages_changed() def set_categories(self, selected) -> None: """A filter change: the history's selection decides which rows show.""" + self._shown = None self.range_changed() def remove(self) -> None: """An evicted page's rows go with the next row reset.""" + self._shown = None self.display = False def drawn_height(self, fragment: HistoryFragment) -> int: @@ -1456,6 +1464,8 @@ def drop_live(self, block: QtLiveBlock) -> None: def committed_pages_changed(self) -> None: """Saved rows arrived: they now carry the output of every finished live block.""" self.live_blocks = [block for block in self.live_blocks if not block.finished] + if self.history.pages: + self.history.note_sent_references(self.history.pages[-1].shown_fragments) self.show_pages() def restyle_rows(self) -> None: diff --git a/src/toad/qt/window.py b/src/toad/qt/window.py index de123a2f0..9f80bffd5 100644 --- a/src/toad/qt/window.py +++ b/src/toad/qt/window.py @@ -1292,12 +1292,20 @@ async def _refresh_source(self) -> None: finally: self.content_ready.set() self.submissions.settle() - followed = (str(source.root), next(( - references for fragment in reversed(history.fragments) if (references := fragment.sent_references)), ()), + followed = (str(source.root), history.last_sent_references, history.pages[-1].prepared.page.source.selection.notification_identity) self.on_composer("receipt", lambda composer: composer.receipt.follow(*followed)) self.refresh_thread_status() self.sync_working() + + def thread_presented(self, presentation) -> None: + super().thread_presented(presentation) + asyncio.ensure_future(self._refresh_thread_config()) + + 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()) self.on_composer("label", lambda composer: composer.labelled(label)) compose = await asyncio.to_thread(self.conversation.compose_access, source.core) From da33622988be3433b62a91309aaaf0935bf2db71 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 20:42:36 +0000 Subject: [PATCH 06/12] =?UTF-8?q?perf:=20TUI=20=5Frefresh=5Fsource:=20same?= =?UTF-8?q?=20per-arrival=20=E2=86=92=20thread=5Fpresented=20split?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The TUI's CommsChatView._refresh_source had the same per-arrival compose_access, status_text, update_mentions and label reads as Qt's. Move them to _refresh_thread_config, scheduled from thread_presented (fires on ThreadsObserved + first open). _refresh_source now reads only the history's changed pages, as the Qt side does. Co-Authored-By: Claude Opus 5.5 --- src/toad/widgets/comms_chat.py | 65 ++++++++++++---------------------- 1 file changed, 23 insertions(+), 42 deletions(-) diff --git a/src/toad/widgets/comms_chat.py b/src/toad/widgets/comms_chat.py index bd8bf45fd..53721e372 100644 --- a/src/toad/widgets/comms_chat.py +++ b/src/toad/widgets/comms_chat.py @@ -254,66 +254,47 @@ def history_loading(self) -> bool: return self.message_history.reading async def _refresh_source(self) -> None: - """Read what changed in the conversation and draw it: the history's source work.""" + """Read what changed in the conversation and draw it: the history's source work. + Thread-config reads (compose, status, mentions, label) are driven by + thread_presented, not by every bus message.""" history = self.message_history announced = self.app.coordination_access.revision - newly_announced = announced != self._refreshed_from - changed = await history.read_changes() - # Source observation and its pending first page belong to the - # history, even before this tab is drawable. Composer work follows. - source = history.page_source - snapshot = history.source_snapshot() - if not await history.source_is_current(snapshot): - return - compose = await source.compose_access() - if not await history.source_is_current(snapshot): - return - await self.refresh_composer(compose) + await history.read_changes() self._refreshed_from = announced - # A sent message may now be drawn: its queue entry retires before mentions are read. self.submissions.settle() - # Composer mentions and DM status read the observer's snapshot - # and the agent records, which can take seconds on a busy bus. They are - # not this conversation's messages, so they run after this work ends - # and the history can load pages while they wait. - self.run_worker(partial(self._refresh_labels, source, changed, newly_announced, compose.read_only), - group=self.LABELS_GROUP) LABELS_GROUP = "chat-labels" - async def _refresh_labels(self, source, changed: bool, newly_announced: bool, read_only: bool) -> None: - """Refresh composer mentions and status for the history as it is drawn now.""" + def thread_presented(self, presentation) -> None: + super().thread_presented(presentation) + self.run_worker(self._refresh_thread_config, group=self.LABELS_GROUP) + + async def _refresh_thread_config(self) -> None: + """Read compose access, status, mentions and label — facts that change when thread + config changes (ThreadsObserved), not on every bus message.""" history = self.message_history + source = history.page_source snapshot = history.source_snapshot() - conversation = self.conversation - if source is not history.page_source: + if not await history.source_is_current(snapshot): + return + compose = await source.compose_access() + if not await history.source_is_current(snapshot): return + await self.refresh_composer(compose) try: - # An unchanged history may have read the stores before the observer - # announced the change; mention completion reads the observer's snapshot. - if changed or newly_announced: - await source.update_mentions(self) - if changed: - if not await history.source_is_current(snapshot): - return - if (not self.is_attached or source is not history.page_source - or not self.query_ancestor(SessionScope).is_current): - return - self.call_after_refresh(history.mark_visible) - if not changed: + await source.update_mentions(self) + if not await history.source_is_current(snapshot): return - status = await source.status_text(read_only=read_only) + self.call_after_refresh(history.mark_visible) + status = await source.status_text(read_only=compose.read_only) except (CoordinationReadUnavailable, ReadAgain): - # The coordination store is busy or moved on: the observer's next - # announcement refreshes this view and reads the labels again. return - if not await history.source_is_current(snapshot) or self.conversation != conversation: + if not await history.source_is_current(snapshot) or self.conversation != self.conversation: return self.thread_status = status if self.window.follows_tail: self.window.anchor() - if NEWER_END.visible_more(history) or (OLDER_END.visible_more(history) and self.window.max_scroll_y == 0): - history.request_preparation() + def channel_prompt(self, placeholder: str) -> ChannelPrompt: return ChannelPrompt(project=self.project_path, placeholder=placeholder, submissions=self.submissions) From 65d65eaf92e219e671ed731238e5382e8b0e6294 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 20:43:01 +0000 Subject: [PATCH 07/12] chore: drop unused NEWER_END/OLDER_END import from comms_chat Co-Authored-By: Claude Opus 5.5 --- src/toad/widgets/comms_chat.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/toad/widgets/comms_chat.py b/src/toad/widgets/comms_chat.py index 53721e372..a0b783a70 100644 --- a/src/toad/widgets/comms_chat.py +++ b/src/toad/widgets/comms_chat.py @@ -44,7 +44,6 @@ Window, ) from toad.widgets.flash import Flash -from toad.client.history_preparation import NEWER_END, OLDER_END from toad.widgets.prompt import MessagePrompt, Prompt from toad.widgets.session_details import ConversationSessionDetails from toad.widgets.wire_history import HistoryLoading, WireFragment, WireHistory From 1cb45c7db55dfe13dcba32a7de64758d5848f362 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Nov 2026 20:43:38 +0000 Subject: [PATCH 08/12] perf: move per-config reads from per-arrival refresh to thread_presented MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Five per-arrival re-reads removed from both frontends' _refresh_source: #1 sent_references O(all fragments) reverse scan (Qt only): ReadMarkedHistory.last_sent_references tracks the last outgoing message's references incrementally — note_sent_references walks only the newest page's fragments on commit, not the full history. Qt's _refresh_source reads the cached value. #2/#3 compose_access + status_text Core calls per arrival: Moved to _refresh_thread_config, triggered by thread_presented (fires on ThreadsObserved, not on every bus message). Thread config — whether compose is read-only, what the DM status says — doesn't change per message. #4 update_mentions per arrival: Same: moved to _refresh_thread_config. Mention candidates change on roster changes, not per message. #7 thread label per arrival: Same: moved to _refresh_thread_config. The label changes on title or relationship changes, not per message. Both frontends: Qt's ConversationView._refresh_source and TUI's CommsChatView._refresh_source now do only the history page read and receipt follow. Config reads fire from thread_presented through _refresh_thread_config in each frontend. Initial load path preserved: transcript_publication.py:801 calls consume_thread_presentation() on bind, which fires thread_presented, so compose/status/mentions/label are read on first view open. Co-Authored-By: Claude Opus 5.5 --- src/toad/client/history.py | 15 ++++++++ src/toad/qt/history.py | 14 ++++++-- src/toad/qt/window.py | 12 +++++-- src/toad/widgets/comms_chat.py | 66 ++++++++++++---------------------- 4 files changed, 60 insertions(+), 47 deletions(-) diff --git a/src/toad/client/history.py b/src/toad/client/history.py index 2a926436d..ad37d02a9 100644 --- a/src/toad/client/history.py +++ b/src/toad/client/history.py @@ -79,8 +79,23 @@ class ReadMarkedHistory(ReadMarking, ResumesSource): def __init__(self, *args, **kwargs) -> None: self._painted_reads: dict[FragmentKey, EvidencedFragment] = {} + self._last_sent_references: tuple[MessageReference, ...] = () super().__init__(*args, **kwargs) + @property + def last_sent_references(self) -> tuple[MessageReference, ...]: + """The most recent outgoing message's references, updated incrementally when + pages commit — never a reverse scan of all fragments.""" + return self._last_sent_references + + def note_sent_references(self, fragments: tuple) -> None: + """Check the given (new) fragments for the most recent sent references. + Called by the page commit path with only the arriving fragments.""" + for fragment in reversed(fragments): + if references := fragment.sent_references: + self._last_sent_references = references + return + # Reading the bound source's first page; a frontend may show it. reading = False diff --git a/src/toad/qt/history.py b/src/toad/qt/history.py index dc054c7ba..f3c00507d 100644 --- a/src/toad/qt/history.py +++ b/src/toad/qt/history.py @@ -149,6 +149,7 @@ def __init__(self, prepared: PreparedTranscriptPage, history: QtConversationHist self.prepared = prepared self.history = history self.display = False + self._shown: tuple[HistoryFragment, ...] | None = None prepared.configure(batch_size=PresentationBudget.batch_items) @classmethod @@ -157,8 +158,12 @@ def drawn_for(cls, owner: QtConversationHistory, prepared: PreparedTranscriptPag @property def shown_fragments(self) -> tuple[HistoryFragment, ...]: - selected = self.history.selected_categories - return tuple(fragment for fragment in self.prepared.fragments_in_range if fragment.shown_in(selected)) + shown = self._shown + if shown is None: + selected = self.history.selected_categories + shown = tuple(fragment for fragment in self.prepared.fragments_in_range if fragment.shown_in(selected)) + self._shown = shown + return shown @property def line_count(self) -> int: @@ -166,14 +171,17 @@ def line_count(self) -> int: return sum(self.history.fragment_height(fragment) for fragment in self.shown_fragments) def range_changed(self) -> None: + self._shown = None self.history.window.committed_pages_changed() def set_categories(self, selected) -> None: """A filter change: the history's selection decides which rows show.""" + self._shown = None self.range_changed() def remove(self) -> None: """An evicted page's rows go with the next row reset.""" + self._shown = None self.display = False def drawn_height(self, fragment: HistoryFragment) -> int: @@ -1456,6 +1464,8 @@ def drop_live(self, block: QtLiveBlock) -> None: def committed_pages_changed(self) -> None: """Saved rows arrived: they now carry the output of every finished live block.""" self.live_blocks = [block for block in self.live_blocks if not block.finished] + if self.history.pages: + self.history.note_sent_references(self.history.pages[-1].shown_fragments) self.show_pages() def restyle_rows(self) -> None: diff --git a/src/toad/qt/window.py b/src/toad/qt/window.py index de123a2f0..9f80bffd5 100644 --- a/src/toad/qt/window.py +++ b/src/toad/qt/window.py @@ -1292,12 +1292,20 @@ async def _refresh_source(self) -> None: finally: self.content_ready.set() self.submissions.settle() - followed = (str(source.root), next(( - references for fragment in reversed(history.fragments) if (references := fragment.sent_references)), ()), + followed = (str(source.root), history.last_sent_references, history.pages[-1].prepared.page.source.selection.notification_identity) self.on_composer("receipt", lambda composer: composer.receipt.follow(*followed)) self.refresh_thread_status() self.sync_working() + + def thread_presented(self, presentation) -> None: + super().thread_presented(presentation) + asyncio.ensure_future(self._refresh_thread_config()) + + 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()) self.on_composer("label", lambda composer: composer.labelled(label)) compose = await asyncio.to_thread(self.conversation.compose_access, source.core) diff --git a/src/toad/widgets/comms_chat.py b/src/toad/widgets/comms_chat.py index bd8bf45fd..a0b783a70 100644 --- a/src/toad/widgets/comms_chat.py +++ b/src/toad/widgets/comms_chat.py @@ -44,7 +44,6 @@ Window, ) from toad.widgets.flash import Flash -from toad.client.history_preparation import NEWER_END, OLDER_END from toad.widgets.prompt import MessagePrompt, Prompt from toad.widgets.session_details import ConversationSessionDetails from toad.widgets.wire_history import HistoryLoading, WireFragment, WireHistory @@ -254,66 +253,47 @@ def history_loading(self) -> bool: return self.message_history.reading async def _refresh_source(self) -> None: - """Read what changed in the conversation and draw it: the history's source work.""" + """Read what changed in the conversation and draw it: the history's source work. + Thread-config reads (compose, status, mentions, label) are driven by + thread_presented, not by every bus message.""" history = self.message_history announced = self.app.coordination_access.revision - newly_announced = announced != self._refreshed_from - changed = await history.read_changes() - # Source observation and its pending first page belong to the - # history, even before this tab is drawable. Composer work follows. - source = history.page_source - snapshot = history.source_snapshot() - if not await history.source_is_current(snapshot): - return - compose = await source.compose_access() - if not await history.source_is_current(snapshot): - return - await self.refresh_composer(compose) + await history.read_changes() self._refreshed_from = announced - # A sent message may now be drawn: its queue entry retires before mentions are read. self.submissions.settle() - # Composer mentions and DM status read the observer's snapshot - # and the agent records, which can take seconds on a busy bus. They are - # not this conversation's messages, so they run after this work ends - # and the history can load pages while they wait. - self.run_worker(partial(self._refresh_labels, source, changed, newly_announced, compose.read_only), - group=self.LABELS_GROUP) LABELS_GROUP = "chat-labels" - async def _refresh_labels(self, source, changed: bool, newly_announced: bool, read_only: bool) -> None: - """Refresh composer mentions and status for the history as it is drawn now.""" + def thread_presented(self, presentation) -> None: + super().thread_presented(presentation) + self.run_worker(self._refresh_thread_config, group=self.LABELS_GROUP) + + async def _refresh_thread_config(self) -> None: + """Read compose access, status, mentions and label — facts that change when thread + config changes (ThreadsObserved), not on every bus message.""" history = self.message_history + source = history.page_source snapshot = history.source_snapshot() - conversation = self.conversation - if source is not history.page_source: + if not await history.source_is_current(snapshot): + return + compose = await source.compose_access() + if not await history.source_is_current(snapshot): return + await self.refresh_composer(compose) try: - # An unchanged history may have read the stores before the observer - # announced the change; mention completion reads the observer's snapshot. - if changed or newly_announced: - await source.update_mentions(self) - if changed: - if not await history.source_is_current(snapshot): - return - if (not self.is_attached or source is not history.page_source - or not self.query_ancestor(SessionScope).is_current): - return - self.call_after_refresh(history.mark_visible) - if not changed: + await source.update_mentions(self) + if not await history.source_is_current(snapshot): return - status = await source.status_text(read_only=read_only) + self.call_after_refresh(history.mark_visible) + status = await source.status_text(read_only=compose.read_only) except (CoordinationReadUnavailable, ReadAgain): - # The coordination store is busy or moved on: the observer's next - # announcement refreshes this view and reads the labels again. return - if not await history.source_is_current(snapshot) or self.conversation != conversation: + if not await history.source_is_current(snapshot) or self.conversation != self.conversation: return self.thread_status = status if self.window.follows_tail: self.window.anchor() - if NEWER_END.visible_more(history) or (OLDER_END.visible_more(history) and self.window.max_scroll_y == 0): - history.request_preparation() + def channel_prompt(self, placeholder: str) -> ChannelPrompt: return ChannelPrompt(project=self.project_path, placeholder=placeholder, submissions=self.submissions) From b7d26f4aa9f290f160efaae8ab8b8d770c4e69ea Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Wed, 18 Nov 2026 15:49:36 -0500 Subject: [PATCH 09/12] tests: keep the burst-stack test file as on main (the covers-visible-header test was removed in #2135: it compared identical-by-construction labels) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3 --- tests/textual/test_arrival_burst_stack.py | 55 ----------------------- 1 file changed, 55 deletions(-) diff --git a/tests/textual/test_arrival_burst_stack.py b/tests/textual/test_arrival_burst_stack.py index 74bb235a3..c95fe8f90 100644 --- a/tests/textual/test_arrival_burst_stack.py +++ b/tests/textual/test_arrival_burst_stack.py @@ -61,58 +61,3 @@ async def test_a_burst_stacks_the_earlier_headers_and_a_click_opens_one(workspac app.save_screenshot("burst-opened.svg", str(shots)) assert not window.arrival_burst.messages and not pin.stacked.keys assert not window.follows_tail - - -async def test_burst_stack_covers_visible_header_without_overlap(workspace, tmp_path): - """When a burst message's header is the viewport's top row (pinned.headers empty), - the overlay draws 'N new' + stacked earlier headers + that header as its last line, - covering the flow's copy so no other header sits on top of it.""" - workspace.thread("sender", "bstack", running=True) - comms = workspace.comms - for index in range(10): - comms.messaging.send("sender", "#bstack", f"fill {index}: " + "padding " * 6) - shots = Path(os.environ.get("BURST_SHOTS", tmp_path)) - async with workspace.app(size=(80, 30)) as ui: - app, pilot = ui.textual - await ui.open_channel("#bstack", actor="sender") - chat = app.screen.query_one(CommsChatView) - history, window = chat.message_history, chat.window - await ui.until(lambda: history.state.accepts_source_work, why="the channel's messages") - await ui.until(lambda: window.follows_tail, why="the reader on the tail") - - for index in range(BURST): - comms.messaging.send("sender", "#bstack", f"BURST {index}\n" + "\n".join( - f"line {row} of burst message {index}" for row in range(8))) - await refresh_chat(chat) - await ui.until_shows(f"BURST {BURST - 1}") - pin = window.sticky_header - await ui.until(lambda: pin.stacked.keys, why="the burst stacked", seconds=15) - - burst = window.arrival_burst.messages - assert len(burst) == BURST - latest = burst[-1] - top = window.message_top(latest.key) - assert top is not None, "latest burst message on screen" - - # Put the latest message's first row (Gap) at the viewport top. - # Its header divider is visible; pinned.headers is empty. - with window.layout_scroll(): - window.scroll_y = top - window.repin_header() - await pilot.pause() - app.save_screenshot("burst-header-at-top.svg", str(shots)) - - above = [m for m in burst[:-1] - if (t := window.message_top(m.key)) is not None and t < window.scroll_y] - assert above, "earlier burst heads are above the top row" - assert pin.display, "pin visible when burst heads are above" - assert pin.stacked.keys, "stacked keys present" - assert pin.headers[0].label == f"{BURST} new", pin.headers[:1] - # The latest header appears exactly once — as the overlay's last line, - # never A's header covering visible B. - latest_label = latest.header.label - overlay_labels = [h.label for h in pin.headers] - assert overlay_labels.count(latest_label) == 1, ( - f"latest header once in overlay, got {overlay_labels}") - assert overlay_labels[-1] == latest_label, ( - f"latest header is the overlay's last line, got {overlay_labels}") From 929811e68c6202f32afacefab2247ac9fc48b649 Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Wed, 18 Nov 2026 15:54:56 -0500 Subject: [PATCH 10/12] qt history: every offset pins again, the reader's response runs per frame only for reader scrolls The frame-coalesced scroll returned before scheduling anything while the window restored its own offset (an arrival's glide), so an arrival's header never pinned and its burst never stacked (batch-8 arrival drive). The per-frame pass now always repins; velocity, page requests and tail-follow still run only when the reader moved. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3 --- src/toad/qt/history.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/toad/qt/history.py b/src/toad/qt/history.py index a7483824e..c9fcdb885 100644 --- a/src/toad/qt/history.py +++ b/src/toad/qt/history.py @@ -1504,6 +1504,10 @@ def scrolled(self, value: int) -> None: The at_end/follows_tail transitions are immediate — they are cheap state flips and consumers (jump bar + anchor) need to see them during every touch tick.""" + # Every offset pins, the window's own as well as the reader's: a glide down into a tall + # arrival moves the top row into it, and skipping the window's own offsets left the + # arrival's header unpinned and its burst unstacked (Tristan, Android, 2026-11-18). + self._schedule_scroll_frame() if self._restoring: return if self.at_end and not self.follows_tail: @@ -1512,18 +1516,25 @@ def scrolled(self, value: int) -> None: self.release_anchor() elif not self.follows_tail: self.reader_position = RowPosition(value) + self._reader_scrolled = True + + _reader_scrolled = False + + def _schedule_scroll_frame(self) -> None: if not self._scroll_frame_pending: self._scroll_frame_pending = True interval = max(1, round(frame_interval(QWidget.screen(self)) * 1000)) self._scroll_frame_timer.start(interval) def _scroll_frame(self) -> None: - """One display frame's scroll response: repin, velocity, page requests, tail-follow. - Runs at frame rate regardless of input rate — the same cadence as the TUI.""" + """One display frame's scroll response: the pin for every offset, and the reader's + response (velocity, page requests, tail-follow) when the reader moved. Runs at frame + rate regardless of input rate — the same cadence as the TUI.""" self._scroll_frame_pending = False - value = self.verticalScrollBar().value() self.repin_header() - self.respond_to_scroll(value) + if self._reader_scrolled: + self._reader_scrolled = False + self.respond_to_scroll(self.verticalScrollBar().value()) _flinging = False From 2d66af62ec63f5add346c7e812f467363bfb06b0 Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Wed, 18 Nov 2026 16:02:49 -0500 Subject: [PATCH 11/12] conversation views: thread config is read on the first refresh and when the roster moves, channels included Moving compose access, label, status and mentions off the per-arrival refresh onto thread_presented left channel views (which never get thread_presented) without them: the composer drive found no mention offers on #any. Both frontends now read the config when the revision's roster part moved (NoRevision before the first read), and on thread_presented. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3 --- src/toad/qt/window.py | 10 ++++++++++ src/toad/widgets/comms_chat.py | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/src/toad/qt/window.py b/src/toad/qt/window.py index 9f80bffd5..85089ba7c 100644 --- a/src/toad/qt/window.py +++ b/src/toad/qt/window.py @@ -113,6 +113,8 @@ from toad.constants import WELCOME from toad.core import session_requests from toad.core.events import CoordinationObserved, ExternalTranscriptChanged, TabHistoryChanged +from agent_comms.messaging.revision_views import RosterView +from agent_comms.presentation import NoRevision, ReadState from toad.launch_binding import AgentBinding, NoAgent from toad.launch_opening import LaunchOpening, NoLaunchOpening from toad.navigation_context import HomeNavigation, NavigationOwner @@ -1297,6 +1299,14 @@ async def _refresh_source(self) -> None: self.on_composer("receipt", lambda composer: composer.receipt.follow(*followed)) self.refresh_thread_status() self.sync_working() + # Thread config (compose, label, status, mentions) is read on the first refresh and when + # the roster moved, the roster owner's own signal: channels get no thread_presented. + revision = self.app.coordination_access.revision + if revision.changed_since(RosterView(), self._config_revision): + self._config_revision = revision + asyncio.ensure_future(self._refresh_thread_config()) + + _config_revision: ReadState = NoRevision() def thread_presented(self, presentation) -> None: super().thread_presented(presentation) diff --git a/src/toad/widgets/comms_chat.py b/src/toad/widgets/comms_chat.py index a0b783a70..02e3ef9a8 100644 --- a/src/toad/widgets/comms_chat.py +++ b/src/toad/widgets/comms_chat.py @@ -1,6 +1,8 @@ """Native Toad conversation view for an agent-comms channel or DM.""" from __future__ import annotations +from agent_comms.messaging.revision_views import RosterView +from agent_comms.presentation import NoRevision, ReadState import re from functools import partial @@ -261,6 +263,13 @@ async def _refresh_source(self) -> None: await history.read_changes() self._refreshed_from = announced self.submissions.settle() + # Thread config (compose, label, status, mentions) is read on the first refresh and when + # the roster moved, the roster owner's own signal: channels get no thread_presented. + if announced.changed_since(RosterView(), self._config_revision): + self._config_revision = announced + self.run_worker(self._refresh_thread_config, group=self.LABELS_GROUP) + + _config_revision: ReadState = NoRevision() LABELS_GROUP = "chat-labels" From 628c87924ee5196cb100cbc638e832a785cbd25d Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Wed, 18 Nov 2026 16:04:50 -0500 Subject: [PATCH 12/12] message files: a DM's files are read in that DM as its sender, whoever reads the page #any shows DMs between two other threads; reading their files as the reader's DM with the sender was refused ('Not in claude-a as you may read it') and failed the whole #any page: the composer drive could not open #any once such DMs were on the bus. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3 --- src/toad/message_rows.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/toad/message_rows.py b/src/toad/message_rows.py index 5782e4275..4026a1f3e 100644 --- a/src/toad/message_rows.py +++ b/src/toad/message_rows.py @@ -135,7 +135,9 @@ def recorded(self, source: HistorySource, name: str) -> LineLink: class MessageFileReader(MroProjection[FileReader]): """Whose read a message's files are, from where it was sent: a channel message is read in - its channel; a direct message in the DM with the participant that is not its reader.""" + its channel; a direct message in its own DM, as its sender. The reader is not always a + participant: #any shows DMs between two other threads, and naming the reader's DM with + the sender there was refused, failing the whole page (2026-11-18).""" @handles(ChannelTarget) def channel(self, target: ChannelTarget, row: MessageRow) -> FileReader: @@ -143,7 +145,7 @@ def channel(self, target: ChannelTarget, row: MessageRow) -> FileReader: @handles(ThreadTarget) def direct(self, target: ThreadTarget, row: MessageRow) -> FileReader: - return FileReader(target.name if row.outgoing else row.message.sender, row.reader) + return FileReader(target.name, row.message.sender) MESSAGE_FILE_READER = MessageFileReader()