Skip to content

qt + tui: arrivals insert only their rows, burst stack never covers a header, --open NAME, exact-match search, serve-tailnet restored - #2135

Merged
trissim merged 21 commits into
mainfrom
qt-ui-batch-7
Nov 18, 2026
Merged

trissim merged 21 commits into
mainfrom
qt-ui-batch-7

Conversation

@trissim

@trissim trissim commented Nov 18, 2026

Copy link
Copy Markdown

One batch, gated once locally (ratchet, shadow, all 22 live-bus Qt drives, the TUI on the owner's real settings with --open claude-a):

  • Phone speed (phone-ui-budget): sidebar applies partial changes, tabs retitle only what changed, a burst ends only when the reader leaves the tail, a rising row fades as one picture, the pin reuses its header layout.
  • Arrivals insert only their rows (arrival-insert + PyQT-reactive#68): HistoryRows.show emits insert/remove/change instead of a reset; existing rows keep their measured heights (1500 rows: ~30 ms → ~5 ms per arrival in the interpreter check). The composer reads the delivery-preview setting once per change.
  • Burst stack never covers a header: a burst leaves the top row's message out by identity (equal same-second headers were dropping messages); with nothing pinned, the header drawn at the top edge becomes the stack's last line, drawn once.
  • The thread-opening placeholder is a Page: a CLI-transcript change no longer raises on it.
  • --open NAME opens a thread or #channel at launch, one parse and one opener for the TUI and Qt; sidebar search lists the exact name first, then prefixes (Textual's TargetTree copy of the match rule deleted).
  • toad serve-tailnet PORT restored from feat/toad-serve-tailnet: owner-only unix socket, tailnet-login check through agent-comms' TailnetSelf (agent-comms#4894); the systemd unit runs the installed toad.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

trissim and others added 21 commits November 18, 2026 13:47
Qt's Sidebar.present redrew every channel and thread line on each bare present, which
`present_sidebar` makes on every sidebar observation; the rows' changes already reach `sync`
as partial ChangedChannels/ChangedThreads. On Tristan's phone during a burst of arrivals that
redraw was 17% of the UI thread. A bare present now runs the shared state transition and keeps
the status line current in place, as Textual's sidebar does; `sync` applies every change the
state machine hands it: a partial one that keeps the channel order touches its rows, every
other one (all rows, a channel added, removed or moved) draws the tree again in place. The
search filter asks for all rows, as Textual's search follower re-syncs every group.

The tab bar removed and re-added every tab on each paint_tabs, which the sidebar asked for on
each observation (8.6% of the phone's UI thread). It now changes nothing when the tabs are the
same, retitles only a changed title when the tabs and their order are the same (Textual's tab
strip reconciles its labels so), and re-marks the selected tab only when the tabs or the
selection changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…e offset falls

The arrival drive's burst check found "the burst holds 0 messages of 5 posted" at phone speed:
the burst grew to 8 messages while the window followed, then emptied with the window still
following. Rows above that shrink (a receipt, the queue rows closing) make Qt clamp the scroll
offset up outside `layout_scroll`, and `repin_header` ended the burst on any upward offset. A
reader's own scroll up releases the anchor, so the burst now ends only once the window no
longer follows the end. Shared: both frontends' windows pin through `PinsMessageHeader`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…n again each frame

A burst's arrivals fade in row after row (`ArrivalFade`), and each frame of the fade drew every
rising row's rich text again: its document's layout and every glyph, at the frame's opacity.
Their look does not change while they rise, so the delegate draws a rising row once into a
picture (by width, height, pixel ratio and document) and paints that at each frame's opacity;
the picture goes when the row has risen or its fade lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
The pin laid out every header it draws again whenever the drawn set changed, and a burst's
stack changes as each head glides past the top: each header's html built anew, its theme's
colours resolved span by span. A phone-speed profile of a burst put that at a third of the UI
thread (repin_header 31.9%, header_document 16.2%). The pin now keeps each header's document
while its width, font, link context and renderer stay the same, and lays out only headers
it has not. The renderer is part of that context, so a theme change lays the pin out again;
before, an unchanged header set kept the old theme's document.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…s its preview setting once per change

The two largest per-frame costs left during a burst on the phone (busy main-thread time):
every arrival reset the history model, so the view measured every row again (rows_changed /
_update_viewport / sizeHint, ~23%), and each queue sync resolved the delivery-preview setting
through the settings scope several times (~8%).

HistoryRows.show now tells the view what changed. Rows of pages that did not change are the
same fragment objects, so the unchanged rows before and after the change are found by
identity, and only the rows between them are inserted, removed or changed (the changed rows
keep their old content through the insert or removal and change in place after, as Qt's
model contract requires; QAbstractItemModelTester in Fatal mode passes append, prepend,
replaced live tail, arrivals before the draft, removal, mixed and full changes). With
pyqt-reactive's kept row sizes (OpenHCSDev/PyQT-reactive#68) every unchanged row keeps its
measured height. The row-key index is rebuilt only from the first changed row.
show_pages and rows_changed lay out once and leave none pending (a model insert schedules
Qt's own layout, which a direct doItemsLayout left to run a second time).

PromptComposer keeps the delivery-preview setting as last read, until its change effect
(apply_delivery_preview) drops it.

Interpreter timings, offscreen: an append through HistoryRows into VirtualRowView, 1500 rows:
29-30 ms with the installed pyqt-reactive, 4.3-4.4 ms with #68 (main's reset path: 43.8 ms
at 1000 rows).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…gain

The batch gate's hold and menu_parity drives found the comms sidebar placed as a 24 px band at
the bottom with the tab strip, where main places it at the left beside the conversation, so no
sidebar row was on screen to press. paint_tabs had stopped calling mark_current when neither
the tabs nor the selection changed, and mark_current is what presents the panes
(`show_current_tab` -> `present_panes` -> each side bar's present and the chrome's arrange):
the side bars stayed presented as before the drive's resize to phone width. paint_tabs marks
the selected tab every time again, as on main; the bar itself still redraws only what changed.

Checked with an offscreen interpreter run at 412x915 on main and this branch: the same 108
conversation rows, 12 inside the tree's viewport with no tab open, the same layout after #comms
opens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
The systemd unit bypassed ToadWebServer entirely with a raw python -c
one-liner calling the unprotected base Server class. --tailnet-port never
existed; the stale part was the unit's command.

Add TailnetWebServer(Server) in web_server.py: same version check, no
cookie gate (the tailnet's ACL is the access control), public_url passed
through for correct WebSocket URL generation behind tailscale serve.

The unit now uses `toad serve --public-url URL --port 8040 acp
agent-comms-acp` instead of importing textual_serve directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…ghts

A row's kept height (OpenHCSDev/PyQT-reactive#68) answers without asking the row's key again,
so a key that changes in place must be told. `request_show` changes a fragment's look in place
(show sees the same object): the model now emits dataChanged for those rows, which drops their
kept heights only, so each is measured again in its new look. A link or style change gives
every row a new key: the delegate forgets every kept height. Live and draft rows are new
fragment objects on each change, which show's identity comparison already tells as changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…ists the exact name first

One launch owner for both frontends: `ClientLaunch.startup` (local_connection) reads the
Core (`select_connection`) and the conversation (`LaunchOpening.startup`, removing `--open
NAME` as the connection's own options are removed) from the terminal launch's and Qt's
desktop launch's arguments. The shared start (`ApplicationLifetime.start`) opens it after
the saved tabs come back, through `TargetOpen`, as a sidebar row and a link naming it do.

Sidebar search: `SidebarFilter.matching` is the one listing both frontends draw: matches
ranked exact, then prefix, then the rest, each in model order. Textual's `TargetTree` kept
its own copy of the match rule (`search` + `matches`); it now lists through its sidebar's
filter, as Qt's channels tree and thread panel do.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
… identity

The re-gate's arrival drive found one burst head above the top row and none stacked:
burst messages from one sender to one destination in the same second draw equal headers,
and `ArrivalBurst.stack` left out every message whose header equalled the top row's, so
the earlier ones were dropped with it. `PinnedHeader` now carries the top row's message
(its fragment key's source, from the shared `FragmentRowUnderTop` both front ends pin
through) and the stack leaves out only that message. The drive's count does the same.

The Qt pin sets its tap pass-through before its unchanged-drawing return: equal headers
can stand for other messages, so the flag follows the stack, not the drawing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
The isolation applied only when the shell held no XDG_CONFIG_HOME / XDG_STATE_HOME. A
shell exporting XDG_CONFIG_HOME=~/.config gave the batch-4 gate's drives the reader's
own toad.json: its ssh-origin layout docks both sidebars at the bottom, which left the
hold drive's sidebar tree one line tall, so its holds and its tap landed on nothing
(`held on []`, then "tapped row"). Their writes went to the real file too. Every gate
script already names these same OUTDIR folders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…d-serve-tailnet

The unmerged feat/toad-serve-tailnet branch (head 7ba3e21) carried owner-only
tailnet serving behind tailscale serve: a TailnetBrowserEndpoint on a 0600 unix
socket, TailnetBrowserAuthentication checking Tailscale-User-Login against the
machine owner's login from tailscale status, and a ToadWebServer refactored to
take any BrowserAuthentication.

Port the architecture onto current main:
- BrowserEndpoint ABC with LocalBrowserEndpoint and TailnetBrowserEndpoint
- BrowserAuthentication ABC with Local and Tailnet siblings
- ToadWebServer takes BrowserAuthentication; one class, two auth strategies
- ToadWebServer.serve() overridden to listen on the endpoint's own socket
- ProcessSingleton claims the tailnet lock so a second instance fails
- OwnerOnlyDirectory verifies the runtime dir's ownership and mode

The systemd unit now uses the installed toad command with no PYTHONPATH to
a worktree: `toad serve-tailnet 8443 acp agent-comms-acp`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…b.com/OpenHCSDev/toad into claude/toad-serve-tailnet-port-dw4byw

# Conflicts:
#	docs/browser-serving.md
#	src/toad/cli.py
#	src/toad/web_server.py
#	tools/systemd/toad-serve.service
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 <noreply@anthropic.com>
… and, when that row is its header, draws it once as the stack's last line

Merge of gaming-a-headers (visible header covered by an earlier one) onto
phone-ui-budget's identity rule: PinnedHeader.source names the top row's
message in both frontends, so no separate scan is needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
…ng status

TailnetBrowserAuthentication.from_status now calls TailnetBuses.this_machine()
which returns a TailnetSelf(dns_name, owner_login) — the same tailscale status
command and JSON parse that peer discovery already owns.

Removes the subprocess import and raw dict-path reading that restated the
status decode (IDEN-5: one fact, two stores).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… opening placeholder is a Page

- ArrivalBurst.stack: with nothing pinned, a header is drawn at the top edge (the top row is
  a message's head or the gap before it). The first burst message starting at or below the
  top edge is that header; it becomes the overlay's last line, drawn once, so no earlier
  header is drawn over it (gaming-a-headers' overlap). Traced on a 5-message burst: tops
  60/73/86/99/112 with the furthest scroll at 103.
- QtOpeningSessionView inherits Page: the window asks every open view for
  external_transcript_changed, and the placeholder shown while a thread opens had none
  (batch-6 hold drive: AttributeError on a CLI-transcript change).
- Dropped the cloud test that compared identical-by-construction header labels and scrolled
  to a position the window cannot reach.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3
@trissim
trissim merged commit ed4389b into main Nov 18, 2026
trissim added a commit that referenced this pull request Nov 18, 2026
… frame, channel thread config, #any DM files (#2137)

* fix: burst stack must not cover a visible header

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 <noreply@anthropic.com>

* fix: burst stack covers visible header as the overlay's last line

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 <noreply@anthropic.com>

* qt scroll: defer repin_header and read-ahead to frame rate during touch drag

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 <noreply@anthropic.com>

* qt scroll: coalesce touch-rate events to one display frame, same cadence as TUI

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 <noreply@anthropic.com>

* perf: arrival path re-reads: five per-arrival costs removed

#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 <noreply@anthropic.com>

* perf: TUI _refresh_source: same per-arrival → thread_presented split

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 <noreply@anthropic.com>

* chore: drop unused NEWER_END/OLDER_END import from comms_chat

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* perf: move per-config reads from per-arrival refresh to thread_presented

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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

* 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

* 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

* 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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RnH6dT7wdh7i4tjJZQdFu3

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants