'use client'; import { useMemo } from 'react'; import type { BeadIssue } from '../../lib/types'; import type { ProjectScopeOption } from '../../lib/project-scope'; import { TopBar } from './top-bar'; import { LeftPanel } from './left-panel'; import { RightPanel } from './right-panel'; import { MobileNav } from './mobile-nav'; import { ThreadDrawer } from './thread-drawer'; import { useUrlState } from '../../hooks/use-url-state'; import { GraphView } from '../graph/graph-view'; import { SocialPage } from '../social/social-page'; import { SwarmPage } from '../swarm/swarm-page'; import { buildSocialCards } from '../../lib/social-cards'; import { buildSwarmCards } from '../../lib/swarm-cards'; import { ActivityPanel } from '../activity/activity-panel'; export interface UnifiedShellProps { issues: BeadIssue[]; projectRoot: string; projectScopeKey: string; projectScopeOptions: ProjectScopeOption[]; projectScopeMode: 'single' | 'aggregate'; } export function UnifiedShell({ issues, }: UnifiedShellProps) { const { view, taskId, setTaskId, swarmId, setSwarmId, graphTab, setGraphTab, panel, drawer, setDrawer } = useUrlState(); const socialCards = useMemo(() => buildSocialCards(issues), [issues]); const swarmCards = useMemo(() => buildSwarmCards(issues), [issues]); const selectedSocialCard = taskId ? socialCards.find(c => c.id === taskId) : null; const selectedSwarmCard = swarmId ? swarmCards.find(c => c.swarmId === swarmId) : null; const handleGraphSelect = (id: string) => { setTaskId(id); }; const handleCardSelect = (id: string) => { if (view === 'social') { setTaskId(id); } else if (view === 'swarm') { setSwarmId(id); } setDrawer('open'); }; const handleCloseDrawer = () => { setDrawer('closed'); }; // Chat Mode Logic: If a card is selected (drawer='open'), we show Chat + Mini Activity Rail const isChatOpen = drawer === 'open' && (!!taskId || !!swarmId); const drawerTitle = selectedSocialCard?.title || selectedSwarmCard?.title || ''; const drawerId = taskId || swarmId || ''; // Right Panel Content Logic // - Chat Mode: Main = Chat, Rail = Activity(Collapsed) // - Default: Main = Activity, Rail = None const rightPanelMain = isChatOpen ? ( ) : ( ); const rightPanelRail = isChatOpen ? ( ) : undefined; // Grid Layout: Expand Right Panel width when Chat is open const rightPanelWidth = isChatOpen ? '26rem' : '17rem'; const renderMiddleContent = () => { if (view === 'graph') { return ( ); } if (view === 'social') { return ( ); } if (view === 'swarm') { return ( ); } return null; }; return (
{/* TOP BAR: 3rem fixed */} {/* MAIN AREA: CSS Grid [13rem | 1fr | RightPanel] */}
{/* LEFT PANEL: 13rem channel tree */} {/* MIDDLE CONTENT: flex-1 */}
{renderMiddleContent()}
{/* RIGHT PANEL: Dynamic Content + Optional Rail */} {rightPanelMain}
{/* MOBILE NAV: Bottom tab bar */}
); }