fix(sdk): bridge preview selection into session state#1362
Merged
vanceingalls merged 1 commit intoJun 13, 2026
Conversation
vanceingalls
approved these changes
Jun 13, 2026
vanceingalls
left a comment
Collaborator
There was a problem hiding this comment.
Clean fix — the contract was documented in PreviewAdapter.on("selection") but never wired up in the session constructor. Implementation is correct: updateSelection mirrors the resolved selection without re-interpreting additive (that's the adapter's job before emitting), dispose cleanup is idempotent, and the three tests cover mirror, proxy dispatch, and leak prevention. Good catch, thank you.
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.
Summary
PreviewAdapterselection events.getSelection()/selection().selectionchangefrom the session and clean up the preview listener ondispose().Why
PreviewAdapter.select()is documented as firingselectionchangeon the session, and the SDK React embed example reads selection throughcomp.on("selectionchange")andcomp.getSelection().Before this change,
openComposition(..., { preview })stored the preview adapter but never subscribed to its selection events, so preview-driven selection was not reflected in the SDK session state.Testing
bun run --cwd packages/sdk testbun run --cwd packages/sdk typecheckbunx oxfmt --check packages/sdk/src/session.ts packages/sdk/src/session.test.tsbunx oxlint packages/sdk/src/session.ts packages/sdk/src/session.test.tsgit diff --check