Skip to content

fix(widget): carry landing message in the URL as well as window.name#8

Merged
mike-doctorina merged 1 commit into
masterfrom
widget-message-handoff-hardening
Jun 18, 2026
Merged

fix(widget): carry landing message in the URL as well as window.name#8
mike-doctorina merged 1 commit into
masterfrom
widget-message-handoff-hardening

Conversation

@mike-doctorina

Copy link
Copy Markdown
Collaborator

Part of DoctorinaAI/doctorina#3940 (epic DoctorinaAI/doctorina#3911). Pairs with app-side PR DoctorinaAI/doctorina#3941.

Problem

The widget's primary path passed the typed message to the web app only via window.name. window.name lives in the originating browser tab, so when an iOS universal-link intercept tears that tab down (the app.doctorina.com deep-link bug fixed app-side in #3941), the payload is destroyed and the message is lost. The URL carried no copy on this path.

Change

  • src/widget/tab-opener.ts: on the primary (window.open) path, also carry the message in the destination URL (buildTargetUrl(config, text)), so it survives a lost window.name. The web app already reads window.name first and falls back to the URL hash, so there's no double-handling — the hash is pure backup. The popup-blocked fallback is unchanged.
  • Exported buildTargetUrl and normalizeMessage.
  • Added tests/widget-tab-opener.test.ts — first unit tests for the widget's URL construction (default target, auto_accept_policies/referrer, default + overridable utm_medium, custom params, hash round-trip incl. unicode, custom target URL). 8 passed.

Notes

  • This keeps the current plaintext transport (hardening only). The token-only handoff (#3911 §6, message stored server-side, only a token in the URL) is the long-term replacement and is tracked separately.
  • No behavior change for the popup-blocked path or for embedders' data-* config.

npm run type-check, eslint, and vitest all pass.

The primary path passed the typed message only via window.name, which is destroyed when an iOS universal-link intercept tears down the originating tab — so the message was lost. Send it over both channels (window.name + URL hash); the web app reads window.name first and falls back to the hash.

Also export buildTargetUrl/normalizeMessage and add unit tests for URL construction (none existed).

Refs DoctorinaAI/doctorina#3940
@github-actions

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 75c0eb3):

https://doctorina-pages--pr-8-wcxf2c5t.web.app

(expires Thu, 25 Jun 2026 13:04:30 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 9cce88f2a7a5916aaad58a2b37340f46f15c32e8

@mike-doctorina mike-doctorina merged commit 8576ef2 into master Jun 18, 2026
6 checks passed
@mike-doctorina mike-doctorina deleted the widget-message-handoff-hardening branch June 18, 2026 15:56
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