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 a row's commit tags instead of cutting them off

Eren4ee90e0442da
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3d94ba8..64947f7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- 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
+- 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.
- 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.
- The `Thought:` trailer is added in every project, also when the record stays out of git, so `blame` and `show <sha>` follow the exact link locally; only the record staging follows the commit policy. `init`, `cogit config git` and the rename migration install the hooks for both policies.
- The first code commit carries `.cogit/project.json` and `.cogit/.gitignore` with the session record, so a clone gets the project and the local-state rules, not only the sessions.
diff --git a/packages/template/src/gitLayout.ts b/packages/template/src/gitLayout.ts
index ca0c2c9..24594d9 100644
--- a/packages/template/src/gitLayout.ts
+++ b/packages/template/src/gitLayout.ts
@@ -253,6 +253,13 @@ 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`.
+ */
+export const TAGS_PER_LINE = 2;
+const TAG_WIDTH = 56;
+const TAG_LINE = 18;
/** Padding, the time column and the gaps around it. */
const ROW_FIXED = 106;
@@ -271,7 +278,7 @@ export function rowHeight(
(message.label ?? message.id).length * 7 +
(row.first ? BRANCH_MAX + 8 : 0) +
row.returns * 44 +
- row.tags * 62 +
+ Math.min(row.tags, TAGS_PER_LINE) * TAG_WIDTH +
(row.head ? 92 : 0) +
(message.unsummarized ? 116 : 0) +
// The "↑ continues <session> · m67" mark sits in the row, next to the title.
@@ -281,7 +288,11 @@ export function rowHeight(
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));
+ 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),
+ );
}
/** Parent ids that point forward, at themselves or outside the session become roots. */
diff --git a/packages/template/src/styles.css b/packages/template/src/styles.css
index 71b94cb..32e8a34 100644
--- a/packages/template/src/styles.css
+++ b/packages/template/src/styles.css
@@ -1634,17 +1634,21 @@ time {
}
/* Commit tags on a message row (Story 8.8): a short hash, greyed when git no
- longer knows the commit. */
+ longer knows the commit. Two hashes a line; more wrap below instead of being
+ cut off (`TAGS_PER_LINE` in `gitLayout.ts`). */
.git-tags {
display: flex;
- flex: 0 1 auto;
+ flex: none;
+ flex-wrap: wrap;
+ justify-content: flex-end;
gap: 4px;
- min-width: 0;
- overflow: hidden;
+ max-width: 112px;
}
.git-tag {
+ flex: none;
padding: 0 4px;
+ white-space: nowrap;
color: var(--muted);
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 10px;
diff --git a/packages/template/test/layout.test.ts b/packages/template/test/layout.test.ts
index 650ddef..b2d0af0 100644
--- a/packages/template/test/layout.test.ts
+++ b/packages/template/test/layout.test.ts
@@ -1,6 +1,6 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
-import { rowHeight, 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";
/**
@@ -114,6 +114,17 @@ describe("map layout (Story 9.2)", () => {
});
expect(height).toBeGreaterThanOrEqual(12 + Math.ceil((120 * 6.4) / TITLE_MIN_WIDTH) * 16);
});
+
+ 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 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.
+ expect(rowHeight(message, { ...row, tags: TAGS_PER_LINE + 1 })).toBeGreaterThan(ROW_HEIGHT);
+ });
});
describe("small text contrast (Story 9.2)", () => {