Compare commits

..

2 Commits

6 changed files with 45 additions and 49 deletions

View File

@ -166,7 +166,6 @@ export default function AgentChatPage() {
threadId={threadId}
autoFocus={isNewThread}
showWelcomeStyle={isNewThread}
hasSubmitted={!isNewThread}
status={
thread.error
? "error"

View File

@ -233,7 +233,6 @@ export default function ChatPage() {
[thread.values.artifacts],
);
const [hasSubmitted, setHasSubmitted] = useState(false);
const [historyCutoff, setHistoryCutoff] = useState<number | null>(null);
useEffect(() => {
@ -241,7 +240,6 @@ export default function ChatPage() {
setHistoryCutoff(null);
return;
}
if (hasSubmitted) return;
// Welcome 态下、未提交前,把当前已有消息都当作“历史”切掉。
// 这样即使历史消息是后续异步补齐,也不会重新露出。
setHistoryCutoff((prev) => {
@ -250,7 +248,6 @@ export default function ChatPage() {
return next > prev ? next : prev;
});
}, [
hasSubmitted,
historyCutoff,
shouldRenderHistory,
thread.isThreadLoading,
@ -322,7 +319,6 @@ export default function ChatPage() {
if (isNewThread && safeThreadId && !isThreadInitReady) {
return;
}
setHasSubmitted(true);
if (safeThreadId && (isNewThread || showWelcomeStyle)) {
router.replace(`/workspace/chats/${safeThreadId}?is_chatting=true`);
}
@ -343,22 +339,6 @@ export default function ChatPage() {
await thread.stop();
}, [thread]);
const resetNewSessionState = useCallback(() => {
setIsNewThread(true);
setHasSubmitted(false);
setHistoryCutoff(null);
setArtifacts([]);
deselectArtifact();
setArtifactsOpen(false);
setArtifactsFullscreen(false);
}, [
deselectArtifact,
setArtifacts,
setArtifactsFullscreen,
setArtifactsOpen,
setIsNewThread,
]);
return (
<ThreadContext.Provider value={{ threadId, thread }}>
<div
@ -379,7 +359,7 @@ export default function ChatPage() {
<header
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",
showWelcomeStyle && !hasSubmitted ? "hidden" : "",
showWelcomeStyle ? "hidden" : "",
)}
>
<div className="flex items-center justify-start overflow-hidden text-sm font-medium">
@ -388,7 +368,14 @@ export default function ChatPage() {
variant="ghost"
className="px-[10px] py-[5px] text-sm font-medium text-ws-base-1 hover:text-ws-base-1/80"
disabled={isStreaming}
onClick={() => setShowExitDialog(true)}
onClick={() => {
sendToParent({
type: POST_MESSAGE_TYPES.IS_CHATTING,
isChatting: false,
});
router.replace(`/workspace/chats/${threadId}?is_chatting=false`)
}
}
>
<svg
width="20"
@ -444,6 +431,20 @@ export default function ChatPage() {
</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 && (
<Tooltip content={t.chatPage.viewArtifactsTooltip}>
@ -456,7 +457,12 @@ export default function ChatPage() {
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}
</Button>
</Tooltip>
@ -466,16 +472,14 @@ export default function ChatPage() {
<main
className={cn(
"flex min-h-0 max-w-full grow flex-col",
showWelcomeStyle && !hasSubmitted
? "bg-ws-surface-base"
: "bg-background",
showWelcomeStyle ? "bg-ws-surface-base" : "bg-background",
)}
>
<div className="flex size-full justify-center">
<MessageList
className={cn(
"size-full",
(!showWelcomeStyle || hasSubmitted) && "pt-[58px]",
!showWelcomeStyle && "pt-[58px]",
)}
threadId={threadId}
thread={thread}
@ -508,7 +512,7 @@ export default function ChatPage() {
<div
className={cn(
"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",
)}
>
@ -570,9 +574,7 @@ export default function ChatPage() {
<div
className={cn(
"pointer-events-auto relative w-full max-w-[720px]",
showWelcomeStyle &&
!hasSubmitted &&
"-translate-y-[calc(50vh-96px)]",
showWelcomeStyle && "-translate-y-[calc(50vh-96px)]",
)}
>
{!(showWelcomeStyle && thread.isThreadLoading) ? (
@ -581,7 +583,6 @@ export default function ChatPage() {
className={cn("w-full rounded-[20px] bg-ws-surface-elevated")}
threadId={threadId}
showWelcomeStyle={showWelcomeStyle}
hasSubmitted={hasSubmitted}
autoFocus={showWelcomeStyle}
status={
thread.error
@ -593,9 +594,7 @@ export default function ChatPage() {
context={settings.context}
extraHeader={
<div className="flex flex-col gap-4">
{showWelcomeStyle && !hasSubmitted && (
<Welcome mode={settings.context.mode} />
)}
{showWelcomeStyle && <Welcome mode={settings.context.mode} />}
</div>
}
disabled={

View File

@ -219,7 +219,6 @@ export function InputBox({
context,
extraHeader,
showWelcomeStyle,
hasSubmitted,
initialValue,
onContextChange,
onSubmit,
@ -238,7 +237,6 @@ export function InputBox({
};
extraHeader?: React.ReactNode;
showWelcomeStyle: boolean;
hasSubmitted?: boolean;
initialValue?: string;
onContextChange?: (
context: Omit<
@ -294,14 +292,13 @@ export function InputBox({
const [isInputToolsTourReady, setIsInputToolsTourReady] = useState(false);
const { data: referenceFilesData } = useReferenceFiles(threadIdFromProps);
// isNewThread 时禁用收缩,始终保持展开(除非已提交消息)
const effectiveIsFocused =
((showWelcomeStyle ?? false) && !hasSubmitted) || isFocused;
// Welcome 态下禁用收缩,始终保持展开
const effectiveIsFocused = (showWelcomeStyle ?? false) || isFocused;
const shouldShowSuggestionList =
showWelcomeStyle && !hasSubmitted && searchParams.get("mode") !== "skill";
showWelcomeStyle && searchParams.get("mode") !== "skill";
useEffect(() => {
if (!showWelcomeStyle || hasSubmitted) {
if (!showWelcomeStyle) {
setIsInputToolsTourReady(false);
return;
}
@ -318,14 +315,13 @@ export function InputBox({
return () => window.cancelAnimationFrame(frameId);
}, [
showWelcomeStyle,
hasSubmitted,
shouldShowSuggestionList,
iframeSkill.isBootstrapping,
iframeSkill.selectedSkills.length,
]);
useEffect(() => {
if (!showWelcomeStyle || hasSubmitted || !isInputToolsTourReady) {
if (!showWelcomeStyle || !isInputToolsTourReady) {
setIsInputToolsTourOpen(false);
return;
}
@ -337,7 +333,7 @@ export function InputBox({
if (!hasSeenTourForCurrentThread) {
setIsInputToolsTourOpen(true);
}
}, [showWelcomeStyle, hasSubmitted, isInputToolsTourReady, threadId]);
}, [showWelcomeStyle, isInputToolsTourReady, threadId]);
const finishInputToolsTour = useCallback(() => {
const seenState = parseInputToolsTourSeenState(
@ -817,7 +813,6 @@ export function InputBox({
"border-0 rounded-[20px] backdrop-blur-sm",
"transition-[height] duration-300 ease-out shadow-none ",
!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]",
)}
disabled={isInputDisabled}
@ -970,14 +965,14 @@ export function InputBox({
/>
</div>
)}
{!showWelcomeStyle && (
{/* {!showWelcomeStyle && (
<div className="shrink-0 h-full">
<ExitChattingButton
router={router}
threadId={threadIdFromProps}
/>
</div>
)}
)} */}
<div ref={attachmentsButtonTourRef} className="shrink-0 h-full">
<AddAttachmentsButton />
</div>

View File

@ -53,6 +53,7 @@ export const enUS: Translations = {
exportSuccess: "Conversation exported",
removeAttachment: "Remove attachment",
reference: "Reference",
resetThread: "Reset thread",
},
// Welcome

View File

@ -48,6 +48,7 @@ export interface Translations {
exportSuccess: string;
removeAttachment: string;
reference: string;
resetThread: string;
};
// Welcome

View File

@ -55,6 +55,7 @@ export const zhCN: Translations = {
exportSuccess: "对话已导出",
removeAttachment: "移除附件",
reference: "引用",
resetThread: "重置会话",
},
// Welcome