Git for the intent behind agent-written code. Records what your coding agent decided and why, and links every commit to it.
JavaScript ai-codingclaudeclaude-codeclaude-code-pluginclicoding-agentsdeveloper-toolsgitllmtypescript
fix(map): keep the panel's Shape diagram legible
Erena1519c002b1b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 8ec5ca1..c7051b4 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- `cogit build` in a fresh clone of a shared project downloads the team's sessions first, instead of writing an empty map.- The map's outline follows the search: it marks and scrolls to the hit you are on, and scrolls to a message you click on the map.- Git older than 2.29 can download the team's records again: cogit no longer passes it `--no-write-fetch-head`, and a failed download names git's error instead of a line of its usage text.+- A Shape diagram in the message panel keeps legible text: it shrinks to the panel's width but not below half size, and a tall or wide one scrolls inside its box instead of shrinking until the labels cannot be read.## [1.0.0] - 2026-11-04### Changeddiff --git a/packages/template/src/MermaidDiagram.tsx b/packages/template/src/MermaidDiagram.tsxindex 2c6b3d8..bc557c0 100644--- a/packages/template/src/MermaidDiagram.tsx+++ b/packages/template/src/MermaidDiagram.tsx@@ -7,7 +7,7 @@ import {useState,} from "react";import { type DiagramTheme, effectiveTheme, mermaidThemeVariables } from "./diagramTheme.js";-import { clampPan, fitView, type PanView, type Size, zoomAt } from "./panZoom.js";+import { clampPan, fitView, type PanView, previewSize, type Size, zoomAt } from "./panZoom.js";import { getTheme, subscribeTheme, type ThemeMode } from "./theme.js";/**@@ -92,6 +92,24 @@ export function naturalSize(svg: SVGSVGElement): void {svg.style.maxWidth = "none";}+/**+ * Sizes the panel preview's diagram from its own drawn size (the viewBox):+ * shrunk to the box down to the legibility floor, then the box scrolls.+ */+export function fitPreview(svg: SVGSVGElement, box: HTMLElement): void {+ const natural = svg.viewBox?.baseVal;+ if (natural === undefined || natural.width <= 0 || natural.height <= 0) return;+ const size = previewSize(+ { width: box.clientWidth, height: box.clientHeight },+ { width: natural.width, height: natural.height },+ );+ svg.style.maxWidth = "none";+ svg.setAttribute("width", String(size.width));+ svg.setAttribute("height", String(size.height));+ svg.style.width = `${size.width}px`;+ svg.style.height = `${size.height}px`;+}+/** How far an arrow key pans, in pixels. */const KEY_STEP = 40;/** Zoom per button press. */@@ -188,6 +206,7 @@ export function MermaidDiagram({host.current.innerHTML = svg;const drawn = host.current.querySelector("svg");if (!fit && drawn !== null) naturalSize(drawn);+ if (fit && drawn !== null) fitPreview(drawn, host.current);if (interactive) refit();}).catch(() => {diff --git a/packages/template/src/panZoom.ts b/packages/template/src/panZoom.tsindex 4ba908d..e5473b5 100644--- a/packages/template/src/panZoom.ts+++ b/packages/template/src/panZoom.ts@@ -93,3 +93,14 @@ export function zoomAt(const ratio = scale / view.scale;return { scale, x: px - (px - view.x) * ratio, y: py - (py - view.y) * ratio };}++/**+ * The size the panel's preview draws a diagram at: shrunk to the box's width+ * (never enlarged), and never below the legibility floor. A tall diagram keeps+ * its text size and the box scrolls down, instead of shrinking to the box's+ * height until the text is unreadable.+ */+export function previewSize(box: Size, natural: Size): Size {+ const scale = fitScale({ width: box.width, height: Number.POSITIVE_INFINITY }, natural);+ return { width: Math.round(natural.width * scale), height: Math.round(natural.height * scale) };+}diff --git a/packages/template/src/styles.css b/packages/template/src/styles.cssindex 2cf7142..e243a3e 100644--- a/packages/template/src/styles.css+++ b/packages/template/src/styles.css@@ -2735,15 +2735,13 @@ time {.shape-preview-diagram {height: 240px;margin: 6px 0;- overflow: hidden;+ overflow: auto;}-/* A diagram drawn inside the preview is scaled down to the box, never cropped- mid-shape: Mermaid writes width="100%" and a max-width, so both are reset. */+/* The preview shrinks a diagram to the box, but not below a legible size+ (MermaidDiagram's fitPreview sets the size); a bigger one scrolls. */.shape-preview-diagram svg {- width: 100% !important;- max-width: none !important;- height: 100% !important;+ max-width: none;}.shape-open {diff --git a/packages/template/test/panZoom.test.tsx b/packages/template/test/panZoom.test.tsxindex 11543cf..c24b36a 100644--- a/packages/template/test/panZoom.test.tsx+++ b/packages/template/test/panZoom.test.tsx@@ -2,7 +2,7 @@ import { createElement } from "react";import { renderToStaticMarkup } from "react-dom/server";import { describe, expect, it } from "vitest";import { MermaidDiagram } from "../src/MermaidDiagram.js";-import { clampPan, fitScale, fitView, zoomAt } from "../src/panZoom.js";+import { clampPan, fitScale, fitView, previewSize, zoomAt } from "../src/panZoom.js";const box = { width: 800, height: 500 };@@ -95,3 +95,16 @@ describe("MermaidDiagram controls", () => {expect(html).not.toContain("Zoom in");});});++describe("previewSize", () => {+ const panel = { width: 394, height: 238 };++ it("keeps a tall diagram's text size and lets the box scroll down", () => {+ expect(previewSize(panel, { width: 301, height: 811 })).toEqual({ width: 301, height: 811 });+ });++ it("shrinks a wide diagram to the box's width, but not below the floor", () => {+ expect(previewSize(panel, { width: 788, height: 200 })).toEqual({ width: 394, height: 100 });+ expect(previewSize(panel, { width: 2000, height: 300 })).toEqual({ width: 1000, height: 150 });+ });+});