Skip to content

Commit aa603b1

Browse files
committed
fix(gui-extensions): fall back when crypto.randomUUID is unavailable
The /btw command generated its chat id with crypto.randomUUID(), which is undefined outside secure contexts. Opening the web UI over plain HTTP (e.g. a LAN IP) made every /btw submission throw "crypto.randomUUID is not a function" and surface a "Failed to send command" toast. Fall back to a non-cryptographic id in that case, matching the existing fallback in packages/app/src/runtime/persistence/uuid.ts.
1 parent 775d1d0 commit aa603b1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

‎packages/gui-extensions/src/btw/model.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { batch, onCleanup } from "solid-js"
2-
import { createStore } from "solid-js/store"
32
import { showToast } from "@opencode/ui/toast"
3+
import { createStore } from "solid-js/store"
44
import type { MountedSession, SetupContext } from "../sdk"
55
import type Btw from "./index"
66

@@ -73,7 +73,10 @@ export function createBtw(ctx: SetupContext<typeof Btw>) {
7373

7474
if (!session?.id) return
7575

76-
const id = crypto.randomUUID()
76+
// crypto.randomUUID is undefined outside secure contexts (for example the
77+
// web UI served over plain HTTP), where asking must fall back to a
78+
// non-cryptographic id instead of throwing.
79+
const id = crypto.randomUUID?.() ?? Math.random().toString(16).slice(2)
7780

7881
// Desktop storage loads asynchronously. A write before load queues and lands in the same batch that marks the
7982
// store ready, and the panel keeps a tab hidden until then, so the chat and its tab need not wait. The session's

0 commit comments

Comments
 (0)