fix: scope Browser previews to each Run - #2002
Merged
Merged
Conversation
4pmtong
force-pushed
the
feat/route-browser-previews-to-owning-session
branch
2 times, most recently
from
October 2, 2026 07:55
bb73f31 to
0db9834
Compare
4pmtong
marked this pull request as ready for review
October 2, 2026 14:15
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.
Pull Request
Related Issue
Description
A Session can reuse one SSE transport for later Runs. Browser preview handoff state previously lived for the transport lifetime, so a preview shown by the first Run could suppress a later explicit preview request, and an unkeyed pending visit from the old Run could be reused by the new one.
This change scopes preview handoff state to the Run. Protection in production comes from two mechanisms:
updateLockedReferences), a new handoff is created, so a follow-up Run gets its own reveal and pending-visit state.ACTIVATE_TOOLKITand completion-tail frames now pass the transport ownership gate before projection or URL recording: frames from an aborted transport, or from a transport no longer bound to the owning Run, are dropped. This covers late activations after a Resume or a restarted task.Within a single reused transport, the backend emits the old Run's frames and the follow-up's
CONFIRMED/NEW_TASK_STATEfrom one serial queue, so an old Run's unkeyed frame cannot arrive after the switch.The gate also rejects frames whose explicit
run_id/project_id(top level or underdata) conflicts with the transport owner. This is a forward-compatible defensive layer and is inactive today: legacy/chatframes carry onlystepanddata, with no Run or Project ids. Tests that exercise it are labelled "forward-compatible id guard".Existing behavior remains intact: each Run reveals at most one preview, only supported local URLs are handed off, and managed-profile Browser capabilities are unchanged.
This fixes the reproduced reused-transport path. The broader historical report remains partial until the original model/tool scenario is repeated in a release build.
Testing Evidence (REQUIRED)
What is the purpose of this pull request?
Contribution Guidelines Acknowledgement