Window Remote UI conversation history for iOS PWA stability - #176
Merged
Merged
Conversation
…(fizzy-226) GET /agents/:key/conversation shipped the entire transcript in one JSON payload with no cap, and the client rendered every block into the DOM in one pass on view-open. For a finished agent with a 9.5MB raw.log / 1.8MB memory.jsonl (1836 blocks), that is a ~1.1MB payload and ~37k DOM nodes on open -- confirmed via an isolated fixture + real Chrome (mobile viewport, 4x CPU throttle): 36982 DOM nodes, 13.9MB JS heap, 3.09MB innerHTML before this change. On iOS Safari's tighter per-tab memory ceiling this repeatedly killed the WebKit content process (Fizzy #226). Server: conversation_snapshot now defaults to the most recent 200 blocks (capped at 2000 via ?limit=) and exposes the true total via conversation_block_count/has_older so the revision/digest polling contract is unchanged. Older pages are fetched with ?before=<blocks-already-loaded>, a tail-relative cursor that stays correct even if new blocks land while paging. The metadata digest is now a small fingerprint (total count + last 20 blocks) instead of SHA256(JSON.generate(full transcript)) on every poll tick. Parsed blocks are cached per agent revision to avoid re-parsing memory.jsonl on every request. Client: tracks total/hasOlder separately from the rendered window so "N new messages" math stays correct; adds a "Load older messages" control that pages backward and preserves scroll position (primes the tail marker so the existing sticky-to-bottom auto-scroll doesn't misfire on a prepend). FRED (personal assistant) conversations still request the server's max window since their reconciliation logic needs full session history and daily sessions are bounded in practice. After: 5620 DOM nodes, 6.6MB JS heap, 459KB innerHTML for the same fixture -- confirmed in the same real-browser harness. Added regression coverage in remote_server_test.rb proving a 500+ block transcript stays windowed, pages contiguously, and metadata still reports the true total.
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.
Fixes Fizzy #226.
Summary
Validation
bundle exec ruby test/remote_server_test.rbbundle exec ruby test/remote_ui_conversation_loading_test.rbnode --check lib/hq/remote_ui/assets/app.jsFull
bin/testandbin/remote-ui-smokewere started but their detached runs cannot persist in this managed environment, so rerun them in CI or a persistent shell before merge.