opencove icon indicating copy to clipboard operation
opencove copied to clipboard

fix: polyfill renderer randomUUID

Open InitialMoon opened this issue 5 months ago • 1 comments

💡 Change Scope

  • [x] Small Change: Fast feedback, localized UI/logic, low-risk.
  • [ ] Large Change: New feature, cross-boundary logic, runtime-risk (persistence, IPC, lifecycle, recovery).

📝 What Does This PR Do?

Fixes a Web UI runtime crash when creating nodes such as Agent nodes in browsers that do not expose crypto.randomUUID.

The renderer already assumes crypto.randomUUID() is available in several UI creation paths. In the Worker Web UI, that API may be missing depending on the browser/runtime context, which causes actions like creating an Agent node to throw crypto.randomUUID is not a function.

This change installs a small renderer bootstrap compatibility layer. If crypto.randomUUID is unavailable, it defines a UUID v4-compatible fallback using crypto.getRandomValues. Both the desktop renderer entry and the Web UI renderer entry install the fallback before rendering the app.

No new automated test is included because this is a runtime compatibility shim for browsers where crypto.getRandomValues exists but crypto.randomUUID is unavailable. The existing node/Agent creation paths already call crypto.randomUUID; the bug only appears in that specific Web UI runtime capability gap. I manually verified the Worker Web UI bundle includes ensureRandomUuid() and that Agent creation succeeds after a hard refresh.


🏗️ Large Change Spec (Required if "Large Change" is checked)

Not applicable. This PR is classified as a Small Change because it adds a localized renderer compatibility fallback for crypto.randomUUID and does not introduce cross-boundary state ownership, persistence, IPC, lifecycle, or recovery changes.

1. Context & Business Logic

N/A

2. State Ownership & Invariants

N/A

3. Verification Plan & Regression Layer

N/A


✅ Delivery & Compliance Checklist

  • [x] My code passes the ultimate gatekeeper: pnpm pre-commit is completely green.
  • [x] I have signed the CLA if required (see CLA.md).
  • [x] I have included new tests to lock down the behavior (or explicitly stated why it's untestable).
  • [x] I have strictly adhered to the DEVELOPMENT.md architectural boundaries.
  • [x] I have attached a screenshot or screen recording (if this touches the UI).
  • [x] I have updated the documentation accordingly (if adding a feature or changing a contract).

📸 Screenshots / Visual Evidence

image b3ee5517-c9c4-4661-ad57-775dc96158f5

I have read and agree to the OpenCove Contributor License Agreement.

InitialMoon avatar Jun 06 '26 18:06 InitialMoon

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 06 '26 18:06 CLAassistant