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): show a message's commits and changed files as tidy rows
Erenbd5a6a67a604
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 64947f7..21f8bfe 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- 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 calmer map head: the top bar holds only "cogit", the search and Settings; the project switcher (recent projects and Ctrl/Cmd+K, its button now "Switch project") sits under the project's name and path. On the panel a click anywhere on a project's card opens its map.- 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.+- A message's details list its commits and changed files as tidy rows: each commit shows its short hash, its Conventional Commits type as a coloured badge (feat, fix, docs…), its scope and description, and each file its name in bold with its folder beside it; both headings carry a count.### Fixed- A message row's commit tags wrap two to a line instead of being cut off at the row's edge, and the row grows to hold them.diff --git a/packages/template/src/SidePanel.tsx b/packages/template/src/SidePanel.tsxindex d1cfbe5..aac1314 100644--- a/packages/template/src/SidePanel.tsx+++ b/packages/template/src/SidePanel.tsx@@ -6,6 +6,7 @@ import type {ViewSession,} from "../../cli/src/view/model.js";import { resumeCommand } from "../../cli/src/view/resume.js";+import { parseSubject, splitPath, typeColour } from "./codeRefs.js";import { formatTime, kindLabel } from "./format.js";import { layoutGitGraph } from "./gitLayout.js";import {@@ -463,36 +464,38 @@ function NodeDetails({</ul></section>) : null}- {node.commits?.length || node.files?.length ? (+ {node.commits?.length ? (<section>- <h3>In the code</h3>- {node.commits?.length ? (- <p className="drilldown-code">- {node.commits.map((commit) => {- const tag = node.commitTags?.find((candidate) => candidate.hash === commit);- const missing = node.commitTags !== undefined && tag?.subject === undefined;- return (- <code- key={commit}- className={missing ? "is-missing" : undefined}- title={missing ? "commit not in this repository" : undefined}- >- {commit}- {tag?.subject === undefined ? "" : ` ${tag.subject}`}- </code>- );- })}- </p>- ) : null}- {node.files?.length ? (- <ul className="drilldown-list">- {node.files.map((file) => (- <li key={file}>- <code>{file}</code>+ <h3>+ Commits <span className="count">{node.commits.length}</span>+ </h3>+ <ul className="commit-list">+ {node.commits.map((commit) => {+ const tag = node.commitTags?.find((candidate) => candidate.hash === commit);+ const missing = node.commitTags !== undefined && tag?.subject === undefined;+ return (+ <CommitItem key={commit} hash={commit} subject={tag?.subject} missing={missing} />+ );+ })}+ </ul>+ </section>+ ) : null}+ {node.files?.length ? (+ <section>+ <h3>+ Changed files <span className="count">{node.files.length}</span>+ </h3>+ <ul className="file-list">+ {node.files.map((file) => {+ const { dir, name } = splitPath(file);+ return (+ <li key={file} title={file}>+ <span className="file-name">{name}</span>+ {dir ? <span className="file-dir">{dir}</span> : null}</li>- ))}- </ul>- ) : null}+ );+ })}+ </ul></section>) : null}{node.kind === "message" ? <Conversation session={session} id={node.nodeId} /> : null}@@ -526,6 +529,40 @@ function NodeDetails({);}+/**+ * One commit of a message: the short hash, the Conventional Commits type as a+ * coloured badge, the scope and the description. A commit git no longer has+ * stays listed, greyed (Story 8.8).+ */+function CommitItem({+ hash,+ subject,+ missing,+}: {+ hash: string;+ subject: string | undefined;+ missing: boolean;+}) {+ const parsed = subject === undefined ? undefined : parseSubject(subject);+ const lane = parsed?.type === undefined ? undefined : typeColour(parsed.type);+ return (+ <li className={missing ? "commit-item is-missing" : "commit-item"} title={hash}>+ <code className="commit-hash">{hash.slice(0, 7)}</code>+ {parsed?.type ? (+ <span+ className="commit-type"+ style={lane === undefined ? undefined : { background: `var(--l${lane})` }}+ >+ {parsed.type}+ {parsed.breaking ? "!" : ""}+ </span>+ ) : null}+ {parsed?.scope ? <span className="commit-scope">{parsed.scope}</span> : null}+ <span className="commit-subject">{parsed ? parsed.text : "not in this repository"}</span>+ </li>+ );+}+/*** The session's "squash message" (Story 8.7): what the whole session was for,* what it got done and what is still open.diff --git a/packages/template/src/codeRefs.ts b/packages/template/src/codeRefs.tsnew file mode 100644index 0000000..7423afc--- /dev/null+++ b/packages/template/src/codeRefs.ts@@ -0,0 +1,57 @@+/**+ * The "In the code" part of a message's details: commit subjects split into+ * their Conventional Commits parts and file paths split into folder and name,+ * so the panel can draw each part on its own.+ */++export interface CommitSubject {+ /** `feat`, `fix`, … when the subject follows Conventional Commits. */+ type?: string;+ scope?: string;+ /** The subject marks a breaking change (`feat!: …`). */+ breaking: boolean;+ /** The description after the prefix, or the whole subject. */+ text: string;+}++const CONVENTIONAL = /^([a-z]+)(?:\(([^)]+)\))?(!)?:\s+(.+)$/;++export function parseSubject(subject: string): CommitSubject {+ const match = CONVENTIONAL.exec(subject);+ if (!match) return { breaking: false, text: subject };+ const [, type, scope, bang, text] = match as unknown as [+ string,+ string,+ string | undefined,+ string | undefined,+ string,+ ];+ return { type, ...(scope ? { scope } : {}), breaking: bang === "!", text };+}++/** Lane colour index for a commit type; anything else draws neutral. */+const TYPE_COLOUR: Record<string, number> = {+ feat: 1,+ fix: 5,+ docs: 4,+ refactor: 3,+ perf: 3,+ test: 2,+};++export function typeColour(type: string): number | undefined {+ return TYPE_COLOUR[type];+}++export interface FilePath {+ /** The folder with its trailing slash, or "" at the repository root. */+ dir: string;+ name: string;+}++export function splitPath(file: string): FilePath {+ const slash = file.lastIndexOf("/");+ return slash < 0+ ? { dir: "", name: file }+ : { dir: file.slice(0, slash + 1), name: file.slice(slash + 1) };+}diff --git a/packages/template/src/styles.css b/packages/template/src/styles.cssindex 32e8a34..4dc2a70 100644--- a/packages/template/src/styles.css+++ b/packages/template/src/styles.css@@ -1176,18 +1176,121 @@ body:has(.map-shell.is-expanded) {margin-top: 4px;}-.drilldown-code {+/* Commits and changed files of a message. */+h3 .count {+ margin-left: 4px;+ padding: 0 6px;+ color: var(--muted);+ font-size: 11px;+ font-weight: 500;+ background: var(--chip-bg);+ border-radius: 8px;+}++.commit-list,+.file-list {+ margin: 6px 0 0;+ padding: 0;+ list-style: none;+ border: 1px solid var(--line);+ border-radius: 6px;+ overflow: hidden;+}++.commit-item {display: flex;flex-wrap: wrap;+ align-items: baseline;gap: 6px;+ padding: 7px 10px;+ font-size: 13px;+ line-height: 18px;+ background: var(--row-bg);+}++.commit-item + .commit-item,+.file-list li + li {+ border-top: 1px solid var(--line);+}++.commit-hash {+ flex: none;+ padding: 0 5px;+ color: var(--accent);+ font-size: 11px;+ background: var(--chip-bg);+ border: 1px solid var(--chip-line);+ border-radius: 4px;+}++.commit-type {+ flex: none;+ padding: 0 6px;+ color: var(--on-lane);+ font-size: 10px;+ font-weight: 700;+ line-height: 16px;+ text-transform: uppercase;+ letter-spacing: 0.03em;+ background: var(--muted);+ border-radius: 4px;+}++.commit-scope {+ flex: none;+ color: var(--muted);+ font-size: 12px;+}++.commit-scope::before {+ content: "(";+}++.commit-scope::after {+ content: ")";+}++.commit-subject {+ flex: 1 1 180px;+ min-width: 0;}/* A commit git no longer has stays listed, greyed (Story 8.8). */-.drilldown-code code.is-missing {+.commit-item.is-missing .commit-hash {color: var(--missing);border-style: dashed;}+.commit-item.is-missing .commit-subject {+ color: var(--missing);+ font-style: italic;+}++.file-list li {+ display: flex;+ align-items: baseline;+ gap: 8px;+ min-width: 0;+ padding: 5px 10px;+ font-family: ui-monospace, SFMono-Regular, Menlo, monospace;+ font-size: 12px;+ background: var(--row-bg);+}++.file-name {+ flex: none;+ color: var(--text);+ font-weight: 600;+}++.file-dir {+ min-width: 0;+ overflow: hidden;+ color: var(--muted);+ text-overflow: ellipsis;+ white-space: nowrap;+}+.drilldown-meta {display: grid;gap: 8px;diff --git a/packages/template/test/codeRefs.test.ts b/packages/template/test/codeRefs.test.tsnew file mode 100644index 0000000..d5ecbfc--- /dev/null+++ b/packages/template/test/codeRefs.test.ts@@ -0,0 +1,49 @@+import { describe, expect, it } from "vitest";+import { parseSubject, splitPath, typeColour } from "../src/codeRefs.js";++describe("parseSubject", () => {+ it("splits a Conventional Commits subject into type, scope and text", () => {+ expect(parseSubject("feat(map): open a map from its card")).toEqual({+ type: "feat",+ scope: "map",+ breaking: false,+ text: "open a map from its card",+ });+ });++ it("reads a subject without a scope and a breaking mark", () => {+ expect(parseSubject("fix!: drop the old flag")).toEqual({+ type: "fix",+ breaking: true,+ text: "drop the old flag",+ });+ });++ it("keeps any other subject whole", () => {+ expect(parseSubject("Merge branch 'main'")).toEqual({+ breaking: false,+ text: "Merge branch 'main'",+ });+ });+});++describe("typeColour", () => {+ it("colours the common types and leaves the rest neutral", () => {+ expect(typeColour("feat")).toBe(1);+ expect(typeColour("fix")).toBe(5);+ expect(typeColour("chore")).toBeUndefined();+ });+});++describe("splitPath", () => {+ it("splits a path into its folder and file name", () => {+ expect(splitPath("packages/template/src/Graph.tsx")).toEqual({+ dir: "packages/template/src/",+ name: "Graph.tsx",+ });+ });++ it("has no folder at the repository root", () => {+ expect(splitPath("README.md")).toEqual({ dir: "", name: "README.md" });+ });+});