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
fix(map): frame the left-off message in the middle and link back to the panel
Eren0faec52d1c66
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex d41dbfe..2785ae1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0## [Unreleased]### Changed- The panel uses the map's centred 8-of-12 column, and every page names the product: "cogit" with its slogan "Cogito, ergo commit." opens the top bar, and on a served map it leads back to the panel.+- A project's map has a visible "← All projects" link above its name, and opening the map, "Left off here", a search step or a file click frame the whole message row (lanes and text) in the middle of the map instead of only its dot, so the message no longer sits off to the right; a row wider than the map starts at its left edge.### Fixed- The git hooks work without a `cogit` on PATH (a plugin-only install): the hook block falls back to the CLI that installed it, run with `node`, and does nothing — no "command not found" — when neither is there; each prompt points an existing block at the current CLI, so a plugin update does not break it. `cogit hooks install` adds or refreshes the blocks by hand.diff --git a/packages/template/src/App.tsx b/packages/template/src/App.tsxindex 826bdbc..e0bba3a 100644--- a/packages/template/src/App.tsx+++ b/packages/template/src/App.tsx@@ -7,7 +7,7 @@ import {searchLineage,stepHitIndex,} from "../../cli/src/view/search.js";-import { Brand } from "./Brand.js";+import { BackToPanel, Brand } from "./Brand.js";import { formatTime } from "./format.js";import { Graph } from "./Graph.js";import { type MapSearchState, SearchBox } from "./MapSearch.js";@@ -62,6 +62,7 @@ export function App({ model }: { model: LineageViewModel }) {<header className="project"><div>+ <BackToPanel /><h1>{model.project.name}</h1><p className="muted">{model.project.path}</p></div>diff --git a/packages/template/src/Brand.tsx b/packages/template/src/Brand.tsxindex d3d1a4f..3b843b6 100644--- a/packages/template/src/Brand.tsx+++ b/packages/template/src/Brand.tsx@@ -22,3 +22,16 @@ export function Brand({ home = false }: { home?: boolean }) {</a>);}++/**+ * The way back from a project's map to the panel, above the project name. Only+ * a served map has a panel to go back to.+ */+export function BackToPanel() {+ if (!isLivePage()) return null;+ return (+ <a className="back-link" href="/">+ ← All projects+ </a>+ );+}diff --git a/packages/template/src/Graph.tsx b/packages/template/src/Graph.tsxindex ac20caa..d999fcc 100644--- a/packages/template/src/Graph.tsx+++ b/packages/template/src/Graph.tsx@@ -17,7 +17,7 @@ import { type FilesTarget, FilesView } from "./FilesView.js";import { useFullscreen } from "./fullscreen.js";import { GitGraph } from "./GitGraph.js";import { type GitLayout, layoutGitGraph } from "./gitLayout.js";-import { headOf } from "./graph.js";+import { centreViewport, headOf, type MapPoint } from "./graph.js";import type { MapSearchState } from "./MapSearch.js";import { Outline, type OutlineTarget } from "./Outline.js";import { OPEN_LINK_DROP, SessionMap } from "./SessionMap.js";@@ -358,7 +358,13 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta(candidate) => candidate.kind === "message" && candidate.message.id === messageId,);if (!opening || !row) return null;- return { x: opening.left + opening.git.graphWidth / 2, y: opening.top + row.y };+ // Frame the whole row (lanes and text), not only its dot.+ return {+ x: opening.left + opening.git.graphWidth / 2,+ y: opening.top + row.y,+ left: opening.left,+ right: opening.left + opening.git.width,+ };},[openings],);@@ -665,9 +671,9 @@ function MapCanvas({}: {nodes: MapFlowNode[];/** Point to centre on at load; null fits the whole graph. */- focusRow: { x: number; y: number } | null;+ focusRow: MapPoint | null;/** A user request to centre on a point; a new `key` moves the view again. */- jump: { key: number; point: { x: number; y: number } | null } | null;+ jump: { key: number; point: MapPoint | null } | null;/** A search move: the active hit or a pasted hash (Story 8.14). */searchJump: { key: number; point: { x: number; y: number } } | null;/** A files-view click: the message it opened (Story 8.15). */@@ -678,18 +684,10 @@ function MapCanvas({const { fitView, setViewport } = useReactFlow();/** Centres the view on a canvas point; does nothing before the canvas exists. */- function centre(point: { x: number; y: number }): void {+ function centre(point: MapPoint): void {const canvas = document.querySelector(".react-flow")?.getBoundingClientRect();if (!canvas) return;- const zoom = 0.9;- void setViewport(- {- zoom,- x: canvas.width / 2 - point.x * zoom,- y: canvas.height / 2 - point.y * zoom,- },- { duration: 300 },- );+ void setViewport(centreViewport(point, canvas, 0.9), { duration: 300 });}useEffect(() => {@@ -730,12 +728,7 @@ function MapCanvas({const timer = window.setTimeout(() => {const canvas = document.querySelector(".react-flow")?.getBoundingClientRect();if (focusRow && canvas) {- const zoom = 0.9;- void setViewport({- zoom,- x: canvas.width / 2 - focusRow.x * zoom,- y: canvas.height / 2 - focusRow.y * zoom,- });+ void setViewport(centreViewport(focusRow, canvas, 0.9));return;}void fitView({ padding: 0.12, maxZoom: 1, duration: 200 });diff --git a/packages/template/src/graph.ts b/packages/template/src/graph.tsindex 4eb0e19..3f29df9 100644--- a/packages/template/src/graph.ts+++ b/packages/template/src/graph.ts@@ -119,3 +119,33 @@ export function messageNeighbors(if (index < 0) return { previous: null, next: null };return { previous: messages[index - 1] ?? null, next: messages[index + 1] ?? null };}++/**+ * A point the map centres on. `left` and `right` are the canvas span of the+ * row it belongs to (the lanes plus the message text), so the whole row is+ * framed, not only the dot.+ */+export type MapPoint = { x: number; y: number; left?: number; right?: number };++/** Space kept between the canvas edge and a row too wide to centre. */+export const CENTRE_MARGIN = 24;++/**+ * The viewport that puts `point` in the middle of the canvas. A row wider than+ * the canvas starts at the left edge (plus a margin) instead, so its lanes and+ * the start of its text stay in view.+ */+export function centreViewport(+ point: MapPoint,+ canvas: { width: number; height: number },+ zoom: number,+): { x: number; y: number; zoom: number } {+ const y = canvas.height / 2 - point.y * zoom;+ const { left, right } = point;+ if (left !== undefined && right !== undefined) {+ const span = (right - left) * zoom;+ if (span > canvas.width - 2 * CENTRE_MARGIN) return { zoom, y, x: CENTRE_MARGIN - left * zoom };+ return { zoom, y, x: canvas.width / 2 - ((left + right) / 2) * zoom };+ }+ return { zoom, y, x: canvas.width / 2 - point.x * zoom };+}diff --git a/packages/template/src/styles.css b/packages/template/src/styles.cssindex 8d6a5c2..3832bc8 100644--- a/packages/template/src/styles.css+++ b/packages/template/src/styles.css@@ -151,6 +151,20 @@ a.brand:hover .brand-tagline {color: var(--text);}+/* "← All projects" above a project's name on its map. */+.back-link {+ display: inline-block;+ margin-bottom: 4px;+ color: var(--muted);+ font-size: 13px;+ text-decoration: none;+}++.back-link:hover {+ color: var(--text);+ text-decoration: underline;+}+/* The map page: head on top, map fills the rest of the window. */main.map-page {display: flex;diff --git a/packages/template/test/brand.test.ts b/packages/template/test/brand.test.tsindex 306c962..1835316 100644--- a/packages/template/test/brand.test.ts+++ b/packages/template/test/brand.test.ts@@ -1,7 +1,7 @@import { createElement } from "react";import { renderToStaticMarkup } from "react-dom/server";import { afterEach, describe, expect, it } from "vitest";-import { Brand } from "../src/Brand.js";+import { BackToPanel, Brand } from "../src/Brand.js";/** A stand-in document: only the live-page meta lookup is read. */function fakeDocument(live: boolean): void {@@ -28,3 +28,18 @@ describe("Brand", () => {expect(renderToStaticMarkup(createElement(Brand))).toContain('<span class="brand"');});});++describe("BackToPanel", () => {+ afterEach(() => {+ delete (globalThis as { document?: unknown }).document;+ });++ it("links a served map back to the panel and stays out of a file", () => {+ fakeDocument(true);+ expect(renderToStaticMarkup(createElement(BackToPanel))).toBe(+ '<a class="back-link" href="/">← All projects</a>',+ );+ fakeDocument(false);+ expect(renderToStaticMarkup(createElement(BackToPanel))).toBe("");+ });+});diff --git a/packages/template/test/graph.test.ts b/packages/template/test/graph.test.tsindex d20a26e..92a99f3 100644--- a/packages/template/test/graph.test.ts+++ b/packages/template/test/graph.test.ts@@ -1,6 +1,14 @@import { describe, expect, it } from "vitest";import type { LineageViewModel, ViewNode } from "../../cli/src/view/model.js";-import { headOf, messageNeighbors, nodeId, sessionId, toNodeDetail } from "../src/graph.js";+import {+ CENTRE_MARGIN,+ centreViewport,+ headOf,+ messageNeighbors,+ nodeId,+ sessionId,+ toNodeDetail,+} from "../src/graph.js";const AT = "2026-10-21T10:00:00.000Z";@@ -130,3 +138,28 @@ describe("ids", () => {expect(nodeId("session:abc", "m1")).toBe("node:session:abc:m1");});});++describe("centreViewport", () => {+ const canvas = { width: 800, height: 400 };++ it("centres the whole row, not only its dot", () => {+ // Row from 100 to 700 at zoom 1: its middle (400) lands on the canvas middle.+ expect(centreViewport({ x: 130, y: 50, left: 100, right: 700 }, canvas, 1)).toEqual({+ zoom: 1,+ x: 0,+ y: 150,+ });+ });++ it("starts a row wider than the canvas at the left margin", () => {+ expect(centreViewport({ x: 130, y: 50, left: 100, right: 1100 }, canvas, 1)).toEqual({+ zoom: 1,+ x: CENTRE_MARGIN - 100,+ y: 150,+ });+ });++ it("centres a bare point when the row span is unknown", () => {+ expect(centreViewport({ x: 100, y: 100 }, canvas, 0.5)).toEqual({ zoom: 0.5, x: 350, y: 150 });+ });+});