Skip to content

id: browser reconnect resume retains its baseline; host restores viewport from the retained baseline #12648

Closed

Description

@dezren39

Problem

Browser reconnect resume is degraded end to end, on v1 today and independent of the binary transport (#12242):

  1. Browser discards its baseline but keeps the token. web/src/world.ts connect() clears renderedSurface/renderedViewRevision while retaining the resume token (Codex P2 finding on PR feat(id): negotiate binary screen patches #12246, world.ts:648). If the host answers the reconnect with a catch-up patch, the browser has no base to apply it to and falls back to a full view — the patch round-trip is wasted.
  2. The host does not restore the viewport on resume. joined() initializes every connection's viewport to None; neither the join frame nor the resume-token lookup restores it (Codex P2 finding on PR feat(id): negotiate binary screen patches #12246, world.ts:665). The first resumed view renders at the program's default size, so a retained baseline recorded at the browser's real viewport does not match, and views stay default-sized until the pane changes size.

Prior work

PR #12246 (superseded by the #12242 lane-T2 implementation for the transport itself) implemented both halves: the browser retains the matching screen/revision with the token and sends the token on reconnect, and the host restores the participant-bound viewport from the retained baseline before rendering the first resumed view (its head commit 3751be8). That head's regression test — reconnect at a non-default viewport, apply a catch-up patch — was never run (no CI on the head, per the PR body), so the fix needs verification, not just porting.

Scope

  • Browser: retain token + surface + revision as one unit across reconnects; send the token on rejoin; drop all three together when the viewport actually changes.
  • Host: when a join presents a resume token whose retained baseline matches, restore the session viewport from the baseline before the first send_view.
  • No token semantics change: a token stays a cursor, not a credential; misses still get a full view; join authorization unchanged.
  • Coverage: the non-default-viewport reconnect regression (from feat(id): negotiate binary screen patches #12246) run and green, plus a browser-side test that a catch-up patch applies after reconnect without an intervening resize.

Filed from lane T2's reconciliation of PR #12246 into the #12242 slice; the transport slice deliberately did not absorb this because it changes resume behavior beyond negotiation and its only test was never executed.

Activity

  1. developing-today commented on Nov 22, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Lane AQ pickup (archer). Premise check against current main (a7af4b7):

    • Browser half — present, in stronger form. The browser has no resume-token handling at all on main: web/src/world.ts never reads resume_token from view frames (the WorldFrame type doesn't declare it), never sends one in the join frame, receiveBinary decodes it via screen-codec.ts and ignores it, and connect() clears renderedSurface/renderedViewRevision. Every reconnect is a full view today.
    • Host half — present. joined() in crates/id-worlds/src/world_session/mod.rs initializes viewport = None and sets pending_resume, but never restores the viewport from the retained baseline; BaselineCache has no non-consuming peek. send_view only honors the token when the screen fitted at the current viewport matches the baseline shape, so a baseline retained at a non-default viewport always misses — exactly what the existing test a_wrong_viewport_resume_token_falls_back_to_a_full_view pins.

    Slice: port the two #12246 fix commits (2b9428d browser, 3751be8 host) adapted to main's post-#12242 shape (screen_msgpack negotiation, no v2 route):

    • Host: BaselineCache::viewport_for peek (participant-bound, non-consuming) + joined() restores the viewport from the retained baseline before the first send_view; the wrong-viewport test is replaced by the feat(id): negotiate binary screen patches #12246 regression a_resume_token_restores_the_viewport_before_catching_up, plus a unit test pinning that the peek does not consume.
    • Browser: retain token + surface + revision as one unit across reconnects, send the token on rejoin, adopt the token issued with each applied view, drop all three together on a real viewport change or a forced resync, and don't let a same-size resize reset the host's retained baseline on a resumable reconnect. New world-resume.test.ts carries the coverage the issue names: a catch-up patch applies after reconnect with no intervening resize, and a viewport change drops the unit.
  3. added a commit that references this issue on Nov 22, 2026
  4. dezren39 commented on Nov 22, 2026

    @dezren39
    MemberAuthor

    Done — both findings discharged by PR #12704, merged as dee25f7dbf67b8ca9add2eea2b76072eeb5ebbfb (commits a5a3d39353d host, eaea23ead94 browser). This issue auto-closed via the PR's Closes #12648.

    What landed (the #12246 fix pair, ported to the post-#12242 screen_msgpack shape and verified this time):

    • Host: BaselineCache::viewport_for — participant-bound, non-consuming peek; joined() restores the connection viewport from the retained baseline before the first send_view consumes the one-shot token. Token semantics unchanged: still a cursor, misses still get a full view, join authorization untouched.
    • Browser: token + surface + revision are retained as one unit across reconnects, adopted together from every applied view (JSON patch, JSON full screen, MessagePack patch), and offered in the join frame when the unit is complete. A same-size resize no longer goes out on a resumable reconnect; a real viewport change or a forced resync drops all three together. The read-only host view clears the token with the surface.

    Coverage, as the issue required:

    • Host regression a_resume_token_restores_the_viewport_before_catching_up (reconnect at a non-default viewport → catch-up patch against the retained base) — run and green; it replaces a_wrong_viewport_resume_token_falls_back_to_a_full_view, whose premise is exactly the defect. Plus viewport_for_peeks_without_consuming for the peek's contract.
    • Browser web/src/world-resume.test.ts: a catch-up patch applies after reconnect with no intervening resize, and a viewport change drops the unit — run and green.

    Verification (laptop, pkgs/id nix dev shell, branch head eaea23ead94):

    • Failing first: with tests only, the host test failed at the catch-up-patch assertion and the browser test failed on the missing join resume_token.
    • cargo test -p id-worlds --lib resume — 14 passed. Full cargo test -p id-worlds --lib — 910 passed, 1 failed: the shell_contract join.device_input disagreement, reproduced identically on pristine main and filed as id: shell contract test fails on main — join.device_input null disagreement between contract and host #12703 (unrelated; not a remainder of this issue).
    • bun run test (full web unit) — 881 passed, 9 skipped (879 baseline + 2 new). bun run typecheck clean; biome format/lint clean on touched files; cargo fmt --check clean for touched files; no clippy warnings at touched locations.

    No remainder: both scope bullets and both coverage items are in the merged PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions