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(record): give an untitled session a title at session end
Eren9ce1c3d42e53
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex cbdf236..20b5950 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).## [Unreleased]+### Fixed+- A session the side model left untitled takes its first thread's title (or its first message's) at session end, instead of showing only its id on the map and in `cogit log`; `cogit log` also stops printing such an id twice.## [1.0.1] - 2026-11-06### Fixeddiff --git a/packages/cli/src/commands/close.ts b/packages/cli/src/commands/close.tsindex 88631d7..76d8d75 100644--- a/packages/cli/src/commands/close.ts+++ b/packages/cli/src/commands/close.ts@@ -253,6 +253,17 @@ export function closePayload(});const payload: Record<string, unknown> = { sessionId: record.sessionId, nodes: out };+ // The last pass over a session: one still without a title would show its bare+ // id everywhere, so it takes its first thread's title, else its first message's.+ if (record.title.trim() === "") {+ const first = order[0];+ const node = first === undefined ? undefined : nodes.get(idOf.get(first) as string);+ const fallback =+ (first === undefined ? undefined : branches.get(first)?.title) ??+ node?.branch?.title ??+ node?.title;+ if (fallback !== undefined && fallback.trim() !== "") payload.title = clip(fallback, 200);+ }if (typeof answer.leftOff === "string" && answer.leftOff.trim() !== "")payload.leftOff = clip(answer.leftOff, 400);// A malformed status would fail the whole write; it is left out instead.diff --git a/packages/cli/src/commands/log.ts b/packages/cli/src/commands/log.tsindex f11aca5..7bca79a 100644--- a/packages/cli/src/commands/log.ts+++ b/packages/cli/src/commands/log.ts@@ -287,12 +287,13 @@ export function buildLog(sessions: EffectiveSession[], opts: LogOptions = {}): L}function sessionHeading(session: LogSession): string {- const title = session.title.trim() === "" ? session.sessionId : oneLine(session.title);+ // An untitled session shows its id once, not as "id (id)".+ const title =+ session.title.trim() === ""+ ? session.sessionId+ : `${oneLine(session.title)} (${session.sessionId})`;const author = session.author === undefined ? "" : ` · by ${session.author}`;- return (- `## ${title} (${session.sessionId})${author} · ` +- `${stamp(session.startedAt)} → ${stamp(session.updatedAt)}`- );+ return `## ${title}${author} · ` + `${stamp(session.startedAt)} → ${stamp(session.updatedAt)}`;}function branchLines(branch: LogBranch): string[] {diff --git a/packages/cli/test/close.test.ts b/packages/cli/test/close.test.tsindex dd51dee..fe8a310 100644--- a/packages/cli/test/close.test.ts+++ b/packages/cli/test/close.test.ts@@ -167,6 +167,8 @@ describe("closePayload", () => {);expect(payload).toEqual({sessionId: "s1",+ // An untitled session takes its first thread's title.+ title: "Work",leftOff: "Work done, detour open",nodes: [{@@ -194,9 +196,15 @@ describe("closePayload", () => {);expect(payload.nodes).toEqual([{ id: "m1", kind: "message", title: "One", parent: "s0:h10" }]);expect(payload.status).toEqual({ goal: "g", done: [], pending: [], next: "n" });+ // No thread to name it: the first message's title.expect(closePayload({ continues: "h10", status: { pending: "x" } }, turns, record, { status: true }),- ).toEqual({ sessionId: "s1", nodes: [] });+ ).toEqual({ sessionId: "s1", title: "One", nodes: [] });+ // A session that has a title keeps it.+ expect(closePayload({}, turns, { ...record, title: "Named" }, { status: false })).toEqual({+ sessionId: "s1",+ nodes: [],+ });});});diff --git a/packages/cli/test/log.test.ts b/packages/cli/test/log.test.tsindex 3a9485d..ae3c3a4 100644--- a/packages/cli/test/log.test.ts+++ b/packages/cli/test/log.test.ts@@ -234,6 +234,16 @@ describe("cogit log and show", () => {await expect(log({ dir: root, io, session: "nope" })).rejects.toThrow(/no session matches/);});+ it("names an untitled session by its id once", async () => {+ const model = await log({ dir: root, io });+ const untitled = {+ ...model,+ sessions: model.sessions.map((entry) => ({ ...entry, title: "" })),+ };+ const headings = formatLog(untitled).filter((line) => line.startsWith("## "));+ expect(headings[0]).toMatch(/^## s2 · /);+ });+it("keeps a header for a session with no messages yet", async () => {const model = await log({ dir: root, io });const lines = formatLog(model);