修复会话页面的滚动条位置在切换模式之后会丢失

This commit is contained in:
xintaofei
2026-03-24 23:47:11 +08:00
parent da95b9f8a7
commit 593bbe70e3

View File

@@ -49,6 +49,7 @@ import {
ResizablePanelGroup, ResizablePanelGroup,
} from "@/components/ui/resizable" } from "@/components/ui/resizable"
import type { AgentType } from "@/lib/types" import type { AgentType } from "@/lib/types"
import { cn } from "@/lib/utils"
const TOAST_DURATION_MS = 15000 const TOAST_DURATION_MS = 15000
const WORKSPACE_PANEL_GROUP_ID = "workspace-panel-group" const WORKSPACE_PANEL_GROUP_ID = "workspace-panel-group"
@@ -61,8 +62,6 @@ const FOLDER_SHELL_RIGHT_PANEL_ID = "folder-shell-right-panel"
const FOLDER_MAIN_GROUP_ID = "folder-main-group" const FOLDER_MAIN_GROUP_ID = "folder-main-group"
const FOLDER_MAIN_WORKSPACE_PANEL_ID = "folder-main-workspace-panel" const FOLDER_MAIN_WORKSPACE_PANEL_ID = "folder-main-workspace-panel"
const FOLDER_MAIN_TERMINAL_PANEL_ID = "folder-main-terminal-panel" const FOLDER_MAIN_TERMINAL_PANEL_ID = "folder-main-terminal-panel"
const CONVERSATION_ONLY_LAYOUT: [number, number] = [100, 0]
const FILES_ONLY_LAYOUT: [number, number] = [0, 100]
const DEFAULT_FUSION_LAYOUT: [number, number] = [56, 44] const DEFAULT_FUSION_LAYOUT: [number, number] = [56, 44]
const MIN_CENTER_WIDTH_PX = 420 const MIN_CENTER_WIDTH_PX = 420
const MIN_WORKSPACE_HEIGHT_PX = 220 const MIN_WORKSPACE_HEIGHT_PX = 220
@@ -145,15 +144,10 @@ function WorkspaceContent({ children }: { children: React.ReactNode }) {
useEffect(() => { useEffect(() => {
if (mode === "fusion") { if (mode === "fusion") {
applyLayout(fusionLayoutRef.current) applyLayout(fusionLayoutRef.current)
return
} }
// Non-fusion modes keep panels at their current sizes to preserve
if (mode === "conversation") { // scroll positions. CSS overlay on the active section provides
applyLayout(CONVERSATION_ONLY_LAYOUT) // full-width display (see absolute inset-0 below).
return
}
applyLayout(FILES_ONLY_LAYOUT)
}, [applyLayout, mode]) }, [applyLayout, mode])
const handleLayout = useCallback( const handleLayout = useCallback(
@@ -179,7 +173,7 @@ function WorkspaceContent({ children }: { children: React.ReactNode }) {
) )
return ( return (
<div className="h-full min-h-0 overflow-hidden"> <div className="relative h-full min-h-0 overflow-hidden">
<ResizablePanelGroup <ResizablePanelGroup
id={WORKSPACE_PANEL_GROUP_ID} id={WORKSPACE_PANEL_GROUP_ID}
ref={panelGroupRef} ref={panelGroupRef}
@@ -193,7 +187,10 @@ function WorkspaceContent({ children }: { children: React.ReactNode }) {
minSize={mode === "fusion" ? 25 : 0} minSize={mode === "fusion" ? 25 : 0}
> >
<section <section
className="flex h-full min-h-0 flex-col overflow-hidden" className={cn(
"flex h-full min-h-0 flex-col overflow-hidden",
mode === "conversation" && "absolute inset-0 z-30 bg-background"
)}
onPointerDownCapture={markConversationActive} onPointerDownCapture={markConversationActive}
onFocusCapture={markConversationActive} onFocusCapture={markConversationActive}
aria-hidden={mode === "files"} aria-hidden={mode === "files"}
@@ -219,7 +216,10 @@ function WorkspaceContent({ children }: { children: React.ReactNode }) {
minSize={mode === "fusion" ? 20 : 0} minSize={mode === "fusion" ? 20 : 0}
> >
<section <section
className="flex h-full min-h-0 flex-col overflow-hidden" className={cn(
"flex h-full min-h-0 flex-col overflow-hidden",
mode === "files" && "absolute inset-0 z-30 bg-background"
)}
onPointerDownCapture={markFileActive} onPointerDownCapture={markFileActive}
onFocusCapture={markFileActive} onFocusCapture={markFileActive}
aria-hidden={mode === "conversation"} aria-hidden={mode === "conversation"}