Skip to content

armgit / cogit

Public Imported from GitHub
0

Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.

feat(map): widen the session rows along with the message rows

Eren253d2ef5f1e8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c34d377..27728c1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Changed
+- Dragging the message rows' edge on the map now widens the session rows too, so the whole map grows with it.
+
## [0.22.0] - 2026-10-30
### Added
- Drag the right edge of an open session's messages to make the rows wider or narrower, so long titles wrap into fewer lines; double-click the edge to reset. The width applies to every session and is remembered in this browser.
diff --git a/packages/template/src/Graph.tsx b/packages/template/src/Graph.tsx
index 6bbdebd..6e254ef 100644
--- a/packages/template/src/Graph.tsx
+++ b/packages/template/src/Graph.tsx
@@ -402,7 +402,10 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
return out;
}, [messageGits]);
- const sessionGraph = useMemo(() => layoutSessionGraph(model, spaceAfter), [model, spaceAfter]);
+ const sessionGraph = useMemo(
+ () => layoutSessionGraph(model, spaceAfter, rowWidth),
+ [model, spaceAfter, rowWidth],
+ );
const openings = useMemo(() => {
const out: Opening[] = [];
diff --git a/packages/template/src/sessionLayout.ts b/packages/template/src/sessionLayout.ts
index 04580f3..24caa4f 100644
--- a/packages/template/src/sessionLayout.ts
+++ b/packages/template/src/sessionLayout.ts
@@ -1,5 +1,5 @@
import type { LineageViewModel, ViewSession } from "../../cli/src/view/model.js";
-import { type GitLayout, type GitNode, layoutGitGraph } from "./gitLayout.js";
+import { type GitLayout, type GitNode, layoutGitGraph, ROW_WIDTH } from "./gitLayout.js";
import { headOf } from "./graph.js";
/**
@@ -13,6 +13,14 @@ import { headOf } from "./graph.js";
/** Wider than a message row: a session row carries a title, a count and a tag. */
export const SESSION_ROW_WIDTH = 720;
+/**
+ * Session rows follow the dragged width of the message rows, keeping the same
+ * extra room, so widening one session's messages widens the whole map.
+ */
+export function sessionRowWidth(messageRowWidth: number): number {
+ return SESSION_ROW_WIDTH + messageRowWidth - ROW_WIDTH;
+}
+
function time(value: string | undefined): number {
if (!value) return Number.NEGATIVE_INFINITY;
const at = Date.parse(value);
@@ -71,6 +79,8 @@ export function layoutSessionGraph(
model: LineageViewModel,
/** Room to leave under a session's row for its opened messages, by session id. */
spaceAfter?: ReadonlyMap<string, number>,
+ /** The message rows' width; the session rows keep pace with it. */
+ messageRowWidth: number = ROW_WIDTH,
): SessionGraph {
const sessions = allSessions(model);
const byId = new Map(sessions.map((session) => [session.sessionId, session]));
@@ -102,7 +112,7 @@ export function layoutSessionGraph(
const git = layoutGitGraph(items, {
fold: false,
- rowWidth: SESSION_ROW_WIDTH,
+ rowWidth: sessionRowWidth(messageRowWidth),
headId: headOf(model)?.sessionId ?? null,
itemEnd: endIndex,
...(spaceAfter === undefined ? {} : { spaceAfter }),
diff --git a/packages/template/test/sessionLayout.test.ts b/packages/template/test/sessionLayout.test.ts
index 2ce0ca3..ba3b543 100644
--- a/packages/template/test/sessionLayout.test.ts
+++ b/packages/template/test/sessionLayout.test.ts
@@ -84,6 +84,12 @@ describe("layoutSessionGraph", () => {
]);
});
+ it("widens the session rows along with dragged message rows", () => {
+ const model = modelOf([session("a", 0, 60)]);
+ expect(layoutSessionGraph(model).git.rowWidth).toBe(720);
+ expect(layoutSessionGraph(model, undefined, 820).git.rowWidth).toBe(1020);
+ });
+
it("runs a child session in the parent's lane", () => {
const earlier = session("a", 0, 60);
const later = session("b", 90, 120, { sessionId: "a", id: "h1", sessionTitle: "Session a" });