beadboard/src/hooks/use-panel-resize.ts
zenchantlive c246ceaf21 feat(ux): consolidate Launch Swarm + telemetry UX with minimized strip
- Removed broken LaunchSwarmDialog (formula-based) from TopBar/LeftPanel
- All Rocket buttons (TopBar, LeftPanel, DAG nodes, social cards) now open
  AssignmentPanel (archetype-based) which actually works
- Every Rocket clears taskId first so assignMode && !taskId condition passes
- Conversation button priority: taskId always shows conversation, not assign panel
- Added TelemetryStrip: minimized right sidebar with status dots when non-telemetry
  panel (conversation/assignment) is active
- Live feed has minimize button → restores last taskId or assignMode
- DAG nodes: Signal icon → restores telemetry feed
- Social button on DAG nodes: single router.push to avoid race (setView + setTaskId)
- Fixed social card message button: opens right panel with drawer:closed (no popup)

Co-Authored-By: Oz <oz-agent@warp.dev>
2026-03-01 18:17:58 -08:00

71 lines
2.1 KiB
TypeScript

import { useState, useEffect, useCallback } from 'react';
const LEFT_PANEL_KEY = 'bb.ui.leftPanelWidth';
const RIGHT_PANEL_KEY = 'bb.ui.rightPanelWidth';
const DEFAULT_LEFT_WIDTH = 320;
const DEFAULT_RIGHT_WIDTH = 332;
export const MIN_LEFT_WIDTH = 192;
export const MIN_RIGHT_WIDTH = 256;
export function usePanelResize() {
const [leftWidth, setLeftWidth] = useState(DEFAULT_LEFT_WIDTH);
const [rightWidth, setRightWidth] = useState(DEFAULT_RIGHT_WIDTH);
const [mounted, setMounted] = useState(false);
useEffect(() => {
const savedLeft = localStorage.getItem(LEFT_PANEL_KEY);
const savedRight = localStorage.getItem(RIGHT_PANEL_KEY);
if (savedLeft) {
setLeftWidth(parseInt(savedLeft, 10));
}
if (savedRight) {
setRightWidth(parseInt(savedRight, 10));
}
setMounted(true);
}, []);
useEffect(() => {
if (mounted) {
localStorage.setItem(LEFT_PANEL_KEY, String(leftWidth));
}
}, [leftWidth, mounted]);
useEffect(() => {
if (mounted) {
localStorage.setItem(RIGHT_PANEL_KEY, String(rightWidth));
}
}, [rightWidth, mounted]);
const clampLeftWidth = useCallback((width: number) => {
const maxWidth = Math.floor(window.innerWidth * 0.30);
return Math.max(MIN_LEFT_WIDTH, Math.min(width, maxWidth));
}, []);
const clampRightWidth = useCallback((width: number) => {
const maxWidth = Math.floor(window.innerWidth * 0.35);
return Math.max(MIN_RIGHT_WIDTH, Math.min(width, maxWidth));
}, []);
const handleLeftResize = useCallback((delta: number) => {
setLeftWidth(prev => clampLeftWidth(prev + delta));
}, [clampLeftWidth]);
const handleRightResize = useCallback((delta: number) => {
setRightWidth(prev => clampRightWidth(prev + delta));
}, [clampRightWidth]);
return {
leftWidth,
rightWidth,
handleLeftResize,
handleRightResize,
clampLeftWidth,
clampRightWidth,
MIN_LEFT_WIDTH,
MIN_RIGHT_WIDTH
};
}