Skip to content

fix(sdk): bridge preview selection into session state#1362

Merged
vanceingalls merged 1 commit into
heygen-com:mainfrom
kiyeonjeon21:kj/sdk-preview-selection-bridge
Jun 13, 2026
Merged

fix(sdk): bridge preview selection into session state#1362
vanceingalls merged 1 commit into
heygen-com:mainfrom
kiyeonjeon21:kj/sdk-preview-selection-bridge

Conversation

@kiyeonjeon21

Copy link
Copy Markdown
Contributor

Summary

  • Subscribe SDK sessions to PreviewAdapter selection events.
  • Mirror preview-selected ids into getSelection() / selection().
  • Emit selectionchange from the session and clean up the preview listener on dispose().

Why

PreviewAdapter.select() is documented as firing selectionchange on the session, and the SDK React embed example reads selection through comp.on("selectionchange") and comp.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 test
  • bun run --cwd packages/sdk typecheck
  • bunx oxfmt --check packages/sdk/src/session.ts packages/sdk/src/session.test.ts
  • bunx oxlint packages/sdk/src/session.ts packages/sdk/src/session.test.ts
  • git diff --check

@vanceingalls vanceingalls 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.

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.

@vanceingalls vanceingalls merged commit 84a5698 into heygen-com:main Jun 13, 2026
35 checks passed
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