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.

feat(map): drop the dashed return arrows and the epoch tag

Eren2d8fb294f0d8
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5dd63eb..4c3dfc3 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]
+### Removed
+- The map no longer draws the dashed return arrow and the "↩ mN" mark (a branch already shows the return; the details panel still lists it), nor the epoch tag on session rows.
+
### Changed
- Each session on the map now keeps its own message row width: dragging one session's edge leaves the others alone. The width is stored in the project's local `.cogit/state/row-widths.json` (never committed, so teammates keep their own), and survives a reload or a different browser.
diff --git a/packages/template/src/GitGraph.tsx b/packages/template/src/GitGraph.tsx
index 5377169..04a459c 100644
--- a/packages/template/src/GitGraph.tsx
+++ b/packages/template/src/GitGraph.tsx
@@ -1,4 +1,4 @@
-import { type MouseEvent, type ReactElement, useMemo } from "react";
+import { type MouseEvent, useMemo } from "react";
import { formatChange, isBigChange } from "../../cli/src/view/change.js";
import type { ViewNode } from "../../cli/src/view/model.js";
import { formatStamp } from "./format.js";
@@ -8,13 +8,11 @@ import {
type GitMessageRow,
type GitRow,
LANE_COLORS,
- linkArrow,
- linkPath,
} from "./gitLayout.js";
/**
* Draws one session's messages as a git graph (Story 8.2): time-ordered rows on
- * the right, dots, lanes, branch starts and returns on the left. The geometry
+ * the right, dots, lanes and branch starts on the left. The geometry
* comes from `gitLayout.ts`; this file only renders it.
*/
@@ -27,19 +25,6 @@ function rowRange(row: GitRow): string {
return row.message.at ? formatStamp(row.message.at) : "";
}
-function returnMark(row: GitMessageRow): ReactElement | null {
- if (row.returns.length === 0) return null;
- return (
- <span className="git-returns">
- {row.returns.map((back) => (
- <span key={back.id} className="git-return" style={{ color: color(back.colorIndex) }}>
- ↩ {back.label}
- </span>
- ))}
- </span>
- );
-}
-
function Row({
row,
selected,
@@ -163,7 +148,6 @@ function Row({
{message.continues.label ?? message.continues.id}
</span>
) : null}
- {returnMark(row)}
{row.head ? <span className="left-off">left off here</span> : null}
{message.unsummarized ? <span className="unsummarized">not summarized yet</span> : null}
</button>
@@ -204,12 +188,6 @@ export function GitGraph({
() => new Map(git.segments.map((segment) => [segment.id, segment])),
[git.segments],
);
- const segmentOf = useMemo(() => {
- const map = new Map<string, string>();
- for (const segment of git.segments) for (const id of segment.ids) map.set(id, segment.id);
- return map;
- }, [git.segments]);
-
return (
<div className="git-graph" style={{ width: git.width, height: git.height }}>
<svg
@@ -242,18 +220,6 @@ export function GitGraph({
</g>
);
})}
- {git.links.map((link) => {
- const target = segmentOf.get(link.toId);
- const from = segmentOf.get(link.fromId);
- const targetX = git.laneX[branches.get(target ?? "")?.lane ?? 0] ?? 0;
- const fromX = git.laneX[branches.get(from ?? "")?.lane ?? 0] ?? 0;
- return (
- <g key={`${link.fromId}-${link.toId}`} fill="none" stroke={color(link.colorIndex)}>
- <path d={linkPath(link, targetX, fromX)} strokeWidth={1.8} strokeDasharray="5 3" />
- <path d={linkArrow(link, fromX)} strokeWidth={1.8} />
- </g>
- );
- })}
{git.rows.map((row) => {
if (row.kind !== "message") return null;
const x = git.laneX[branches.get(row.segmentId)?.lane ?? 0] ?? 0;
diff --git a/packages/template/src/SessionMap.tsx b/packages/template/src/SessionMap.tsx
index 0ca4673..5388594 100644
--- a/packages/template/src/SessionMap.tsx
+++ b/packages/template/src/SessionMap.tsx
@@ -6,8 +6,8 @@ import type { SessionGraph } from "./sessionLayout.js";
/**
* Draws the project's sessions as a git graph (Story 8.7): one dot per session
- * in start order, lanes for branches of sessions, an epoch tag on each dot and
- * the session title as its label. Clicking a row opens that session's messages
+ * in start order, lanes for branches of sessions, and the session title as its
+ * label. Clicking a row opens that session's messages
* in place. The geometry comes from `sessionLayout.ts`; this file only renders.
*/
@@ -18,25 +18,9 @@ function color(index: number): string {
return `var(--l${index % LANE_COLORS})`;
}
-/** A neutral, outlined epoch tag — deliberately unlike a branch label. */
-function TagIcon() {
- return (
- <svg width="10" height="10" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
- <path
- d="M2 2h5.2l6.3 6.3-5.2 5.2L2 7.2V2z"
- fill="none"
- stroke="currentColor"
- strokeWidth="1.4"
- />
- <circle cx="5.2" cy="5.2" r="1.2" fill="currentColor" />
- </svg>
- );
-}
-
function SessionRow({
row,
session,
- epochTitle,
selected,
open,
searchHit,
@@ -45,7 +29,6 @@ function SessionRow({
}: {
row: GitMessageRow;
session: ViewSession;
- epochTitle: string | null;
selected: boolean;
/** Its messages are open below the row. */
open: boolean;
@@ -81,12 +64,6 @@ function SessionRow({
{open ? "▾" : "▸"}
</span>
<span className="git-time">{session.startedAt ? formatStamp(session.startedAt) : ""}</span>
- {epochTitle ? (
- <span className="epoch-tag" title={`Epoch: ${epochTitle}`}>
- <TagIcon />
- {epochTitle}
- </span>
- ) : null}
<span className="git-title">{session.title || session.sessionId}</span>
{session.author ? (
<span className="muted session-author" title={`Recorded by ${session.author}`}>
@@ -138,7 +115,6 @@ export function SessionMap({
onContinue: (sessionId: string, messageId: string) => void;
}) {
const { git } = graph;
- const epochTitles = new Map(model.epochs.map((epoch) => [epoch.id, epoch.title]));
const segments = new Map(git.segments.map((segment) => [segment.id, segment]));
const open: (row: GitRow) => void = (row) => {
@@ -223,13 +199,11 @@ export function SessionMap({
{git.rows.map((row) => {
const session = row.kind === "message" ? graph.sessions.get(row.message.id) : undefined;
if (row.kind !== "message" || !session) return null;
- const epochTitle = session.epoch ? (epochTitles.get(session.epoch) ?? null) : null;
return (
<SessionRow
key={row.message.id}
row={row}
session={session}
- epochTitle={epochTitle}
selected={selectedSessionId === session.sessionId}
open={openIds.has(session.sessionId)}
searchHit={highlightSessionIds.has(session.sessionId)}
diff --git a/packages/template/src/gitLayout.ts b/packages/template/src/gitLayout.ts
index 854da54..8924eba 100644
--- a/packages/template/src/gitLayout.ts
+++ b/packages/template/src/gitLayout.ts
@@ -2,15 +2,15 @@ import type { ViewNode } from "../../cli/src/view/model.js";
/**
* Lays a git graph out (Stories 8.2 and 8.7): one row per item in send order,
- * one lane per branch, branch starts curving out of the item they react to,
- * returns routed through a channel left of the lanes. Pure: the React component
- * draws exactly what this returns.
+ * one lane per branch, branch starts curving out of the item they react to.
+ * Pure: the React component draws exactly what this returns.
*
* The same code lays out both levels: a session's messages (a message is a
* commit, `parent` is the message it reacts to) and the project's sessions (a
* session is a commit, `parent` is the session it continues). Git terms: a root
- * starts something new, a branch is a chain of items with only one child each,
- * and `links` are returns to older items.
+ * starts something new, and a branch is a chain of items with only one child
+ * each. A message's `links` stay in the record and the details panel; the map
+ * does not draw them, since a branch already shows the return.
*/
/**
@@ -24,7 +24,6 @@ export interface GitNode {
summary?: string | undefined;
at?: string | undefined;
parent?: string | null | undefined;
- links?: string[] | undefined;
branch?: ViewNode["branch"];
continues?: ViewNode["continues"];
commits?: string[] | undefined;
@@ -48,9 +47,6 @@ export const FOLD_LIMIT = 4;
export const ROOT_GAP = 24;
/** Distance between lanes; also the dot column spacing. */
export const LANE_GAP = 20;
-/** Distance between the return channels on the left. */
-export const CHANNEL_GAP = 12;
-const CHANNEL_PAD = 8;
const LANE_PAD = 10;
const LANE_TAIL = 6;
/** Width reserved for the row text right of the dots. */
@@ -144,14 +140,6 @@ function tagsOf(message: GitNode): GitCommitTag[] {
return tags;
}
-export interface GitReturn {
- /** The older message this row returns to. */
- id: string;
- /** Its `m22` label, which the row shows instead of the stable id. */
- label: string;
- colorIndex: number;
-}
-
export interface GitMessageRow {
kind: "message";
message: GitNode;
@@ -163,7 +151,6 @@ export interface GitMessageRow {
first: boolean;
/** A new root starts here, with a gap above it. */
gap: boolean;
- returns: GitReturn[];
/** Code commits the record lists for this message; empty for most rows. */
tags: GitCommitTag[];
/** "left off here": the newest message or session. */
@@ -189,25 +176,12 @@ export interface GitMoreRow {
export type GitRow = GitMessageRow | GitMoreRow;
-export interface GitLink {
- /** The message that returns. */
- fromId: string;
- /** The older message it returns to. */
- toId: string;
- fromY: number;
- toY: number;
- /** The column left of the lanes this link runs through. */
- channelX: number;
- colorIndex: number;
-}
-
export interface GitLayout {
segments: GitSegment[];
rows: GitRow[];
- links: GitLink[];
/** Dot x per lane. */
laneX: number[];
- /** Width of the channel + lanes area; the row text starts after it. */
+ /** Width of the lanes area; the row text starts after it. */
graphWidth: number;
/** Width of the row text right of the dots. */
rowWidth: number;
@@ -279,13 +253,12 @@ const ROW_FIXED = 106;
*/
export function rowHeight(
message: GitNode,
- row: { returns: number; tags: number; head: boolean },
+ row: { tags: number; head: boolean },
rowWidth = ROW_WIDTH,
): number {
const fixed =
ROW_FIXED +
(message.label ?? message.id).length * 7 +
- row.returns * 44 +
Math.min(row.tags, TAGS_PER_LINE) * TAG_WIDTH +
(row.head ? 92 : 0) +
(message.unsummarized ? 116 : 0) +
@@ -449,7 +422,6 @@ export function layoutGitGraph(messages: GitNode[], options: GitLayoutOptions =
? rowHeight(
message,
{
- returns: (message.links ?? []).filter((id) => segOf.has(id)).length,
tags: tagsOf(message).length,
head: message.id === headId,
},
@@ -504,29 +476,11 @@ export function layoutGitGraph(messages: GitNode[], options: GitLayoutOptions =
}
const laneCount = Math.max(0, ...segments.map((segment) => segment.lane + 1));
- const links: GitLink[] = [];
- for (const message of messages) {
- for (const target of message.links ?? []) {
- const from = rowOf.get(message.id);
- const to = rowOf.get(target);
- if (!from || !to) continue;
- links.push({
- fromId: message.id,
- toId: target,
- fromY: from.y,
- toY: to.y,
- channelX: 6 + links.length * CHANNEL_GAP,
- colorIndex: segOf.get(target)?.colorIndex ?? 0,
- });
- }
- }
-
- const channelWidth = links.length > 0 ? links.length * CHANNEL_GAP + CHANNEL_PAD : 0;
const laneX = Array.from(
{ length: Math.max(laneCount, 1) },
- (_, lane) => channelWidth + LANE_PAD + lane * LANE_GAP,
+ (_, lane) => LANE_PAD + lane * LANE_GAP,
);
- const graphWidth = channelWidth + LANE_PAD + Math.max(laneCount, 1) * LANE_GAP + LANE_TAIL;
+ const graphWidth = LANE_PAD + Math.max(laneCount, 1) * LANE_GAP + LANE_TAIL;
const rows: GitRow[] = raw.map((row): GitRow => {
if (row.kind === "more") {
@@ -541,15 +495,6 @@ export function layoutGitGraph(messages: GitNode[], options: GitLayoutOptions =
}
const message = byId.get(row.id ?? "");
if (!message) throw new Error(`message ${String(row.id)} vanished from the layout`);
- const returns: GitReturn[] = [];
- for (const target of message.links ?? []) {
- if (!rowOf.has(target)) continue;
- returns.push({
- id: target,
- label: byId.get(target)?.label ?? target,
- colorIndex: segOf.get(target)?.colorIndex ?? 0,
- });
- }
return {
kind: "message",
message,
@@ -558,7 +503,6 @@ export function layoutGitGraph(messages: GitNode[], options: GitLayoutOptions =
y: row.y,
first: row.segment.ids[0] === message.id,
gap: row.gap,
- returns,
tags: tagsOf(message),
head: message.id === headId,
height: row.height,
@@ -569,7 +513,6 @@ export function layoutGitGraph(messages: GitNode[], options: GitLayoutOptions =
return {
segments,
rows,
- links,
laneX,
graphWidth,
rowWidth,
@@ -579,25 +522,6 @@ export function layoutGitGraph(messages: GitNode[], options: GitLayoutOptions =
};
}
-/** The dashed return route: target dot → left channel → arrow at the returning dot. */
-export function linkPath(link: GitLink, targetX: number, fromX: number): string {
- const q = 6;
- const g = link.channelX;
- return [
- `M${targetX},${link.toY}`,
- `L${g + q},${link.toY}`,
- `Q${g},${link.toY} ${g},${link.toY + q}`,
- `L${g},${link.fromY - q}`,
- `Q${g},${link.fromY} ${g + q},${link.fromY}`,
- `L${fromX - 9},${link.fromY}`,
- ].join(" ");
-}
-
-/** Arrowhead at the returning message, pointing at its dot. */
-export function linkArrow(link: GitLink, fromX: number): string {
- return `M${fromX - 15},${link.fromY - 4} L${fromX - 8},${link.fromY} L${fromX - 15},${link.fromY + 4}`;
-}
-
/** The curve a branch start draws from its parent's dot into its lane. */
export function branchPath(segment: GitSegment, laneX: number[]): string {
const x = laneX[segment.lane] ?? 0;
diff --git a/packages/template/src/styles.css b/packages/template/src/styles.css
index 4b8ac44..69660ae 100644
--- a/packages/template/src/styles.css
+++ b/packages/template/src/styles.css
@@ -1176,25 +1176,6 @@ body:has(.map-shell.is-expanded) {
white-space: nowrap;
}
-/* An epoch is a tag on a session dot, not a box around sessions. */
-.epoch-tag {
- display: inline-flex;
- flex: 0 1 auto;
- align-items: center;
- gap: 4px;
- min-width: 0;
- max-width: 160px;
- overflow: hidden;
- padding: 1px 6px;
- color: var(--muted);
- font-size: 10px;
- line-height: 14px;
- white-space: nowrap;
- text-overflow: ellipsis;
- border: 1px solid var(--line);
- border-radius: 4px;
-}
-
.left-off {
display: inline-block;
margin-top: 4px;
@@ -2238,15 +2219,6 @@ time {
overflow-wrap: anywhere;
}
-.git-returns {
- display: flex;
- flex: 0 1 auto;
- gap: 4px;
- min-width: 0;
- overflow: hidden;
- font-size: 11px;
-}
-
/* Commit tags on a message row (Story 8.8): a short hash, greyed when git no
longer knows the commit. Two hashes a line; more wrap below instead of being
cut off (`TAGS_PER_LINE` in `gitLayout.ts`). */
diff --git a/packages/template/test/gitLayout.test.ts b/packages/template/test/gitLayout.test.ts
index a42b05f..7d55120 100644
--- a/packages/template/test/gitLayout.test.ts
+++ b/packages/template/test/gitLayout.test.ts
@@ -4,8 +4,6 @@ import {
FOLD_LIMIT,
type GitMessageRow,
layoutGitGraph,
- linkArrow,
- linkPath,
ROOT_GAP,
ROW_HEIGHT,
} from "../src/gitLayout.js";
@@ -218,40 +216,21 @@ describe("rows", () => {
});
});
-describe("returns", () => {
- it("routes each return through its own channel left of every lane", () => {
+describe("links", () => {
+ it("draws no return arrow: a branch already shows the return", () => {
const messages = [
message("m1", null),
message("m2", "m1"),
- message("m3", "m2", { links: ["m1"] }),
- message("m4", "m3", { links: ["m2"] }),
- ];
- const { layout } = rowsOf(messages);
- expect(layout.links.map((link) => link.channelX)).toEqual([6, 18]);
- expect(layout.links.map((link) => link.toId)).toEqual(["m1", "m2"]);
- expect(Math.max(...layout.links.map((link) => link.channelX))).toBeLessThan(
- layout.laneX[0] ?? 0,
- );
-
- const link = layout.links[0]!;
- const path = linkPath(link, 40, 60);
- expect(path).toContain(`M40,${link.toY}`);
- expect(path.endsWith(`L51,${link.fromY}`)).toBe(true);
- expect(linkArrow(link, 60)).toContain(`M45,${link.fromY - 4}`);
- });
-
- it("marks the returning row and colours it like the branch it returns to", () => {
- const messages = [
- message("m1", null),
- message("m2", "m1"),
- message("m3", null),
- message("m4", "m2", { links: ["m1"] }),
+ message("m3", "m1", { links: ["m2"] }),
];
const { layout } = rowsOf(messages);
+ expect(layout).not.toHaveProperty("links");
+ // No channel left of the lanes either: the first lane starts at the pad.
+ expect(layout.laneX[0]).toBe(10);
const row = layout.rows.find(
(candidate): candidate is GitMessageRow =>
- candidate.kind === "message" && candidate.message.id === "m4",
+ candidate.kind === "message" && candidate.message.id === "m3",
);
- expect(row?.returns).toEqual([{ id: "m1", label: "m1", colorIndex: 0 }]);
+ expect(row).not.toHaveProperty("returns");
});
});
diff --git a/packages/template/test/layout.test.ts b/packages/template/test/layout.test.ts
index 784b95f..5099bf1 100644
--- a/packages/template/test/layout.test.ts
+++ b/packages/template/test/layout.test.ts
@@ -106,7 +106,7 @@ describe("map layout (Story 9.2)", () => {
// floor; the height follows the title, not the chips next to it.
const message = { id: "x", label: "m1", title: "a".repeat(120) };
// A narrow map: the chips leave the title only its minimum width.
- const height = rowHeight(message, { returns: 2, tags: 3, head: false }, 300);
+ const height = rowHeight(message, { tags: 3, head: false }, 300);
expect(height).toBeGreaterThanOrEqual(12 + Math.ceil((120 * 6.4) / TITLE_MIN_WIDTH) * 16);
});
@@ -114,7 +114,7 @@ describe("map layout (Story 9.2)", () => {
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 = { returns: 0, head: false };
+ const row = { 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.