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.

fix(map): wrap long titles instead of cutting them

Eren3deaba1d640c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9f8776d..43c5262 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]
+### Fixed
+- Map: long message titles and branch labels in the git graph wrap onto more lines (the row grows) instead of being cut with an ellipsis; a not-yet-summarized message shows up to 200 characters of its text instead of 80.
+
## [0.7.0] - 2026-10-23
### Added
- Lineage records: each message node now hangs from the earlier message it reacts to (or is a new root), with up to five `links` back to other messages and a `branch` summary (title, asked, outcome, open) on the first message of each branch. `session write` moves a parent that is not an earlier message to the previous message and drops links that are not earlier messages, with a warning; `session show` hints each unrecorded message with `gapMinutes`, `resumed` (a `/clear` or a resume in between) and `commitBetween` (a commit this session made), and lists the last recorded messages with their parent.
diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts
index 9f96184..e2b9363 100644
--- a/packages/cli/src/commands/build.ts
+++ b/packages/cli/src/commands/build.ts
@@ -29,7 +29,7 @@ export interface BuildOptions {
}
/** How many characters of a not-yet-summarized message become its card title. */
-export const PENDING_TITLE_LENGTH = 80;
+export const PENDING_TITLE_LENGTH = 200;
export interface TranscriptViews {
/**
diff --git a/packages/template/src/GitGraph.tsx b/packages/template/src/GitGraph.tsx
index 5e264ed..e3eb5b2 100644
--- a/packages/template/src/GitGraph.tsx
+++ b/packages/template/src/GitGraph.tsx
@@ -8,7 +8,6 @@ import {
LANE_COLORS,
linkArrow,
linkPath,
- ROW_HEIGHT,
} from "./gitLayout.js";
/**
@@ -55,8 +54,8 @@ function Row({
onUnfold: (segmentId: string) => void;
}) {
const style = {
- top: row.y - ROW_HEIGHT / 2,
- height: ROW_HEIGHT,
+ top: row.y - row.height / 2,
+ height: row.height,
borderColor: branchSelected ? color(row.colorIndex) : undefined,
};
diff --git a/packages/template/src/gitLayout.ts b/packages/template/src/gitLayout.ts
index 2b6c337..1fa7cec 100644
--- a/packages/template/src/gitLayout.ts
+++ b/packages/template/src/gitLayout.ts
@@ -81,6 +81,8 @@ export interface GitMessageRow {
returns: GitReturn[];
/** "left off here": the newest message of the newest session. */
head: boolean;
+ /** Row height: titles wrap instead of being cut, so long ones get taller rows. */
+ height: number;
}
export interface GitMoreRow {
@@ -88,6 +90,7 @@ export interface GitMoreRow {
segmentId: string;
colorIndex: number;
y: number;
+ height: number;
/** The messages the fold hides. */
hidden: string[];
}
@@ -137,9 +140,43 @@ interface RawRow {
id?: string;
hidden?: string[];
y: number;
+ height: number;
gap: boolean;
}
+/** Average glyph widths at the row's font sizes; a rough estimate is enough. */
+const TITLE_CHAR = 6.4;
+const TITLE_LINE = 16;
+const BRANCH_CHAR = 6;
+const BRANCH_LINE = 14;
+const BRANCH_MAX = 150;
+/** Padding, the time column and the gaps around it. */
+const ROW_FIXED = 106;
+
+/**
+ * Height of a message row whose title (and branch label) wrap instead of being
+ * cut with an ellipsis: the width left for the title after the fixed parts of
+ * the row decides how many lines it needs.
+ */
+export function rowHeight(
+ message: ViewNode,
+ row: { first: boolean; branchTitle: string; returns: number; head: boolean },
+): number {
+ const fixed =
+ ROW_FIXED +
+ message.id.length * 7 +
+ (row.first ? BRANCH_MAX + 8 : 0) +
+ row.returns * 44 +
+ (row.head ? 92 : 0) +
+ (message.unsummarized ? 116 : 0);
+ const room = Math.max(120, ROW_WIDTH - fixed);
+ const titleLines = Math.max(1, Math.ceil((message.title.length * TITLE_CHAR) / room));
+ const branchLines = row.first
+ ? Math.max(1, Math.ceil((row.branchTitle.length * BRANCH_CHAR) / (BRANCH_MAX - 12)))
+ : 1;
+ return Math.max(ROW_HEIGHT, 12 + Math.max(titleLines * TITLE_LINE, branchLines * BRANCH_LINE));
+}
+
/** Parent ids that point forward, at themselves or outside the session become roots. */
function parentOf(message: ViewNode, index: Map<string, number>): string | null {
const parent = message.parent;
@@ -235,6 +272,7 @@ export function layoutGitGraph(messages: ViewNode[], options: GitLayoutOptions =
segment,
id: first,
y: 0,
+ height: ROW_HEIGHT,
gap: false,
});
raw.push({
@@ -243,6 +281,7 @@ export function layoutGitGraph(messages: ViewNode[], options: GitLayoutOptions =
segment,
hidden,
y: 0,
+ height: ROW_HEIGHT,
gap: false,
});
raw.push({
@@ -251,6 +290,7 @@ export function layoutGitGraph(messages: ViewNode[], options: GitLayoutOptions =
segment,
id: last,
y: 0,
+ height: ROW_HEIGHT,
gap: false,
});
} else {
@@ -261,6 +301,7 @@ export function layoutGitGraph(messages: ViewNode[], options: GitLayoutOptions =
segment,
id,
y: 0,
+ height: ROW_HEIGHT,
gap: false,
});
}
@@ -278,8 +319,17 @@ export function layoutGitGraph(messages: ViewNode[], options: GitLayoutOptions =
row.segment.parentId === null &&
row.segment.ids[0] === row.id;
if (row.gap) cursor += ROOT_GAP;
- row.y = cursor + ROW_HEIGHT / 2;
- cursor += ROW_HEIGHT;
+ const message = row.kind === "message" ? byId.get(row.id ?? "") : undefined;
+ row.height = message
+ ? rowHeight(message, {
+ first: row.segment.ids[0] === message.id,
+ branchTitle: row.segment.branch.title,
+ returns: (message.links ?? []).filter((id) => segOf.has(id)).length,
+ head: message.id === headId,
+ })
+ : ROW_HEIGHT;
+ row.y = cursor + row.height / 2;
+ cursor += row.height;
if (row.kind === "message" && row.id) rowOf.set(row.id, row);
for (const hidden of row.hidden ?? []) rowOf.set(hidden, row);
});
@@ -342,6 +392,7 @@ export function layoutGitGraph(messages: ViewNode[], options: GitLayoutOptions =
segmentId: row.segment.id,
colorIndex: row.segment.colorIndex,
y: row.y,
+ height: row.height,
hidden: row.hidden ?? [],
};
}
@@ -362,6 +413,7 @@ export function layoutGitGraph(messages: ViewNode[], options: GitLayoutOptions =
gap: row.gap,
returns,
head: message.id === headId,
+ height: row.height,
};
});
diff --git a/packages/template/src/styles.css b/packages/template/src/styles.css
index 2f2d071..6ec2af5 100644
--- a/packages/template/src/styles.css
+++ b/packages/template/src/styles.css
@@ -835,7 +835,6 @@ time {
font: inherit;
font-size: 12px;
text-align: left;
- white-space: nowrap;
background: none;
border: 1px solid transparent;
border-radius: 5px;
@@ -878,7 +877,7 @@ time {
color: #0f1115;
font-size: 10px;
font-weight: 600;
- text-overflow: ellipsis;
+ line-height: 14px;
background: var(--accent);
border-radius: 4px;
}
@@ -893,9 +892,8 @@ time {
.git-title {
flex: 1;
min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
+ line-height: 16px;
+ overflow-wrap: anywhere;
}
.git-returns {
diff --git a/packages/template/test/gitLayout.test.ts b/packages/template/test/gitLayout.test.ts
index 35a7161..48a6f1d 100644
--- a/packages/template/test/gitLayout.test.ts
+++ b/packages/template/test/gitLayout.test.ts
@@ -135,6 +135,29 @@ describe("rows", () => {
expect(between).toBe(ROW_HEIGHT + ROOT_GAP);
});
+ it("gives a long title a taller row instead of cutting it, and keeps rows from overlapping", () => {
+ const long =
+ "Kutular genişletilebilir olsun, yazılar kesiliyor ve devamını okuyamıyorum ".repeat(3);
+ const { messageRows, layout } = rowsOf([
+ message("m1", null, {
+ branch: {
+ title: "A branch title long enough to wrap twice",
+ asked: "",
+ outcome: "",
+ open: "",
+ },
+ }),
+ message("m2", "m1", { title: long }),
+ message("m3", "m2", { unsummarized: true }),
+ ]);
+ const [first, second, third] = messageRows;
+ expect(first!.height).toBeGreaterThan(ROW_HEIGHT);
+ expect(second!.height).toBeGreaterThanOrEqual(ROW_HEIGHT + 2 * 16);
+ expect(third!.height).toBe(ROW_HEIGHT);
+ expect(second!.y - second!.height / 2).toBe(first!.y + first!.height / 2);
+ expect(layout.height).toBe(ROW_HEIGHT / 2 + first!.height + second!.height + third!.height);
+ });
+
it("marks the newest message as HEAD unless told otherwise", () => {
const messages = [message("m1", null), message("m2", "m1"), message("m3", "m2")];
const rows = layoutGitGraph(messages).rows.filter(