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

View File

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