import { Fragment } from "react"; import { ResizableHandle, ResizablePanel, ResizablePanelGroup, } from "@/components/ui/resizable"; import type { SearchAddon } from "@xterm/addon-search"; import { TerminalPane, type TerminalPaneHandle } from "./TerminalPane"; import type { PaneNode } from "./lib/panes"; type LeafBundle = { setRef: (h: TerminalPaneHandle | null) => void; onSearch: (addon: SearchAddon) => void; onCwd: (cwd: string) => void; onExit: (code: number) => void; }; type Props = { node: PaneNode; tabVisible: boolean; activeLeafId: number; onFocusLeaf: (leafId: number) => void; getBundle: (leafId: number) => LeafBundle; }; export function PaneTreeView({ node, tabVisible, activeLeafId, onFocusLeaf, getBundle, }: Props) { if (node.kind === "leaf") { const focused = node.id === activeLeafId; const b = getBundle(node.id); return (
{ if (!focused) onFocusLeaf(node.id); }} // Catches focus from Tab, programmatic focus, or any path that // skips mousedown — keeps activeLeafId in sync with DOM focus. onFocus={() => { if (!focused) onFocusLeaf(node.id); }} data-pane-leaf={node.id} className="relative h-full w-full" > b.onSearch(addon)} onCwd={(_id, cwd) => b.onCwd(cwd)} onExit={(_id, code) => b.onExit(code)} />
); } return ( {node.children.map((child, i) => ( {i > 0 && } ))} ); }