Skip to content

fix(id): reconnect resume retains its baseline; host restores viewport (#12648) - #12704

Merged
dezren39 merged 2 commits into
mainfrom
archer-lane-aq/12648-reconnect-resume
Nov 22, 2026
Merged

dezren39 merged 2 commits into
mainfrom
archer-lane-aq/12648-reconnect-resume

Conversation

@dezren39

@dezren39 dezren39 commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Closes #12648

What

Reconnect resume was degraded at both ends, on the v1/JSON path and the negotiated MessagePack path alike:

  • Browser (web/src/world.ts): the browser never participated in resume — it didn't declare resume_token on the frame type, never adopted the token view frames carry, never offered one at join, and connect() cleared the rendered surface/revision on every reconnect.
  • Host (id-worlds world_session): joined() initialized every connection's viewport to None and never restored it from the retained baseline, so the first resumed view rendered at the program default size and the shape-checked consume in send_view missed for every baseline retained at a non-default viewport.

This ports the two fix commits from the superseded PR #12246 (2b9428d browser, 3751be8 host), adapted to the post-#12242 shape (screen_msgpack negotiation instead of the v2 route), and — unlike #12246 — actually runs the regression coverage.

Host

  • BaselineCache::viewport_for: a participant-bound, non-consuming peek at the viewport a live token's baseline was retained at. take_matching still performs the one-shot, shape-checked consume; a miss still falls back to a full view, and join authorization is untouched.
  • joined() restores the connection viewport from the retained baseline before the first send_view.
  • The old a_wrong_viewport_resume_token_falls_back_to_a_full_view test is replaced by a_resume_token_restores_the_viewport_before_catching_up (WideScreen gains the step counter so a real catch-up patch exists to assert on), plus a unit test pinning that the peek does not consume and is participant-bound.

Browser

  • Token + surface + revision move as one unit: adopted together from every applied view (JSON patch, JSON full screen, and MessagePack patch paths), offered in the join frame when the unit is complete, retained across reconnects.
  • A same-size resize no longer goes out on a resumable reconnect (it resets the host's retained baseline); a real viewport change or a forced resync (patch gap / undecodable binary) drops all three together and asks for a full view. The read-only host view clears the token with the surface.
  • New web/src/world-resume.test.ts: a catch-up patch applies after a reconnect with no intervening resize; a viewport change drops the unit.

Verification (laptop, pkgs/id nix dev shell)

Failing first, tests-only: the new host test failed at the catch-up-patch assertion (full view instead of a patch) and the new browser test failed on the missing join resume_token; the viewport_for unit test passed against the peek alone, isolating the missing restore.

With the fix:

  • cargo test -p id-worlds --lib resume — 14 passed, 0 failed.
  • cargo test -p id-worlds --lib (full) — 910 passed, 1 failed: shell_contract::tests::the_contracts_required_fields_are_exactly_what_the_host_requires (join.device_input null disagreement). Pre-existing on pristine main — reproduced identically in a clean worktree of origin/main (bff67fd) running only that test; filed as id: shell contract test fails on main — join.device_input null disagreement between contract and host #12703.
  • bun run test (web unit, full) — 43 files, 881 passed, 9 skipped (879 baseline + the 2 new tests).
  • bun run typecheck — clean. Biome format + lint on the touched files — clean. cargo fmt --check — clean for the touched files (pre-existing diffs in id-core/id-store files untouched here). Clippy on id-worlds — no warnings at the touched locations.

Run Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

A resume token's retained baseline records the viewport that produced
it, but joined() initialized every connection's viewport to None, so
the first resumed view rendered at the program's default size and the
shape-checked consume in send_view always missed for a baseline
retained at a non-default viewport. The resume was silently a full
view every time.

BaselineCache gains a participant-bound, non-consuming peek
(viewport_for); joined() restores the viewport from the retained
baseline before the first send_view consumes the one-shot token.
take_matching still performs the shape-checked consume, and a miss
still falls back to a full view.

The wrong-viewport test is replaced by the regression this behavior
needs: a_resume_token_restores_the_viewport_before_catching_up (the
test PR #12246 wrote but never ran), plus a unit test pinning that
the peek does not consume. Ported from PR #12246 commit 3751be8,
adapted to the post-#12242 session shape.

Refs #12648
The browser never participated in resume: world.ts did not declare
resume_token on the frame type, never adopted the token view frames
carry, never offered one in the join frame, and connect() cleared the
rendered surface and revision on every reconnect — so even a host
willing to send a catch-up patch had nothing to patch against.

Token, surface, and revision now move as one unit: adopted together
from every applied view (JSON and MessagePack paths), offered in the
join frame when the unit is complete, and retained across reconnects.
A same-size resize no longer goes out on a resumable reconnect (it
resets the host's retained baseline); a real viewport change or a
forced resync drops all three together and asks for a full view.
Host view (the read-only HTTP path) clears the token with the
surface, since its renders are not session baselines.

New world-resume.test.ts carries the coverage #12648 names: a
catch-up patch applies after a reconnect with no intervening resize,
and a viewport change drops the unit. Adapted from PR #12246 commit
2b9428d to the screen_msgpack negotiation that landed in #12242.

Refs #12648
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T22:46:31.308520Z eaea23e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f8b0e27d-89fa-48c8-88eb-5b5d540fa329
Commits

Reviewing files that changed from the base of the PR and between bff67fd and eaea23e.

Files selected for processing: 5

  • pkgs/id/crates/id-worlds/src/world_session/mod.rs
  • pkgs/id/crates/id-worlds/src/world_session/resume.rs
  • pkgs/id/crates/id-worlds/src/world_session/tests.rs
  • pkgs/id/web/src/world-resume.test.ts
  • pkgs/id/web/src/world.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@dezren39
dezren39 merged commit dee25f7 into main Nov 22, 2026
2 checks passed
@dezren39
dezren39 deleted the archer-lane-aq/12648-reconnect-resume branch November 22, 2026 22:45
@dezren39
dezren39 requested a review from a team as a code owner November 22, 2026 22:45
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.

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

1 participant