Closes #249: layoutStore.ts wraps the existing layout.ts tree model in Zustand, persisting to localStorage on a 400ms debounce and adding boot reconciliation to prune leaves for sessions no longer live. MultiView/TabBar/PaneContainer/PaneTitle render tabs, nested splits with draggable dividers, drag-and-drop tab reordering, and dispatch each pane to TerminalPane or StructuredPane by session view. Preview mode (#251) and sidebar drag-to-dock stay out of scope here.
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
// @vitest-environment happy-dom
|
|
import { cleanup, render, screen } from "@testing-library/react";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
|
|
import type { Session } from "../../types.js";
|
|
import { PaneTitle } from "./PaneTitle.js";
|
|
|
|
afterEach(cleanup);
|
|
|
|
function session(over: Partial<Session> = {}): Session {
|
|
return {
|
|
id: "s1",
|
|
cwd: "/home/n",
|
|
command: "claude",
|
|
env: {},
|
|
metadata: {},
|
|
status: "Running",
|
|
created_at: "2026-01-01T00:00:00Z",
|
|
...over,
|
|
} as Session;
|
|
}
|
|
|
|
describe("PaneTitle", () => {
|
|
it("falls back to a short session id when the session isn't known yet", () => {
|
|
render(<PaneTitle sessionId="abcdef12-3456-7890-abcd-ef1234567890" />);
|
|
expect(screen.getByText(/abcdef12/)).toBeTruthy();
|
|
});
|
|
|
|
it("shows the name alone when the command matches it", () => {
|
|
render(<PaneTitle sessionId="s1" session={session({ command: "claude", metadata: { name: "claude" } })} />);
|
|
expect(screen.getByText("claude")).toBeTruthy();
|
|
expect(document.querySelector(".at-cmd")).toBeNull();
|
|
});
|
|
|
|
it("shows the command alongside a custom name", () => {
|
|
render(
|
|
<PaneTitle sessionId="s1" session={session({ command: "hx src/main.rs", metadata: { name: "editor" } })} />,
|
|
);
|
|
expect(screen.getByText("editor")).toBeTruthy();
|
|
expect(document.querySelector(".at-cmd")).not.toBeNull();
|
|
});
|
|
|
|
it("never injects markup from a session name", () => {
|
|
render(<PaneTitle sessionId="s1" session={session({ metadata: { name: "<img onerror=x>" } })} />);
|
|
expect(document.querySelector("img")).toBeNull();
|
|
expect(screen.getByText("<img onerror=x>")).toBeTruthy();
|
|
});
|
|
});
|