Skip to content

fix(renderer): support status authority without randomUUID - #16235

Closed
psh4607 wants to merge 1 commit into
stablyai:mainfrom
psh4607:fix/web-crypto-uuid-fallback
Closed

psh4607 wants to merge 1 commit into
stablyai:mainfrom
psh4607:fix/web-crypto-uuid-fallback

Conversation

@psh4607

@psh4607 psh4607 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

ELI5

Plain-HTTP browsers can expose crypto.getRandomValues without exposing crypto.randomUUID. Orca created the renderer's agent-status authority ID while its module loaded, so that missing method could blank the web client before the UI started. The renderer now uses Orca's existing browser-safe UUID creator for that one ID.

What Changed

  • Let createAgentStatusAuthorityId accept an optional UUID creator while preserving its native crypto.randomUUID default.
  • Supply createBrowserUuid when the renderer creates its import-time authority singleton.
  • Extend the existing non-secure-context crypto repro suite to import the real renderer module and require a renderer-prefixed UUIDv4 authority ID.

Why

This fixes the startup crash at its runtime boundary without copying another UUID fallback into shared code. Main-process agent hooks keep their existing default behavior, and authority IDs remain distinct per process instance.

Linked Issue

Fixes #16232

Visual Proof

N/A — this changes no appearance or interaction design; it prevents an import-time web-client crash.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • RED: pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/lib/non-secure-context-crypto.repro.test.ts failed only the new case with TypeError: globalThis.crypto.randomUUID is not a function at createAgentStatusAuthorityId.

  • GREEN: the same focused suite passed 5/5 on Node 24.18.0.

  • Adjacent renderer/shared matrix: 7 files, 55 tests passed.

  • pnpm lint passed, including 89 reliability gates and the max-lines ratchet.

  • pnpm typecheck passed; targeted Node and web typechecks also passed.

  • env -u HISTFILE ZDOTDIR=/var/empty pnpm test passed 6,134 files and 57,704 tests, with 39 files and 239 tests skipped by the repository.

  • pnpm build passed for desktop, web, relay, CLI, and native macOS targets.

  • Automated validation ran on macOS. Linux, Windows, SSH/paired runtime, and plain-HTTP browser pairing were not manually exercised.

AI Disclosure

OpenAI Codex (GPT-5) was used to investigate, implement, test, and self-review this change.

Review

  • Correctness: The new test executes the real import-time singleton path with the reported missing-randomUUID global. Shared uniqueness coverage and renderer observation tests remain green.
  • Security: No authentication, credential, secret, or trust boundary changes. The authority ID is ordering provenance, not a security token, and the renderer reuses the existing browser UUID policy.
  • Cross-platform: No platform-specific paths, processes, shortcuts, native modules, or shell behavior changed. Node/main keeps the native default; web uses the existing browser-safe provider.
  • Remote/local/mixed versions: No wire schema, RPC, stream opcode, persistence, or published payload changed. Local, SSH, paired, folder-workspace, and mixed client/host behavior therefore keep the same protocol surface.
  • Agents/integrations/providers: Provider-neutral status sequencing only; no agent, integration, or Git-provider behavior changed.
  • Performance: One injected function call runs once when the renderer module initializes. No polling, I/O, subscriptions, or hot-path work was added.
  • UI/mobile: No layout, styling, interaction, or mobile code changed. Visual proof is not applicable.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • No manual HTTP pairing, UI validation, screenshot, or video was performed.
  • X / Twitter: Not provided.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@psh4607
psh4607 marked this pull request as ready for review August 24, 2026 09:02
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 925486f5-75f3-4f8a-8fc0-c11873a7701d

📥 Commits

Reviewing files that changed from the base of the PR and between afd76a4 and 00e8dbe.

📒 Files selected for processing (3)
  • src/renderer/src/lib/non-secure-context-crypto.repro.test.ts
  • src/renderer/src/lib/renderer-agent-status-observations.ts
  • src/shared/agent-status-observation.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The authority ID factory now accepts an optional UUID generator while retaining its default cryptographic UUID behavior and role-prefixed format. Renderer status observations pass the browser UUID generator during authority initialization. Tests reset modules and verify that initialization produces a correctly formatted renderer: UUID when crypto.randomUUID is unavailable.

Merge Risk: ⚪ Minimal · up to 00e8d

This localized change prevents a renderer startup failure in browsers without crypto.randomUUID while preserving existing behavior elsewhere; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the renderer fix for missing randomUUID support.
Description check ✅ Passed The description covers the required sections, explains the fix, links issue #16232, documents testing, and marks visual proof as not applicable.
Linked Issues check ✅ Passed The changes address issue #16232 by preventing the renderer startup crash when crypto.randomUUID is unavailable and adding regression coverage.
Out of Scope Changes check ✅ Passed All code and test changes directly support insecure-context renderer UUID handling and contain no unrelated behavior changes.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker

Copy link
Copy Markdown
Contributor

Flagging overlap rather than closing: #22516 now covers this bug end to end — every crypto.randomUUID call site in src/renderer/src and src/shared, one shared generator instead of the per-site fallbacks, and an oxlint ratchet over both layers so a new call site cannot regress it. It also carries a before/after of the real web bundle on a non-secure origin.

The AI Vault request-token test from #20465 has been ported into #22516, so that coverage is not lost. A maintainer should close this in favour of #22516 unless it covers something #22516 misses — if it does, please say so on #22516.

@nwparker

nwparker commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded by #22516, which is merged and present on main.

I checked this PR's scope and discussion against the merged implementation. The replacement explicitly supersedes this PR and covers its requested behavior. Thanks for the contribution; the branch is preserved.

@nwparker nwparker closed this Oct 6, 2026
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.

[Bug]: Web client white-screens over HTTP when crypto.randomUUID is unavailable

2 participants