Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.
JavaScript ai-codingclaudeclaude-codeclaude-code-pluginclicoding-agentsdeveloper-toolsgitllmtypescript
feat(map): store each session's row width in local project state
Erenaf38ba28cd25
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4bc10c3..5dd63eb 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]### Changed-- Each session on the map now keeps its own message row width: dragging one session's edge leaves the others alone, and the width survives a reload.+- Each session on the map now keeps its own message row width: dragging one session's edge leaves the others alone. The width is stored in the project's local `.cogit/state/row-widths.json` (never committed, so teammates keep their own), and survives a reload or a different browser.## [0.22.0] - 2026-10-30### Addeddiff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.tsindex 756b8b5..1cceaea 100644--- a/packages/cli/src/commands/build.ts+++ b/packages/cli/src/commands/build.ts@@ -32,6 +32,7 @@ import { withLock } from "../store/lock.js";import { projectPaths } from "../store/paths.js";import { readReadState } from "../store/read-state.js";import { resolveProjectRoot } from "../store/root.js";+import { readRowWidths } from "../store/row-widths.js";import { loadAllSessions, loadConfig, loadProject } from "../store/stores.js";import { attachThoughtTrailers, earliestSessionStart, readThoughtTrailers } from "../thought.js";import { attachChanges } from "../view/change.js";@@ -356,6 +357,7 @@ export async function buildProject(opts: BuildOptions): Promise<LineageViewModel});built.switcher = switcher;built.read = [...read].sort();+ built.rowWidths = await readRowWidths(root);// Story 11.1: the map head carries this project's rows only. The panel// already collected them from the registry; a project outside it (a// broken registry, a hand-made directory) is read here instead.diff --git a/packages/cli/src/server.ts b/packages/cli/src/server.tsindex b3239f0..fa88ee0 100644--- a/packages/cli/src/server.ts+++ b/packages/cli/src/server.ts@@ -21,6 +21,7 @@ import { dismissInboxSession } from "./store/inbox-state.js";import { LockBusyError } from "./store/lock.js";import { globalPaths, projectPaths } from "./store/paths.js";import { setMessageRead } from "./store/read-state.js";+import { setRowWidth } from "./store/row-widths.js";import { loadConfig, loadRegistry, updateConfig } from "./store/stores.js";import { isPanelEditableKey, LIVE_META_NAME, TOKEN_META_NAME } from "./view/model.js";import { buildPanel, panelSettings } from "./view/panel.js";@@ -660,6 +661,83 @@ export async function startMapServer(opts: MapServerOptions): Promise<MapServer>res.end(JSON.stringify({ ok: true, sessionId, at }));}+ /**+ * `POST /api/row-width` { dir, sessionId, width } : the map's row edge, sent+ * when a drag ends. `width` null forgets the session (the double-click reset).+ * It writes the project's local state file, never a committed one. Same Host,+ * Origin, content-type and token checks as a read mark, and `dir` must be+ * registered.+ */+ async function writeRowWidth(+ req: IncomingMessage,+ res: ServerResponse,+ port: number,+ ): Promise<void> {+ if (+ !originAllowed(req.headers.origin, port) ||+ !tokenMatches(req.headers[CONFIG_TOKEN_HEADER])+ ) {+ respond(res, 403, "forbidden");+ return;+ }+ const type = req.headers["content-type"];+ if (+ typeof type !== "string" ||+ type.split(";")[0]?.trim().toLowerCase() !== "application/json"+ ) {+ respond(res, 415, "content-type must be application/json");+ return;+ }+ const body = await readLimitedBody(req);+ if (body === null) {+ respond(res, 413, "request body too large");+ return;+ }+ let parsed: unknown;+ try {+ parsed = JSON.parse(body);+ } catch {+ respond(res, 400, "invalid JSON");+ return;+ }+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {+ respond(res, 400, "expected a JSON object");+ return;+ }+ const { dir, sessionId, width } = parsed as Record<string, unknown>;+ if (+ typeof dir !== "string" ||+ typeof sessionId !== "string" ||+ (width !== null && typeof width !== "number")+ ) {+ respond(res, 400, "expected { dir, sessionId, width }");+ return;+ }+ if (+ !/^[A-Za-z0-9._:-]{1,128}$/.test(sessionId) ||+ (width !== null && !(Number.isInteger(width) && width > 0 && width <= 10_000))+ ) {+ respond(res, 400, "sessionId or width is not valid");+ return;+ }+ const root = await registeredRoot(env, dir);+ if (root === null) {+ respond(res, 403, "not a registered project");+ return;+ }+ try {+ await setRowWidth(root, sessionId, width);+ } catch {+ respond(res, 500, "could not write the row width");+ return;+ }+ res.writeHead(200, {+ "content-type": "application/json",+ "cache-control": "no-store",+ });+ res.end(JSON.stringify({ ok: true, sessionId, width }));+ }+async function handle(req: IncomingMessage, res: ServerResponse): Promise<void> {const port = (server.address() as AddressInfo | null)?.port ?? opts.port;if (req.method === "POST") {@@ -687,6 +765,10 @@ export async function startMapServer(opts: MapServerOptions): Promise<MapServer>await writeInboxDismiss(req, res, port);return;}+ if (url.pathname === "/api/row-width") {+ await writeRowWidth(req, res, port);+ return;+ }if (url.pathname !== "/api/config") {respond(res, 405, "method not allowed");return;diff --git a/packages/cli/src/store/paths.ts b/packages/cli/src/store/paths.tsindex ffec6e4..a17ca40 100644--- a/packages/cli/src/store/paths.ts+++ b/packages/cli/src/store/paths.ts@@ -40,6 +40,8 @@ export function projectPaths(root: string) {readState: join(base, "state", "read.json"),/** Inbox rows the user dismissed, per session (Story 11.1); also local. */inboxState: join(base, "state", "inbox.json"),+ /** How wide the user dragged each session's message rows on the map; also local. */+ rowWidths: join(base, "state", "row-widths.json"),/** What the detached hook children (build, side run) printed; local, capped. */detachedLog: join(base, "state", "detached.log"),locks: join(base, "locks"),diff --git a/packages/cli/src/store/row-widths.ts b/packages/cli/src/store/row-widths.tsnew file mode 100644index 0000000..ccaddb1--- /dev/null+++ b/packages/cli/src/store/row-widths.ts@@ -0,0 +1,63 @@+import { z } from "zod";+import { atomicWriteJson, readJson } from "./fs.js";+import { withLock } from "./lock.js";+import { projectPaths } from "./paths.js";++/**+ * How wide the user dragged each session's message rows on the map. A view+ * preference, so it is local per-user state under `.cogit/state/` like the read+ * marks: never committed, so one person's wide screen never reshapes a+ * teammate's map. The page keeps the width in range; this file only checks that+ * it is a sane number.+ */++export const ROW_WIDTHS_SCHEMA = 1;++const SESSION_ID = /^[A-Za-z0-9._:-]{1,128}$/;+/** Far past anything the map lets a drag reach. */+const MAX_WIDTH = 10_000;++export const RowWidths = z.object({+ schema: z.literal(ROW_WIDTHS_SCHEMA),+ /** Session id → the message rows' width in map pixels. */+ widths: z.record(z.string(), z.number().int().positive().max(MAX_WIDTH)).default({}),+});++export type RowWidths = z.infer<typeof RowWidths>;++/** The stored widths. A missing or unreadable file is "nothing dragged yet". */+export async function readRowWidths(root: string): Promise<Record<string, number>> {+ const read = await readJson(projectPaths(root).rowWidths);+ if (!read.found || "error" in read) return {};+ const parsed = RowWidths.safeParse(read.value);+ return parsed.success ? parsed.data.widths : {};+}++/**+ * Stores one session's width, or forgets it (`null`, the double-click reset).+ * The file is derived state: an unreadable one is replaced rather than blocking+ * the drag.+ */+export async function setRowWidth(+ root: string,+ sessionId: string,+ width: number | null,+): Promise<void> {+ if (!SESSION_ID.test(sessionId)) throw new Error(`not a session id: ${sessionId}`);+ if (width !== null && !(Number.isInteger(width) && width > 0 && width <= MAX_WIDTH))+ throw new Error(`not a row width: ${width}`);+ const paths = projectPaths(root);+ await withLock(+ paths.lock("row-widths"),+ async () => {+ const widths = await readRowWidths(root);+ if (width === null) delete widths[sessionId];+ else widths[sessionId] = width;+ const sorted = Object.fromEntries(+ Object.entries(widths).sort(([a], [b]) => a.localeCompare(b)),+ );+ await atomicWriteJson(paths.rowWidths, { schema: ROW_WIDTHS_SCHEMA, widths: sorted });+ },+ { timeoutMs: 2000 },+ );+}diff --git a/packages/cli/src/view/model.ts b/packages/cli/src/view/model.tsindex d53f83d..2da80f2 100644--- a/packages/cli/src/view/model.ts+++ b/packages/cli/src/view/model.ts@@ -311,6 +311,12 @@ export interface LineageViewModel {* a rebuild embeds the new list.*/read?: string[];+ /**+ * How wide the user dragged each session's message rows, by session id, from+ * `.cogit/state/row-widths.json` at build time. Local state like `read`.+ * Absent on pages built before it.+ */+ rowWidths?: Record<string, number>;/*** The "your turn" inbox for this project only (Story 11.1). Absent on pages* built before it; a project's map never carries another project's rows.diff --git a/packages/cli/test/row-widths.test.ts b/packages/cli/test/row-widths.test.tsnew file mode 100644index 0000000..263d024--- /dev/null+++ b/packages/cli/test/row-widths.test.ts@@ -0,0 +1,42 @@+import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { afterEach, beforeEach, describe, expect, it } from "vitest";+import { projectPaths } from "../src/store/paths.js";+import { readRowWidths, setRowWidth } from "../src/store/row-widths.js";++describe("row widths state", () => {+ let root: string;+ beforeEach(async () => {+ root = await mkdtemp(join(tmpdir(), "cogit-row-widths-"));+ });+ afterEach(async () => {+ await rm(root, { recursive: true, force: true });+ });++ it("stores, replaces and forgets a session's width", async () => {+ expect(await readRowWidths(root)).toEqual({});+ await setRowWidth(root, "b", 700);+ await setRowWidth(root, "a", 900);+ await setRowWidth(root, "b", 640);+ expect(await readRowWidths(root)).toEqual({ a: 900, b: 640 });+ await setRowWidth(root, "a", null);+ expect(await readRowWidths(root)).toEqual({ b: 640 });+ });++ it("refuses a bad session id or width", async () => {+ await expect(setRowWidth(root, "bad id!", 700)).rejects.toThrow("not a session id");+ await expect(setRowWidth(root, "a", 0)).rejects.toThrow("not a row width");+ await expect(setRowWidth(root, "a", 1.5)).rejects.toThrow("not a row width");+ await expect(setRowWidth(root, "a", 20_000)).rejects.toThrow("not a row width");+ });++ it("reads a damaged file as nothing stored, and replaces it on the next write", async () => {+ const file = projectPaths(root).rowWidths;+ await mkdir(join(file, ".."), { recursive: true });+ await writeFile(file, '{"schema":1,"widths":{"a":"wide"}}');+ expect(await readRowWidths(root)).toEqual({});+ await setRowWidth(root, "a", 700);+ expect(await readRowWidths(root)).toEqual({ a: 700 });+ });+});diff --git a/packages/cli/test/server.test.ts b/packages/cli/test/server.test.tsindex bb99415..fbea739 100644--- a/packages/cli/test/server.test.ts+++ b/packages/cli/test/server.test.ts@@ -31,6 +31,7 @@ import { atomicWrite } from "../src/store/fs.js";import { readInboxDismissed } from "../src/store/inbox-state.js";import { globalPaths, projectPaths } from "../src/store/paths.js";import { readReadState } from "../src/store/read-state.js";+import { readRowWidths } from "../src/store/row-widths.js";import { loadConfig, updateConfig } from "../src/store/stores.js";import { DATA_ELEMENT_ID, LIVE_META_NAME, TOKEN_META_NAME } from "../src/view/model.js";import { envFor, fakeIo, noGitProject, tempDir } from "./helpers.js";@@ -890,6 +891,69 @@ describe("inbox dismiss endpoint (Story 11.1)", () => {});});+describe("row width endpoint", () => {+ const SESSION = "3f2b1c4d-0000-4000-8000-000000000001";++ function widthWrite(+ server: MapServer,+ token: string,+ payload: unknown,+ overrides: Record<string, string> = {},+ ): Promise<Reply> {+ return postConfig(`${server.url}/api/row-width`, JSON.stringify(payload), {+ origin: `http://127.0.0.1:${server.port}`,+ [CONFIG_TOKEN_HEADER]: token,+ ...overrides,+ });+ }++ it("stores a session's width in local state and forgets it on null", async () => {+ const server = await start();+ const token = await panelToken(server);+ const reply = await widthWrite(server, token, { dir: root, sessionId: SESSION, width: 840 });+ expect(reply.status).toBe(200);+ expect(JSON.parse(reply.body)).toEqual({ ok: true, sessionId: SESSION, width: 840 });+ expect(await readRowWidths(root)).toEqual({ [SESSION]: 840 });+ await widthWrite(server, token, { dir: root, sessionId: SESSION, width: null });+ expect(await readRowWidths(root)).toEqual({});+ });++ it("refuses a foreign project, a bad payload, a bad token and a bad body", async () => {+ const server = await start();+ const token = await panelToken(server);+ const good = { dir: root, sessionId: SESSION, width: 700 };+ expect((await widthWrite(server, token, { ...good, dir: join(dir, "elsewhere") })).status).toBe(+ 403,+ );+ expect((await widthWrite(server, "nope", good)).status).toBe(403);+ expect((await widthWrite(server, token, good, { "content-type": "text/plain" })).status).toBe(+ 415,+ );+ expect((await widthWrite(server, token, { ...good, sessionId: "bad id!" })).status).toBe(400);+ expect((await widthWrite(server, token, { ...good, width: 700.5 })).status).toBe(400);+ expect((await widthWrite(server, token, { ...good, width: -1 })).status).toBe(400);+ expect((await widthWrite(server, token, { ...good, width: "wide" })).status).toBe(400);+ expect((await widthWrite(server, token, [])).status).toBe(400);+ expect(+ (+ await postConfig(`${server.url}/api/row-width`, "{oops", {+ origin: `http://127.0.0.1:${server.port}`,+ [CONFIG_TOKEN_HEADER]: token,+ })+ ).status,+ ).toBe(400);+ expect((await widthWrite(server, token, { ...good, pad: "x".repeat(5000) })).status).toBe(413);+ });++ it("answers 500 instead of crashing when the state cannot be written", async () => {+ const server = await start();+ const token = await panelToken(server);+ await mkdir(projectPaths(root).rowWidths, { recursive: true });+ const reply = await widthWrite(server, token, { dir: root, sessionId: SESSION, width: 700 });+ expect(reply.status).toBe(500);+ });+});+describe("commit diff endpoint (Story 10.5)", () => {const run = promisify(execFile);diff --git a/packages/template/src/Graph.tsx b/packages/template/src/Graph.tsxindex 15b02c2..39b77ef 100644--- a/packages/template/src/Graph.tsx+++ b/packages/template/src/Graph.tsx@@ -14,7 +14,7 @@ import { createContext, useCallback, useContext, useEffect, useMemo, useState }import { unreadViewMessages } from "../../cli/src/view/change.js";import type { LineageViewModel, ViewSession } from "../../cli/src/view/model.js";import { hitMessageIds, hitSessionIds } from "../../cli/src/view/search.js";-import { pageToken, saveRead } from "./data.js";+import { pageToken, saveRead, saveRowWidth } from "./data.js";import { type FilesTarget, FilesView } from "./FilesView.js";import { useFullscreen } from "./fullscreen.js";import { GitGraph } from "./GitGraph.js";@@ -22,7 +22,7 @@ import { type GitLayout, layoutGitGraph, ROW_WIDTH } from "./gitLayout.js";import { centreViewport, headOf, type MapPoint } from "./graph.js";import type { MapSearchState } from "./MapSearch.js";import { Outline, type OutlineTarget } from "./Outline.js";-import { loadRowWidths, RowEdge, type RowWidths, saveRowWidths } from "./RowEdge.js";+import { RowEdge, type RowWidths, rowWidthsOf } from "./RowEdge.js";import { OPEN_LINK_DROP, SessionMap } from "./SessionMap.js";import { DrillDown, type Selection } from "./SidePanel.js";import { usePageWheel } from "./scroll.js";@@ -57,6 +57,7 @@ const GraphActions = createContext<{unfold: (segmentId: string) => void;/** Sets the width of the open sessions' message rows (their right edge). */resizeRows: (sessionId: string, width: number) => void;+ storeRowWidth: (sessionId: string, width: number) => void;}>({selection: null,openIds: new Set(),@@ -67,6 +68,7 @@ const GraphActions = createContext<{openContinue: () => {},unfold: () => {},resizeRows: () => {},+ storeRowWidth: () => {},});/** An opened session: its message graph and where it sits on the canvas. */@@ -97,8 +99,16 @@ function SessionMessages({highlights: ReadonlySet<string> | undefined;activeHitId: string | null;}) {- const { selection, readIds, bigChangeLines, openNode, openContinue, unfold, resizeRows } =- useContext(GraphActions);+ const {+ selection,+ readIds,+ bigChangeLines,+ openNode,+ openContinue,+ unfold,+ resizeRows,+ storeRowWidth,+ } = useContext(GraphActions);const own = selection?.sessionId === session.sessionId;if (git.rows.length === 0)return <p className="graph-status empty">No messages recorded in this session yet.</p>;@@ -116,7 +126,11 @@ function SessionMessages({onUnfold={unfold}onContinue={(continues) => openContinue(continues.sessionId, continues.id)}/>- <RowEdge git={git} onResize={(width) => resizeRows(session.sessionId, width)} />+ <RowEdge+ git={git}+ onResize={(width) => resizeRows(session.sessionId, width)}+ onDone={(width) => storeRowWidth(session.sessionId, width)}+ /></div>);}@@ -235,8 +249,7 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta});const [unfolded, setUnfolded] = useState<Set<string>>(() => new Set());/** Each session's message row width, dragged at the rows' right edge. */- const [rowWidths, setRowWidths] = useState<RowWidths>(loadRowWidths);- useEffect(() => saveRowWidths(rowWidths), [rowWidths]);+ const [rowWidths, setRowWidths] = useState<RowWidths>(() => rowWidthsOf(model.rowWidths));const resizeRows = useCallback((sessionId: string, width: number) => {setRowWidths((previous) => {// Back at the default (double-click): forget the session.@@ -244,6 +257,23 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchStareturn width === ROW_WIDTH ? rest : { ...rest, [sessionId]: width };});}, []);+ /** A drag ended: store the width in the project's local state. */+ const storeRowWidth = useCallback(+ (sessionId: string, width: number) => {+ // Over `file://` there is no server; the width lasts for this open page.+ const token = pageToken();+ if (token === null) return;+ void saveRowWidth(+ model.project.path,+ sessionId,+ width === ROW_WIDTH ? null : width,+ token,+ ).catch((err: unknown) => {+ console.warn("cogit: could not save the row width", err);+ });+ },+ [model.project.path],+ );const [openAll, setOpenAll] = useState(false);const [showOutline, setShowOutline] = useState(true);// The files, unread and outline views share the left column; only one shows.@@ -599,6 +629,7 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchStaopenContinue,unfold,resizeRows,+ storeRowWidth,}),[selection,@@ -610,6 +641,7 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchStaopenContinue,unfold,resizeRows,+ storeRowWidth,],);diff --git a/packages/template/src/RowEdge.tsx b/packages/template/src/RowEdge.tsxindex 5ffedb0..eb61676 100644--- a/packages/template/src/RowEdge.tsx+++ b/packages/template/src/RowEdge.tsx@@ -5,35 +5,23 @@ import { clampRowWidth, type GitLayout, ROW_WIDTH } from "./gitLayout.js";/*** The right edge of an open session's message rows: drag it to make the rows* wider or narrower, double-click it to reset. Titles get the room and wrap- * into fewer lines. Each session keeps its own width, and it stays in this- * browser.+ * into fewer lines. Each session keeps its own width, stored in the project's+ * local state when the drag ends.*/-const KEY = "cogit.sessionRowWidths";/** The grab area stays this wide on screen whatever the zoom. */const GRAB = 12;/** Widths the user dragged, by session id; a session not listed has `ROW_WIDTH`. */export type RowWidths = Readonly<Record<string, number>>;-export function loadRowWidths(): RowWidths {- try {- const raw: unknown = JSON.parse(window.localStorage.getItem(KEY) ?? "{}");- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return {};- const out: Record<string, number> = {};- for (const [sessionId, width] of Object.entries(raw)) out[sessionId] = clampRowWidth(width);- return out;- } catch {- return {};- }-}--export function saveRowWidths(widths: RowWidths): void {- try {- window.localStorage.setItem(KEY, JSON.stringify(widths));- } catch {- // Private window or blocked storage: the width lasts until the page closes.- }+/** The page's stored widths, kept in range; anything else is dropped. */+export function rowWidthsOf(raw: unknown): RowWidths {+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return {};+ const out: Record<string, number> = {};+ for (const [sessionId, width] of Object.entries(raw))+ if (typeof width === "number") out[sessionId] = clampRowWidth(width);+ return out;}/** Keeps the drag on the edge when the pointer leaves it; best effort. */@@ -46,7 +34,17 @@ function capture(event: PointerEvent, on: boolean): void {}}-export function RowEdge({ git, onResize }: { git: GitLayout; onResize: (width: number) => void }) {+export function RowEdge({+ git,+ onResize,+ onDone,+}: {+ git: GitLayout;+ /** Every move of a drag. */+ onResize: (width: number) => void;+ /** The width a drag or a reset ended at: the one worth storing. */+ onDone: (width: number) => void;+}) {// The canvas may be zoomed: a screen pixel is 1/zoom of a canvas pixel.const zoom = useStore((state) => state.transform[2]) || 1;const [start, setStart] = useState<{ x: number; width: number } | null>(null);@@ -72,10 +70,12 @@ export function RowEdge({ git, onResize }: { git: GitLayout; onResize: (width: nif (!start) return;capture(event, false);setStart(null);+ onDone(clampRowWidth(start.width + (event.clientX - start.x) / zoom));}}onDoubleClick={(event) => {event.stopPropagation();onResize(ROW_WIDTH);+ onDone(ROW_WIDTH);}}/>);diff --git a/packages/template/src/data.ts b/packages/template/src/data.tsindex 24f8498..6109ee6 100644--- a/packages/template/src/data.ts+++ b/packages/template/src/data.ts@@ -98,6 +98,28 @@ export async function saveRead(}}+/**+ * Stores how wide one session's message rows are, or forgets it (`null`). The+ * state lives in the project's `.cogit/state/`, so this needs the local server;+ * over `file://` the width lasts for the open page only.+ */+export async function saveRowWidth(+ dir: string,+ sessionId: string,+ width: number | null,+ token: string,+): Promise<void> {+ const response = await fetch("/api/row-width", {+ method: "POST",+ headers: { "content-type": "application/json", "x-cogit-token": token },+ body: JSON.stringify({ dir, sessionId, width }),+ });+ if (!response.ok) {+ const text = (await response.text()).trim();+ throw new Error(text || `could not save the row width (HTTP ${response.status})`);+ }+}+/*** Dismisses one inbox row (Story 11.1). The state lives in the project's* `.cogit/state/`, so this needs the local server; over `file://` the rowdiff --git a/packages/template/test/rowEdge.test.ts b/packages/template/test/rowEdge.test.tsindex 9c913e7..c551f50 100644--- a/packages/template/test/rowEdge.test.ts+++ b/packages/template/test/rowEdge.test.ts@@ -2,7 +2,7 @@ import { readFileSync } from "node:fs";import { ReactFlowProvider } from "@xyflow/react";import { createElement } from "react";import { renderToStaticMarkup } from "react-dom/server";-import { afterEach, describe, expect, it, vi } from "vitest";+import { describe, expect, it } from "vitest";import {clampRowWidth,layoutGitGraph,@@ -10,13 +10,11 @@ import {ROW_WIDTH_MAX,ROW_WIDTH_MIN,} from "../src/gitLayout.js";-import { loadRowWidths, RowEdge, saveRowWidths } from "../src/RowEdge.js";+import { RowEdge, rowWidthsOf } from "../src/RowEdge.js";const T0 = "2026-10-26T10:00:00.000Z";describe("dragging the message rows wider", () => {- afterEach(() => vi.unstubAllGlobals());-it("keeps a dragged width in range and reads junk as the default", () => {expect(clampRowWidth(10)).toBe(ROW_WIDTH_MIN);expect(clampRowWidth(99_999)).toBe(ROW_WIDTH_MAX);@@ -31,7 +29,11 @@ describe("dragging the message rows wider", () => {{ rowWidth: 700 },);const html = renderToStaticMarkup(- createElement(ReactFlowProvider, null, createElement(RowEdge, { git, onResize: () => {} })),+ createElement(+ ReactFlowProvider,+ null,+ createElement(RowEdge, { git, onResize: () => {}, onDone: () => {} }),+ ),);expect(html).toContain('role="separator"');// At zoom 1 the strip is 12px wide, centred on the edge.@@ -44,33 +46,13 @@ describe("dragging the message rows wider", () => {expect(css).toMatch(/\.row-edge,[^{]*\{\s*pointer-events:\s*all/);});- it("remembers each session's width, and reads blocked, empty or junk storage as none", () => {- const store = new Map<string, string>();- vi.stubGlobal("window", {- localStorage: {- getItem: (key: string) => store.get(key) ?? null,- setItem: (key: string, value: string) => store.set(key, value),- },- });- expect(loadRowWidths()).toEqual({});- saveRowWidths({ a: 840, b: 600 });- expect(loadRowWidths()).toEqual({ a: 840, b: 600 });- store.set("cogit.sessionRowWidths", JSON.stringify({ a: 99_999, b: "wide" }));- expect(loadRowWidths()).toEqual({ a: ROW_WIDTH_MAX, b: ROW_WIDTH });- store.set("cogit.sessionRowWidths", "[1,2]");- expect(loadRowWidths()).toEqual({});-- vi.stubGlobal("window", {- localStorage: {- getItem: () => {- throw new Error("blocked");- },- setItem: () => {- throw new Error("blocked");- },- },+ it("reads the stored widths in range and drops anything else", () => {+ expect(rowWidthsOf({ a: 840, b: 99_999, c: 10, d: "wide" })).toEqual({+ a: 840,+ b: ROW_WIDTH_MAX,+ c: ROW_WIDTH_MIN,});- expect(loadRowWidths()).toEqual({});- expect(() => saveRowWidths({ a: 600 })).not.toThrow();+ expect(rowWidthsOf(undefined)).toEqual({});+ expect(rowWidthsOf([1, 2])).toEqual({});});});