From eceeecf4b82458bac96bf8c2d7233d8918c0b063 Mon Sep 17 00:00:00 2001 From: MT-Mint <798521692@qq.com> Date: Tue, 7 Apr 2026 16:35:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=B2=BE=E7=AE=80showWelcomeStyle?= =?UTF-8?q?=E5=92=8CisNewThread=E6=96=AD=E8=A8=80=E3=80=82=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E5=9C=A8/[thread=5Fid]=3Fxclaw=5Fused=3Dtrue=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E6=98=BE=E7=A4=BA=E6=AC=A2=E8=BF=8E=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workspace/chats/use-thread-chat.ts | 16 +++++++--------- frontend/src/core/threads/utils.ts | 17 ----------------- 2 files changed, 7 insertions(+), 26 deletions(-) diff --git a/frontend/src/components/workspace/chats/use-thread-chat.ts b/frontend/src/components/workspace/chats/use-thread-chat.ts index eed2754d..ba201334 100644 --- a/frontend/src/components/workspace/chats/use-thread-chat.ts +++ b/frontend/src/components/workspace/chats/use-thread-chat.ts @@ -3,7 +3,6 @@ import { useParams, usePathname, useSearchParams } from "next/navigation"; import { useCallback, useEffect, useState } from "react"; -import { resolveThreadQueryIntent } from "@/core/threads/utils"; export function useThreadChat() { const pathname = usePathname(); @@ -68,21 +67,19 @@ export function useThreadChat() { }, [queryThreadIdFromParams], ); - const intent = resolveThreadQueryIntent({ - pathThreadId: threadIdFromPathOrParams, - queryThreadId: queryThreadIdFromParams, - isNewRoute, - }); - const { isNewThread: isNewRequested, showWelcomeStyle } = intent; + // New session is only controlled by `/workspace/chats/new`. + const [isNewThread, setIsNewThread] = useState(() => isNewRoute); + + const [showWelcomeStyle, setShowWelcomeStyle] = useState(() => { + return isNewRoute|| searchParams.get("xclaw_used") === "true"; + }); // console.log("[useThreadChat] effectiveThreadIdFromPath", effectiveThreadIdFromPath); const [threadId, setThreadId] = useState(() => { return threadIdFromPathOrParams; }); - // New session is only controlled by `/workspace/chats/new`. - const [isNewThread, setIsNewThread] = useState(() => isNewRequested); useEffect(() => { // 记住最近一次有效的 thread_id,供下次加载兜底使用。 @@ -92,6 +89,7 @@ export function useThreadChat() { setIsNewThread(isNewRoute); // Prefer path thread id, fall back to query thread_id when path is /new. setThreadId(threadIdFromPathOrParams); + setShowWelcomeStyle(isNewRoute || searchParams.get("xclaw_used") === "true"); }, [ isNewRoute, normalizeThreadId, diff --git a/frontend/src/core/threads/utils.ts b/frontend/src/core/threads/utils.ts index 651a1420..264eba17 100644 --- a/frontend/src/core/threads/utils.ts +++ b/frontend/src/core/threads/utils.ts @@ -29,23 +29,6 @@ function normalizeThreadId(value?: string | null): string | undefined { return trimmed; } -export function resolveThreadQueryIntent({ - pathThreadId, - queryThreadId, - isNewRoute = false, -}: ThreadQueryIntentInput): ThreadQueryIntent { - const normalizedPathId = normalizeThreadId(pathThreadId); - const normalizedQueryId = normalizeThreadId(queryThreadId); - const isNewThread = isNewRoute; - - return { - // 优先使用路径 thread_id;/new 场景回落到 query thread_id - threadId: normalizedPathId ?? normalizedQueryId, - // 新逻辑只由路由 /workspace/chats/new 控制“新会话” - isNewThread, - showWelcomeStyle: isNewThread, - }; -} export function textOfMessage(message: Message) { if (typeof message.content === "string") {