Repository navigation
feat(remote): read the run's log on the desktop, so a reply is whole - #1020
Merged
Merged
Conversation
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.
# Conflicts: # desktop/src/features/remote-peer/RemoteConversationView.tsx
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.
huichen
enabled auto-merge (squash)
October 13, 2026 06:26
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.
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 each completed model call; the pushes begin where this window subscribed. So a reader who opens a conversation while the host is answering gets a fragment — and, since #1008 folded the two copies together on the assumption that the lanes do not overlap, occasionally the same words twice.
They can overlap. 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):get_statenames the run in flight before any frame happens to arrive (a long tool call pushes nothing for minutes);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 — carrying the run's own start time, which no push can supply, and continued in place by the frames that follow.
What moved into
@future-os/thread-projection, because both clients read the same host:runCursor— the per-run integrity cursor (high water + whether the beginning is provably present), previously the phone's.replay— the page loop and its rules (readRunReplay,tailCoversRange,normalizeReplayEvent): snapshot bootstrap, pinned watermark, stalled cursor, trimmed-feed counting.startedAtMs(fromagent_start) anddurationMs(fromagent_end), which is what makes the elapsed time on a joined reply the run's.That deletes two duplicates: #1013's desktop port of the cursor (
replayWindow) and the phone's private copy of the page loop, whose wire tests moved with it (36 cases, now covering both clients).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 answers
Unsupported command(said once, then not asked again for the connection), or the first read still in flight. Two consequences fall out of that, and the harness caught one of them: a fragment built from pushes alone is dropped when the run ends (its beginning is only in the record, so keeping it drew the words twice — which is whatremote-streamingreported), while 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).Adjustments to the previous model, as I flagged they might be needed:
get_statenow also sets the streaming flag ("the host has a run in flight"), which is what a window that just opened has no other way of knowing — before this, the header said nothing was running until the first frame arrived.liveprop becameliveReplies, because the two rules can briefly apply to two runs at once (a settled rebuilt reply waiting for its record, then the next run).Verified
tsc,eslint,vitest run— 302 files / 4017 tests.tsc,eslint,jest --runInBand— 153 suites / 3078 tests.toolCallId/runId— verified identical onorigin/main, fixed here because this suite is only run locally).get_state'sactiveRun,get_events_since), andremote-mid-flightasserts 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. Falsified: with the log read disabled the scenario fails with "the reply is timed from the reader's arrival, not from the run".remote-streamingandremote-lean-stream(the fold path) pass with a settled entry that carriesrun.status, as the real host's does.docs/internals/desktop/CONNECTION.{md,zh-CN.md}updated: the paragraph docs(remote): the desktop client now shares the phone's catalog, replay and gaps #1019 wrote described the state perf(remote): incremental replay on remote timeline resume #1013 left, and the fallback it named is no longer "one whole-page read".