feat: 生成中禁用返回按钮

This commit is contained in:
肖应宇 2026-04-09 10:41:52 +08:00 committed by Titan
parent ced3b45569
commit 0028e142f7
1 changed files with 9 additions and 6 deletions

View File

@ -63,7 +63,7 @@ export default function ChatPage() {
isMock,
showWelcomeStyle,
} = useThreadChat();
// 新逻辑:历史渲染和新会话仅由路由 /chats/new 控制,不再读取 isnew/is_chatting 参数。
const shouldRenderHistory = !showWelcomeStyle;
const createNewSession = useMemo(() => isNewThread, [isNewThread]);
@ -99,8 +99,8 @@ export default function ChatPage() {
onStart: (currentThreadId) => {
setIsNewThread(false);
// if (!shouldStayOnNewRoute) {
// Keep /new in history so router.back() can return to it.
router.replace(`/workspace/chats/${currentThreadId}?is_chatting=true`);
// Keep /new in history so router.back() can return to it.
router.replace(`/workspace/chats/${currentThreadId}?is_chatting=true`);
// }
// history.pushState(null, "", pathOfThread(currentThreadId));
},
@ -193,6 +193,7 @@ export default function ChatPage() {
const todoListCollapsed = true;
const [showExitDialog, setShowExitDialog] = useState(false);
const isStreaming = isUploading || thread.isLoading;
const handleSubmit = useCallback(
(message: Parameters<typeof sendMessage>[1]) => {
if (isSelectedSkillBootstrapping) {
@ -222,10 +223,10 @@ export default function ChatPage() {
setArtifactsOpen,
setIsNewThread,
]);
return (
<ThreadContext.Provider value={{ threadId,thread }}>
<ThreadContext.Provider value={{ threadId, thread }}>
<div
className={cn(
"m-auto flex h-screen min-h-svh overflow-hidden rounded-t-[20px] transition-[width] duration-300 ease-in-out",
@ -252,6 +253,7 @@ export default function ChatPage() {
size="sm"
variant="ghost"
className="px-[10px] py-[5px] text-sm font-medium text-[#150033] hover:text-[#150033]/80"
disabled={isStreaming}
onClick={() => setShowExitDialog(true)}
>
<svg
@ -354,6 +356,7 @@ export default function ChatPage() {
<div
className={cn(
"h-full w-full transition-transform duration-300 ease-in-out",
showWelcomeStyle && !hasSubmitted ? "translate-x-0" : "",
artifactPanelOpen ? "translate-x-0" : "translate-x-full",
)}
>
@ -475,7 +478,7 @@ export default function ChatPage() {
<DevDialogTitle></DevDialogTitle>
</DevDialogHeader>
<p className="text-muted-foreground text-sm">
退
退
</p>
<DevDialogFooter>
<Button