Skip to content

fix(ui/tabs): crypto.randomUUID fallback for non-secure contexts - #177

Merged
luokerenx4 merged 2 commits into
masterfrom
dev
May 12, 2026
Merged

fix(ui/tabs): crypto.randomUUID fallback for non-secure contexts#177
luokerenx4 merged 2 commits into
masterfrom
dev

Conversation

@luokerenx4

@luokerenx4 luokerenx4 commented May 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Browser tab id generation crashed for testers accessing OpenAlice over a
plain-HTTP LAN-IP URL — crypto.randomUUID is only defined in secure
contexts. Fix is a self-contained UUIDv4 fallback in ui/src/tabs/store.ts
that uses crypto.getRandomValues (which IS available over HTTP) and
falls back to Math.random if even that is missing. Also adds a
.playwright-mcp/ entry to .gitignore for the session-scoped browser
debug artifacts that the Playwright MCP server drops when an agent runs
end-to-end verification.

Per-session contributions

2026-05-12 — Crypto.randomUUID secure-context fix

  • newId() in ui/src/tabs/store.ts now feature-tests crypto.randomUUID
    and synthesizes a v4 id from crypto.getRandomValues (or Math.random)
    when it is undefined.
  • Why: a tester reported TypeError: crypto.randomUUID is not a function
    on first page load. The regression landed with the workspace store
    in b1f1ec8 / 82aecd9 — local dev (http://localhost:3002) is a
    secure context so it went unnoticed; LAN-IP HTTP access is not.
  • Add .playwright-mcp/ to .gitignore so Playwright MCP's per-session
    console logs / accessibility snapshots stop polluting untracked status.
  • Key commits: 0814b1d, 42c4e7b

Full commit log

42c4e7b chore: gitignore .playwright-mcp/
0814b1d fix(ui/tabs): crypto.randomUUID fallback for non-secure contexts

Test plan

  • npx tsc --noEmit clean (root + ui/ package)
  • pnpm test — 86 files / 1675 tests pass from repo root
  • Bundle confirms fallback shipped (grep getRandomValues dist/ui/assets/index-*.js)
  • Live verification via Playwright MCP — with crypto.randomUUID deleted at runtime, clicking Market → Browse Markets creates a tab with a valid v4 id and zero console errors. Same gesture before the fix throws TypeError: crypto.randomUUID is not a function at openOrFocus.

🤖 Generated with Claude Code

Ame and others added 2 commits May 12, 2026 14:12
`crypto.randomUUID()` is only defined in secure contexts (HTTPS /
localhost). LAN-IP HTTP access — exactly how external testers reach a
self-hosted OpenAlice — gets `undefined`, so opening the very first tab
threw `TypeError: crypto.randomUUID is not a function` on a fresh tester
session.

Build a v4 id ourselves using `crypto.getRandomValues` (available over
HTTP) when `randomUUID` is missing, with a `Math.random` last resort.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Playwright MCP saves accessibility snapshots and console logs under
`.playwright-mcp/` whenever an agent uses the browser tools for
verification — they're per-session debug artifacts, not source.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@luokerenx4
luokerenx4 merged commit 742ebc6 into master May 12, 2026
2 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.

1 participant