fix(settings): use randomUUID helper with getRandomValues fallback for non-secure contexts

This commit is contained in:
xintaofei
2026-04-18 18:25:28 +08:00
parent ff48810603
commit 75c2dd4cc5
2 changed files with 7 additions and 6 deletions

View File

@@ -64,7 +64,7 @@ import {
ComboboxLabel,
ComboboxList,
} from "@/components/ui/combobox"
import { cn } from "@/lib/utils"
import { cn, randomUUID } from "@/lib/utils"
import {
acpClearBinaryCache,
acpDetectAgentLocalVersion,
@@ -3052,7 +3052,7 @@ export function AcpAgentSettings() {
[agent.agent_type]:
kind ?? (mode === "download" ? "download_binary" : "upgrade_binary"),
}))
const taskId = crypto.randomUUID()
const taskId = randomUUID()
setStreamAgentType(agent.agent_type)
await installStream.start(taskId)
try {
@@ -3118,7 +3118,7 @@ export function AcpAgentSettings() {
...prev,
[agent.agent_type]: mode === "install" ? "install_npx" : "upgrade_npx",
}))
const taskId = crypto.randomUUID()
const taskId = randomUUID()
setStreamAgentType(agent.agent_type)
await installStream.start(taskId)
try {
@@ -3198,7 +3198,7 @@ export function AcpAgentSettings() {
? "uninstall_binary"
: "uninstall_npx",
}))
const taskId = crypto.randomUUID()
const taskId = randomUUID()
setStreamAgentType(agent.agent_type)
await installStream.start(taskId)
try {

View File

@@ -17,6 +17,7 @@ import {
opencodeUninstallPlugin,
} from "@/lib/api"
import { usePluginInstallStream } from "@/hooks/use-plugin-install-stream"
import { randomUUID } from "@/lib/utils"
import type { PluginCheckSummary, PluginInfo } from "@/lib/types"
interface OpencodePluginsModalProps {
@@ -74,7 +75,7 @@ export function OpencodePluginsModal({
}, [stream.status])
const handleInstallAll = useCallback(async () => {
const taskId = crypto.randomUUID()
const taskId = randomUUID()
await stream.start(taskId)
try {
await opencodeInstallPlugins(taskId)
@@ -85,7 +86,7 @@ export function OpencodePluginsModal({
const handleInstallOne = useCallback(
async (name: string) => {
const taskId = crypto.randomUUID()
const taskId = randomUUID()
await stream.start(taskId)
try {
await opencodeInstallPlugins(taskId, [name])