Repository navigation
perf(threads): resume ui watches from journal checkpoints - #271
Merged
Merged
Conversation
nixuuu
marked this pull request as ready for review
November 6, 2026 11:52
nixuuu
added a commit
that referenced
this pull request
Nov 6, 2026
Opening a long bot conversation currently transfers every message again. This adds durable, owner-scoped checkpoints for bot conversations and bot-to-bot exchanges, so clients can request only changed messages and current control state. The bot tables have their own commit-ordered key journal, following the thread mirror epoch/cursor design. A checkpoint binds the owner, view and revision. Message edits, deletion and turn failures produce upserts/removals. A metadata digest confirms approvals, read state, pending cards, configuration, streaming text, routines and reminders; changed control state is replaced atomically. Missing/expired cursors, gaps, another epoch, rewritten exchange membership and moves fall back to a full projection. Linked bot reads pass the cursor to the home through the existing route. Offline reads retain the existing mirror path and gateway action enforcement. Proto additions are opt-in: old clients get full snapshots, and a home ignoring the new fields returns full state that new clients can apply. No link protocol version change. Migration 0091 is the next free number on the rebased dev; schema expectations and generated contracts are included. ### Measurements Single-run development-server measurements with a real local gateway/Postgres and 3,000 stored messages, each containing about 2 KB of long output. Browser first content is measured from route switch to message DOM appearing. SSE bytes include the ready frame and initial state, excluding HTTP/TLS headers and unrelated sidebar polling. The after column uses the whole stack, including the opt-in web client in the next layer. | Measurement | Before | After | |---|---:|---:| | Web warm switch, first content | 3,819.9 ms | 187.2 ms | | Initial bot SSE, unchanged reopen | 7,050,627 B | 393 B | | Web cold route, first content | 4,512.9 ms | 910.2 ms | | Initially mounted message rows | 3,000 | 100 | | Android first content / bytes | Unverified | Unverified | The baseline full protobuf was 6,772,217 B. Cold full history remains approximately 6.77 MB: this does not add server-side pagination. The cold browser sample includes development module loading; these are observations, not statistical latency bounds. Android timing and runtime visuals are unverified: the device tool's dev-client deep link failed with `COMMAND_FAILED: adb exited with code 1`, including its advised debug retry. No SSH/ADB UI fallback was used. ### Verification - Real-gateway integration and schema tests: 28 passed, including edits/deletes/failures, control confirmation, gap/epoch/view fallback, owner isolation, cursor after restart, linked chat/exchange, and a home ignoring the additive request fields. - `bun install`, `bun run gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check` passed on this stage after rebasing. - Polish protocol/read-path documentation updated. No new UI copy in this layer. The bot mirror publisher still uses its existing full projection protocol; this stack changes UI reads, not partner journal publishing. Live control metadata is a complete replacement when changed, rather than a second journal for approvals and linked thread cards. Related: #271, #272, #273.
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Opening a UI watch can now resume from the snapshot already held by the client. Additive
incrementalandcursorrequest fields opt into the existing owner journal; full snapshots carry an atomic checkpoint. Projected item/turn upserts, tombstones and replacement metadata reconstruct the current state without transferring unchanged history.An unknown, expired, future or other-epoch checkpoint, journal gap, fork reset or moved history falls back to full state. Live events update the client copy without advancing its atomic checkpoint, so reconnect replays projected changes idempotently. Owner authorization remains in the gateway. No migration is needed.
For remote threads, a warm UI cursor passes through to the home. A cold UI retains local mirror-first behavior. Older clients omit the opt-in and keep full snapshots; older gateways ignore the new fields and return snapshots without a cursor. Linked-computer capability negotiation remains unchanged. Related: #264, #265.
Measurements use two synthetic threads, each with 500 completed turns and 3,001 timeline items, including roughly 1.9 KB tool outputs. The stack's client layers measured these changes against a real gateway, scripted worker, isolated Postgres and actual browser/Android app:
Browser warm content appeared before the live response. These are development-mode measurements on shared hardware; payload figures exclude transport/framing overhead. Client-specific Android results and device qualification are recorded in the mobile layer.
Verification: additive proto generated with
bun run gen;gen:check, install, typecheck, lint and formatting passed on every layer. Top-of-stackcheck:tmp: 1,490 passed, 159 skipped, zero failures; web build and Expo lint passed. Real gateway UI integration coverage exercises caught-up reads, upserts/deletions versus full state, old clients, invalid/future/other-epoch cursors, gaps, restart and owner isolation. Existing two-gateway tests also exercise warm UI reads of remote threads. The stack stays draft and must not be merged individually.