Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(layout): restore missing panel header in TwoPanelLayout

Steven Enamakel1c4f03a62f69
diff --git a/app/src/components/layout/TwoPanelLayout.tsx b/app/src/components/layout/TwoPanelLayout.tsx
index 2a905c12ff..d9037d1ef2 100644
--- a/app/src/components/layout/TwoPanelLayout.tsx
+++ b/app/src/components/layout/TwoPanelLayout.tsx
@@ -161,89 +161,30 @@ export default function TwoPanelLayout({
const isOpen = forceSidebarVisible || layout.sidebarVisible;
- // Live width while dragging is kept local (and applied via inline style) so
- // we don't dispatch — and re-persist — on every pointer move.
- const [dragWidth, setDragWidth] = useState<number | null>(null);
- const dragWidthRef = useRef<number | null>(null);
const persistedWidth = clampWidth(layout.sidebarWidth, minSidebarWidth, maxSidebarWidth);
- const width = dragWidth ?? persistedWidth;
const commitWidth = useCallback(
- (next: number) => {
- const clamped = clampWidth(Math.round(next), minSidebarWidth, maxSidebarWidth);
+ (clamped: number) => {
dispatch(setSidebarWidth({ id, width: clamped }));
debug('commit width', { id, width: clamped });
},
- [dispatch, id, minSidebarWidth, maxSidebarWidth]
- );
-
- // Active-drag teardown, stashed so an unmount mid-drag can detach the global
- // listeners. Each drag installs locally-scoped `pointermove`/`pointerup`
- // handlers (hoisted function declarations so they can reference each other),
- // keeping the resize self-contained without inter-callback dependencies.
- const dragCleanupRef = useRef<(() => void) | null>(null);
-
- const onPointerDown = useCallback(
- (e: React.PointerEvent) => {
- e.preventDefault();
- const startX = e.clientX;
- const startWidth = width;
- dragWidthRef.current = startWidth;
- setDragWidth(startWidth);
- document.body.style.cursor = 'col-resize';
- document.body.style.userSelect = 'none';
-
- function handleMove(ev: PointerEvent) {
- const next = clampWidth(
- startWidth + (ev.clientX - startX),
- minSidebarWidth,
- maxSidebarWidth
- );
- dragWidthRef.current = next;
- setDragWidth(next);
- }
- function detach() {
- window.removeEventListener('pointermove', handleMove);
- window.removeEventListener('pointerup', stop);
- document.body.style.removeProperty('cursor');
- document.body.style.removeProperty('user-select');
- dragCleanupRef.current = null;
- }
- function stop() {
- detach();
- const finalWidth = dragWidthRef.current;
- dragWidthRef.current = null;
- setDragWidth(null);
- if (finalWidth != null) commitWidth(finalWidth);
- }
-
- dragCleanupRef.current = detach;
- window.addEventListener('pointermove', handleMove);
- window.addEventListener('pointerup', stop);
- debug('drag start', { id, startWidth });
- },
- [width, minSidebarWidth, maxSidebarWidth, commitWidth, id]
+ [dispatch, id]
);
- // Detach global listeners if we unmount mid-drag.
- useLayoutEffect(() => {
- return () => {
- dragCleanupRef.current?.();
- };
- }, []);
+ // Drag/keyboard mechanics (clamp + commit-on-release) live in a shared hook
+ // — see `useResizableDivider` for why this isn't the same code as the shell
+ // sidebar's `SidebarRail`.
+ const { dragWidth, onPointerDown, onKeyDown: onDividerKeyDown } = useResizableDivider({
+ width: persistedWidth,
+ minWidth: minSidebarWidth,
+ maxWidth: maxSidebarWidth,
+ keyboardStep,
+ onCommit: commitWidth,
+ });
- const onDividerKeyDown = useCallback(
- (e: React.KeyboardEvent) => {
- if (e.key === 'ArrowLeft') {
- e.preventDefault();
- commitWidth(persistedWidth - keyboardStep);
- } else if (e.key === 'ArrowRight') {
- e.preventDefault();
- commitWidth(persistedWidth + keyboardStep);
- }
- },
- [commitWidth, persistedWidth, keyboardStep]
- );
+ // Live width while dragging is kept local (and applied via inline style) so
+ // we don't dispatch — and re-persist — on every pointer move.
+ const width = dragWidth ?? persistedWidth;
// In seamless mode the card lives on the wrapper that holds both panes, so the
// panes themselves carry no border/rounding and sit flush against the divider.