Repository navigation
fix(web): keep Remote Web loading over plain HTTP without crypto.randomUUID - #22516
Conversation
…omUUID Browsers hide crypto.randomUUID outside secure contexts, so Remote Web over http://<lan-or-tailnet-ip> threw while importing the store and never painted. createAgentStatusAuthorityId now takes its UUID source (renderer passes createBrowserUuid, main passes node:crypto randomUUID), and the other unguarded renderer calls go through createBrowserUuid.
…teBrowserUuid Replaces five hand-rolled crypto?.randomUUID?.() fallbacks (including a copy of the browser-uuid fallback in mint-stable-pane-id) with createBrowserUuid, and adds an oxlint no-restricted-properties rule so renderer code cannot call randomUUID directly again.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- UUID source injected into the authority-id builder —
createAgentStatusAuthorityIdnow takes a() => string, so shared code no longer touchesglobalThis.crypto: the renderer passescreateBrowserUuid, main passesnode:crypto'srandomUUID. Therole:<uuid>format is unchanged. - 21 unguarded renderer call sites routed through
createBrowserUuid— automations, skills install/delete, workspace cleanup, native-chat outbox, agent-status authority actions, settings, desync evidence, and worktree teardown now use the non-secure-context-safe helper. - Five ad-hoc fallbacks consolidated — emulator stream id, open-in ids, desync capture nonce, and
mint-stable-pane-id.ts, whose 18-line inline browser-UUID copy is replaced by the shared helper. - Lint guard — renderer-scoped
no-restricted-propertiesban onrandomUUID, exemptinglib/browser-uuid.tsand tests. Rationale for banning the property (not justcrypto.randomUUID) is sound and covers theglobalThis.crypto?.randomUUID?.()shape. - Regression test — reconstructs the non-secure
cryptoshape, resets modules, and asserts the authority sequencer and store slice load and yield a v4renderer:<uuid>.
Verified this run: the new repro test and the shared/renderer UUID tests pass (15/15), the 14 impacted renderer suites pass (209/209), the lint rule flags both access shapes while leaving browser-uuid.ts clean, and origin/main does call globalThis.crypto.randomUUID() at renderer module load — so the regression test genuinely fails without the fix. Remaining randomUUID references in src/shared are all guarded, and no consumer parses the replaced fallback formats.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughShared and renderer code now use centralized UUID helpers instead of direct crypto calls and local fallback logic. Lint rules restrict direct use of randomUUID in renderer and shared code. Tests cover UUID generation without crypto.randomUUID and renderer module initialization. Terminal render evidence uses a shared capture-ID pattern for generation and main-process validation. Priority: ⬆️ High Severity of issue fixed: High Merge Risk: ⚪ Minimal · up to UUID generation is centralized for Remote Web contexts where Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The identifier changes appear compatible with the checked consumers and preserve validation before terminal evidence is stored. No introduced security finding was established, but the breadth of affected callers and incomplete security coverage leave some uncertainty. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The PR satisfies the UUID-related coding requirements in [
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. Comment |
…/shared The white screen came from src/shared, so the fix belongs there. src/shared had three hand-rolled copies of the same randomUUID-then-getRandomValues-then-Math.random ladder (nested-repo-telemetry, project-groups, setup-agent-sequencing) because there was nothing in that layer to import; createBrowserUuid lived one directory over in the renderer. createNonSecureContextUuid() now holds the single implementation, @/lib/browser-uuid re-exports it under the renderer's existing name so no renderer import site changes, and the three duplicates call it. That also lets createAgentStatusAuthorityId go back to one argument. The injected randomUuid source was justified as keeping browser APIs out of shared code, but this generator is runtime-agnostic — it works unchanged in Node. Injecting it bought no layering and made the safe choice a parameter every future caller had to get right, unguarded: a caller could pass () => globalThis.crypto.randomUUID() and restore the white screen with lint and tests green.
…atch
vite.web.config.ts compiles src/shared straight into the web bundle, but the new
randomUUID ban only covered src/renderer/src — so the exact module that white-screened
the app sat outside the guard it shipped with, and the regression could come back with
a green lint. The override now covers src/shared/**/*.ts too; it costs zero diagnostics
because the duplicates it would have flagged are gone. `import { randomUUID } from
'node:crypto'` is untouched, so main-only shared modules keep working.
Both blanket "off" overrides are gone. no-restricted-properties is keyed by property
name, so the moment a second property joins the renderer block those overrides would
have silently exempted it — in the one file that is the escape hatch, and in every test
in the repo. Tests are where people copy patterns from, so they stay covered; the four
real uses carry line-scoped disables with a reason.
createCaptureId builds `${Date.now()}-${panePart}-${nonce}`. A real paneKey is
`${tabId}:${leafId}` — two UUIDs, 73 chars after sanitizing — so with a 36-char UUID
nonce the id is 124 chars and main rejects it with 'Invalid render-desync capture id'.
persistHealedReference swallows that into console.error, so it shows up as diagnostics
that silently never appear.
This was already broken on the desktop app, where randomUUID is available; routing the
non-secure path through the same generator would have made it unconditional, including
on the plain-HTTP web client this branch exists to repair.
Bound the pane part rather than the nonce: keep the trailing 40 chars, which is the
whole leaf id (the identifying half, unique on its own) and drop the tab-id prefix, so
ids stay unique and traceable at 91 chars. The 120-char contract now lives in
src/shared next to the IPC args, imported by both sides, so the renderer cannot mint an
id main will reject without the test noticing.
…ndomUUID The reported stack was the store chunk, not two named modules, so the repro test now evaluates the store root under the stubbed non-secure crypto. Any new import-time secure-context call anywhere in that graph fails here, not just the one this branch removed. Also ports the request-token regression from stablyai#20465, the one piece of coverage the competing branches for this bug contributed that this one lacked. Both cases fail with "randomUUID is not a function" when their production change is reverted.
|
Heads up @mmarabel — @nwparker has taken this PR over and pushed five commits on top of yours rather than leaving review notes. Nothing of yours was rewritten or force-pushed. Thanks for the branch; the shape was right and that's why it got picked up over the four competing attempts. What changed on top (
Also added the before/after visual proof the body was missing: the real All green locally: |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 932d04b7-f2e9-47e0-a741-146d135c4549
📒 Files selected for processing (15)
.oxlintrc.jsonsrc/main/ipc/terminal-render-desync-evidence.tssrc/renderer/src/components/native-chat/use-structured-agent-session-outbox.test.tsxsrc/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.tssrc/renderer/src/components/terminal-pane/terminal-render-desync-evidence-persistence.test.tssrc/renderer/src/components/terminal-pane/terminal-render-desync-evidence-persistence.tssrc/renderer/src/lib/browser-uuid.tssrc/renderer/src/lib/non-secure-context-crypto.repro.test.tssrc/renderer/src/store/slices/settings.tssrc/shared/agent-status-observation.tssrc/shared/nested-repo-telemetry.tssrc/shared/non-secure-context-uuid.tssrc/shared/project-groups.tssrc/shared/setup-agent-sequencing.tssrc/shared/terminal-render-desync-evidence.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- UUID generator relocated into
src/shared—createNonSecureContextUuid()insrc/shared/non-secure-context-uuid.tsis now the single v4 generator;@/lib/browser-uuidre-exports it, andcreateAgentStatusAuthorityId(role)calls it internally instead of receiving a UUID source argument. - Shared call sites migrated —
nested-repo-telemetry,project-groups, andsetup-agent-sequencingdrop their ad-hoccrypto?.randomUUID?.()fallbacks for the shared helper. - Lint guard broadened to
src/shared/**/*.ts— theno-restricted-propertiesban onrandomUUIDnow covers shared code, and the blanket test-file exemption was replaced with line-level disables at the six test member-access sites. - Render-desync capture ids capped —
createCaptureIdtruncates the pane part to its trailing 40 chars so the id stays under main's 120-char limit, with the validation pattern now shared between renderer and main. - New coverage — a whole-store-graph import test that fails on any import-time secure-context call, an AI-vault request-token test, and three
createCaptureIdtests.
Verified this run: the new and affected suites pass (37 passed, 1 skipped), oxlint src/shared src/renderer/src is clean (0 warnings / 0 errors), every createAgentStatusAuthorityId call site uses the one-arg signature, and no consumer parses the capture-id pane part or the replaced fallback formats.
ℹ️ PR description still describes the reverted injected-source design
The "Mechanism" and "Why" sections of the PR body present createAgentStatusAuthorityId(role, randomUuid) with the renderer/main passing their own UUID source, and explicitly argue against moving the generator into src/shared. Commit 48290d71ed does the opposite, so the body's design rationale now contradicts the code. Worth updating before merge; no code change is needed.
Technical details
# PR body vs. implementation
## Affected sites
- PR body "Mechanism" step 1 — describes `createAgentStatusAuthorityId` taking the UUID source as an argument. Current `src/shared/agent-status-observation.ts:199` takes only `role`.
- PR body "Why" — asks "Why inject the UUID source rather than move `createBrowserUuid` into `src/shared`?" and rejects the move. `src/shared/non-secure-context-uuid.ts` now holds the implementation and `src/renderer/src/lib/browser-uuid.ts:3` is a re-export.
## Required outcome
- The PR description's mechanism and rationale describe the merged design.
## Suggested approach (optional)
- Rewrite step 1 to describe the shared generator that both renderer and main import, and replace the injection rationale with the actual reason: one implementation shared across runtimes while the renderer keeps a stable `@/lib/browser-uuid` import.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ult case randomUUID lives on Crypto.prototype, so stubbing it as an own property of globalThis.crypto left the restore branch with an undefined descriptor and a leaked own `randomUUID: undefined`. Swap the whole crypto own property instead, through one shared stub the repro suite already needed.
|
Follow-up commit d900bce on top of the takeover, addressing the last open item. The AI Vault non-secure-context case I added in dfc4909 had a leaky teardown — coderabbit flagged it and it reproduces: under happy-dom Fixed at the seam rather than by adding a delete branch: both suites now share one Also: the repo's PR CI had never actually run on this branch — both workflows were parked at Locally on the new head: |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 507631e4-4653-448f-8a26-0efa0a246a15
📒 Files selected for processing (3)
src/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.tssrc/renderer/src/lib/non-secure-context-crypto-stub.tssrc/renderer/src/lib/non-secure-context-crypto.repro.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| try { | ||
| return await body() | ||
| } finally { | ||
| Object.defineProperty(globalThis, 'crypto', { configurable: true, value: secureCrypto }) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
set -eu
printf '%s\n' '--- changed file ---'
cat -n src/renderer/src/lib/non-secure-context-crypto-stub.ts
printf '%s\n' '--- helper usages ---'
rg -n -C 3 'withNonSecureContextCrypto|createNonSecureContextCrypto' --glob '!node_modules' .
printf '%s\n' '--- vitest/config/setup references ---'
rg -n -C 3 'vitest|testEnvironment|setupFiles|globalThis\.crypto|crypto' --glob '*.{config,setup}.{js,ts,mjs,cjs}' --glob 'vitest*.{js,ts,mjs,cjs}' --glob '*setup*.{js,ts,mjs,cjs}' src package.json 2>/dev/null || true
printf '%s\n' '--- PR diff for changed file ---'
git diff 563dd5487fb6ca2f9a79b12075df2ed054934d7d..d900bce236275ff6af84b96be88ef77fd340305d -- src/renderer/src/lib/non-secure-context-crypto-stub.tsRepository: stablyai/orca
Length of output: 39904
🏁 Script executed:
set -eu
cat -n src/renderer/src/lib/non-secure-context-crypto-stub.ts
printf '%s\n' '--- usages ---'
rg -n -C 3 'withNonSecureContextCrypto|createNonSecureContextCrypto' --glob '!node_modules' .
printf '%s\n' '--- vitest/setup/config ---'
rg -n -C 3 'vitest|testEnvironment|setupFiles|globalThis\.crypto' --glob '*.{js,ts,mjs,cjs}' --glob 'package.json' . 2>/dev/null || true
printf '%s\n' '--- diff ---'
git diff 563dd5487fb6ca2f9a79b12075df2ed054934d7d..d900bce236275ff6af84b96be88ef77fd340305d -- src/renderer/src/lib/non-secure-context-crypto-stub.tsRepository: stablyai/orca
Length of output: 45668
🏁 Script executed:
set -eu
cat -n src/renderer/src/lib/non-secure-context-crypto-stub.ts
rg -n -C 3 'withNonSecureContextCrypto|createNonSecureContextCrypto|testEnvironment|setupFiles|globalThis\.crypto' --glob '!node_modules' .
git diff 563dd5487fb6ca2f9a79b12075df2ed054934d7d..d900bce236275ff6af84b96be88ef77fd340305d -- src/renderer/src/lib/non-secure-context-crypto-stub.tsRepository: stablyai/orca
Length of output: 33378
🏁 Script executed:
set -eu
printf '%s\n' '--- Vitest config ---'
sed -n '1,55p' config/vitest.config.ts
printf '%s\n' '--- relevant crypto repro test ---'
cat -n src/renderer/src/lib/non-secure-context-crypto.repro.test.ts
printf '%s\n' '--- helper caller test block ---'
sed -n '800,835p' src/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.ts
printf '%s\n' '--- crypto-related package metadata ---'
rg -n -C 2 '"(happy-dom|jsdom|vitest)"' package.json pnpm-lock.yamlRepository: stablyai/orca
Length of output: 7943
🏁 Script executed:
set -eu
sed -n '1,55p' config/vitest.config.ts
cat -n src/renderer/src/lib/non-secure-context-crypto.repro.test.ts
sed -n '800,835p' src/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.ts
rg -n -C 2 '"(happy-dom|jsdom|vitest)"' package.json pnpm-lock.yamlRepository: stablyai/orca
Length of output: 7813
🏁 Script executed:
set -eu
node --no-experimental-webstorage - <<'JS'
const before = Object.getOwnPropertyDescriptor(globalThis, 'crypto')
const secureCrypto = globalThis.crypto
Object.defineProperty(globalThis, 'crypto', {
configurable: true,
value: { getRandomValues: secureCrypto.getRandomValues.bind(secureCrypto) }
})
const during = Object.getOwnPropertyDescriptor(globalThis, 'crypto')
Object.defineProperty(globalThis, 'crypto', { configurable: true, value: secureCrypto })
const after = Object.getOwnPropertyDescriptor(globalThis, 'crypto')
console.log(JSON.stringify({
node: process.version,
before: { configurable: before?.configurable, enumerable: before?.enumerable, hasGet: typeof before?.get === 'function', hasSet: typeof before?.set === 'function', hasValue: 'value' in (before ?? {}) },
during: { configurable: during?.configurable, enumerable: during?.enumerable, hasGet: typeof during?.get === 'function', hasSet: typeof during?.set === 'function', hasValue: 'value' in (during ?? {}) },
after: { configurable: after?.configurable, enumerable: after?.enumerable, hasGet: typeof after?.get === 'function', hasSet: typeof after?.set === 'function', hasValue: 'value' in (after ?? {}) }
}))
JSRepository: stablyai/orca
Length of output: 455
Restore the original globalThis.crypto descriptor.
The Node test environment starts with globalThis.crypto as an accessor. The teardown restores only its value, which leaves an own data property. Later tests can observe different property behavior.
🐛 Suggested fix
- const secureCrypto = globalThis.crypto
+ const originalCryptoDescriptor = Object.getOwnPropertyDescriptor(globalThis, 'crypto')
+ const secureCrypto = globalThis.crypto
...
} finally {
- Object.defineProperty(globalThis, 'crypto', { configurable: true, value: secureCrypto })
+ if (originalCryptoDescriptor) {
+ Object.defineProperty(globalThis, 'crypto', originalCryptoDescriptor)
+ } else {
+ Reflect.deleteProperty(globalThis, 'crypto')
+ }
}There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review at dfc49093e0, one commit (d900bce236) landed — a test-only follow-up to the CodeRabbit leak finding:
- Extracted the non-secure
cryptotest stub into a shared helper — newsrc/renderer/src/lib/non-secure-context-crypto-stub.tsexposescreateNonSecureContextCrypto()(returns{ getRandomValues }bound to the real crypto) andwithNonSecureContextCrypto(body), which swaps the wholeglobalThis.cryptoown property and restores the real object infinally. - Fixed the leaky teardown in the AI-vault suite — the manual own-property
randomUUID: undefinedstub (unrestorable becauserandomUUIDlives onCrypto.prototype) is replaced by the shared helper. - Added a teardown guard case —
leaves the real crypto.randomUUID in place afterwardspins that the restore actually happens, so the silent leak cannot return. - The repro suite now reuses the same helper in
beforeEachand its secure-hash case, dropping the second hand-rolled copy.
Verified this run: both changed suites pass (42/42), the full 39-file diff was read end-to-end, and the prior PR-body staleness note from review 5313811725 is addressed — the description now matches the shared-module design. Both prior pullfrog reviews had zero inline threads, so nothing needed retiring.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…reateBrowserUuid main added `createStructuredAgentSessionOperationId(() => crypto.randomUUID())` in structured-agent-session-launch-options.ts while this branch was open — exactly the regression the new oxlint ratchet exists to catch, and it caught it.
|
CI update and a merge. CI is green. The fork-workflow runs were approved and Merged The ratchet caught a live regression while doing it. main had landed Re-verified on the merge head: repo-wide For the record, two test files fail on my macOS box both on this branch and on unmodified |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Since the prior pullfrog review at d900bce236, one merge commit (612c914ed6) landed — it brings main in and adapts the call site main added while this branch was open, which is exactly the regression shape the new lint ratchet exists to catch:
mainmerged and its newrandomUUIDcall site routed through the helper —structured-agent-session-launch-options.tsnow callscreateStructuredAgentSessionOperationId(createBrowserUuid)instead of() => crypto.randomUUID(), andstructured-agent-session-launch-prompt.tsdoes the same for the refusal-requeue operation id.launch-structured-agent-session.tscarried through — session id and create params usecreateBrowserUuid(alongsidemain's unrelated seed-options andownerVerdictchanges).- Merge preserved every branch-side change — the shared generator, the lint ratchet over
src/renderer/srcandsrc/shared, the render-desync capture-id cap, and the three test suites all survive intact; the only branch-side edits are the three call-site swaps above.
Verified this run: a post-merge sweep finds no unguarded crypto.randomUUID member access left in src/renderer/src or src/shared (only comments, the sanctioned escape hatch, and test disables), oxlint over the changed files reports 0 warnings / 0 errors, and the focused suites (structured-agent-session-launch-options, the non-secure repro, AI Vault, setup-agent-sequencing, structured-agent-session-create) pass 75/75 with 1 skipped. All prior pullfrog reviews have zero inline threads, so nothing needed retiring.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Green on the merge head. Also re-ran the end-to-end proof against the post-merge build rather than trusting the earlier capture: Ready for review. |

ELI5
Browsers only hand out the built-in ID generator
crypto.randomUUID()on pages they consider secure — HTTPS, orlocalhost. Open Orca's Remote Web client at a plainhttp://address on your home network or tailnet and that function simply isn't there.Orca called it while the app was still starting up. The call threw, startup stopped, and you got a permanently blank white page. Orca now uses its own ID generator, which works on secure and non-secure pages alike, and a lint rule stops anyone from reaching for the browser's version again.
What Changed
Before. Opening
http://<lan-or-tailnet-ip>:<port>/web-index.htmlfrom a second device showed a white page that never recovered, withUncaught TypeError: globalThis.crypto.randomUUID is not a functionin the console. Nothing painted. Even past that first crash, the other ~29 direct calls (workspace cleanup, skills install/delete, native-chat outbox, automations, worktree visibility, the AI Vault sidebar) would throw the moment you reached them.After. The page loads and the app works. Every ID generator in the renderer, and in the shared code the web bundle compiles in, survives a non-secure origin.
Mechanism.
src/shared/non-secure-context-uuid.tsholds the single implementation: trycrypto.randomUUID, fall back tocrypto.getRandomValues, fall back toMath.random, always returning a v4 UUID.@/lib/browser-uuidre-exports it under the renderer's existing name, so no renderer import changes.createAgentStatusAuthorityId— the exact function in the reported stack — calls it instead ofglobalThis.crypto.randomUUID().mint-stable-pane-id.tsand three more insrc/shared(nested-repo-telemetry.ts,project-groups.ts,setup-agent-sequencing.ts) that existed only because there was nothing in that layer to import.no-restricted-propertiesban on anyrandomUUIDproperty access undersrc/renderer/src/**andsrc/shared/**. It catches all three real shapes (crypto.randomUUID(),globalThis.crypto?.randomUUID?.(), and destructuring), and leavesimport { randomUUID } from 'node:crypto'alone so main-only shared code is unaffected. It has already earned its keep: mergingmaininto this branch surfaced a brand-newcrypto.randomUUID()call instructured-agent-session-launch-options.tsthat landed while this PR was open, and the rule failed the build until it was routed through the helper.createCaptureIdfor terminal render-desync diagnostics builds${Date.now()}-${paneKey}-${nonce}. A real paneKey is two UUIDs (73 chars), so a 36-char UUID nonce made the id 124 chars — over main's hard 120-char cap, where it is rejected and the failure is swallowed intoconsole.error. It now keeps the trailing leaf id instead of the whole paneKey (91 chars). This was already broken on the desktop app; it is fixed there too.Why
Why a shared module rather than injecting the UUID source? The previous revision of this branch passed the generator into
createAgentStatusAuthorityIdas a parameter, justified as "keeps browser APIs out of shared code." That reasoning doesn't hold: the generator is not a browser API — it's a plain fallback ladder that runs identically in Node. So injection bought no layering, and it turned a settled decision into a parameter every future caller has to get right, unguarded: someone could pass() => globalThis.crypto.randomUUID()and restore this exact white screen with a green lint and a green test suite. The evidence that a shared module was the missing piece sat in the same directory — three independent authors had each hand-rolled the same fallback insrc/sharedbecause there was nothing there to import.Why guard
src/sharedand not just the renderer?vite.web.config.tscompilessrc/sharedstraight into the web bundle, andsrc/shared/agent-status-observation.tsis the module that actually white-screened the app. A guard that stopped atsrc/renderer/srcwould have sat downstream of the defect. Extending it costs zero new diagnostics, because consolidating the three duplicates already cleared every hit.Why line-scoped disables instead of exempting the helper file and all tests?
no-restricted-propertiesis keyed by property name. The two blanket"off"overrides meant the moment a second restricted property joined the rule, it would be silently exempt in the one file that is the escape hatch, and in every test in the repo. Tests are where people copy patterns from, so they stay covered; the handful of legitimate uses carry a one-line disable with a reason.Why not a runtime polyfill on
crypto? It would hide the problem for every other secure-context API check and mutate a global. The helper already existed and was already the house pattern.Linked Issue
Fixes #19667
Fixes #16232
Fixes #18096
#19667 asked for two things. This PR delivers the first: the renderer and the shared code it bundles never call secure-context-only Web Crypto directly, and the regression test imports the real store root rather than a hand-picked module. The second — the pairing UI advertising an
http://origin that can never be a secure context — is a product decision and is now tracked separately as #22774.Supersedes #16235, #18102, #20465 and #13142, each of which fixed one call site (the startup authority id, or the AI Vault refresh token). Thanks to their author. This PR covers both of those, the remaining call sites, the shared-layer duplicates, and the lint guard; it also ports the AI Vault regression test from #20465, which is the one piece of coverage those branches had and this one lacked.
Visual Proof
Both captures are the real built web bundle (
pnpm build:web), served over HTTP and opened in Chromium withcrypto.randomUUIDdeleted before page load — which is exactly what the browser does on a non-secure origin, with no LAN device needed.Before (branch point,
563dd5487fb) — blank page. Measured:performance.getEntriesByType('paint')is[],#root.innerHTML.lengthis0, console showsUncaught globalThis.crypto.randomUUID is not a function— byte-identical to the stack in #19667.After (this branch) — the app paints. Measured: paint entries
["first-paint", "first-contentful-paint"],#root.innerHTML.lengthis5801, zero console errors.Testing
Reproduce the before/after yourself:
pnpm build:web, serveout/web, and openweb-index.htmlin Chromium with an init script that runsdelete crypto.randomUUIDbefore page load. On the branch point you get a blank page and the TypeError above; on this branch the pairing screen renders.Re-run on the post-merge tree, deleting
randomUUIDfrom bothCrypto.prototypeand the instance so it is genuinely absent: paint entries["first-paint", "first-contentful-paint"],#root.innerHTML.length5801, zero page errors — identical to the attached "after" capture, so the merge did not disturb the fix.Automated:
src/renderer/src/lib/non-secure-context-crypto.repro.test.tsstubs the non-securecryptoshape (getRandomValuesonly) and now evaluates the whole store root (await import('@/store')), not two named modules — so any future import-time secure-context call anywhere in that graph fails here.src/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.tscovers the Vault request token withrandomUUIDremoved (ported from fix(web): use createBrowserUuid in non-secure contexts #20465), and asserts the realrandomUUIDis back afterwards.src/renderer/src/lib/non-secure-context-crypto-stub.tsis the single definition of the non-securecryptoshape, shared by both suites. It swaps the wholeglobalThis.cryptoown property rather than stubbingrandomUUIDon it:randomUUIDlives onCrypto.prototype, so an own-property stub has no descriptor to restore and leaks into every later case in the file.src/renderer/src/components/terminal-pane/terminal-render-desync-evidence-persistence.test.tsasserts a capture id built from a realistic two-UUID paneKey matches the sameTERMINAL_RENDER_DESYNC_CAPTURE_ID_PATTERNmain validates against — the pattern now lives insrc/sharedand is imported by both sides, so the two can't drift.Each of those was verified by reverting its production change and confirming it fails, then restoring:
randomUUID is not a functionfor the store-graph and Vault cases, a literal 124-char id against the 120-char pattern for the capture-id case, andexpected 'undefined' to be 'function'for the teardown case.Checks run locally on macOS (arm64), Node 24:
tsc -p config/tsconfig.tc.web.json— cleantsc -p config/tsconfig.node.json— cleanoxlintacross the repo — 0 errorsoxfmt --checkon every changed file — cleanpnpm run check:code-quality:changed— 0 new findings across 38 changed files, all 7 sub-gatespnpm build:web— cleanvitestoversrc/shared,src/renderer/src/lib,src/renderer/src/store,src/renderer/src/components/{terminal-pane,right-sidebar,native-chat}and the render-desync IPC test: 2643 files, 26747 passingPlatforms exercised locally: macOS (arm64) host, plus Chromium rendering the real web bundle on a plain-HTTP origin. Windows and Linux were not exercised locally; there is no platform-dependent code in this diff, and repo CI covers those legs.
Repo CI: these runs are gated behind fork-workflow approval, so nothing executed on GitHub until it was approved.
PR Checksthen ran green end to end ond900bce— typecheck, static analysis,package,package (windows), relay integration and all 8 Linux test shards. This branch has since mergedmain(one conflict inlaunch-structured-agent-session.ts, resolved by keeping both sides), and the same suite then ran green again on the merge head612c914: typecheck, static analysis,package,package (windows), relay integration and all 8 Linux test shards.mergeStateStatusisCLEAN.AI Disclosure
Original PR written with Claude Opus 5.5 in the pi coding agent by the contributor. The takeover commits were written with Claude Opus 5 and reviewed by @nwparker.
Review
crypto.getRandomValues, which browsers keep available in non-secure contexts. TheMath.randomtier only runs where there is no Web Crypto at all.open-in-<base36>,project-group-<ts>-<rand>) whenrandomUUIDwas missing. They now always get a UUID — which is what the primary path already produced, so nothing that parses them changes.Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
role:<uuid>format, so no reader changes.createAgentStatusAuthorityIdstill mints one fresh id per process start, for the same reason as before (a restarted authority's revision counter must not be comparable with its earlier observations). Only the source of randomness changed.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass locally on macOS; repo CI ran fully green on Linux and Windows, ond900bceand again on the merge head612c914