Skip to content

fix(web): keep Remote Web loading over plain HTTP without crypto.randomUUID - #22516

Merged
nwparker merged 8 commits into
stablyai:mainfrom
mmarabel:mmarabel/fix-remote-web-uuid-19667
Sep 25, 2026
Merged

nwparker merged 8 commits into
stablyai:mainfrom
mmarabel:mmarabel/fix-remote-web-uuid-19667

Conversation

@mmarabel

@mmarabel mmarabel commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Browsers only hand out the built-in ID generator crypto.randomUUID() on pages they consider secure — HTTPS, or localhost. Open Orca's Remote Web client at a plain http:// 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.html from a second device showed a white page that never recovered, with Uncaught TypeError: globalThis.crypto.randomUUID is not a function in 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.

  1. One generator, in the layer the bug came from. src/shared/non-secure-context-uuid.ts holds the single implementation: try crypto.randomUUID, fall back to crypto.getRandomValues, fall back to Math.random, always returning a v4 UUID. @/lib/browser-uuid re-exports it under the renderer's existing name, so no renderer import changes. createAgentStatusAuthorityId — the exact function in the reported stack — calls it instead of globalThis.crypto.randomUUID().
  2. Every unguarded call site moved over, including an 18-line hand-rolled copy of the same fallback in mint-stable-pane-id.ts and three more in src/shared (nested-repo-telemetry.ts, project-groups.ts, setup-agent-sequencing.ts) that existed only because there was nothing in that layer to import.
  3. A lint ratchet, so call site N+1 cannot regress: an oxlint no-restricted-properties ban on any randomUUID property access under src/renderer/src/** and src/shared/**. It catches all three real shapes (crypto.randomUUID(), globalThis.crypto?.randomUUID?.(), and destructuring), and leaves import { randomUUID } from 'node:crypto' alone so main-only shared code is unaffected. It has already earned its keep: merging main into this branch surfaced a brand-new crypto.randomUUID() call in structured-agent-session-launch-options.ts that landed while this PR was open, and the rule failed the build until it was routed through the helper.
  4. A capture-id overflow this change would otherwise have made worse. createCaptureId for 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 into console.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 createAgentStatusAuthorityId as 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 in src/shared because there was nothing there to import.

Why guard src/shared and not just the renderer? vite.web.config.ts compiles src/shared straight into the web bundle, and src/shared/agent-status-observation.ts is the module that actually white-screened the app. A guard that stopped at src/renderer/src would 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-properties is 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 with crypto.randomUUID deleted 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.length is 0, console shows Uncaught globalThis.crypto.randomUUID is not a function — byte-identical to the stack in #19667.

before.png

After (this branch) — the app paints. Measured: paint entries ["first-paint", "first-contentful-paint"], #root.innerHTML.length is 5801, zero console errors.

after.png

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Reproduce the before/after yourself: pnpm build:web, serve out/web, and open web-index.html in Chromium with an init script that runs delete crypto.randomUUID before 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 randomUUID from both Crypto.prototype and the instance so it is genuinely absent: paint entries ["first-paint", "first-contentful-paint"], #root.innerHTML.length 5801, 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.ts stubs the non-secure crypto shape (getRandomValues only) 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.ts covers the Vault request token with randomUUID removed (ported from fix(web): use createBrowserUuid in non-secure contexts #20465), and asserts the real randomUUID is back afterwards.
  • src/renderer/src/lib/non-secure-context-crypto-stub.ts is the single definition of the non-secure crypto shape, shared by both suites. It swaps the whole globalThis.crypto own property rather than stubbing randomUUID on it: randomUUID lives on Crypto.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.ts asserts a capture id built from a realistic two-UUID paneKey matches the same TERMINAL_RENDER_DESYNC_CAPTURE_ID_PATTERN main validates against — the pattern now lives in src/shared and 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 function for the store-graph and Vault cases, a literal 124-char id against the 120-char pattern for the capture-id case, and expected 'undefined' to be 'function' for the teardown case.

Checks run locally on macOS (arm64), Node 24:

  • tsc -p config/tsconfig.tc.web.json — clean
  • tsc -p config/tsconfig.node.json — clean
  • oxlint across the repo — 0 errors
  • oxfmt --check on every changed file — clean
  • pnpm run check:code-quality:changed — 0 new findings across 38 changed files, all 7 sub-gates
  • pnpm build:web — clean
  • vitest over src/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 passing

Platforms 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 Checks then ran green end to end on d900bce — typecheck, static analysis, package, package (windows), relay integration and all 8 Linux test shards. This branch has since merged main (one conflict in launch-structured-agent-session.ts, resolved by keeping both sides), and the same suite then ran green again on the merge head 612c914: typecheck, static analysis, package, package (windows), relay integration and all 8 Linux test shards. mergeStateStatus is CLEAN.

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

  • Security: these ids label local UI operations and correlate telemetry; they are not credentials or tokens. The first fallback is crypto.getRandomValues, which browsers keep available in non-secure contexts. The Math.random tier only runs where there is no Web Crypto at all.
  • Behaviour change in fallback id shapes: open-in-app ids, emulator stream ids, project-group ids, setup-sequence nonces and desync capture nonces previously used ad-hoc formats (open-in-<base36>, project-group-<ts>-<rand>) when randomUUID was missing. They now always get a UUID — which is what the primary path already produced, so nothing that parses them changes.
  • Render-desync capture ids get shorter (91 chars instead of 124). Ids are opaque directory names; nothing parses them, and older directories on disk are untouched.

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

  • Cross-platform: no platform-specific behaviour. The generator is runtime-agnostic; Electron main and Node hit the first branch, browsers on non-secure origins hit the second.
  • SSH / remote: none of these ids cross the execution boundary or the client/host wire. The main process's agent-status authority id keeps the identical role:<uuid> format, so no reader changes.
  • Agent status: createAgentStatusAuthorityId still 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.
  • Mobile / backwards compatibility: no wire format, persisted format, or IPC shape changed.
  • Performance: unchanged.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • 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 locally on macOS; repo CI ran fully green on Linux and Windows, on d900bce and again on the merge head 612c914

…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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • UUID source injected into the authority-id builder — createAgentStatusAuthorityId now takes a () => string, so shared code no longer touches globalThis.crypto: the renderer passes createBrowserUuid, main passes node:crypto's randomUUID. The role:<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-properties ban on randomUUID, exempting lib/browser-uuid.ts and tests. Rationale for banning the property (not just crypto.randomUUID) is sound and covers the globalThis.crypto?.randomUUID?.() shape.
  • Regression test — reconstructs the non-secure crypto shape, resets modules, and asserts the authority sequencer and store slice load and yield a v4 renderer:<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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 935dfda2-3091-45e6-a0a8-b4203f257a36

📥 Commits

Reviewing files that changed from the base of the PR and between d900bce and 612c914.

📒 Files selected for processing (3)
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox.test.tsx
  • src/renderer/src/lib/launch-structured-agent-session.ts
  • src/renderer/src/lib/structured-agent-session-launch-options.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox.test.tsx

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


📝 Walkthrough

Walkthrough

Shared 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 612c9

UUID generation is centralized for Remote Web contexts where crypto.randomUUID() is unavailable. The test restores the original crypto object, and no actionable merge-blocking risk remains in the supplied change context.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 612c9

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
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The checked effects span renderer session identifiers, shared agent-status identity, and local terminal evidence names. They do not establish a new credential, service authority, or cross-tenant boundary.

Trust Boundaries and Controls

  • observed — Main rejects capture IDs that fail the shared pattern and limits evidence payloads before writing terminal pixels and metadata with private local-file modes.

Resilience and Maintainability Implications

  • inferred — The changed capture-key construction does not itself alter the checked renderer persistence cleanup or the main writer's validation and write sequence; sequential files are not shown to form an atomic transaction.

Hardening Proposals

  • proposed — If any UUID consumer comes to rely on unpredictability for authorization rather than identity or correlation, require a cryptographic generator at that consumer instead of relying on the shared fallback.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR satisfies the UUID-related coding requirements in [#19667] and [#16232]. createNonSecureContextUuid uses randomUUID, then getRandomValues, then Math.random. Renderer and shared call sit… Implement the [#19667] pairing requirement by serving non-loopback web access through HTTPS/WSS, or stop offering the non-loopback “Open in browser” URL while retaining supported localhost/native pairing options.
Docstring Coverage ⚠️ Warning Docstring coverage is 16.28% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 42 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The changes remain connected to the linked Remote Web failures. UUID helper consolidation, renderer and shared call-site updates, lint restrictions, non-secure-context tests, and AI Vault coverage sup…
Title check ✅ Passed The title clearly and concisely identifies the primary change: keeping Remote Web loading over plain HTTP when crypto.randomUUID is unavailable.
Description check ✅ Passed The description covers all required template sections, including the user impact, implementation details, rationale, linked issues, visual proof, testing, AI disclosure, review considerations, and che…
Full details: Linked Issues check

Explanation

The PR satisfies the UUID-related coding requirements in [#19667] and [#16232]. createNonSecureContextUuid uses randomUUID, then getRandomValues, then Math.random. Renderer and shared call sites use the helper. The regression tests remove randomUUID, load the renderer and store paths, and cover the AI Vault token path. The Agents refresh path in [#18096] also uses the helper with regression coverage. However, [#19667] also requires that non-loopback HTTP pairing does not advertise an unusable browser URL. This PR does not add HTTPS/WSS or remove that URL.

  • Fix all pre-merge checks with AI

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.

…/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.
@nwparker

nwparker commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

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 (f022db3...d900bce):

  1. refactor(shared) — moved the generator into src/shared/non-secure-context-uuid.ts, with @/lib/browser-uuid re-exporting it, so no renderer import site changed. This let createAgentStatusAuthorityId go back to one argument. The injected randomUuid parameter was the one call I'd reverse: the justification ("keeps browser APIs out of shared code") doesn't hold, since the generator is a plain fallback ladder that runs identically in Node — so the injection bought no layering, and an unguarded parameter means a future caller can pass () => globalThis.crypto.randomUUID() and restore this exact white screen with lint and tests green. The same move let the three hand-rolled copies already sitting in src/shared (nested-repo-telemetry.ts, project-groups.ts, setup-agent-sequencing.ts) collapse into it.
  2. fix(lint) — extended the randomUUID ban to src/shared/**. vite.web.config.ts compiles that directory into the web bundle, and agent-status-observation.ts is where the crash actually lived, so the guard was sitting downstream of the defect. It costs zero new diagnostics because step 1 cleared the hits. Also replaced the two blanket "off" overrides with line-scoped disables: no-restricted-properties is keyed by property name, so exempting the helper file and every test in the repo would have silently exempted the next restricted property too.
  3. fix(terminal) — one real bug the migration introduced. createCaptureId builds ${Date.now()}-${paneKey}-${nonce}; a real paneKey is two UUIDs, so swapping an 11-char Math.random nonce for a 36-char UUID pushed the id to 124 chars, past main's hard 120-char cap in terminal-render-desync-evidence.ts, where it throws and persistHealedReference swallows it into console.error. It now keeps the leaf-id tail instead of the whole paneKey (91 chars), and the 120-char contract moved to src/shared so both sides import it. This was already broken on desktop; fixed there too.
  4. test(web) — widened the repro test to evaluate the whole store root instead of two named modules (the reported stack was the store chunk), and ported the AI Vault request-token case from fix(web): use createBrowserUuid in non-secure contexts #20465.
  5. test(web) — fixed the teardown on that new AI Vault case, which coderabbit caught and I reproduced. It stubbed randomUUID as an own property of globalThis.crypto, but the method lives on Crypto.prototype, so there was no own descriptor to restore and the stub leaked into every later test in the file. Both suites now share one non-secure-context-crypto-stub.ts that swaps the whole crypto object, and a new case pins the restore.

Also added the before/after visual proof the body was missing: the real pnpm build:web bundle in Chromium with randomUUID deleted before page load — blank page with your exact TypeError before, painted app after.

All green locally: tc:web, tc:node, oxlint (0 errors), oxfmt --check, check:code-quality:changed (0 new findings), build:web, and 26,747 vitest cases over every touched area. Each new test was confirmed to fail with its production change reverted.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 932d04b7-f2e9-47e0-a741-146d135c4549

📥 Commits

Reviewing files that changed from the base of the PR and between f022db3 and dfc4909.

📒 Files selected for processing (15)
  • .oxlintrc.json
  • src/main/ipc/terminal-render-desync-evidence.ts
  • src/renderer/src/components/native-chat/use-structured-agent-session-outbox.test.tsx
  • src/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.ts
  • src/renderer/src/components/terminal-pane/terminal-render-desync-evidence-persistence.test.ts
  • src/renderer/src/components/terminal-pane/terminal-render-desync-evidence-persistence.ts
  • src/renderer/src/lib/browser-uuid.ts
  • src/renderer/src/lib/non-secure-context-crypto.repro.test.ts
  • src/renderer/src/store/slices/settings.ts
  • src/shared/agent-status-observation.ts
  • src/shared/nested-repo-telemetry.ts
  • src/shared/non-secure-context-uuid.ts
  • src/shared/project-groups.ts
  • src/shared/setup-agent-sequencing.ts
  • src/shared/terminal-render-desync-evidence.ts

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

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • UUID generator relocated into src/shared — createNonSecureContextUuid() in src/shared/non-secure-context-uuid.ts is now the single v4 generator; @/lib/browser-uuid re-exports it, and createAgentStatusAuthorityId(role) calls it internally instead of receiving a UUID source argument.
  • Shared call sites migrated — nested-repo-telemetry, project-groups, and setup-agent-sequencing drop their ad-hoc crypto?.randomUUID?.() fallbacks for the shared helper.
  • Lint guard broadened to src/shared/**/*.ts — the no-restricted-properties ban on randomUUID now 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 — createCaptureId truncates 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 createCaptureId tests.

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.

Pullfrog  | View workflow run | Using 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.
@nwparker

Copy link
Copy Markdown
Contributor

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 randomUUID lives on Crypto.prototype, so Object.getOwnPropertyDescriptor(globalThis.crypto, 'randomUUID') is undefined, the restore branch was skipped, and an own randomUUID: undefined shadowed the real method for every later test in the file.

Fixed at the seam rather than by adding a delete branch: both suites now share one src/renderer/src/lib/non-secure-context-crypto-stub.ts that swaps the whole crypto own property (the pattern the repro suite already used and the only reversible one), and a new case pins the restore. Verified load-bearing — with the old own-property stub back, the new case fails expected 'undefined' to be 'function' while the original assertion still passes, which is exactly why the leak was silent.

Also: the repo's PR CI had never actually run on this branch — both workflows were parked at action_required awaiting fork approval, so every check claim was local-only. Approved; PR Checks and PR test LoC are now running against d900bce. The body's testing section says so plainly now.

Locally on the new head: tc:web clean, oxlint clean, oxfmt --check clean, check:code-quality:changed 0 new findings across 38 files, both affected suites 42/42.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 507631e4-4653-448f-8a26-0efa0a246a15

📥 Commits

Reviewing files that changed from the base of the PR and between dfc4909 and d900bce.

📒 Files selected for processing (3)
  • src/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.ts
  • src/renderer/src/lib/non-secure-context-crypto-stub.ts
  • src/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 })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 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.ts

Repository: 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.ts

Repository: 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.ts

Repository: 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.yaml

Repository: 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.yaml

Repository: 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 ?? {}) }
}))
JS

Repository: 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')
+    }
   }

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 crypto test stub into a shared helper — new src/renderer/src/lib/non-secure-context-crypto-stub.ts exposes createNonSecureContextCrypto() (returns { getRandomValues } bound to the real crypto) and withNonSecureContextCrypto(body), which swaps the whole globalThis.crypto own property and restores the real object in finally.
  • Fixed the leaky teardown in the AI-vault suite — the manual own-property randomUUID: undefined stub (unrestorable because randomUUID lives on Crypto.prototype) is replaced by the shared helper.
  • Added a teardown guard case — leaves the real crypto.randomUUID in place afterwards pins that the restore actually happens, so the silent leak cannot return.
  • The repro suite now reuses the same helper in beforeEach and 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.

Pullfrog  | View workflow run | Using 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.
@nwparker

Copy link
Copy Markdown
Contributor

CI update and a merge.

CI is green. The fork-workflow runs were approved and PR Checks completed success on d900bce — typecheck, static analysis, package, package (windows), relay integration and all 8 Linux test shards. Nothing on GitHub had validated this diff before that.

Merged main (612c914), because the PR had gone DIRTY. One conflict, in launch-structured-agent-session.ts, where main added ...launchSeedOptions(state, agent) next to the line this PR changed — resolved by keeping both.

The ratchet caught a live regression while doing it. main had landed createStructuredAgentSessionOperationId(() => crypto.randomUUID()) in structured-agent-session-launch-options.ts after this branch was cut. The new oxlint rule failed on the merged tree, which is precisely the "call site N+1" case the rule exists for. It now goes through createBrowserUuid. That is the argument for the guard, made by the guard, one week in.

Re-verified on the merge head: repo-wide oxlint 0 errors, tc:web and tc:node clean, oxfmt --check clean on the changed files, check:code-quality:changed 0 new findings across 39 files. CI re-approved and running on 612c914.

For the record, two test files fail on my macOS box both on this branch and on unmodified origin/main (serialized-screen-background-rows, and three src/main suites) — pre-existing and unrelated; the Linux shards cover them and pass.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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:

  • main merged and its new randomUUID call site routed through the helper — structured-agent-session-launch-options.ts now calls createStructuredAgentSessionOperationId(createBrowserUuid) instead of () => crypto.randomUUID(), and structured-agent-session-launch-prompt.ts does the same for the refusal-requeue operation id.
  • launch-structured-agent-session.ts carried through — session id and create params use createBrowserUuid (alongside main's unrelated seed-options and ownerVerdict changes).
  • Merge preserved every branch-side change — the shared generator, the lint ratchet over src/renderer/src and src/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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor

Green on the merge head. PR Checks run 36102951613 on 612c914 finished success — typecheck, static analysis, package, package (windows), relay integration and all 8 Linux test shards. mergeStateStatus is now CLEAN.

Also re-ran the end-to-end proof against the post-merge build rather than trusting the earlier capture: vite build --config vite.web.config.ts, served out/web, opened it in Chromium with randomUUID deleted from both Crypto.prototype and the crypto instance so it is genuinely absent the way a non-secure origin makes it. Result: paint entries ["first-paint","first-contentful-paint"], #root.innerHTML.length 5801, zero page errors — byte-for-byte the same numbers as the attached "after" screenshot. The merge did not disturb the fix.

Ready for review.

@nwparker nwparker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved to run CI. Taken over and reworked by @nwparker; findings addressed and independently re-verified.

@nwparker
nwparker merged commit 7d2c399 into stablyai:main Sep 25, 2026
30 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

2 participants