fix(*): 客户端标识 - 兼容 HTTP 内网访问并修复创造页卡死

Fixes #86
This commit is contained in:
ddCat
2026-08-03 15:06:09 +08:00
parent 72420895b2
commit d3b044e009
9 changed files with 35 additions and 9 deletions

View File

@@ -6,6 +6,7 @@ import { Copy, FolderOpen, History, KeyRound, Link2, LoaderCircle, MessageSquare
import { motion } from "motion/react";
import { canvasThemes } from "@/lib/canvas-theme";
import { createClientId } from "@/lib/client-id";
import { useThemeStore } from "@/stores/use-theme-store";
import { useUserStore } from "@/stores/use-user-store";
import { useCanvasAgentStore, type AgentAttachment, type AgentChatItem, type AgentEventLog, type AgentPanelTab, type AgentPendingToolCall, type AgentThreadSummary } from "@/stores/canvas/use-canvas-agent-store";
@@ -57,7 +58,7 @@ export const CanvasLocalAgentPanel = memo(function CanvasLocalAgentPanel({ snaps
const connectedRef = useRef(false);
const errorLoggedRef = useRef(false);
const attachmentUrlsRef = useRef(new Set<string>());
const clientIdRef = useRef(typeof crypto === "undefined" ? `${Date.now()}` : crypto.randomUUID());
const clientIdRef = useRef(createClientId());
const endpoint = useMemo(() => url.trim().replace(/\/$/, ""), [url]);
const urlAgentAutoConnect = searchParams.has("agentUrl") && searchParams.has("agentToken");
const loadThreads = useCallback(async () => {
@@ -1017,7 +1018,7 @@ function formatThreadTime(value?: number) {
}
function createId() {
return typeof crypto === "undefined" ? `${Date.now()}-${Math.random()}` : crypto.randomUUID();
return createClientId();
}
function clamp(value: number, min: number, max: number) {