Compare commits
2 Commits
cd4c33f3cd
...
cb56507767
| Author | SHA1 | Date | |
|---|---|---|---|
| cb56507767 | |||
| b7f2001914 |
@ -166,7 +166,6 @@ export default function AgentChatPage() {
|
|||||||
threadId={threadId}
|
threadId={threadId}
|
||||||
autoFocus={isNewThread}
|
autoFocus={isNewThread}
|
||||||
showWelcomeStyle={isNewThread}
|
showWelcomeStyle={isNewThread}
|
||||||
hasSubmitted={!isNewThread}
|
|
||||||
status={
|
status={
|
||||||
thread.error
|
thread.error
|
||||||
? "error"
|
? "error"
|
||||||
|
|||||||
@ -233,7 +233,6 @@ export default function ChatPage() {
|
|||||||
[thread.values.artifacts],
|
[thread.values.artifacts],
|
||||||
);
|
);
|
||||||
|
|
||||||
const [hasSubmitted, setHasSubmitted] = useState(false);
|
|
||||||
const [historyCutoff, setHistoryCutoff] = useState<number | null>(null);
|
const [historyCutoff, setHistoryCutoff] = useState<number | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -241,7 +240,6 @@ export default function ChatPage() {
|
|||||||
setHistoryCutoff(null);
|
setHistoryCutoff(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (hasSubmitted) return;
|
|
||||||
// Welcome 态下、未提交前,把当前已有消息都当作“历史”切掉。
|
// Welcome 态下、未提交前,把当前已有消息都当作“历史”切掉。
|
||||||
// 这样即使历史消息是后续异步补齐,也不会重新露出。
|
// 这样即使历史消息是后续异步补齐,也不会重新露出。
|
||||||
setHistoryCutoff((prev) => {
|
setHistoryCutoff((prev) => {
|
||||||
@ -250,7 +248,6 @@ export default function ChatPage() {
|
|||||||
return next > prev ? next : prev;
|
return next > prev ? next : prev;
|
||||||
});
|
});
|
||||||
}, [
|
}, [
|
||||||
hasSubmitted,
|
|
||||||
historyCutoff,
|
historyCutoff,
|
||||||
shouldRenderHistory,
|
shouldRenderHistory,
|
||||||
thread.isThreadLoading,
|
thread.isThreadLoading,
|
||||||
@ -322,7 +319,6 @@ export default function ChatPage() {
|
|||||||
if (isNewThread && safeThreadId && !isThreadInitReady) {
|
if (isNewThread && safeThreadId && !isThreadInitReady) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setHasSubmitted(true);
|
|
||||||
if (safeThreadId && (isNewThread || showWelcomeStyle)) {
|
if (safeThreadId && (isNewThread || showWelcomeStyle)) {
|
||||||
router.replace(`/workspace/chats/${safeThreadId}?is_chatting=true`);
|
router.replace(`/workspace/chats/${safeThreadId}?is_chatting=true`);
|
||||||
}
|
}
|
||||||
@ -343,22 +339,6 @@ export default function ChatPage() {
|
|||||||
await thread.stop();
|
await thread.stop();
|
||||||
}, [thread]);
|
}, [thread]);
|
||||||
|
|
||||||
const resetNewSessionState = useCallback(() => {
|
|
||||||
setIsNewThread(true);
|
|
||||||
setHasSubmitted(false);
|
|
||||||
setHistoryCutoff(null);
|
|
||||||
setArtifacts([]);
|
|
||||||
deselectArtifact();
|
|
||||||
setArtifactsOpen(false);
|
|
||||||
setArtifactsFullscreen(false);
|
|
||||||
}, [
|
|
||||||
deselectArtifact,
|
|
||||||
setArtifacts,
|
|
||||||
setArtifactsFullscreen,
|
|
||||||
setArtifactsOpen,
|
|
||||||
setIsNewThread,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThreadContext.Provider value={{ threadId, thread }}>
|
<ThreadContext.Provider value={{ threadId, thread }}>
|
||||||
<div
|
<div
|
||||||
@ -379,7 +359,7 @@ export default function ChatPage() {
|
|||||||
<header
|
<header
|
||||||
className={cn(
|
className={cn(
|
||||||
"bg-background absolute top-0 right-0 left-0 z-30 mx-4 grid h-[58px] shrink-0 grid-cols-3 items-center border-b transition-all duration-300 ease-in-out",
|
"bg-background absolute top-0 right-0 left-0 z-30 mx-4 grid h-[58px] shrink-0 grid-cols-3 items-center border-b transition-all duration-300 ease-in-out",
|
||||||
showWelcomeStyle && !hasSubmitted ? "hidden" : "",
|
showWelcomeStyle ? "hidden" : "",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="flex items-center justify-start overflow-hidden text-sm font-medium">
|
<div className="flex items-center justify-start overflow-hidden text-sm font-medium">
|
||||||
@ -388,7 +368,14 @@ export default function ChatPage() {
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="px-[10px] py-[5px] text-sm font-medium text-ws-base-1 hover:text-ws-base-1/80"
|
className="px-[10px] py-[5px] text-sm font-medium text-ws-base-1 hover:text-ws-base-1/80"
|
||||||
disabled={isStreaming}
|
disabled={isStreaming}
|
||||||
onClick={() => setShowExitDialog(true)}
|
onClick={() => {
|
||||||
|
sendToParent({
|
||||||
|
type: POST_MESSAGE_TYPES.IS_CHATTING,
|
||||||
|
isChatting: false,
|
||||||
|
});
|
||||||
|
router.replace(`/workspace/chats/${threadId}?is_chatting=false`)
|
||||||
|
}
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
width="20"
|
width="20"
|
||||||
@ -444,6 +431,20 @@ export default function ChatPage() {
|
|||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
/> */}
|
/> */}
|
||||||
|
<Tooltip content={t.common.resetThread}>
|
||||||
|
<Button
|
||||||
|
size="sm"
|
||||||
|
variant="ghost"
|
||||||
|
className="h-full px-[10px] py-[5px] text-sm font-medium text-ws-base-1 hover:text-ws-base-1"
|
||||||
|
disabled={isStreaming}
|
||||||
|
onClick={() => setShowExitDialog(true)}
|
||||||
|
>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
|
||||||
|
<path d="M2 4H6M16 4H12M6 4H12M6 4C6 2.89543 6.89543 2 8 2H10C11.1046 2 12 2.89543 12 4M4 6V14C4 15.1046 4.89543 16 6 16H12C13.1046 16 14 15.1046 14 14V6M7 8V13M11 8V13" stroke="#150033" stroke-linecap="round" />
|
||||||
|
</svg>
|
||||||
|
{t.common.resetThread}
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
{artifacts?.length > 0 && !artifactsOpen && (
|
{artifacts?.length > 0 && !artifactsOpen && (
|
||||||
<Tooltip content={t.chatPage.viewArtifactsTooltip}>
|
<Tooltip content={t.chatPage.viewArtifactsTooltip}>
|
||||||
@ -456,7 +457,12 @@ export default function ChatPage() {
|
|||||||
setSidebarOpen(false);
|
setSidebarOpen(false);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FilesIcon />
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
|
||||||
|
<path d="M16 7V4C16 2.89543 15.1046 2 14 2H4C2.89543 2 2 2.89543 2 4V14C2 15.1046 2.89543 16 4 16H9" stroke="#150033" stroke-linecap="round" />
|
||||||
|
<path d="M5 5H9M5 8H7" stroke="#150033" stroke-linecap="round" stroke-linejoin="round" />
|
||||||
|
<circle cx="11.5" cy="10.5" r="3" stroke="#150033" />
|
||||||
|
<path d="M15.5 14.5L14 13" stroke="#150033" stroke-linecap="round" stroke-linejoin="round" />
|
||||||
|
</svg>
|
||||||
{t.common.artifacts}
|
{t.common.artifacts}
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@ -466,16 +472,14 @@ export default function ChatPage() {
|
|||||||
<main
|
<main
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex min-h-0 max-w-full grow flex-col",
|
"flex min-h-0 max-w-full grow flex-col",
|
||||||
showWelcomeStyle && !hasSubmitted
|
showWelcomeStyle ? "bg-ws-surface-base" : "bg-background",
|
||||||
? "bg-ws-surface-base"
|
|
||||||
: "bg-background",
|
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="flex size-full justify-center">
|
<div className="flex size-full justify-center">
|
||||||
<MessageList
|
<MessageList
|
||||||
className={cn(
|
className={cn(
|
||||||
"size-full",
|
"size-full",
|
||||||
(!showWelcomeStyle || hasSubmitted) && "pt-[58px]",
|
!showWelcomeStyle && "pt-[58px]",
|
||||||
)}
|
)}
|
||||||
threadId={threadId}
|
threadId={threadId}
|
||||||
thread={thread}
|
thread={thread}
|
||||||
@ -508,7 +512,7 @@ export default function ChatPage() {
|
|||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"h-full w-full transition-transform duration-300 ease-in-out",
|
"h-full w-full transition-transform duration-300 ease-in-out",
|
||||||
showWelcomeStyle && !hasSubmitted ? "translate-x-0" : "",
|
showWelcomeStyle ? "translate-x-0" : "",
|
||||||
artifactPanelOpen ? "translate-x-0" : "translate-x-full",
|
artifactPanelOpen ? "translate-x-0" : "translate-x-full",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
@ -570,9 +574,7 @@ export default function ChatPage() {
|
|||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
"pointer-events-auto relative w-full max-w-[720px]",
|
"pointer-events-auto relative w-full max-w-[720px]",
|
||||||
showWelcomeStyle &&
|
showWelcomeStyle && "-translate-y-[calc(50vh-96px)]",
|
||||||
!hasSubmitted &&
|
|
||||||
"-translate-y-[calc(50vh-96px)]",
|
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{!(showWelcomeStyle && thread.isThreadLoading) ? (
|
{!(showWelcomeStyle && thread.isThreadLoading) ? (
|
||||||
@ -581,7 +583,6 @@ export default function ChatPage() {
|
|||||||
className={cn("w-full rounded-[20px] bg-ws-surface-elevated")}
|
className={cn("w-full rounded-[20px] bg-ws-surface-elevated")}
|
||||||
threadId={threadId}
|
threadId={threadId}
|
||||||
showWelcomeStyle={showWelcomeStyle}
|
showWelcomeStyle={showWelcomeStyle}
|
||||||
hasSubmitted={hasSubmitted}
|
|
||||||
autoFocus={showWelcomeStyle}
|
autoFocus={showWelcomeStyle}
|
||||||
status={
|
status={
|
||||||
thread.error
|
thread.error
|
||||||
@ -593,9 +594,7 @@ export default function ChatPage() {
|
|||||||
context={settings.context}
|
context={settings.context}
|
||||||
extraHeader={
|
extraHeader={
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
{showWelcomeStyle && !hasSubmitted && (
|
{showWelcomeStyle && <Welcome mode={settings.context.mode} />}
|
||||||
<Welcome mode={settings.context.mode} />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
disabled={
|
disabled={
|
||||||
|
|||||||
@ -219,7 +219,6 @@ export function InputBox({
|
|||||||
context,
|
context,
|
||||||
extraHeader,
|
extraHeader,
|
||||||
showWelcomeStyle,
|
showWelcomeStyle,
|
||||||
hasSubmitted,
|
|
||||||
initialValue,
|
initialValue,
|
||||||
onContextChange,
|
onContextChange,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
@ -238,7 +237,6 @@ export function InputBox({
|
|||||||
};
|
};
|
||||||
extraHeader?: React.ReactNode;
|
extraHeader?: React.ReactNode;
|
||||||
showWelcomeStyle: boolean;
|
showWelcomeStyle: boolean;
|
||||||
hasSubmitted?: boolean;
|
|
||||||
initialValue?: string;
|
initialValue?: string;
|
||||||
onContextChange?: (
|
onContextChange?: (
|
||||||
context: Omit<
|
context: Omit<
|
||||||
@ -294,14 +292,13 @@ export function InputBox({
|
|||||||
const [isInputToolsTourReady, setIsInputToolsTourReady] = useState(false);
|
const [isInputToolsTourReady, setIsInputToolsTourReady] = useState(false);
|
||||||
const { data: referenceFilesData } = useReferenceFiles(threadIdFromProps);
|
const { data: referenceFilesData } = useReferenceFiles(threadIdFromProps);
|
||||||
|
|
||||||
// isNewThread 时禁用收缩,始终保持展开(除非已提交消息)
|
// Welcome 态下禁用收缩,始终保持展开
|
||||||
const effectiveIsFocused =
|
const effectiveIsFocused = (showWelcomeStyle ?? false) || isFocused;
|
||||||
((showWelcomeStyle ?? false) && !hasSubmitted) || isFocused;
|
|
||||||
const shouldShowSuggestionList =
|
const shouldShowSuggestionList =
|
||||||
showWelcomeStyle && !hasSubmitted && searchParams.get("mode") !== "skill";
|
showWelcomeStyle && searchParams.get("mode") !== "skill";
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!showWelcomeStyle || hasSubmitted) {
|
if (!showWelcomeStyle) {
|
||||||
setIsInputToolsTourReady(false);
|
setIsInputToolsTourReady(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -318,14 +315,13 @@ export function InputBox({
|
|||||||
return () => window.cancelAnimationFrame(frameId);
|
return () => window.cancelAnimationFrame(frameId);
|
||||||
}, [
|
}, [
|
||||||
showWelcomeStyle,
|
showWelcomeStyle,
|
||||||
hasSubmitted,
|
|
||||||
shouldShowSuggestionList,
|
shouldShowSuggestionList,
|
||||||
iframeSkill.isBootstrapping,
|
iframeSkill.isBootstrapping,
|
||||||
iframeSkill.selectedSkills.length,
|
iframeSkill.selectedSkills.length,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!showWelcomeStyle || hasSubmitted || !isInputToolsTourReady) {
|
if (!showWelcomeStyle || !isInputToolsTourReady) {
|
||||||
setIsInputToolsTourOpen(false);
|
setIsInputToolsTourOpen(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -337,7 +333,7 @@ export function InputBox({
|
|||||||
if (!hasSeenTourForCurrentThread) {
|
if (!hasSeenTourForCurrentThread) {
|
||||||
setIsInputToolsTourOpen(true);
|
setIsInputToolsTourOpen(true);
|
||||||
}
|
}
|
||||||
}, [showWelcomeStyle, hasSubmitted, isInputToolsTourReady, threadId]);
|
}, [showWelcomeStyle, isInputToolsTourReady, threadId]);
|
||||||
|
|
||||||
const finishInputToolsTour = useCallback(() => {
|
const finishInputToolsTour = useCallback(() => {
|
||||||
const seenState = parseInputToolsTourSeenState(
|
const seenState = parseInputToolsTourSeenState(
|
||||||
@ -817,7 +813,6 @@ export function InputBox({
|
|||||||
"border-0 rounded-[20px] backdrop-blur-sm",
|
"border-0 rounded-[20px] backdrop-blur-sm",
|
||||||
"transition-[height] duration-300 ease-out shadow-none ",
|
"transition-[height] duration-300 ease-out shadow-none ",
|
||||||
!showWelcomeStyle && "h-[200px] shadow-[0_0_20px_0_rgba(0,0,0,0.10)]",
|
!showWelcomeStyle && "h-[200px] shadow-[0_0_20px_0_rgba(0,0,0,0.10)]",
|
||||||
hasSubmitted && "shadow-[0_0_20px_0_rgba(0,0,0,0.10)]!",
|
|
||||||
effectiveIsFocused ? "h-[200px]" : "h-[80px]",
|
effectiveIsFocused ? "h-[200px]" : "h-[80px]",
|
||||||
)}
|
)}
|
||||||
disabled={isInputDisabled}
|
disabled={isInputDisabled}
|
||||||
@ -970,14 +965,14 @@ export function InputBox({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{!showWelcomeStyle && (
|
{/* {!showWelcomeStyle && (
|
||||||
<div className="shrink-0 h-full">
|
<div className="shrink-0 h-full">
|
||||||
<ExitChattingButton
|
<ExitChattingButton
|
||||||
router={router}
|
router={router}
|
||||||
threadId={threadIdFromProps}
|
threadId={threadIdFromProps}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)} */}
|
||||||
<div ref={attachmentsButtonTourRef} className="shrink-0 h-full">
|
<div ref={attachmentsButtonTourRef} className="shrink-0 h-full">
|
||||||
<AddAttachmentsButton />
|
<AddAttachmentsButton />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -53,6 +53,7 @@ export const enUS: Translations = {
|
|||||||
exportSuccess: "Conversation exported",
|
exportSuccess: "Conversation exported",
|
||||||
removeAttachment: "Remove attachment",
|
removeAttachment: "Remove attachment",
|
||||||
reference: "Reference",
|
reference: "Reference",
|
||||||
|
resetThread: "Reset thread",
|
||||||
},
|
},
|
||||||
|
|
||||||
// Welcome
|
// Welcome
|
||||||
|
|||||||
@ -48,6 +48,7 @@ export interface Translations {
|
|||||||
exportSuccess: string;
|
exportSuccess: string;
|
||||||
removeAttachment: string;
|
removeAttachment: string;
|
||||||
reference: string;
|
reference: string;
|
||||||
|
resetThread: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Welcome
|
// Welcome
|
||||||
|
|||||||
@ -55,6 +55,7 @@ export const zhCN: Translations = {
|
|||||||
exportSuccess: "对话已导出",
|
exportSuccess: "对话已导出",
|
||||||
removeAttachment: "移除附件",
|
removeAttachment: "移除附件",
|
||||||
reference: "引用",
|
reference: "引用",
|
||||||
|
resetThread: "重置会话",
|
||||||
},
|
},
|
||||||
|
|
||||||
// Welcome
|
// Welcome
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user