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): remove the branch-name pill from the rows

Erene1b5b820eb49
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ff4a55a..6049a82 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Changed
-- The map no longer shows a branch pill that only repeats the message title next to it (a branch without a summary is named after its first message).
+- The map no longer draws the coloured branch-name pill in front of a branch's first row and its "⋮ N more" row; it mostly repeated the message title. The lane colour still marks the branch, and the branch summary stays in the detail panel.
### Fixed
- A new session shows on the map while its first turn is still running; 0.21.1 listed it only once that turn ended.
- The side model's message ids are checked against the transcript: a node with an id it made up is no longer stored, so the real message stays unrecorded and the next catch-up records it. Before, the made-up nodes counted as recorded, the real messages were never recorded, and the closing pass wrote a stale "where it left off" line without them.
diff --git a/packages/template/src/GitGraph.tsx b/packages/template/src/GitGraph.tsx
index 602c3cc..5377169 100644
--- a/packages/template/src/GitGraph.tsx
+++ b/packages/template/src/GitGraph.tsx
@@ -10,7 +10,6 @@ import {
LANE_COLORS,
linkArrow,
linkPath,
- showsBranchPill,
} from "./gitLayout.js";
/**
@@ -43,7 +42,6 @@ function returnMark(row: GitMessageRow): ReactElement | null {
function Row({
row,
- branchTitle,
selected,
branchSelected,
searchHit,
@@ -55,7 +53,6 @@ function Row({
onContinue,
}: {
row: GitRow;
- branchTitle: string;
selected: boolean;
branchSelected: boolean;
/** The message matches the search (Story 8.14). */
@@ -88,9 +85,6 @@ function Row({
}}
title="Show the folded messages of this branch"
>
- <span className="git-branch" style={{ background: color(row.colorIndex) }}>
- {branchTitle}
- </span>
<span className="git-title">⋮ {row.hidden.length} more — open</span>
</button>
);
@@ -124,11 +118,6 @@ function Row({
title={message.summary || message.title}
>
<span className="git-time">{rowRange(row)}</span>
- {showsBranchPill(row.first, branchTitle, message.title) ? (
- <span className="git-branch" style={{ background: color(row.colorIndex) }}>
- {branchTitle}
- </span>
- ) : null}
<span className="git-id">{message.label ?? message.id}</span>
<span className="git-title">{message.title}</span>
{row.tags.length > 0 ? (
@@ -304,13 +293,11 @@ export function GitGraph({
</svg>
<div className="git-rows" style={{ left: git.graphWidth + 8, width: git.rowWidth }}>
{git.rows.map((row) => {
- const branch = branches.get(row.segmentId);
const messageId = row.kind === "message" ? row.message.id : null;
return (
<Row
key={row.kind === "more" ? `${row.segmentId}-more` : row.message.id}
row={row}
- branchTitle={branch?.branch.title ?? ""}
selected={messageId !== null && selectedId !== null && messageId === selectedId}
branchSelected={activeSegmentId !== null && row.segmentId === activeSegmentId}
searchHit={messageId !== null && highlightIds?.has(messageId) === true}
diff --git a/packages/template/src/gitLayout.ts b/packages/template/src/gitLayout.ts
index ac68fba..b90469e 100644
--- a/packages/template/src/gitLayout.ts
+++ b/packages/template/src/gitLayout.ts
@@ -252,9 +252,6 @@ interface RawRow {
/** 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;
/**
* Commit tags stand in a block of at most this many per line and wrap below
* instead of being clipped; keep in step with `.git-tags` in `styles.css`.
@@ -270,24 +267,14 @@ const ROW_FIXED = 106;
* cut with an ellipsis: the width left for the title after the fixed parts of
* the row decides how many lines it needs.
*/
-/**
- * Whether a branch's first row shows its name: a branch without a summary is
- * named after that first message, and the pill would only repeat its title.
- */
-export function showsBranchPill(first: boolean, branchTitle: string, title: string): boolean {
- return first && branchTitle.trim() !== title.trim();
-}
-
export function rowHeight(
message: GitNode,
- row: { first: boolean; branchTitle: string; returns: number; tags: number; head: boolean },
+ row: { returns: number; tags: number; head: boolean },
rowWidth = ROW_WIDTH,
): number {
- const pill = showsBranchPill(row.first, row.branchTitle, message.title);
const fixed =
ROW_FIXED +
(message.label ?? message.id).length * 7 +
- (pill ? BRANCH_MAX + 8 : 0) +
row.returns * 44 +
Math.min(row.tags, TAGS_PER_LINE) * TAG_WIDTH +
(row.head ? 92 : 0) +
@@ -296,14 +283,8 @@ export function rowHeight(
(message.continues ? 150 + message.continues.sessionTitle.length * 6.4 : 0);
const room = Math.max(TITLE_MIN_WIDTH, rowWidth - fixed);
const titleLines = Math.max(1, Math.ceil((message.title.length * TITLE_CHAR) / room));
- const branchLines = pill
- ? Math.max(1, Math.ceil((row.branchTitle.length * BRANCH_CHAR) / (BRANCH_MAX - 12)))
- : 1;
const tagLines = Math.ceil(row.tags / TAGS_PER_LINE);
- return Math.max(
- ROW_HEIGHT,
- 12 + Math.max(titleLines * TITLE_LINE, branchLines * BRANCH_LINE, tagLines * TAG_LINE),
- );
+ return Math.max(ROW_HEIGHT, 12 + Math.max(titleLines * TITLE_LINE, tagLines * TAG_LINE));
}
/** Parent ids that point forward, at themselves or outside the session become roots. */
@@ -458,8 +439,6 @@ export function layoutGitGraph(messages: GitNode[], options: GitLayoutOptions =
? rowHeight(
message,
{
- first: row.segment.ids[0] === message.id,
- branchTitle: row.segment.branch.title,
returns: (message.links ?? []).filter((id) => segOf.has(id)).length,
tags: tagsOf(message).length,
head: message.id === headId,
diff --git a/packages/template/src/styles.css b/packages/template/src/styles.css
index 3728c8a..135191d 100644
--- a/packages/template/src/styles.css
+++ b/packages/template/src/styles.css
@@ -2220,22 +2220,6 @@ time {
white-space: nowrap;
}
-.git-branch {
- flex: 0 1 auto;
- min-width: 0;
- max-width: 150px;
- overflow: hidden;
- padding: 1px 6px;
- color: var(--on-lane);
- font-size: 10px;
- font-weight: 600;
- line-height: 14px;
- text-overflow: ellipsis;
- white-space: nowrap;
- background: var(--accent);
- border-radius: 4px;
-}
-
.git-id {
flex: none;
color: var(--muted);
diff --git a/packages/template/test/gitLayout.test.ts b/packages/template/test/gitLayout.test.ts
index e36bd8a..a42b05f 100644
--- a/packages/template/test/gitLayout.test.ts
+++ b/packages/template/test/gitLayout.test.ts
@@ -158,7 +158,8 @@ describe("rows", () => {
message("m3", "m2", { unsummarized: true }),
]);
const [first, second, third] = messageRows;
- expect(first!.height).toBeGreaterThan(ROW_HEIGHT);
+ // The branch name is not drawn in the row, so it never makes the row taller.
+ expect(first!.height).toBe(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);
diff --git a/packages/template/test/layout.test.ts b/packages/template/test/layout.test.ts
index 7a2acca..784b95f 100644
--- a/packages/template/test/layout.test.ts
+++ b/packages/template/test/layout.test.ts
@@ -1,12 +1,6 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
-import {
- ROW_HEIGHT,
- rowHeight,
- showsBranchPill,
- TAGS_PER_LINE,
- TITLE_MIN_WIDTH,
-} from "../src/gitLayout.js";
+import { ROW_HEIGHT, rowHeight, TAGS_PER_LINE, TITLE_MIN_WIDTH } from "../src/gitLayout.js";
import { shouldForwardWheel } from "../src/scroll.js";
/**
@@ -103,8 +97,6 @@ describe("map layout (Story 9.2)", () => {
it("never squeezes a title into a one-letter column", () => {
expect(value(".git-title", "min-width")).toBe(`${TITLE_MIN_WIDTH}px`);
// Every chip beside the title may shrink and truncate instead of pushing it.
- expect(declarations(".git-branch")).toMatch(/flex:\s*0 1 auto/);
- expect(declarations(".git-branch")).toMatch(/text-overflow:\s*ellipsis/);
expect(declarations(".git-continues")).toMatch(/flex:\s*0 1 auto/);
expect(declarations(".git-continues")).toMatch(/text-overflow:\s*ellipsis/);
});
@@ -113,33 +105,16 @@ describe("map layout (Story 9.2)", () => {
// 120 characters need 5 lines at 180px, but would need 7 at the old 120px
// floor; the height follows the title, not the chips next to it.
const message = { id: "x", label: "m1", title: "a".repeat(120) };
- const height = rowHeight(message, {
- first: true,
- branchTitle: "a very long branch label that leaves no room",
- returns: 2,
- tags: 3,
- head: false,
- });
+ // A narrow map: the chips leave the title only its minimum width.
+ const height = rowHeight(message, { returns: 2, tags: 3, head: false }, 300);
expect(height).toBeGreaterThanOrEqual(12 + Math.ceil((120 * 6.4) / TITLE_MIN_WIDTH) * 16);
});
- it("leaves out a branch pill that would repeat the title", () => {
- expect(showsBranchPill(true, "Fix the map", " Fix the map ")).toBe(false);
- expect(showsBranchPill(true, "Map fixes", "Fix the map")).toBe(true);
- expect(showsBranchPill(false, "Map fixes", "Fix the map")).toBe(false);
- // Without the pill the title gets its room back and needs fewer lines.
- const message = { id: "x", label: "m1", title: "a".repeat(90) };
- const row = { first: true, returns: 0, tags: 0, head: false };
- expect(rowHeight(message, { ...row, branchTitle: message.title })).toBeLessThan(
- rowHeight(message, { ...row, branchTitle: "Map fixes" }),
- );
- });
-
it("wraps commit tags below each other instead of clipping them", () => {
expect(declarations(".git-tags")).toMatch(/flex-wrap:\s*wrap/);
expect(declarations(".git-tags")).not.toMatch(/overflow:\s*hidden/);
expect(declarations(".git-tag")).toMatch(/flex:\s*none/);
- const row = { first: false, branchTitle: "", returns: 0, head: false };
+ const row = { returns: 0, head: false };
const message = { id: "x", label: "m28", title: "short" };
expect(rowHeight(message, { ...row, tags: TAGS_PER_LINE })).toBe(ROW_HEIGHT);
// A third tag starts a second line, so the row grows to hold it.