Skip to content

fix(studio): a held edit answered too late never blanks a page already shown - #9087

Open
miguel-heygen wants to merge 2 commits into
mainfrom
fix/late-stage-hold
Open

miguel-heygen wants to merge 2 commits into
mainfrom
fix/late-stage-hold

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

What

A stage-act hold now says when its parent stops waiting (expiresAt, set by holdPreviewStage from its own timeout). A sealed frame that reads it at or after that time holds nothing and answers late.

Why

holdPreviewStage gives up after its timeout and queues a restore behind the hold, but the hold itself stays in the frame's queue. A frame whose thread was blocked ran it once unblocked, after the host had already shown the page. A title the person could see went blank, then came back.

Related work

Refs #9042, the host step (beforePreviewShown), which gives a host 250 ms to hold a page before it is shown.

How

  • The check runs when the frame reads the message, so it covers any reason the message waited.
  • A late hold is answered with its own op rather than an empty hold, so the parent reads null ("not held") and never "held, nothing to hold". It leaves a session already open alone.
  • expiresAt is wall-clock time, which a page and its sandboxed frame share. It is optional: a hold without it behaves as before.
  • A hold done just before its expiry and answered after it is still given back by the existing restore.

Test plan

  • Unit tests added/updated. Red on main: 3 of the new core tests and 2 in Studio. Green here, 3 runs in a row; core runtime 3951 and Studio player 2905 pass.
  • Manual testing performed: not yet. No real browser has been run with a blocked frame.
  • Documentation updated (not applicable)
  • Comments follow CONTRIBUTING.md "Comments"

Not covered: a frame whose own page replaces Date.now.

@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 275 (base branch 273), smooth 62 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Newly passing (2)

  • seqscaletwice-scale-px-r0-root-z100
  • seqscaletwice-scale-px-r0-nested-z100

Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)

  • seqscaletwice-scale-px-r0-root-z100
  • seqscaletwice-scale-px-r0-nested-z100

Quarantined, measured but not gated (0)

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes on the PR text and one check, not on the code. Reviewed at fa5ad84.

To clear:

  1. The body has no fails without the fix: line. It says "Red on main: 3 of the new core tests and 2 in Studio" but names none. Please add the line with a test name, for example "changes nothing on the page and answers late" (stageAct.test.ts).
  2. Comments is red from this change: stageAct.ts comment share goes from 4.2% to 4.4% (two comment lines added). Cut two lines or move the explanation into a name.
  3. Studio and player captures is red from this change: the body needs ## Before / ## After, or ## No visible change since no .tsx/.css/.html file changes.

The code itself I would approve as it stands:

  • stageAct.ts: the expiry is checked when the frame runs the hold, and a late one answers { op: "late" } without calling start, so nothing on the page is touched and an open session is left alone. expiresAt is optional and refused unless a finite number, so an older parent keeps working.
  • previewStageAct.ts: replyOf already drops a reply whose op differs from the request, so late reads as null ("not held") with no new branch, and the existing restore is still queued behind it.
  • The parent sets Date.now() + timeoutMs from the same timeout it waits on, so the two cannot drift apart.

stageAct.ts and previewStageAct.ts changes read as hunks, plus replyOf / readHeld whole; both test hunks read. Nothing was run. Test (support) is also red; its packages are not the ones changed here and I could not read its log, so I did not count it.

Need: yes · Size: small · Reuse: yes, rides the existing reply check and restore · Simpler: no · Structure: fine
Risk: low. A frame whose clock differs from the parent's would misjudge; the body names that as not covered.

— Rames

@miguel-heygen

Copy link
Copy Markdown
Collaborator Author

Answering the review. Code is unchanged in what it does; the two added comment lines are cut at 02477ab9 and the ratchet passes.

fails without the fix: stageAct.test.ts > "changes nothing on the page and answers late", "leaves what the frame already holds alone" and "is read at the moment the frame gets to it, not when it was sent"; previewStageAct.test.ts > "tells the frame when it stops waiting, so a hold read later is not done" and "returns what the frame held for the keys it asked". All five are red on main.

The browser run the body says was not done: headless Chrome 155 on Linux, the runtime built from each side (this PR's from fa5ad849; 02477ab9 only renames) in a sealed frame in its own process, hidden as Studio hides one (opacity 0), its thread blocked 500 ms while a 240 ms hold waits, shown at 250 ms. 60 runs each, the page recording itself on every frame.

parent gave up title touched after it was shown painted blank after it was shown
main 60 of 60 60 of 60 59 of 60
this PR 60 of 60 0 of 60 0 of 60

Before

The page as shown, then when its thread is free, then a frame later:

Before: the shown title goes blank, then comes back

After

After: the shown title stays

Not run: macOS, Windows, or through Desktop.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. Reviewed at 02477ab. This clears my earlier change request.

The three points:

  1. fails without the fix: now names five tests, in the author's comment rather than the body. I am taking the comment as meeting it, since the captures check counts an author comment the same way; say so if the body is the only place that counts.
  2. Comments passes: the two added comment lines are gone and the meaning moved into the function name (startUnlessParentGaveUp).
  3. Studio and player captures passes on the Before/After in the same comment.

Delta from fa5ad84, byte-compared: one rename and two comment lines removed in stageAct.ts, nothing else. The behaviour I read at the earlier head is unchanged.

Nothing was run by me; the red-on-main claim for the five tests and the 60-run browser table are the author's. No check is red at this head; the rest were pending when I read and I did not wait.

Need: yes · Size: small · Reuse: yes · Simpler: no · Structure: fine
Risk: low, as before. Not run on macOS, Windows or through the desktop app, per the author.

— Rames

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 29, 2026

This branch has not been deployed

No deployments
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.

2 participants