The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 08:45 UTC
Use Effect UUID generator as randomUUID fallback
- Replace manual UUID byte formatting fallback in `apps/web/src/lib/utils.ts` - Use `Effect.runSync(Random.nextUUIDv4)` when `crypto.randomUUID` is unavailable
Julius Marminge committed
Mar 9, 2026 at 22:46 UTC
767de271e972b38de0633c04efcd62a929790b3e
1 file changed
+3
-7
apps/web/src/lib/utils.ts
+3
-7
@@ -1,6 +1,8 @@
1
import { CommandId, MessageId, ProjectId, ThreadId } from "@t3tools/contracts";
2
import { type CxOptions, cx } from "class-variance-authority";
3
import { twMerge } from "tailwind-merge";
4
+import * as Random from "effect/Random";
5
+import * as Effect from "effect/Effect";
6
7
export function cn(...inputs: CxOptions) {
8
return twMerge(cx(inputs));
@@ -18,13 +20,7 @@ export function randomUUID(): string {
20
if (typeof crypto.randomUUID === "function") {
21
return crypto.randomUUID();
22
}
21
- // Fallback for non-secure contexts (plain HTTP on non-localhost)
22
- const bytes = new Uint8Array(16);
23
- crypto.getRandomValues(bytes);
24
- bytes[6] = (bytes[6] & 0x0f) | 0x40;
25
- bytes[8] = (bytes[8] & 0x3f) | 0x80;
26
- const hex = Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
27
- return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
23
+ return Effect.runSync(Random.nextUUIDv4);
24
}
25
26
export const newCommandId = (): CommandId => CommandId.makeUnsafe(randomUUID());