Skip to content

perf(bots): add durable ui history checkpoints - #288

Merged
nixuuu merged 1 commit into
devfrom
perf/bot-cache-1
Nov 6, 2026
Merged

nixuuu merged 1 commit into
devfrom
perf/bot-cache-1

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

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.

@nixuuu
nixuuu added this pull request to stack #291 November 6, 2026 19:00
@nixuuu
nixuuu marked this pull request as ready for review November 6, 2026 19:11
@nixuuu
nixuuu merged commit a6c3d12 into dev Nov 6, 2026
9 checks passed
@nixuuu
nixuuu deleted the perf/bot-cache-1 branch November 6, 2026 19:18
nixuuu added a commit that referenced this pull request Nov 6, 2026
Mobile conversations used a solid composer block that shortened the
timeline. Composers now float above the feed and fold while reading
history; the main screens also extend their backgrounds and scroll
viewports behind the system bars while keeping controls inside safe
areas.

Rebased onto `dev` after the mobile UI kit landed (Related: #287). Its
shared buttons, notices, search/form controls, confirmation host and
sheet title/close controls are preserved. Connection banners now
participate in the floating header measurement on threads, bot chats,
sidebar and Settings. The extracted sidebar footer uses #287's
interactive connection status with details and retry; Settings retains
its density provider. Full sheets keep the kit's 20 dp content spacing
inside the inset-aware modal frame.

The final rebase also includes the bot-history changes that landed
meanwhile (Related: #288, #289, #290). Bot chats retain the snapshot
cache, incremental updates, cached bot names, loading header/avatar,
syncing subtitle and live-only approval/send/stop guards beneath the
floating layout.

## Composer behavior

- Match web `ComposerCompaction`: fold after 96 dp of travel toward
older messages, at least 192 dp from the end; expand within 8 dp of the
end or on tap, focus, or typing. Only reader gestures fold it; streaming
and layout changes do not. Synchronous questions keep it expanded.
- Match `VirtualFeed.reservedFooter`: measure the full overlay, retain
its largest reserve while reading history, and follow its height at the
latest end. The changing spacer is excluded from the visible-message
anchor. The latest-message action remains above the composer with an
actual Android touch area.
- Reuse the web surface, border, light-theme shadow and 32 dp canvas
fade. Animate folding with shared 400/350 ms tokens and `smoothOut`;
reduced motion uses zero duration. Inputs and folded controls stay
mounted.
- Mobile additionally keeps any draft, attachment or mention picker
expanded, so compaction cannot hide unfinished input. Bot chats retain
their native inline pill. This is a deliberate difference from web's
ability to fold a draft to one line.

## Insets by screen

| Screen | Layout and control insets |
| --- | --- |
| Thread and existing side thread | Full-window inverted feed under a
translucent floating header and composer. Oldest end reserves the
measured header plus top inset; latest end reserves the measured
composer including bottom inset. Composer controls have side/bottom
padding. |
| Bot chat | Same overlay, compaction, reserve and safe-area rules as
threads, with the inline bot composer. |
| Sidebar and thread/bot lists | Full-height list under measured
floating header/footer. Content padding makes first/last rows reachable.
Footer controls sit above the home indicator. Only the outside edge of
each split pane consumes a horizontal inset. |
| New thread and side-thread creation | Expanded forms because there is
no conversation history to compact. New thread scrolls under its
floating header; side-thread creation uses the modal frame. Form content
gets safe-area padding. |
| Settings | Both columns scroll behind the floating header. Navigation
consumes the left outside inset, details the right; a single column
consumes both. Forms retain keyboard-overlap handling. |
| Pairing and empty home pane | Full-window background and scroll
viewport, with content padding protecting controls at both ends and
sides. |
| Full sheets and compact pickers | Full sheets measure their own modal
safe area and scroll under the header. Bottom pickers extend their
surface behind the home indicator and inset actions; centered
landscape/Fold cards fit the safe rectangle. |

`KeyboardArea` keeps its existing keyboard `screenY` calculation.
Closed-keyboard safe-area padding now belongs to scroll content and
composer controls instead of the viewport. Status-bar icons continue to
follow the selected light/dark theme; translucent header surfaces
maintain contrast above scrolling content. No new native dependency or
native configuration change.

## Verification

Reran after the final rebase onto `cf9f6be2`: `bun install`, `bun run
gen:check`, `bun run typecheck`, `bun run lint`, `bun run format:check`,
`bunx expo lint` from `apps/mobile`, and the web build. All passed. Expo
refreshed the ignored generated route list for the newly merged exchange
screen before the passing typecheck. Final `bun run check:tmp`: **1534
passed, 158 skipped, 0 failed**, 1692 tests across 274 files; no test
temp directories left behind.

The full test run uses a private `TMPDIR` inside the ignored worktree
temp directory, with `GIT_CEILING_DIRECTORIES` set to that directory.
This prevents deliberately non-Git fixture folders from discovering the
checkout above them. Live/provider tests remain opt-in. Self-review and
`git diff --check` are clean.

Android Fold device observations before the final edge-to-edge
expansion: light/dark surfaces, long history, content passing below the
composer, folding on scroll, expanding on tap/focus and return to
latest, functioning latest-message action, and a visible multiline
draft. Screenshots are kept outside the checkout. The recording exporter
failed after its documented debug retry.

After the UI-kit rebase, the source launched in the free Android Fold
emulator using the existing development client. Smoke-checked the
edge-to-edge shell in light and dark, readable status icons, inset
sidebar footer, the offline connection banner and its details/retry
overlay, plus Settings search with the real keyboard open and closed.
After the final bot-cache rebase, the bot-chat screen also rendered its
loading header and floating composer. The old fixture gateway was
offline, so live conversation behavior was not rechecked. Multiline
entry could not be verified: Android's `system_server` aborted during
the fill attempt, and the tool's debug retry could not find the field
after the reset. No new native build or download was needed; the owned
emulator and Metro session were shut down afterwards.

Device QA remains incomplete: the earlier iOS development-client launch
timed out twice, and its notch/Dynamic Island layouts remain unverified.
Phone width, conversation keyboard handling, drafts with attachments and
mention suggestions, bot/side-thread flows, reaching the bottom during
streaming, reduced motion, landscape and Android three-button navigation
still need device coverage. The rebase smoke check does not replace
those checks.

Copy audit (`docs/copy.md` §8): no new user-facing copy; existing
English action labels and form text are preserved. No web UI tests or
permanent verification artifacts were added. Shared mobile buttons,
notices and form controls retain #287's implementation; only the shared
sheet's layout delegates to the new modal frame.
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.

1 participant