Skip to content

Fix multi-instance support on same page - #30

Draft
matipojo wants to merge 9 commits into
masterfrom
fix-multi-instances
Draft

Fix multi-instance support on same page#30
matipojo wants to merge 9 commits into
masterfrom
fix-multi-instances

Conversation

@matipojo

@matipojo matipojo commented Mar 15, 2026

Copy link
Copy Markdown
Member

Summary

  • openIframe() now returns { iframe, iframeOrigin } so callers can post messages directly to a specific iframe instance.
  • loadSidebar() sends sdk-widget-config directly to the instance's iframe via postMessage instead of using the shared postMessageToAngieIframe helper, preventing config cross-talk when multiple SDK instances coexist on the same page.
  • Removed the postMessageToAngieIframe import from angie-mcp-sdk.ts since it's no longer needed there.

Test plan

  • Updated existing widget-config tests to assert postMessage is called on the correct iframe with the correct origin
  • Added test for mobile case where openIframe returns undefined — widget config is silently skipped
  • Verified no regressions in other test suites

✨ PR Description

Purpose: Fix multi-instance support to enable multiple Angie SDK instances on the same page with proper iframe isolation and message routing.

Main changes:

  • Added instance-based message filtering using instanceId in sidebar toggle events to prevent cross-instance interference
  • Refactored openIframe to return iframe reference and origin, enabling direct postMessage instead of global helper
  • Added path validation security check and configurable path option with ModeSwitcher and closeButton widget config

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how

matipojo and others added 8 commits March 15, 2026 01:47
- Export ModeSwitcherConfig type from SDK and index
- Add path validation in openIframe to prevent origin override via
  absolute URLs or protocol-relative paths
- Add tests for modeSwitcher/closeButton widget config forwarding
- Add tests for path validation
Return iframe reference and origin from openIframe() so each SDK
instance posts widget-config directly to its own iframe instead of
broadcasting via the shared postMessageToAngieIframe helper.
This prevents config cross-talk when multiple instances coexist.
@wiz-9a149474ff

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 1 Low
Software Management Finding Software Management Findings -
Total 1 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@matipojo
matipojo marked this pull request as draft June 18, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant