Skip to content

Fix Agents sidebar crash in plain-HTTP Remote Web - #18102

Closed
JasonJarvan wants to merge 1 commit into
stablyai:mainfrom
JasonJarvan:JasonJarvan/agents-http-randomuuid
Closed

JasonJarvan wants to merge 1 commit into
stablyai:mainfrom
JasonJarvan:JasonJarvan/agents-http-randomuuid

Conversation

@JasonJarvan

@JasonJarvan JasonJarvan commented Sep 2, 2026 •

Copy link
Copy Markdown

ELI5

The Agents sidebar asked the browser for a UUID API that plain-HTTP pages do not expose. It now uses the renderer UUID helper that already handles those pages safely.

What Changed

  • Generate the AiVault refresh request token with createBrowserUuid.
  • Add a hook-level regression test for a non-secure browser context where getRandomValues exists but randomUUID does not.

Why

Remote Web can be opened from a LAN address over plain HTTP. In that non-secure context, crypto.randomUUID is unavailable, so initializing the AiVault refresh hook threw during render and the Agents right-sidebar ErrorBoundary reappeared on every tab switch.

Reusing createBrowserUuid keeps native UUID generation in secure contexts and uses the existing browser fallback elsewhere, without changing the remote wire contract.

Linked Issue

Fixes #18096

Visual Proof

N/A — this prevents a render crash and does not change layout or visuals.

Testing

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

Commands run:

  • pnpm test src/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.ts — 35 passed
  • pnpm run check:code-quality:changed — passed with 0 new ordinary, type-aware, or React Doctor findings across 2 files

Tested on macOS. The change is browser-only, uses no platform-specific paths or shortcuts, preserves SSH/folder workspace behavior, and makes no remote wire change.

AI Disclosure

OpenAI Codex was used to implement and verify this focused fix.

Review

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 security boundary, persistence, process-management, mobile, Git provider, or performance behavior changed. The request token remains a local cancellation identity and is not an authentication credential.

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)

@coderabbitai

coderabbitai Bot commented Sep 2, 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: Team

Run ID: 5a0f52d0-e0ef-4393-b943-73ab21f10da3

📥 Commits

Reviewing files that changed from the base of the PR and between 4cc0b8d and 6ccdbff.

📒 Files selected for processing (2)
  • src/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-refresh.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/right-sidebar/ai-vault-session-refresh.ts
  • src/renderer/src/components/right-sidebar/ai-vault-session-refresh.test.ts

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


📝 Walkthrough

Walkthrough

The AI vault session refresh now uses createBrowserUuid() instead of crypto.randomUUID() for request-token initialization. Tests cover non-secure contexts by stubbing crypto.getRandomValues and verifying the resulting all-zero UUID. Test cleanup restores stubbed globals with vi.unstubAllGlobals().

Merge Risk: ⚪ Minimal · up to 6ccdb

AI Vault session refresh now uses browser-compatible UUID generation, preventing the Agents sidebar crash in supported plain-HTTP Remote Web contexts. Regression coverage includes environments without crypto.randomUUID, and no merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue [#18096] by replacing direct crypto.randomUUID() usage with createBrowserUuid and adding regression coverage for plain-HTTP contexts where randomUUID is unavailable.
Out of Scope Changes check ✅ Passed The changes are limited to the AiVault refresh token generation and its regression test. They directly support the linked issue and introduce no unrelated behavior.
Title check ✅ Passed The title clearly identifies the primary change: fixing the Agents sidebar crash in plain-HTTP Remote Web contexts.
Description check ✅ Passed The description covers all required sections, explains the change and reason, links issue #18096, documents visual proof as not applicable, lists testing results and platforms, and completes the check…
  • 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.

@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

  • requestToken minted via createBrowserUuid — useAiVaultSessionRefresh now generates its cancellation token with the renderer's browser-UUID helper instead of crypto.randomUUID(), which is hidden in non-secure (plain-HTTP) contexts and caused the sidebar to throw during render.
  • Non-secure-context regression test — a new test stubs crypto down to getRandomValues only and asserts the fallback still produces a valid UUID, which fails against the old crypto.randomUUID() call.
  • Global teardown — vi.unstubAllGlobals() added to afterEach so the stubbed crypto does not leak into other tests.

createBrowserUuid already covers the secure-native, getRandomValues, and Math.random fallback paths, so the fix reuses existing machinery with no remote wire change — the token remains an opaque string validated only for type/length by ai-vault.ts.

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

@JasonJarvan
JasonJarvan force-pushed the JasonJarvan/agents-http-randomuuid branch from d7fcb73 to 6ccdbff Compare September 3, 2026 10:29
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@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

  • Rebased the token minting onto main's lazy ??= init — useAiVaultSessionRefresh now swaps crypto.randomUUID() for createBrowserUuid() inside the requestTokenRef.current ??= ... pattern that main introduced since the prior review, instead of the earlier useRef(createBrowserUuid()). This also stops the UUID from being regenerated on every render, matching the file's existing publicationGateRef lazy-init idiom.

The fix's substance is unchanged: the token remains an opaque string (validated only for type/length by ai-vault.ts), and the non-secure-context regression test still passes (35/35).

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

@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]: Agents sidebar crashes in plain-HTTP Remote Web

2 participants