Add M2 splits-tree layout

- src/lib/layout/tree.ts: pure helpers + types (newLeaf, splitLeaf,
  closeLeaf, replaceById, serialize/deserialize with shape-checking).
- SplitNode.svelte: flex container with pointer-captured gutter drag.
- LeafPane.svelte: per-pane toolbar (split-right ⇥, split-down ⇣,
  close ×) over the existing XtermPane.
- Pane.svelte: recursive dispatcher between SplitNode and LeafPane,
  keyed on leaf.id so swaps unmount XtermPane cleanly (kills PTY).
- App.svelte: tree-as-state with split/close handlers, auto-save to
  localStorage on every \$effect tick. Titlebar shows clickable distro
  buttons setting the default for new panes; existing panes keep theirs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
megaproxy 2026-05-22 12:44:35 +01:00
parent 9beab64e00
commit efcdf6a9ce
7 changed files with 531 additions and 59 deletions

View file

@ -0,0 +1,23 @@
<script lang="ts">
import type { TreeNode, NodeId, Orientation } from "./tree";
import SplitNode from "./SplitNode.svelte";
import LeafPane from "./LeafPane.svelte";
let {
node,
onSplit,
onClose,
}: {
node: TreeNode;
onSplit: (leafId: NodeId, orientation: Orientation) => void;
onClose: (leafId: NodeId) => void;
} = $props();
</script>
{#if node.kind === "split"}
<SplitNode {node} {onSplit} {onClose} />
{:else}
{#key node.id}
<LeafPane leaf={node} {onSplit} {onClose} />
{/key}
{/if}