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(captures): move the capture badge to the session row

Eren8dede4f5f4ee
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1e4b734..eb04c23 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- A `captures` setting (on by default, with a **?** in the settings panel) turns the drafting off; items already in the list are kept, not deleted.
### Changed
-- Captured items belong to their session, not to one message: the store is schema 2 (a schema-1 file is read with its message dropped and written back on the next change), the map marks the session's first message with the number of items it stands for, the message details list them under **Captured here** (read-only), and `cogit captures` names the session as the source.
+- Captured items belong to their session, not to one message: the store is schema 2 (a schema-1 file is read with its message dropped and written back on the next change), an item's source opens the session's first message, and `cogit captures` names the session as the source.
+- The captured-work count is a button on the session row, expanded or folded, and opens that session's card; the card lists the session's items under **Captured work** (read-only), and the message row no longer carries the mark.
- The map's **Captured** button and `cogit captures` show the curated store instead of rows derived from the record, and the button appears only while the setting is on and something waits or is open.
## [0.27.0] - 2026-10-31
diff --git a/docs/guide/map.md b/docs/guide/map.md
index 8a963d7..a58c65d 100644
--- a/docs/guide/map.md
+++ b/docs/guide/map.md
@@ -140,12 +140,12 @@ open costs no model call.
Each drafted item waits in **To review** until you choose: **Accept** keeps it in **Open**,
**Dismiss** closes it without doing it. An open item is closed with **Done**. The last ten
closed items stay under **Done (last 10)**. An item belongs to the whole session it came from,
-not to one message: the map anchors it on the session's **first message** and marks that row
-with the number of items the session stands for (the session's own row while its messages are
-folded away). Clicking a row, the mark or the source line opens that first message, whose details
-list the session's items under **Captured here** — read-only, so a stray click cannot close
-work; accepting, dismissing and closing stay in the Captured list. A session with no messages
-anchors nowhere, and its items show only in the list. The model never reopens or rewrites an
+not to one message. The session's own row carries the number of items it stands for — a button,
+whether the session is expanded or folded — and clicking it opens that session's card, where the
+items are listed under **Captured work** with their state and age — read-only, so a stray click
+cannot close work; accepting, dismissing and closing stay in the Captured list. An item's source
+line in the list opens the session's **first message**. A session with no messages anchors
+nowhere, and its items show only in the list. The model never reopens or rewrites an
item you already saw; closing is your act. In the terminal: `cogit captures`,
`cogit captures accept|dismiss|done <id>`, and `cogit captures distill [--session <id> | --all]
[--dry-run]` to backfill sessions by hand (`--dry-run` prints the proposals and writes nothing).
diff --git a/packages/template/src/CapturesView.tsx b/packages/template/src/CapturesView.tsx
index b3b5a7c..a70fc2f 100644
--- a/packages/template/src/CapturesView.tsx
+++ b/packages/template/src/CapturesView.tsx
@@ -75,7 +75,7 @@ export function captureSource(
/**
* How many `suggested` + `open` items each session stands for, for the map's
- * capture mark. `done` and `dismissed` items are closed and count nothing, so a
+ * capture badge. `done` and `dismissed` items are closed and count nothing, so a
* store of only done items marks no row, like the Captured button.
*/
export function captureCounts(captures: readonly ViewCapture[] | undefined): Map<string, number> {
@@ -87,37 +87,6 @@ export function captureCounts(captures: readonly ViewCapture[] | undefined): Map
return counts;
}
-/** Where each session's capture mark is drawn. */
-export interface CapturePlacements {
- /** The session row, for a session whose anchor message is not drawn. */
- sessions: Map<string, { count: number; messageId: string }>;
- /** The anchor's message row, by message id. */
- messages: Map<string, number>;
-}
-
-/**
- * Places each session's mark on the row the map actually draws: the anchored
- * first message when its row is visible, otherwise the session's own row (a
- * closed session, or a first message folded away). `visible` answers whether a
- * message row is on the map right now.
- */
-export function capturePlacements(
- captures: readonly ViewCapture[] | undefined,
- sessions: readonly ViewSession[],
- visible: (sessionId: string, messageId: string) => boolean,
-): CapturePlacements {
- const counts = captureCounts(captures);
- const placements: CapturePlacements = { sessions: new Map(), messages: new Map() };
- for (const session of sessions) {
- const count = counts.get(session.sessionId);
- const messageId = session.messages[0]?.id;
- if (count === undefined || messageId === undefined) continue;
- if (visible(session.sessionId, messageId)) placements.messages.set(messageId, count);
- else placements.sessions.set(session.sessionId, { count, messageId });
- }
- return placements;
-}
-
export function CapturesView({
captures,
sessions,
diff --git a/packages/template/src/GitGraph.tsx b/packages/template/src/GitGraph.tsx
index 01309ce..cfc7fb3 100644
--- a/packages/template/src/GitGraph.tsx
+++ b/packages/template/src/GitGraph.tsx
@@ -33,7 +33,6 @@ function Row({
searchHit,
searchActive,
bigChangeLines,
- captured,
onSelect,
onUnfold,
}: {
@@ -47,8 +46,6 @@ function Row({
searchActive: boolean;
/** A change at or above this many lines gets the quiet highlight. */
bigChangeLines: number;
- /** Suggested + open captured items this message anchors (Story 15.2). */
- captured?: number | undefined;
onSelect: (row: GitMessageRow) => void;
onUnfold: (segmentId: string) => void;
}) {
@@ -102,20 +99,6 @@ function Row({
<span className="git-time">{rowRange(row, sameDay)}</span>
<span className="git-id">{message.label ?? message.id}</span>
<span className="git-title">{message.title}</span>
- {captured === undefined ? null : (
- // A span, not a button: the whole row is already a button. The mark is
- // the session's captured work, anchored on its first message.
- <span
- className="capture-mark git-capture"
- title={`${captured} captured item${captured === 1 ? "" : "s"} from this session`}
- onClick={(event: MouseEvent) => {
- event.stopPropagation();
- onSelect(row);
- }}
- >
- {captured}
- </span>
- )}
{row.tags.length > 0 ? (
<span className="git-tags">
{row.tags.map((tag) => (
@@ -158,7 +141,6 @@ export function GitGraph({
highlightIds,
activeHitId,
bigChangeLines,
- captured,
onSelect,
onUnfold,
}: {
@@ -172,8 +154,6 @@ export function GitGraph({
activeHitId: string | null;
/** A change at or above this many lines gets the quiet highlight. */
bigChangeLines: number;
- /** Suggested + open captured items, by the message id that anchors them. */
- captured?: ReadonlyMap<string, number> | undefined;
onSelect: (row: GitMessageRow) => void;
onUnfold: (segmentId: string) => void;
}) {
@@ -266,7 +246,6 @@ export function GitGraph({
searchHit={messageId !== null && highlightIds?.has(messageId) === true}
searchActive={messageId !== null && activeHitId !== null && messageId === activeHitId}
bigChangeLines={bigChangeLines}
- captured={messageId === null ? undefined : captured?.get(messageId)}
onSelect={onSelect}
onUnfold={onUnfold}
/>
diff --git a/packages/template/src/Graph.tsx b/packages/template/src/Graph.tsx
index 5030d26..250bd71 100644
--- a/packages/template/src/Graph.tsx
+++ b/packages/template/src/Graph.tsx
@@ -19,7 +19,7 @@ import {
} from "react";
import type { LineageViewModel, ViewSession } from "../../cli/src/view/model.js";
import { hitMessageIds, hitSessionIds } from "../../cli/src/view/search.js";
-import { CapturesView, capturePlacements, capturesButtonVisible } from "./CapturesView.js";
+import { CapturesView, captureCounts, capturesButtonVisible } from "./CapturesView.js";
import { loadMapView, pageToken, saveOpenSessions, saveRowWidth } from "./data.js";
import { type FilesTarget, FilesView } from "./FilesView.js";
import { useFullscreen } from "./fullscreen.js";
@@ -57,6 +57,8 @@ const GraphActions = createContext<{
/** Changes at or above this many lines get the quiet highlight. */
bigChangeLines: number;
openSession: (sessionId: string) => void;
+ /** Opens the session's card with its Captured work in view (the capture badge). */
+ openSessionCard: (sessionId: string) => void;
openNode: (sessionId: string, messageId: string) => void;
openContinue: (sessionId: string, messageId: string) => void;
unfold: (segmentId: string) => void;
@@ -71,6 +73,7 @@ const GraphActions = createContext<{
openIds: new Set(),
bigChangeLines: 300,
openSession: () => {},
+ openSessionCard: () => {},
openNode: () => {},
openContinue: () => {},
unfold: () => {},
@@ -102,14 +105,11 @@ function SessionMessages({
git,
highlights,
activeHitId,
- captured,
}: {
session: ViewSession;
git: GitLayout;
highlights: ReadonlySet<string> | undefined;
activeHitId: string | null;
- /** Capture marks for message rows, by the anchor message id (Story 15.2). */
- captured?: ReadonlyMap<string, number> | undefined;
}) {
const { selection, bigChangeLines, openNode, unfold, resizeRows, storeRowWidth, person, people } =
useContext(GraphActions);
@@ -125,7 +125,6 @@ function SessionMessages({
highlightIds={highlights}
activeHitId={activeHitId}
bigChangeLines={bigChangeLines}
- captured={captured}
onSelect={(row) => openNode(session.sessionId, row.message.id)}
onUnfold={unfold}
/>
@@ -139,18 +138,11 @@ function SessionMessages({
}
function ProjectBox({ data }: NodeProps<ProjectFlowNode>) {
- const { openSession, openNode, openContinue, selection, openIds, person } =
+ const { openSession, openSessionCard, openNode, openContinue, selection, openIds, person } =
useContext(GraphActions);
- // A captured-work mark goes on the anchored message row when it is drawn; a
- // session whose first message is not showing (folded away by branch folding,
- // or the session is closed) carries the mark on its own row instead.
- const capture = capturePlacements(data.model.captures, data.model.sessions, (sessionId, id) =>
- data.openings.some(
- (opening) =>
- opening.session.sessionId === sessionId &&
- opening.git.rows.some((row) => row.kind === "message" && row.message.id === id),
- ),
- );
+ // The capture badge sits on each session's own row, expanded or folded
+ // (Story 15.3): it counts the session's suggested + open items.
+ const capture = useMemo(() => captureCounts(data.model.captures), [data.model.captures]);
return (
<div className="map-node">
<SessionMap
@@ -161,9 +153,9 @@ function ProjectBox({ data }: NodeProps<ProjectFlowNode>) {
openIds={openIds}
highlightSessionIds={data.sessionHits}
person={person}
- captured={capture.sessions}
+ captured={capture}
onOpen={openSession}
- onOpenMessage={openNode}
+ onOpenCard={openSessionCard}
onContinue={openContinue}
/>
{data.openings.map((opening) => {
@@ -181,7 +173,6 @@ function ProjectBox({ data }: NodeProps<ProjectFlowNode>) {
activeHitId={
active?.sessionId === opening.session.sessionId ? active.messageId : null
}
- captured={capture.messages}
/>
</div>
);
@@ -564,9 +555,12 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
},
[keep],
);
+ /** A request to bring a session card's "Captured work" into view (Story 15.3). */
+ const [revealCaptures, setRevealCaptures] = useState(0);
const toggleSession = useCallback(
(sessionId: string) => {
keep(sessionId);
+ setRevealCaptures(0);
if (openIds.has(sessionId)) {
const next = new Set(openIds);
next.delete(sessionId);
@@ -581,9 +575,23 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
},
[openIds, keep],
);
+ /**
+ * The capture badge (Story 15.3): opens the session card without toggling the
+ * row, and asks the panel to show the Captured work section.
+ */
+ const openSessionCard = useCallback(
+ (sessionId: string) => {
+ keep(sessionId);
+ setFocusedId(`session:${sessionId}`);
+ setSelection({ type: "session", sessionId });
+ setRevealCaptures((value) => value + 1);
+ },
+ [keep],
+ );
const openNode = useCallback(
(sessionId: string, messageId: string) => {
ensureOpen(sessionId);
+ setRevealCaptures(0);
setFocusedId(`node:session:${sessionId}:${messageId}`);
setSelection({ type: "node", sessionId, nodeId: messageId });
},
@@ -621,6 +629,7 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
}, []);
const selectFromOutline = useCallback(
(target: OutlineTarget) => {
+ setRevealCaptures(0);
setFocusedId(target.focusId);
if (target.sessionId !== null) ensureOpen(target.sessionId);
setSelection(target.selection);
@@ -655,6 +664,7 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
openIds,
bigChangeLines,
openSession: toggleSession,
+ openSessionCard,
openNode,
openContinue,
unfold,
@@ -668,6 +678,7 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
openIds,
bigChangeLines,
toggleSession,
+ openSessionCard,
openNode,
openContinue,
unfold,
@@ -867,7 +878,11 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
<DrillDown
model={model}
selection={selection}
- onClose={() => setSelection(null)}
+ captureReveal={revealCaptures}
+ onClose={() => {
+ setSelection(null);
+ setRevealCaptures(0);
+ }}
onNavigate={selectFromOutline}
bigChangeLines={bigChangeLines}
/>
diff --git a/packages/template/src/SessionMap.tsx b/packages/template/src/SessionMap.tsx
index 3b05640..81c9184 100644
--- a/packages/template/src/SessionMap.tsx
+++ b/packages/template/src/SessionMap.tsx
@@ -29,7 +29,7 @@ function SessionRow({
searchHit,
captured,
onOpen,
- onOpenMessage,
+ onOpenCard,
onContinue,
}: {
row: GitMessageRow;
@@ -43,14 +43,17 @@ function SessionRow({
open: boolean;
/** The session's title or status matches the search (Story 8.14). */
searchHit: boolean;
- /** Suggested + open captured items whose anchor is not shown on a message row. */
- captured?: { count: number; messageId: string } | undefined;
+ /** Suggested + open captured items the session stands for (Story 15.3). */
+ captured?: number | undefined;
onOpen: (sessionId: string) => void;
- /** Selects one message and opens its details (the capture mark, Story 15.2). */
- onOpenMessage: (sessionId: string, messageId: string) => void;
+ /** Opens the session's card, with its Captured work in view (the capture badge). */
+ onOpenCard: (sessionId: string) => void;
onContinue: (continues: NonNullable<ViewSession["messages"][number]["continues"]>) => void;
}) {
const continues = session.messages[0]?.continues;
+ // A session with no messages anchors nowhere: its items live only in the
+ // Captured list, so its row gets no badge (Story 15.3).
+ const badge = session.messages.length === 0 ? undefined : captured;
const style = { top: row.y - row.height / 2, height: row.height };
const count = session.messages.length;
const className = [
@@ -63,8 +66,11 @@ function SessionRow({
.filter(Boolean)
.join(" ");
return (
- <button
- type="button"
+ // A div, not a button: the row holds the capture badge button (Story 15.3),
+ // and a button may not nest one.
+ <div
+ role="button"
+ tabIndex={0}
className={className}
style={style}
aria-expanded={open}
@@ -72,6 +78,13 @@ function SessionRow({
event.stopPropagation();
onOpen(session.sessionId);
}}
+ onKeyDown={(event) => {
+ // The badge handles its own keys; only the row's focus reaches here.
+ if (event.target !== event.currentTarget) return;
+ if (event.key !== "Enter" && event.key !== " ") return;
+ event.preventDefault();
+ onOpen(session.sessionId);
+ }}
title={session.status.goal || session.title}
>
<span className="session-toggle" aria-hidden="true">
@@ -79,17 +92,18 @@ function SessionRow({
</span>
<span className="git-time">{session.startedAt ? formatStamp(session.startedAt) : ""}</span>
<span className="git-title">{session.title || session.sessionId}</span>
- {captured === undefined ? null : (
- <span
+ {badge === undefined ? null : (
+ <button
+ type="button"
className="capture-mark session-capture"
- title={`${captured.count} captured item${captured.count === 1 ? "" : "s"} from this session`}
+ title={`${badge} captured item${badge === 1 ? "" : "s"} from this session`}
onClick={(event: MouseEvent) => {
event.stopPropagation();
- onOpenMessage(session.sessionId, captured.messageId);
+ onOpenCard(session.sessionId);
}}
>
- {captured.count}
- </span>
+ {badge}
+ </button>
)}
{showAuthor && session.author ? (
<span className="muted session-author" title={`Recorded by ${session.author}`}>
@@ -117,7 +131,7 @@ function SessionRow({
</span>
) : null}
{row.head ? <span className="left-off">left off here</span> : null}
- </button>
+ </div>
);
}
@@ -130,7 +144,7 @@ export function SessionMap({
person = null,
captured,
onOpen,
- onOpenMessage,
+ onOpenCard,
onContinue,
}: {
model: LineageViewModel;
@@ -142,10 +156,11 @@ export function SessionMap({
highlightSessionIds: ReadonlySet<string>;
/** The person filter: everyone when left out. */
person?: PersonFilter;
- /** Captured-work marks, by session id (Story 15.2). */
- captured?: ReadonlyMap<string, { count: number; messageId: string }> | undefined;
+ /** Suggested + open captured items, by session id (Story 15.3). */
+ captured?: ReadonlyMap<string, number> | undefined;
onOpen: (sessionId: string) => void;
- onOpenMessage: (sessionId: string, messageId: string) => void;
+ /** Opens the session's card, with its Captured work in view. */
+ onOpenCard: (sessionId: string) => void;
onContinue: (sessionId: string, messageId: string) => void;
}) {
const { git } = graph;
@@ -246,7 +261,7 @@ export function SessionMap({
searchHit={highlightSessionIds.has(session.sessionId)}
captured={captured?.get(session.sessionId)}
onOpen={onOpen}
- onOpenMessage={onOpenMessage}
+ onOpenCard={onOpenCard}
onContinue={(continues) => onContinue(continues.sessionId, continues.id)}
/>
);
diff --git a/packages/template/src/SidePanel.tsx b/packages/template/src/SidePanel.tsx
index 17c12cb..f51ee96 100644
--- a/packages/template/src/SidePanel.tsx
+++ b/packages/template/src/SidePanel.tsx
@@ -117,21 +117,28 @@ const CAPTURE_STATE_LABEL = {
} as const;
/**
- * The captured work a whole session stands for (Story 15.2), shown on its first
- * message — the anchor the map marks. Read-only: accepting, dismissing or
+ * The captured work the session stands for (Story 15.3), on its card — the card
+ * the session row's capture badge opens. Read-only: accepting, dismissing or
* closing stays in the Captured list, so a stray click here cannot close work.
+ * `reveal` changes when the badge asked for the section; the card then brings it
+ * into view.
*/
-function CapturedHere({ items }: { items: readonly ViewCapture[] }) {
+function CapturedWork({ items, reveal = 0 }: { items: readonly ViewCapture[]; reveal?: number }) {
+ const section = useRef<HTMLElement>(null);
// A dismissed item is closed away from the reading view, like in the list.
const shown = items
.filter((item) => item.state !== "dismissed")
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
+ useEffect(() => {
+ if (reveal === 0) return;
+ section.current?.scrollIntoView({ block: "nearest" });
+ }, [reveal]);
if (shown.length === 0) return null;
const now = new Date().toISOString();
return (
- <section className="captured-here">
+ <section className="captured-work" ref={section}>
<h3>
- Captured here <span className="count">{shown.length}</span>
+ Captured work <span className="count">{shown.length}</span>
</h3>
<ul className="drilldown-list capture-here-list">
{shown.map((item) => {
@@ -415,13 +422,6 @@ function NodeDetails({
{node.decidedBy ? (
<p className="decided-by">Decided by: {DECIDED_LABEL[node.decidedBy]}</p>
) : null}
- {node.kind === "message" && session?.messages[0]?.id === node.nodeId ? (
- <CapturedHere
- items={(model.captures ?? []).filter(
- (item) => item.source.sessionId === session.sessionId,
- )}
- />
- ) : null}
{node.agentDecisions?.length ? (
<section>
<h3>Decided by the agent on its own</h3>
@@ -664,7 +664,16 @@ function FileItem({
* The session's "squash message" (Story 8.7): what the whole session was for,
* what it got done and what is still open.
*/
-function SessionDetails({ model, session }: { model: LineageViewModel; session: ViewSession }) {
+function SessionDetails({
+ model,
+ session,
+ captureReveal = 0,
+}: {
+ model: LineageViewModel;
+ session: ViewSession;
+ /** Changes when the session row's capture badge asked for its section (Story 15.3). */
+ captureReveal?: number;
+}) {
const { done, pending } = session.status;
return (
<>
@@ -706,6 +715,10 @@ function SessionDetails({ model, session }: { model: LineageViewModel; session:
<h3>Next</h3>
<p>{session.status.next || "No next step recorded."}</p>
</section>
+ <CapturedWork
+ items={(model.captures ?? []).filter((item) => item.source.sessionId === session.sessionId)}
+ reveal={captureReveal}
+ />
<SessionSummary model={model} session={session} />
</>
);
@@ -715,12 +728,15 @@ function SessionDetails({ model, session }: { model: LineageViewModel; session:
export function DrillDown({
model,
selection,
+ captureReveal = 0,
onClose,
onNavigate,
bigChangeLines = 300,
}: {
model: LineageViewModel;
selection: Selection | null;
+ /** Counts the clicks on a session row's capture badge; the card shows the section (15.3). */
+ captureReveal?: number;
onClose: () => void;
/** Moves the selection to another node and reveals it on the map. */
onNavigate?: (target: OutlineTarget) => void;
@@ -756,7 +772,7 @@ export function DrillDown({
</button>
</header>
<div className="drilldown-body">
- <SessionDetails model={model} session={session} />
+ <SessionDetails model={model} session={session} captureReveal={captureReveal} />
</div>
</aside>
);
diff --git a/packages/template/src/styles.css b/packages/template/src/styles.css
index 370c3f7..0f317d9 100644
--- a/packages/template/src/styles.css
+++ b/packages/template/src/styles.css
@@ -1291,13 +1291,15 @@ body:has(.map-shell.is-expanded) {
overflow-wrap: anywhere;
}
-/* Story 15.2: the mark on the message or session row a session's items anchor on. */
+/* Story 15.3: the button on the session row that opens its Captured work. */
.capture-mark {
flex: none;
padding: 0 5px;
color: var(--capture);
+ background: none;
border: 1px solid var(--capture);
border-radius: 999px;
+ font: inherit;
font-size: 10px;
font-weight: 600;
line-height: 16px;
diff --git a/packages/template/test/captures-view.test.tsx b/packages/template/test/captures-view.test.tsx
index f01800f..79ec2f7 100644
--- a/packages/template/test/captures-view.test.tsx
+++ b/packages/template/test/captures-view.test.tsx
@@ -5,7 +5,6 @@ import type { ViewCapture, ViewSession } from "../../cli/src/view/model.js";
import {
CapturesView,
captureCounts,
- capturePlacements,
captureSource,
capturesButtonVisible,
} from "../src/CapturesView.js";
@@ -143,7 +142,7 @@ describe("an item's session anchor (Story 15.2)", () => {
});
});
-describe("the map's capture mark count", () => {
+describe("the session row's capture count", () => {
it("counts suggested and open items per session, and nothing when only done ones exist", () => {
const counts = captureCounts([
item({ id: "c00000001", state: "suggested" }),
@@ -157,35 +156,4 @@ describe("the map's capture mark count", () => {
expect(captureCounts([item({ id: "c00000009", state: "done" })]).size).toBe(0);
expect(captureCounts(undefined).size).toBe(0);
});
-
- it("puts the mark on the anchor message when its row is drawn, else on the session row", () => {
- const captures = [
- item({ id: "c00000001", state: "suggested" }),
- item({ id: "c00000002", state: "open" }),
- ];
- const open = capturePlacements(captures, sessions, () => true);
- expect([...open.messages]).toEqual([["m3", 2]]);
- expect(open.sessions.size).toBe(0);
-
- const folded = capturePlacements(captures, sessions, () => false);
- expect([...folded.sessions]).toEqual([["s1", { count: 2, messageId: "m3" }]]);
- expect(folded.messages.size).toBe(0);
-
- const none = capturePlacements(
- [item({ id: "c00000009", state: "done" })],
- sessions,
- () => true,
- );
- expect(none.messages.size).toBe(0);
- expect(none.sessions.size).toBe(0);
-
- // A session with no messages has no row to anchor on.
- const empty = capturePlacements(
- captures,
- [{ ...sessions[0], messages: [] } as ViewSession],
- () => true,
- );
- expect(empty.messages.size).toBe(0);
- expect(empty.sessions.size).toBe(0);
- });
});
diff --git a/packages/template/test/map-changes.test.tsx b/packages/template/test/map-changes.test.tsx
index b94f9a6..81f3567 100644
--- a/packages/template/test/map-changes.test.tsx
+++ b/packages/template/test/map-changes.test.tsx
@@ -63,7 +63,7 @@ function modelOf(current: ViewSession): LineageViewModel {
};
}
-function renderGraph(bigChangeLines = 300, captured?: ReadonlyMap<string, number>): string {
+function renderGraph(bigChangeLines = 300): string {
return renderToStaticMarkup(
createElement(GitGraph, {
git: layoutGitGraph(session.messages),
@@ -71,7 +71,6 @@ function renderGraph(bigChangeLines = 300, captured?: ReadonlyMap<string, number
highlightIds: undefined,
activeHitId: null,
bigChangeLines,
- captured,
onSelect: () => {},
onUnfold: () => {},
onContinue: () => {},
@@ -96,10 +95,7 @@ describe("how much code landed on the map (10.3)", () => {
expect(renderGraph(10_000)).not.toContain("is-big-change");
});
- it("puts the captured-work mark on the anchored message row only", () => {
- const html = renderGraph(300, new Map([["h1", 2]]));
- expect(html.match(/class="capture-mark git-capture"/g)).toHaveLength(1);
- expect(html).toContain('title="2 captured items from this session"');
+ it("draws no capture mark on a message row (it lives on the session row now)", () => {
expect(renderGraph()).not.toContain("capture-mark");
});
diff --git a/packages/template/test/session-git.test.ts b/packages/template/test/session-git.test.ts
index cfec469..49fe5f4 100644
--- a/packages/template/test/session-git.test.ts
+++ b/packages/template/test/session-git.test.ts
@@ -42,7 +42,7 @@ describe("Story 9.3 on the map", () => {
openIds: new Set<string>(),
highlightSessionIds: new Set<string>(),
onOpen: () => {},
- onOpenMessage: () => {},
+ onOpenCard: () => {},
onContinue: () => {},
}),
);
@@ -104,94 +104,99 @@ describe("Story 9.3 on the map", () => {
});
});
-describe("captured work on the map (Story 15.2)", () => {
- it("marks the session row with its count while the first message is not drawn", () => {
+describe("the session row's capture badge (Story 15.3)", () => {
+ const render = (captured?: ReadonlyMap<string, number>, openIds = new Set<string>()): string => {
const model = modelOf(session);
- const render = (captured: Map<string, { count: number; messageId: string }> | undefined) =>
- renderToStaticMarkup(
- createElement(SessionMap, {
- model,
- graph: layoutSessionGraph(model),
- selectedSessionId: null,
- openIds: new Set<string>(),
- highlightSessionIds: new Set<string>(),
- captured,
- onOpen: () => {},
- onOpenMessage: () => {},
- onContinue: () => {},
- }),
- );
- const html = render(new Map([["s1", { count: 2, messageId: "h1" }]]));
- expect(html).toContain("session-capture");
- expect(html).toContain(">2<");
- expect(render(undefined)).not.toContain("session-capture");
+ return renderToStaticMarkup(
+ createElement(SessionMap, {
+ model,
+ graph: layoutSessionGraph(model),
+ selectedSessionId: null,
+ openIds,
+ highlightSessionIds: new Set<string>(),
+ captured,
+ onOpen: () => {},
+ onOpenCard: () => {},
+ onContinue: () => {},
+ }),
+ );
+ };
+
+ it("always draws the count on the session row, expanded or folded", () => {
+ const counts = new Map([["s1", 2]]);
+ for (const openIds of [new Set<string>(), new Set(["s1"])]) {
+ const html = render(counts, openIds);
+ expect(html).toContain('class="capture-mark session-capture"');
+ expect(html).toContain('title="2 captured items from this session"');
+ expect(html).toContain(">2<");
+ }
+ // Empty store, or only done items: count nothing, mark nothing.
+ expect(render(undefined)).not.toContain("capture-mark");
+ expect(render(new Map())).not.toContain("capture-mark");
+ });
+
+ it("is a button inside the row, so its click cannot be the row's toggle", () => {
+ const html = render(new Map([["s1", 1]]));
+ // The row is not a button (a button may not nest one): the badge is the button.
+ expect(html).toMatch(/<div[^>]*class="git-row session-row"[^>]*>/);
+ expect(html).toContain('role="button"');
+ expect(html).toMatch(/<button[^>]*class="capture-mark session-capture"/);
+ expect(html.match(/<button/g)).toHaveLength(1);
+ });
+});
+
+describe("the session card's Captured work (Story 15.3)", () => {
+ const capture = (
+ id: string,
+ state: "suggested" | "open" | "done" | "dismissed",
+ text: string,
+ ) => ({
+ id,
+ text,
+ state,
+ source: { sessionId: "s1" },
+ createdAt: T0,
+ updatedAt: T0,
});
- it("lists the session's items in the first message's details, read-only", () => {
+ it("lists the session's items with their state and age, read-only", () => {
const model: LineageViewModel = {
...modelOf(session),
captures: [
- {
- id: "c00000001",
- text: "write the docs",
- state: "suggested",
- source: { sessionId: "s1" },
- createdAt: T0,
- updatedAt: T0,
- },
- {
- id: "c00000002",
- text: "ship it",
- state: "open",
- source: { sessionId: "s1" },
- createdAt: T0,
- updatedAt: T0,
- },
+ capture("c00000001", "suggested", "write the docs"),
+ capture("c00000002", "open", "ship it"),
+ capture("c00000003", "done", "close the release"),
+ capture("c00000004", "dismissed", "gone"),
],
};
const html = renderToStaticMarkup(
createElement(DrillDown, {
model,
- selection: { type: "node", sessionId: "s1", nodeId: "h1" },
+ selection: { type: "session", sessionId: "s1" },
+ captureReveal: 1,
onClose: () => {},
}),
);
- expect(html).toContain("Captured here");
+ expect(html).toContain("Captured work");
expect(html).toContain("write the docs");
expect(html).toContain("To review");
expect(html).toContain("Open");
+ expect(html).toContain("Done");
+ // A dismissed item is closed and stays out of the card, like the list.
+ expect(html).not.toContain("gone");
// Actions stay in the Captured list.
expect(html).not.toContain(">Accept<");
+ expect(html).not.toContain(">Dismiss<");
});
- it("shows the section only on the anchor, not on another message", () => {
- const two = {
- ...session,
- messages: [
- ...session.messages,
- { id: "h2", label: "m2", kind: "message", title: "Later", at: T0, parent: "h1" },
- ],
- } as ViewSession;
- const model: LineageViewModel = {
- ...modelOf(two),
- captures: [
- {
- id: "c00000001",
- text: "write the docs",
- state: "suggested",
- source: { sessionId: "s1" },
- createdAt: T0,
- updatedAt: T0,
- },
- ],
- };
+ it("shows no section on a session with no captured work", () => {
const html = renderToStaticMarkup(
createElement(DrillDown, {
- model,
- selection: { type: "node", sessionId: "s1", nodeId: "h2" },
+ model: modelOf(session),
+ selection: { type: "session", sessionId: "s1" },
onClose: () => {},
}),
);
- expect(html).not.toContain("Captured here");
+ expect(html).not.toContain("Captured work");
});
});