fix(chat): xclaw_used=false 不加载历史且 /new 先空置
This commit is contained in:
parent
ea396bb1af
commit
ad5c77e534
|
|
@ -0,0 +1,67 @@
|
|||
{
|
||||
"window.title": "${activeEditorShort}${separator}${separator}deer-flow/frontend",
|
||||
"todo-tree.regex.regex": "((%|#|//|<!--|\\{/\\*|^\\s*\\*)\\s*($TAGS)|^\\s*- \\[ \\])",
|
||||
"todo-tree.general.tags": [
|
||||
"TODO:",
|
||||
"BUG:",
|
||||
"TAG:",
|
||||
"DONE:",
|
||||
"MARK:",
|
||||
"TEST:",
|
||||
"XXX:"
|
||||
],
|
||||
"todo-tree.regex.regexCaseSensitive": false,
|
||||
"todo-tree.highlights.defaultHighlight": {
|
||||
"foreground": "#000000",
|
||||
"background": "#fff700",
|
||||
"icon": "check",
|
||||
"rulerColour": "#fff700",
|
||||
"type": "tag",
|
||||
"iconColour": "#fff700"
|
||||
},
|
||||
"todo-tree.highlights.customHighlight": {
|
||||
"TODO:": {
|
||||
"icon": "todo",
|
||||
"background": "#fff700",
|
||||
"rulerColour": "#fff700",
|
||||
"iconColour": "#fff700"
|
||||
},
|
||||
"BUG:": {
|
||||
"background": "#eb5c5c",
|
||||
"icon": "bug",
|
||||
"rulerColour": "#eb5c5c",
|
||||
"iconColour": "#eb5c5c"
|
||||
},
|
||||
"TAG:": {
|
||||
"background": "#38b2f4",
|
||||
"icon": "tag",
|
||||
"rulerColour": "#38b2f4",
|
||||
"iconColour": "#38b2f4",
|
||||
"rulerLane": "full"
|
||||
},
|
||||
"DONE:": {
|
||||
"background": "#5eec95",
|
||||
"icon": "check",
|
||||
"rulerColour": "#5eec95",
|
||||
"iconColour": "#5eec95"
|
||||
},
|
||||
"MARK:": {
|
||||
"background": "#f90",
|
||||
"icon": "note",
|
||||
"rulerColour": "#f90",
|
||||
"iconColour": "#f90"
|
||||
},
|
||||
"TEST:": {
|
||||
"background": "#df7be6",
|
||||
"icon": "flame",
|
||||
"rulerColour": "#df7be6",
|
||||
"iconColour": "#df7be6"
|
||||
},
|
||||
"XXX:": {
|
||||
"background": "#d65d8e",
|
||||
"icon": "versions",
|
||||
"rulerColour": "#d65d8e",
|
||||
"iconColour": "#d65d8e"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import { useCallback, useEffect, useMemo, useState } from "react";
|
|||
|
||||
import { ConversationEmptyState } from "@/components/ai-elements/conversation";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import {
|
||||
DevDialog,
|
||||
DevDialogContent,
|
||||
|
|
@ -57,13 +58,16 @@ export default function ChatPage() {
|
|||
const { threadId, isNewThread, setIsNewThread, isMock } = useThreadChat();
|
||||
const searchParams = useSearchParams();
|
||||
|
||||
// Submission strategy is controlled by `isnew` query param only.
|
||||
// - isnew=false: reuse existing thread
|
||||
// - otherwise: create/start a new session
|
||||
// Submission strategy:
|
||||
// - xclaw_used=true: follow `isnew` (isnew=false => reuse existing thread)
|
||||
// - xclaw_used!=true: always create/start a new session (no history)
|
||||
const createNewSession = useMemo(() => {
|
||||
if (!isNewThread) {
|
||||
return false;
|
||||
}
|
||||
if (searchParams.get("xclaw_used")?.trim().toLowerCase() !== "true") {
|
||||
return true;
|
||||
}
|
||||
return searchParams.get("isnew")?.trim().toLowerCase() !== "false";
|
||||
}, [isNewThread, searchParams]);
|
||||
const streamThreadId = useMemo(() => {
|
||||
|
|
@ -110,6 +114,7 @@ export default function ChatPage() {
|
|||
}, [thread.values?.title]);
|
||||
|
||||
const [hasSubmitted, setHasSubmitted] = useState(false);
|
||||
const showInputBox = !(isNewThread && thread.isThreadLoading);
|
||||
|
||||
useEffect(() => {
|
||||
const pageTitle = isNewThread
|
||||
|
|
@ -359,36 +364,41 @@ export default function ChatPage() {
|
|||
isNewThread && !hasSubmitted && "-translate-y-[calc(50vh-96px)]",
|
||||
)}
|
||||
>
|
||||
<InputBox
|
||||
className={cn("w-full rounded-[20px] bg-[#FBFAFC]")}
|
||||
threadId={threadId}
|
||||
isNewThread={isNewThread}
|
||||
hasSubmitted={hasSubmitted}
|
||||
autoFocus={isNewThread}
|
||||
status={
|
||||
thread.error
|
||||
? "error"
|
||||
: isUploading || thread.isLoading
|
||||
? "streaming"
|
||||
: "ready"
|
||||
}
|
||||
context={settings.context}
|
||||
extraHeader={
|
||||
<div className="flex flex-col gap-4">
|
||||
{isNewThread && !hasSubmitted && (
|
||||
<Welcome mode={settings.context.mode} />
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
disabled={
|
||||
env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true" ||
|
||||
isSelectedSkillBootstrapping ||
|
||||
isUploading
|
||||
}
|
||||
onContextChange={(context) => setSettings("context", context)}
|
||||
onSubmit={handleSubmit}
|
||||
onStop={handleStop}
|
||||
/>
|
||||
{showInputBox ? (
|
||||
<InputBox
|
||||
className={cn("w-full rounded-[20px] bg-[#FBFAFC]")}
|
||||
threadId={threadId}
|
||||
isNewThread={isNewThread}
|
||||
hasSubmitted={hasSubmitted}
|
||||
autoFocus={isNewThread}
|
||||
status={
|
||||
thread.error
|
||||
? "error"
|
||||
: isUploading || thread.isLoading
|
||||
? "streaming"
|
||||
: "ready"
|
||||
}
|
||||
context={settings.context}
|
||||
extraHeader={
|
||||
<div className="flex flex-col gap-4">
|
||||
{isNewThread && !hasSubmitted && (
|
||||
<Welcome mode={settings.context.mode} />
|
||||
)}
|
||||
</div>
|
||||
}
|
||||
disabled={
|
||||
env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true" ||
|
||||
isSelectedSkillBootstrapping ||
|
||||
isUploading
|
||||
}
|
||||
onContextChange={(context) => setSettings("context", context)}
|
||||
onSubmit={handleSubmit}
|
||||
onStop={handleStop}
|
||||
/>
|
||||
) : (
|
||||
// <InputBoxSkeleton />
|
||||
''
|
||||
)}
|
||||
|
||||
{/* {isSelectedSkillBootstrapping && (
|
||||
<div className="text-muted-foreground w-full translate-y-8 text-center text-xs">
|
||||
|
|
@ -477,3 +487,21 @@ export default function ChatPage() {
|
|||
</ThreadContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
function InputBoxSkeleton() {
|
||||
return (
|
||||
<div className="w-full rounded-[20px] bg-[#FBFAFC] p-4 shadow-[0_0_20px_0_rgba(0,0,0,0.10)]">
|
||||
<div className="flex flex-col gap-4">
|
||||
<Skeleton className="h-6 w-[220px]" />
|
||||
<Skeleton className="h-[120px] w-full rounded-[16px]" />
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<Skeleton className="h-9 w-9 rounded-full" />
|
||||
<Skeleton className="h-9 w-9 rounded-full" />
|
||||
</div>
|
||||
<Skeleton className="h-9 w-20 rounded-full" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,12 +10,14 @@ export function useThreadChat() {
|
|||
const pathname = usePathname();
|
||||
|
||||
const searchParams = useSearchParams();
|
||||
const xClawUsedFromQuery = searchParams.get("xclaw_used");
|
||||
const [threadId, setThreadId] = useState(() => {
|
||||
if (threadIdFromPath === "new") {
|
||||
const shouldUseQueryThreadId = pathname.startsWith("/workspace/chats/");
|
||||
const queryThreadId = shouldUseQueryThreadId
|
||||
? searchParams.get("thread_id")?.trim()
|
||||
: undefined;
|
||||
const queryThreadId =
|
||||
shouldUseQueryThreadId && xClawUsedFromQuery === "true"
|
||||
? searchParams.get("thread_id")?.trim()
|
||||
: undefined;
|
||||
return queryThreadId ?? uuid();
|
||||
}
|
||||
return threadIdFromPath;
|
||||
|
|
@ -29,9 +31,10 @@ export function useThreadChat() {
|
|||
if (pathname.endsWith("/new")) {
|
||||
setIsNewThread(true);
|
||||
const shouldUseQueryThreadId = pathname.startsWith("/workspace/chats/");
|
||||
const queryThreadId = shouldUseQueryThreadId
|
||||
? searchParams.get("thread_id")?.trim()
|
||||
: undefined;
|
||||
const queryThreadId =
|
||||
shouldUseQueryThreadId && xClawUsedFromQuery === "true"
|
||||
? searchParams.get("thread_id")?.trim()
|
||||
: undefined;
|
||||
setThreadId(queryThreadId ?? uuid());
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ export function useIframeSkill(): UseIframeSkillReturn {
|
|||
|
||||
// 0. 监听 query 中 XClawUsed=true 且带 thread_id 时跳转并清理 query
|
||||
useEffect(() => {
|
||||
console.log(xClawUsedFromQuery, threadIdFromQuery, lastThreadIdRef.current);
|
||||
|
||||
if (!threadIdFromQuery) return;
|
||||
if (xClawUsedFromQuery !== "true") return;
|
||||
if (lastThreadIdRef.current === threadIdFromQuery) return;
|
||||
|
|
|
|||
Loading…
Reference in New Issue