(null);
+ const [frame, setFrame] = useState<{ center: number; height: number } | null>(null);
const inside = useRef(false);
const [height, setHeight] = useState(300);
const [scrollTop, setScrollTop] = useState(0);
@@ -36,15 +38,33 @@ export const PromptRail = memo(function PromptRail({ bottomOffset, messages, pro
const first = Math.max(0, Math.floor((scrollTop - padding) / GAP) - 4);
const end = Math.min(anchors.length, Math.ceil((scrollTop + height - padding) / GAP) + 5);
- useEffect(() => {
+ useLayoutEffect(() => {
const rail = railRef.current;
if (!rail) return;
- const measure = () => setHeight(rail.clientHeight || 300);
+ // The rail is a direct child of ThreadViewport. Unlike offsetParent this
+ // remains available while the narrow-pane CSS hides the rail.
+ const pane = frameRef.current?.parentElement;
+ const measure = () => {
+ if (navigationFrame && pane) {
+ const target = navigationFrame.getBoundingClientRect();
+ const bounds = pane.getBoundingClientRect();
+ const center = target.top + target.height / 2 - bounds.top;
+ // Keep the centered rail inside the transcript, even when a shared
+ // composer outside this viewport grows. It must not be clipped below.
+ const height = Math.max(0, Math.min(target.height * 0.8, 2 * (Math.min(center, bounds.height - center) - 12)));
+ setFrame((previous) => previous?.center === center && previous.height === height ? previous : { center, height });
+ } else setFrame(null);
+ setHeight(rail.clientHeight || 300);
+ };
measure();
const observer = new ResizeObserver(measure);
observer.observe(rail);
+ if (navigationFrame && pane) {
+ observer.observe(navigationFrame);
+ observer.observe(pane);
+ }
return () => observer.disconnect();
- }, [anchors.length >= 2, bottomOffset]);
+ }, [anchors.length >= 2, navigationFrame]);
useEffect(() => {
const scroller = scrollRef.current;
@@ -117,9 +137,10 @@ export const PromptRail = memo(function PromptRail({ bottomOffset, messages, pro
};
return { inside.current = true; }}
onPointerLeave={() => { inside.current = false; setFocused(null); }}
>
diff --git a/webui/src/components/thread/ThreadShell.tsx b/webui/src/components/thread/ThreadShell.tsx
index 239bbf053..9448f0684 100644
--- a/webui/src/components/thread/ThreadShell.tsx
+++ b/webui/src/components/thread/ThreadShell.tsx
@@ -538,6 +538,7 @@ interface ThreadShellProps {
headerPortalTarget?: HTMLElement | null;
headerActive?: boolean;
composerPortalTarget?: HTMLElement | null;
+ navigationFrame?: HTMLElement | null;
composerActive?: boolean;
composerInputAriaLabel?: string;
emptyComposerVariant?: "hero" | "thread";
@@ -756,6 +757,7 @@ export function ThreadShell({
headerPortalTarget,
headerActive = true,
composerPortalTarget,
+ navigationFrame,
composerActive = true,
composerInputAriaLabel,
emptyComposerVariant = "hero",
@@ -2077,6 +2079,7 @@ export function ThreadShell({
ref={viewportRef}
messages={displayMessages}
navigation={promptNavigation}
+ navigationFrame={navigationFrame}
temporary={temporary}
isStreaming={turnActive}
runStartedAt={currentRunStartedAt}
diff --git a/webui/src/components/thread/ThreadViewport.tsx b/webui/src/components/thread/ThreadViewport.tsx
index 90f87d6f3..fcafa9fd1 100644
--- a/webui/src/components/thread/ThreadViewport.tsx
+++ b/webui/src/components/thread/ThreadViewport.tsx
@@ -44,6 +44,7 @@ interface ThreadViewportProps {
runStartedAt?: number | null;
retryStatus?: RetryStatus | null;
composer?: ReactNode;
+ navigationFrame?: HTMLElement | null;
emptyState?: ReactNode;
scrollToBottomSignal?: number;
activeTurnId?: string | null;
@@ -241,6 +242,7 @@ export const ThreadViewport = forwardRef
) : null}
diff --git a/webui/src/components/workbench/PaneWorkbench.tsx b/webui/src/components/workbench/PaneWorkbench.tsx
index c7ba6fffd..d75f236a0 100644
--- a/webui/src/components/workbench/PaneWorkbench.tsx
+++ b/webui/src/components/workbench/PaneWorkbench.tsx
@@ -53,6 +53,7 @@ interface PaneRenderContext {
active: boolean;
headerPortalTarget: HTMLElement | null | undefined;
composerPortalTarget: HTMLElement | null | undefined;
+ navigationFrame: HTMLElement | null | undefined;
headerActions: ReactNode;
}
@@ -208,6 +209,7 @@ export function PaneWorkbench({
const effectiveLayout = layout;
const [headerPortalTarget, setHeaderPortalTarget] = useState(null);
const [composerPortalTarget, setComposerPortalTarget] = useState(null);
+ const [navigationFrame, setNavigationFrame] = useState(null);
const gridRef = useRef(null);
const paneRefs = useRef(new Map());
const lastRectsRef = useRef(new Map());
@@ -675,6 +677,7 @@ export function PaneWorkbench({
return (
1 ? headerPortalTarget : undefined,
composerPortalTarget: chrome ? composerPortalTarget : undefined,
+ // A single chat includes the shared composer in its visual frame.
+ // Split chats keep navigation centered within their own pane.
+ navigationFrame: displayedPanes.length === 1 ? navigationFrame : undefined,
headerActions,
})}
{chrome && panes.length > 1 && !compact ? (