Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

fix(git): render the commit history ourselves so it fits the panel

Chaitanya Giricb413feccc6c
diff --git a/package.json b/package.json
index 92a4d22f..4f4b541a 100644
--- a/package.json
+++ b/package.json
@@ -19,7 +19,7 @@
"typecheck:node": "tsc --noEmit -p tsconfig.node.json",
"typecheck:web": "tsc --noEmit -p tsconfig.web.json",
"typecheck": "npm run typecheck:node && npm run typecheck:web",
- "test:focused": "node --test test/codex-remote.test.cjs test/control.test.cjs test/provider-automation.test.cjs test/provider-config.test.cjs test/queue-delivery.test.cjs test/terminal-automation.test.cjs test/terminal-recovery.test.cjs test/roster.test.cjs test/proc-kill.test.cjs test/expand-tilde.test.cjs test/hive-cwd.test.cjs test/hive-hook-node.test.cjs test/hive-roster-injection.test.cjs test/hive-runtime-path.test.cjs test/cli-install-ladder.test.cjs test/node-install.test.cjs test/office-gl-recovery.test.cjs test/update-state.test.cjs test/transcript-project-dir.test.cjs",
+ "test:focused": "node --test test/codex-remote.test.cjs test/control.test.cjs test/provider-automation.test.cjs test/provider-config.test.cjs test/queue-delivery.test.cjs test/terminal-automation.test.cjs test/terminal-recovery.test.cjs test/roster.test.cjs test/proc-kill.test.cjs test/expand-tilde.test.cjs test/hive-cwd.test.cjs test/hive-hook-node.test.cjs test/hive-roster-injection.test.cjs test/hive-runtime-path.test.cjs test/cli-install-ladder.test.cjs test/node-install.test.cjs test/office-gl-recovery.test.cjs test/update-state.test.cjs test/transcript-project-dir.test.cjs test/commit-graph.test.cjs",
"check:links": "node tools/check-release-links.cjs",
"dist": "npm run build && electron-builder",
"dist:mac": "npm run build && electron-builder --mac",
diff --git a/src/renderer/src/components/FullscreenTerminal.tsx b/src/renderer/src/components/FullscreenTerminal.tsx
index 690bbce4..ed14a4be 100644
--- a/src/renderer/src/components/FullscreenTerminal.tsx
+++ b/src/renderer/src/components/FullscreenTerminal.tsx
@@ -24,6 +24,8 @@ import type { HarnessConfig } from '@/store/config';
* sliver on a 27" display, where names truncate for no reason — so it tracks
* the viewport between those two ends. */
const SIDEBAR_WIDTH = 'clamp(232px, 14vw, 340px)';
+/** Remembers the roster collapse across fullscreen sessions and app restarts. */
+const ROSTER_COLLAPSED_KEY = 'cth.fullscreen.rosterCollapsed';
/** Roster type scale, derived from the shared terminal zoom so Cmd +/- resizes
* the whole roster along with the terminal — one knob for the whole view
@@ -162,6 +164,19 @@ export function FullscreenTerminal({ config }: FullscreenTerminalProps) {
const reorderAgents = useStore(s => s.reorderAgents);
const [dragId, setDragId] = useState<string | null>(null);
const [overId, setOverId] = useState<string | null>(null);
+ // Roster collapse. Persisted because it is a working preference, not a mode:
+ // someone who hides the rail to read wide terminal output wants it still hidden
+ // the next time they go fullscreen, not to re-hide it every single time.
+ const [rosterCollapsed, setRosterCollapsed] = useState<boolean>(() => {
+ try { return localStorage.getItem(ROSTER_COLLAPSED_KEY) === '1'; } catch { return false; }
+ });
+ const toggleRoster = (): void => {
+ setRosterCollapsed((v) => {
+ const next = !v;
+ try { localStorage.setItem(ROSTER_COLLAPSED_KEY, next ? '1' : '0'); } catch { /* private mode */ }
+ return next;
+ });
+ };
const drag: RowDrag = {
dragId,
overId,
@@ -272,6 +287,24 @@ export function FullscreenTerminal({ config }: FullscreenTerminalProps) {
>
{appThemeNow === 'dark' ? '☀' : '☾'}
</button>
+ <button
+ onClick={toggleRoster}
+ title={rosterCollapsed ? 'Show the agent list' : 'Hide the agent list — full-width terminal'}
+ aria-label={rosterCollapsed ? 'Show the agent list' : 'Hide the agent list'}
+ aria-pressed={rosterCollapsed}
+ style={{
+ display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
+ width: 28, height: 28, padding: 0,
+ // Pressed-in when collapsed, so the rail's absence reads as a state
+ // this button is holding rather than something that broke.
+ background: rosterCollapsed ? 'var(--cth-lemon)' : 'var(--cth-paper-100)',
+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)',
+ border: 'none', borderRadius: 2, cursor: 'pointer',
+ color: rosterCollapsed ? 'var(--cth-ink-900)' : 'var(--cth-ink-900)'
+ }}
+ >
+ <Icon name="sidebar" size={1} style={{ width: 16, height: 16 }} />
+ </button>
<button
onClick={() => setFullscreen(null)}
title="Exit fullscreen (Esc)"
@@ -297,6 +330,11 @@ export function FullscreenTerminal({ config }: FullscreenTerminalProps) {
could show, and grouping by repository is how the user actually thinks
about the fleet. */}
<div style={{ flex: 1, minHeight: 0, display: 'flex' }}>
+ {/* Unmounted rather than width:0 when collapsed — the roster renders a row
+ per agent with live status, and keeping a hidden copy mounted would go
+ on doing that work for a rail nobody can see. Remounting is cheap; the
+ terminals live in the pool and are untouched by this. */}
+ {!rosterCollapsed && (
<aside style={{
width: SIDEBAR_WIDTH, flexShrink: 0,
display: 'flex', flexDirection: 'column',
@@ -446,6 +484,7 @@ export function FullscreenTerminal({ config }: FullscreenTerminalProps) {
</div>
)}
</aside>
+ )}
<div style={{
flex: 1, minWidth: 0, minHeight: 0,
diff --git a/src/renderer/src/components/git/CommitGraph.tsx b/src/renderer/src/components/git/CommitGraph.tsx
index de68e54c..870b350b 100644
--- a/src/renderer/src/components/git/CommitGraph.tsx
+++ b/src/renderer/src/components/git/CommitGraph.tsx
@@ -1,5 +1,28 @@
import { useMemo } from 'react';
-import { CommitGraph as LibCommitGraph, type Commit, type Branch } from 'commit-graph';
+import { layoutGraph, LANE_COLORS } from './graph';
+
+/**
+ * Commit history — lane rail + one line per commit.
+ *
+ * WHY THIS IS HAND-ROLLED. This used to render through the `commit-graph` npm
+ * package, which cannot be made to fit a resizable sidebar:
+ *
+ * - it positions every commit row ABSOLUTELY at a hardcoded `height: 4rem`,
+ * independent of the `commitSpacing` it lays the graph out with, so any
+ * compact spacing makes consecutive rows overlap;
+ * - it reserves a fixed `max-width: 500px` for the graph SVG regardless of how
+ * much room there actually is, so in a narrow panel the text is squeezed into
+ * whatever is left over, wraps, and collides again;
+ * - its class names carry a build hash, so the CSS needed to correct any of
+ * that is substring-matched and breaks on a version bump;
+ * - and it never showed the commit SUBJECT at all — the one field anyone
+ * actually reads a history for.
+ *
+ * The lane algorithm in ./graph.ts was already written for this and sitting
+ * unused. Rows here are a fixed height with single-line text, the rail is sized
+ * from the lanes actually in use, and everything past the rail is normal flex —
+ * so it stays readable from a 240px sidebar to a full-width panel.
+ */
interface CommitLite {
sha: string;
@@ -19,27 +42,20 @@ export interface CommitGraphProps {
onCommitClick?: (sha: string) => void;
}
-// CTH palette → branch lane colors (commit-graph renders raw colors into SVG).
-// v0.3.4 recalibration: the muted set, matching tokens.css.
-const BRANCH_COLORS = [
- '#4F9FAF', // sky
- '#DCAB3C', // lemon/amber
- '#5CA97A', // mint/sage
- '#D96A62', // coral
- '#9482D3', // lilac
- '#D99168' // peach
-];
-
-const GRAPH_STYLE = {
- commitSpacing: 28,
- branchSpacing: 18,
- nodeRadius: 4,
- branchColors: BRANCH_COLORS
-};
+/** One line of 12px text plus breathing room. */
+const ROW_H = 24;
+/** Horizontal pitch between lanes. */
+const LANE_W = 13;
+/** Lanes past this are clamped into the last one: the rail is a wayfinding aid,
+ * and letting a 12-way merge push the subject off-screen trades the thing being
+ * read for the decoration beside it. */
+const MAX_LANES = 6;
+const DOT_R = 3.5;
+/** Corner radius where a line crosses lanes. */
+const BEND = 8;
-function relTime(d: string | number | Date): string {
- const t = typeof d === 'number' ? d / 1000 : new Date(d).getTime() / 1000;
- const delta = Date.now() / 1000 - t;
+function relTime(ms: number): string {
+ const delta = Math.max(0, Date.now() / 1000 - ms / 1000);
if (delta < 60) return `${Math.round(delta)}s`;
if (delta < 3600) return `${Math.round(delta / 60)}m`;
if (delta < 86400) return `${Math.round(delta / 3600)}h`;
@@ -47,48 +63,150 @@ function relTime(d: string | number | Date): string {
return `${Math.round(delta / (86400 * 30))}mo`;
}
+/** Strip git's decoration noise down to something chip-sized. */
+function cleanRefs(refs: string[]): string[] {
+ const out: string[] = [];
+ for (const raw of refs) {
+ const name = raw.replace('HEAD ->', '').replace('tag:', '').trim();
+ if (!name || name === 'HEAD') continue;
+ if (!out.includes(name)) out.push(name);
+ }
+ return out;
+}
+
export function CommitGraph({ commits, currentBranch, onCommitClick }: CommitGraphProps) {
- // Adapt our flat git-log rows into the GitHub-style shape commit-graph expects.
- const libCommits: Commit[] = useMemo(() => commits.map(c => ({
- sha: c.sha,
- commit: {
- author: { name: c.author, date: c.time * 1000 },
- message: c.subject
- },
- parents: c.parents.map(sha => ({ sha }))
- })), [commits]);
+ const { rows, railW, rowIndex } = useMemo(() => {
+ const layout = layoutGraph(commits.map((c) => ({ sha: c.sha, parents: c.parents })));
+ const idx = new Map<string, number>();
+ commits.forEach((c, i) => idx.set(c.sha, i));
+ const lanes = Math.min(layout.maxLane, MAX_LANES - 1) + 1;
+ return {
+ rows: layout.rows,
+ railW: lanes * LANE_W + 8,
+ rowIndex: idx
+ };
+ }, [commits]);
+
+ if (commits.length === 0) return null;
- // Branch tips come from the refs git attached to each commit.
- const branchHeads: Branch[] = useMemo(() => {
- const seen = new Set<string>();
- const heads: Branch[] = [];
- for (const c of commits) {
- for (const ref of c.refs) {
- const name = ref.replace('HEAD -> ', '').trim();
- if (!name || name === 'HEAD' || name.startsWith('tag:')) continue;
- if (seen.has(name)) continue;
- seen.add(name);
- heads.push({ name, commit: { sha: c.sha } });
- }
- }
- // Fallback: detached HEAD or no decorations — anchor a head at the newest
- // commit so the library still has a tip to lay out and colour lanes from.
- if (heads.length === 0 && commits.length > 0) {
- heads.push({ name: currentBranch || 'HEAD', commit: { sha: commits[0].sha } });
- }
- return heads;
- }, [commits, currentBranch]);
+ const laneX = (lane: number): number => Math.min(lane, MAX_LANES - 1) * LANE_W + LANE_W / 2 + 4;
+ const rowY = (i: number): number => i * ROW_H + ROW_H / 2;
+ const height = commits.length * ROW_H;
return (
- <div className="cth-commit-graph" style={{ padding: '4px 8px', minWidth: 0 }}>
- <LibCommitGraph
- commits={libCommits}
- branchHeads={branchHeads}
- graphStyle={GRAPH_STYLE}
- currentBranch={currentBranch ?? undefined}
- dateFormatFn={relTime}
- onCommitClick={onCommitClick ? (c) => onCommitClick(c.hash) : undefined}
- />
+ <div className="cth-commit-graph" style={{ position: 'relative', minWidth: 0 }}>
+ {/* The rail is decoration: absolutely positioned and pointer-transparent so
+ it can never intercept a row click or contribute to layout width. */}
+ <svg
+ width={railW}
+ height={height}
+ style={{ position: 'absolute', left: 0, top: 0, pointerEvents: 'none' }}
+ aria-hidden
+ >
+ {rows.map((r, i) => {
+ const x1 = laneX(r.lane);
+ const y1 = rowY(i);
+ return r.parents.map((p) => {
+ const j = rowIndex.get(p.sha);
+ const color = LANE_COLORS[Math.min(p.lane, MAX_LANES - 1) % LANE_COLORS.length];
+ // Parent outside the fetched window: run the line to the bottom edge
+ // rather than dropping it, so the lane doesn't just stop mid-air.
+ if (j === undefined) {
+ return (
+ <path
+ key={`${r.sha}-${p.sha}`}
+ d={`M ${x1} ${y1} L ${x1} ${height}`}
+ stroke={color} strokeWidth={1.5} fill="none" opacity={0.5}
+ />
+ );
+ }
+ const x2 = laneX(p.lane);
+ const y2 = rowY(j);
+ const d = x1 === x2
+ ? `M ${x1} ${y1} L ${x2} ${y2}`
+ // Straight down the child's lane, then a quarter-turn into the
+ // parent — the shape a git graph is expected to make.
+ : `M ${x1} ${y1} L ${x1} ${y2 - BEND} Q ${x1} ${y2} ${x2} ${y2}`;
+ return (
+ <path
+ key={`${r.sha}-${p.sha}`}
+ d={d}
+ stroke={color} strokeWidth={1.5} fill="none"
+ />
+ );
+ });
+ })}
+ {rows.map((r, i) => (
+ <circle
+ key={r.sha}
+ cx={laneX(r.lane)}
+ cy={rowY(i)}
+ r={DOT_R}
+ fill={LANE_COLORS[Math.min(r.lane, MAX_LANES - 1) % LANE_COLORS.length]}
+ stroke="var(--cth-paper-100)"
+ strokeWidth={1.5}
+ />
+ ))}
+ </svg>
+
+ {commits.map((c, i) => {
+ const refs = cleanRefs(c.refs);
+ const head = refs[0];
+ const isCurrent = !!head && !!currentBranch && head.endsWith(currentBranch);
+ return (
+ <div
+ key={c.sha}
+ onClick={onCommitClick ? () => onCommitClick(c.sha) : undefined}
+ title={`${c.shortSha} · ${c.subject}\n${c.author} · ${relTime(c.time * 1000)} ago`}
+ style={{
+ height: ROW_H,
+ display: 'flex',
+ alignItems: 'center',
+ gap: 6,
+ paddingLeft: railW + 4,
+ paddingRight: 8,
+ minWidth: 0,
+ cursor: onCommitClick ? 'pointer' : 'default',
+ fontSize: 12,
+ lineHeight: `${ROW_H}px`,
+ whiteSpace: 'nowrap'
+ }}
+ >
+ <span style={{
+ fontFamily: 'var(--cth-font-mono)', color: 'var(--cth-ink-500)', flexShrink: 0
+ }}>{c.shortSha}</span>
+
+ {/* The subject is the point of the list, so it is the one thing that
+ gets the leftover width — and the only one allowed to ellipse. */}
+ <span style={{
+ flex: 1, minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis',
+ color: 'var(--cth-ink-900)'
+ }}>{c.subject}</span>
+
+ {head && (
+ <span style={{
+ flexShrink: 1, minWidth: 0, maxWidth: '38%',
+ overflow: 'hidden', textOverflow: 'ellipsis',
+ padding: '0 5px', fontSize: 11,
+ fontFamily: 'var(--cth-font-mono)',
+ color: isCurrent ? 'var(--cth-ink-900)' : 'var(--cth-ink-700)',
+ background: isCurrent ? 'var(--cth-lemon-light)' : 'transparent',
+ boxShadow: `inset 0 0 0 1px ${isCurrent ? 'var(--cth-lemon)' : 'var(--cth-ink-300)'}`
+ }}>{head}</span>
+ )}
+ {refs.length > 1 && (
+ <span style={{ flexShrink: 0, fontSize: 11, color: 'var(--cth-ink-500)' }}>
+ +{refs.length - 1}
+ </span>
+ )}
+
+ <span style={{
+ flexShrink: 0, fontFamily: 'var(--cth-font-mono)',
+ fontSize: 11, color: 'var(--cth-ink-500)'
+ }}>{relTime(c.time * 1000)}</span>
+ </div>
+ );
+ })}
</div>
);
}
diff --git a/src/renderer/src/design/global.css b/src/renderer/src/design/global.css
index 183b8e96..b7a23ce1 100644
--- a/src/renderer/src/design/global.css
+++ b/src/renderer/src/design/global.css
@@ -81,19 +81,17 @@ canvas, img, svg { image-rendering: pixelated; image-rendering: crisp-edges; }
::-webkit-scrollbar-thumb:hover { background: var(--cth-ink-900); }
/* commit-graph (open-source git visualiser) — harmonise with the pixel theme */
-.cth-commit-graph { background: var(--cth-paper-100); }
-.cth-commit-graph,
-.cth-commit-graph * {
- font-family: var(--cth-font-ui) !important;
+/* Commit history. The `* { font-family: … !important }` blanket that used to live
+ here existed to reach inside the third-party commit-graph widget; the rows are
+ ours now, so fonts are set per element and the override would only fight the
+ monospace on hashes and timestamps. */
+.cth-commit-graph {
+ background: var(--cth-paper-100);
+ font-family: var(--cth-font-ui);
color: var(--cth-ink-900);
}
-/* monospace for hashes / dates so they read like the rest of the app */
-.cth-commit-graph .commit-hash,
-.cth-commit-graph .commitHash,
-.cth-commit-graph time {
- font-family: var(--cth-font-mono) !important;
- color: var(--cth-ink-500);
-}
+/* Row hover — the whole line is the click target for opening a commit. */
+.cth-commit-graph > div:hover { background: var(--cth-cream-200); }
/* Drag region for hidden inset title bar (mac) */
.cth-titlebar-drag { -webkit-app-region: drag; }
diff --git a/src/renderer/src/ide/GitPanes.tsx b/src/renderer/src/ide/GitPanes.tsx
index 1670de6a..d51aae74 100644
--- a/src/renderer/src/ide/GitPanes.tsx
+++ b/src/renderer/src/ide/GitPanes.tsx
@@ -129,7 +129,11 @@ export function HistoryPane({ gitRoot, onOpenRevDiff }: {
</button>
<button style={{ ...smallBtn, width: 20, justifyContent: 'center' }} onClick={() => setSelected(null)} title="Close">✕</button>
</div>
- <div style={{ overflow: 'auto', minHeight: 0 }}>
+ {/* `flex: 1` is load-bearing: without it this scroller sizes to its
+ CONTENT, overflows the parent's maxHeight and never reaches its own
+ scroll threshold, so a commit touching many files runs off the
+ bottom with no way to scroll to the rest. */}
+ <div style={{ flex: 1, overflow: 'auto', minHeight: 0 }}>
{!files && !note && <div style={noteStyle}>loading files…</div>}
{note && <div style={{ ...noteStyle, color: 'var(--cth-ink-700)' }}>{note}</div>}
{files && files.length === 0 && <div style={noteStyle}>no file changes (merge?)</div>}
diff --git a/src/renderer/src/ide/IdePanel.tsx b/src/renderer/src/ide/IdePanel.tsx
index 473df24e..8e11f98b 100644
--- a/src/renderer/src/ide/IdePanel.tsx
+++ b/src/renderer/src/ide/IdePanel.tsx
@@ -19,6 +19,9 @@ function defaultMdView(): MdView {
return 'split';
}
+/** Remembers the git rail collapse across IDE opens and app restarts. */
+const GIT_RAIL_COLLAPSED_KEY = 'cth.ide.gitRailCollapsed';
+
// ─── Local mirrors of the main-side git shapes (kept renderer-local like GitTab) ──
interface GitStatusEntry { path: string; index: string; worktree: string }
interface GitStatusT { staged: GitStatusEntry[]; unstaged: GitStatusEntry[]; untracked: string[] }
@@ -80,6 +83,21 @@ export function IdePanel() {
// v0.3.4 git visualization: which rail pane is showing, and the repo's MAIN
// root (a worktree's history/compare must run against the shared repo).
const [railTab, setRailTab] = useState<'changes' | 'history' | 'compare'>('changes');
+ // Git rail collapse. The history graph is tall by nature, and someone working
+ // in the file tree wants that space back — persisted because it is a working
+ // preference, not a mode, and re-collapsing it on every IDE open would be a
+ // chore. Only the pane collapses; the CHANGES/HISTORY/COMPARE strip stays put
+ // so the control that expands it again is always visible.
+ const [gitCollapsed, setGitCollapsed] = useState<boolean>(() => {
+ try { return localStorage.getItem(GIT_RAIL_COLLAPSED_KEY) === '1'; } catch { return false; }
+ });
+ const toggleGitRail = (): void => {
+ setGitCollapsed((v) => {
+ const next = !v;
+ try { localStorage.setItem(GIT_RAIL_COLLAPSED_KEY, next ? '1' : '0'); } catch { /* private mode */ }
+ return next;
+ });
+ };
const [gitRoot, setGitRoot] = useState<string | null>(null);
useEffect(() => {
if (!root) return;
@@ -357,29 +375,49 @@ export function IdePanel() {
flexShrink: 0, display: 'flex', gap: 2, padding: '6px 10px 4px',
background: 'var(--cth-cream-50)', borderBottom: '1px solid var(--cth-ink-100)'
}}>
+ <button
+ onClick={toggleGitRail}
+ title={gitCollapsed ? 'Expand the git panel' : 'Collapse the git panel — more room for the file tree'}
+ aria-label={gitCollapsed ? 'Expand the git panel' : 'Collapse the git panel'}
+ aria-expanded={!gitCollapsed}
+ style={{
+ ...iconBtn,
+ // A caret is the one glyph that reads as "this section folds"
+ // without a legend; it points at where the content will go.
+ fontFamily: 'var(--cth-font-mono)', fontSize: 10, lineHeight: '14px',
+ color: 'var(--cth-ink-700)'
+ }}
+ >{gitCollapsed ? '▸' : '▾'}</button>
{(['changes', 'history', 'compare'] as const).map((k) => (
<button
key={k}
- onClick={() => setRailTab(k)}
+ // Picking a tab while collapsed means "show me this" — expanding
+ // is the only reading of that click that isn't a dead end.
+ onClick={() => { setRailTab(k); if (gitCollapsed) toggleGitRail(); }}
style={{
padding: '1px 8px', border: 'none', cursor: 'pointer',
fontFamily: 'var(--cth-font-display)', fontSize: 8, lineHeight: '14px',
textTransform: 'uppercase', color: 'var(--cth-ink-700)',
- background: railTab === k ? 'var(--cth-sky-light)' : 'transparent',
- boxShadow: railTab === k ? 'inset 0 0 0 1px var(--cth-ink-300)' : 'none'
+ background: railTab === k && !gitCollapsed ? 'var(--cth-sky-light)' : 'transparent',
+ boxShadow: railTab === k && !gitCollapsed ? 'inset 0 0 0 1px var(--cth-ink-300)' : 'none'
}}
>{k}</button>
))}
<span style={{ flex: 1 }} />
- {railTab === 'changes' && (
+ {railTab === 'changes' && !gitCollapsed && (
<button onClick={() => refreshStatus()} title="Refresh" style={iconBtn}>
<Icon name="web" />
</button>
)}
</div>
- {railTab === 'changes' && (
+ {railTab === 'changes' && !gitCollapsed && (
<div style={{ flexShrink: 0, maxHeight: '45%', display: 'flex', flexDirection: 'column', minHeight: 0 }}>
- <div style={{ overflow: 'auto', minHeight: 0 }}>
+ {/* `flex: 1` is what makes this scroll. Without it the scroller's
+ height is its CONTENT height (flex-basis auto), so it grew past
+ the parent's maxHeight and simply overflowed instead of ever
+ reaching its own scroll threshold — a long changed-file list ran
+ off the bottom with no way to reach the end. */}
+ <div style={{ flex: 1, overflow: 'auto', minHeight: 0 }}>
{isRepo === false && (
<div style={{ padding: '6px 12px', fontSize: 12, color: 'var(--cth-ink-500)' }}>not a git repo</div>
)}
@@ -413,10 +451,10 @@ export function IdePanel() {
</div>
</div>
)}
- {railTab === 'history' && gitRoot && (
+ {railTab === 'history' && gitRoot && !gitCollapsed && (
<HistoryPane key={gitRoot} gitRoot={gitRoot} onOpenRevDiff={openRevDiff} />
)}
- {railTab === 'compare' && gitRoot && (
+ {railTab === 'compare' && gitRoot && !gitCollapsed && (
<ComparePane key={gitRoot} gitRoot={gitRoot} onOpenRevDiff={openRevDiff} />
)}
{/* FILES */}
diff --git a/test/commit-graph.test.cjs b/test/commit-graph.test.cjs
new file mode 100644
index 00000000..2ad0b308
--- /dev/null
+++ b/test/commit-graph.test.cjs
@@ -0,0 +1,68 @@
+'use strict';
+
+// Lane layout for the commit history rail. Untested while it sat unused; now it
+// is what the graph actually renders from, so the shapes it has to get right are
+// pinned here.
+
+const test = require('node:test');
+const assert = require('node:assert/strict');
+const loadTs = require('./load-ts.cjs');
+
+const { layoutGraph, LANE_COLORS } = loadTs('src/renderer/src/components/git/graph.ts');
+
+/** `c('a', 'b')` = commit a whose parent is b. Newest first, as git log emits. */
+const c = (sha, ...parents) => ({ sha, parents });
+const laneOf = (out, sha) => out.rows.find((r) => r.sha === sha).lane;
+
+test('linear history stays in a single lane', () => {
+ const out = layoutGraph([c('a', 'b'), c('b', 'c'), c('c')]);
+ assert.deepEqual(out.rows.map((r) => r.lane), [0, 0, 0]);
+ assert.equal(out.maxLane, 0);
+});
+
+test('a merge sends the SECOND parent to a fresh lane', () => {
+ // m has two parents; the first continues m's lane, the side branch forks.
+ const out = layoutGraph([c('m', 'p1', 'p2'), c('p1', 'base'), c('p2', 'base'), c('base')]);
+ assert.equal(laneOf(out, 'm'), 0);
+ assert.equal(laneOf(out, 'p1'), 0, 'first parent keeps the lane');
+ assert.notEqual(laneOf(out, 'p2'), 0, 'second parent forks');
+ assert.ok(out.maxLane >= 1);
+});
+
+test('a lane is reused once its branch is exhausted', () => {
+ // side ends at its root, so the lane it held is free for a later fork.
+ const out = layoutGraph([
+ c('m', 'p1', 'side'),
+ c('side'), // root — releases its lane
+ c('p1', 'p2'),
+ c('p2', 'x', 'y'), // forks again; should reclaim the freed lane
+ c('x'), c('y')
+ ]);
+ assert.ok(out.maxLane <= 1, `expected lanes to be reused, got maxLane ${out.maxLane}`);
+});
+
+test('a parent outside the window does not widen the graph', () => {
+ // The newest commit's parent was not fetched — common with `git log -n`.
+ const out = layoutGraph([c('a', 'missing')]);
+ assert.equal(laneOf(out, 'a'), 0);
+ assert.equal(out.maxLane, 0);
+});
+
+test('every row reports the lane each of its parents landed in', () => {
+ const out = layoutGraph([c('m', 'p1', 'p2'), c('p1'), c('p2')]);
+ const m = out.rows.find((r) => r.sha === 'm');
+ assert.equal(m.parents.length, 2);
+ assert.equal(m.parents[0].lane, laneOf(out, 'p1'));
+ assert.equal(m.parents[1].lane, laneOf(out, 'p2'));
+});
+
+test('an empty history is not a crash', () => {
+ const out = layoutGraph([]);
+ assert.deepEqual(out.rows, []);
+ assert.equal(out.maxLane, 0);
+});
+
+test('lane colours are design tokens, so the rail follows the theme', () => {
+ assert.ok(LANE_COLORS.length > 0);
+ for (const col of LANE_COLORS) assert.match(col, /^var\(--cth-/);
+});