fix: use randomUUID fallback for non-secure contexts in terminal-context
Replace crypto.randomUUID() with the existing randomUUID() utility that falls back to crypto.getRandomValues() over plain HTTP. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
|||||||
type ReactNode,
|
type ReactNode,
|
||||||
} from "react"
|
} from "react"
|
||||||
import { terminalKill } from "@/lib/api"
|
import { terminalKill } from "@/lib/api"
|
||||||
|
import { randomUUID } from "@/lib/utils"
|
||||||
import { useFolderContext } from "@/contexts/folder-context"
|
import { useFolderContext } from "@/contexts/folder-context"
|
||||||
import { useShortcutSettings } from "@/hooks/use-shortcut-settings"
|
import { useShortcutSettings } from "@/hooks/use-shortcut-settings"
|
||||||
import { matchShortcutEvent } from "@/lib/keyboard-shortcuts"
|
import { matchShortcutEvent } from "@/lib/keyboard-shortcuts"
|
||||||
@@ -109,7 +110,7 @@ export function TerminalProvider({ children }: { children: ReactNode }) {
|
|||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const toggle = useCallback(() => {
|
const toggle = useCallback(() => {
|
||||||
const autoId = crypto.randomUUID()
|
const autoId = randomUUID()
|
||||||
const nextCounter = tabCounterRef.current + 1
|
const nextCounter = tabCounterRef.current + 1
|
||||||
|
|
||||||
setIsOpen((wasOpen) => !wasOpen)
|
setIsOpen((wasOpen) => !wasOpen)
|
||||||
@@ -140,7 +141,7 @@ export function TerminalProvider({ children }: { children: ReactNode }) {
|
|||||||
|
|
||||||
setIsOpen(true)
|
setIsOpen(true)
|
||||||
|
|
||||||
const id = crypto.randomUUID()
|
const id = randomUUID()
|
||||||
tabCounterRef.current += 1
|
tabCounterRef.current += 1
|
||||||
setTabs((prev) => [
|
setTabs((prev) => [
|
||||||
...prev,
|
...prev,
|
||||||
@@ -159,7 +160,7 @@ export function TerminalProvider({ children }: { children: ReactNode }) {
|
|||||||
|
|
||||||
setIsOpen(true)
|
setIsOpen(true)
|
||||||
|
|
||||||
const id = crypto.randomUUID()
|
const id = randomUUID()
|
||||||
tabCounterRef.current += 1
|
tabCounterRef.current += 1
|
||||||
const defaultTitle = `Terminal ${tabCounterRef.current}`
|
const defaultTitle = `Terminal ${tabCounterRef.current}`
|
||||||
setTabs((prev) => [
|
setTabs((prev) => [
|
||||||
|
|||||||
Reference in New Issue
Block a user