Repository navigation
perf(remote): incremental replay on remote timeline resume - #1013
Merged
Merged
Conversation
Add replayWindow.ts with run-cursor and replay-window validation ported from mobile. On resumed, useRemoteTimeline now tries get_events_since first and falls back to the newest history page when the host does not support it or the replay window cannot be validated. Keeps per-run cursors across opens via the snapshot and updates them from live pushes. - REPLAY_PAGE_EVENTS = 1000 matches mobile. - tailCoversRange handles both trimmed (rawEvents) and untrimmed feeds. - applyReplayPage detects gaps/overlaps and falls back to full read. - Old host Unsupported command auto-falls back to get_session_entries. Tests added for both replayWindow and useRemoteTimeline.
huichen
enabled auto-merge (squash)
October 13, 2026 04:22
huichen
added a commit
that referenced
this pull request
Oct 13, 2026
…ay and gaps (#1019) Bring §2.2.2 (The Desktop as a client) back in line with origin/main after the remote-alignment round (#1007, #1009, #1010, #1012, #1013, #1014, #1015, #1017, #1018): - The two "mechanism, not a gap" table rows are gone: the desktop replays with get_events_since (falling back to one whole-page read) and probes get_prompt_receipt on a stored send, both as the phone does. The one remaining mechanism difference -- get_presence on a suspect socket vs. the presence subscription -- is stated in prose. - The capability paragraph names the gains: workspace rename on the phone, and per-host/per-conversation drafts, the stored outbox, the done bell, question navigation, list search and image zoom on the desktop. - The merged-list paragraph describes the pushed catalog: domain-tagged snapshots gated by {epoch, revision}, healed by the presence heartbeat, with a slow per-host read only as the fallback for older hosts. - CONNECTION.zh-CN.md carries the same edits.
huichen
added a commit
that referenced
this pull request
Oct 13, 2026
…1020) * feat(remote): read the run's log on the desktop, so a reply is whole A remote conversation is read from two lanes: the host's *record* (a page of its journal) and its *stream* (the events it pushes). Neither is the run: the page ends where the agent last saved, and the pushes begin where this window subscribed, so a reader who opens a conversation while the host is answering sees a fragment — and used to see it twice, as the page's copy and the pushed one were folded together on the assumption that the two lanes do not overlap. They can. The run's own log is the third lane, and this makes the desktop read it the way the phone already does (`get_events_since`): at an open (the state read says which run is in flight, before any frame happens to arrive), when a link comes back, and when a push declares a gap the feed could see. A reply rebuilt from its log covers the run from its beginning, so the record's partial copy of that run is hidden and the reply is drawn once — with the run's *own* start time, which no push can carry, and continued in place by the frames that follow. What moved to `@future-os/thread-projection`, because both clients read the same host: the run cursor (`runCursor`), the replay page loop and its integrity rules (`replay`, `readRunReplay`), and the run's own start and duration in the projector. The desktop's duplicate port of the cursor (replayWindow) is gone, and so is the second copy of the page loop the phone kept for itself. The fold is kept, but demoted: it is the answer for a run this client has *not* read the log of — an older host that does not serve the command, or the first read still in flight. A fragment built from pushes alone is dropped when the run ends (its beginning is only in the record, so keeping it draws the words twice), where a rebuilt reply is kept until the record is readable (the record trails the terminal frame, which is what used to make a settled reply blink). Verified: desktop 297 files / 3978 tests, mobile 153 suites / 3076 tests, the shared package's 19 files / 595 tests, `tsc`, `eslint` on both clients. The harness gained the two commands the desktop now reads and `remote-mid-flight` asserts what only the log can give: one row, carrying the page's words and the run's, timed at the run's own eight minutes. It fails without the read ("the reply is timed from the reader's arrival"), and `remote-streaming` and `remote-lean-stream` — which cover the fold path — still pass. * docs(remote): the two clients' read of a run's log, as it now stands The paragraph #1019 wrote described the state #1013 left: the desktop replayed on resume and handed everything else to one whole-page read. Both clients now read a run's log at the same three moments, the reply they draw comes from it, and the page is kept for the part the log cannot answer. Says what the fallback is when a host does not serve the command, which is no longer "one whole-page read" but the fold. * test(mobile): clear the lane in the refusal test, so jest exits The rewritten case exercises a path that arms the lane's retry timer, and it is not a fake-timer test: leaving it armed kept the node process alive after the suite finished. Locally that is a jest warning; in CI it is the mobile job stuck `in_progress` (35 minutes and counting) on a step whose tests had all passed.
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.
See diff for details. Adds replayWindow.ts, wires get_events_since into useRemoteTimeline, and falls back to full history when unsupported or invalid.