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.

refactor(map): drop read marks and the Unread view

Eren09111865db65
diff --git a/README.md b/README.md
index 6fc1ee0..8b70d25 100644
--- a/README.md
+++ b/README.md
@@ -79,7 +79,7 @@ cogit open .
- [Getting started](docs/guide/getting-started.md): what `init` asks, your first session,
setting up a team
-- [The map](docs/guide/map.md): sessions, branches, the inbox, unread work, files, search,
+- [The map](docs/guide/map.md): sessions, branches, the inbox, files, search,
resuming and forking a session
- [Reading the lineage](docs/guide/reading-the-lineage.md): `log`, `show`, `blame`, `why`,
`search`
diff --git a/docs/guide/README.md b/docs/guide/README.md
index 2e22616..788635e 100644
--- a/docs/guide/README.md
+++ b/docs/guide/README.md
@@ -6,7 +6,7 @@ part in detail.
| Page | What it covers |
|---|---|
| [Getting started](getting-started.md) | Install, what `cogit init` asks, your first session, setting up a team |
-| [The map](map.md) | Sessions, branches, the "Your turn" inbox, unread work, files, search, resuming or forking a session, the people filter |
+| [The map](map.md) | Sessions, branches, the "Your turn" inbox, files, search, resuming or forking a session, the people filter |
| [Reading the lineage](reading-the-lineage.md) | `log`, `show`, `blame`, `why`, `search` in the terminal, and how the agent uses them |
| [Pull requests](pull-requests.md) | `cogit pr`: a review-ready description with the decisions behind the code |
| [Teams and git](teams-and-git.md) | What is committed, the `Thought:` trailer, the git hooks, teammates' records |
diff --git a/docs/guide/map.md b/docs/guide/map.md
index 2eee05d..368d702 100644
--- a/docs/guide/map.md
+++ b/docs/guide/map.md
@@ -118,13 +118,6 @@ answer. Each row shows the project, the session and the agent's last words, with
straight to that message. The × hides a row until the agent writes in that session again.
Sessions older than a day (`inboxMaxAgeDays`) leave the inbox; the map still has them.
-## Unread
-
-"Unread, most code first" lists the messages with commits you have not opened yet, the ones
-that changed the most code first. It is the quickest way to catch up on what a teammate's
-sessions did. Messages past `bigChangeLines` get a quiet highlight. Read state stays on your
-machine. In the terminal: `cogit log --unread`.
-
## Files
The Files view lists every file a recorded message touched, most recently first, with a
diff --git a/docs/guide/privacy.md b/docs/guide/privacy.md
index 8892dc8..cfc7f6e 100644
--- a/docs/guide/privacy.md
+++ b/docs/guide/privacy.md
@@ -17,7 +17,7 @@ and a redaction pass for key and token patterns runs over everything the map wri
`shareConversations` on. Turn it on only if everyone who can read the repository may read
your chats, and never in a public repository.
- **The map** (`.cogit/map.html`) shows the conversation, so it is never committed.
-- **Local state:** read marks, the inbox, locks.
+- **Local state:** the inbox, the map view, locks.
## What git carries
diff --git a/docs/guide/reading-the-lineage.md b/docs/guide/reading-the-lineage.md
index fd572b7..576f0f9 100644
--- a/docs/guide/reading-the-lineage.md
+++ b/docs/guide/reading-the-lineage.md
@@ -7,7 +7,6 @@ directory as `[dir]` or `-C <dir>`.
cogit log # like git log: messages and branches, newest first
cogit log --branches # only the branch summaries
cogit log --file src/auth.ts # the messages that touched this file
-cogit log --unread # messages with commits you have not opened, most code first
cogit show h3f9c2a1b4d6e # one message: what came of it, its decisions, its commits
cogit show a1b2c3d # the message behind a commit (through its Thought: trailer)
cogit blame src/auth.ts:42 # which recorded message produced this line
diff --git a/docs/guide/settings.md b/docs/guide/settings.md
index ae5115d..64bf578 100644
--- a/docs/guide/settings.md
+++ b/docs/guide/settings.md
@@ -146,7 +146,7 @@ A session that waits on you longer than this leaves the inbox. It is hidden, not
**Lines of code after which a message counts as a big change on the map.**
-Messages whose commits changed at least this many lines get a quiet highlight in the unread list. It never hides or ranks anything by itself.
+Messages whose commits changed at least this many lines get a quiet mark on the map and in the message details. It never hides or ranks anything by itself.
### Trailer age
diff --git a/docs/guide/teams-and-git.md b/docs/guide/teams-and-git.md
index 3f93f65..f071639 100644
--- a/docs/guide/teams-and-git.md
+++ b/docs/guide/teams-and-git.md
@@ -10,7 +10,7 @@ cogit keeps its record in `.cogit/` next to your code and ties it to your commit
|---|---|---|
| `.cogit/sessions/`, `.cogit/project.json` (the record) | committed | ignored |
| `.cogit/conversations/` (raw chat) | ignored, unless `shareConversations` is on | ignored |
-| Local state: map, inbox, locks, `HEAD`, read marks | ignored | ignored |
+| Local state: map, inbox, locks, `HEAD` | ignored | ignored |
Under the commit policy, `.cogit/.gitignore` decides what stays local. Under the ignore policy,
one `/.cogit/` line in the root `.gitignore` hides all of it.
@@ -50,7 +50,7 @@ cogit hooks uninstall # remove only the cogit block
2. Everyone installs the CLI and runs `cogit init` once in their clone. It sees the project is
set up, registers it on their machine and installs the git hooks.
3. Each person's sessions are committed with their code. After a pull, teammates' sessions
- appear on the map with their author, and "Unread" lists what changed most.
+ appear on the map with their author, most recent first.
A session belongs to the person who recorded it: cogit stamps it with their git `user.name`
and `user.email`, and like git it tells people apart by email. Your sessions only ever
diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts
index dd1665d..d49b5ce 100644
--- a/packages/cli/src/commands/build.ts
+++ b/packages/cli/src/commands/build.ts
@@ -33,7 +33,6 @@ import { atomicWrite } from "../store/fs.js";
import { withLock } from "../store/lock.js";
import { readMapView } from "../store/map-view.js";
import { projectPaths } from "../store/paths.js";
-import { readReadState } from "../store/read-state.js";
import { resolveProjectRoot } from "../store/root.js";
import { loadAllSessions, loadConfig, loadProject } from "../store/stores.js";
import { attachThoughtTrailers, earliestSessionStart, readThoughtTrailers } from "../thought.js";
@@ -338,7 +337,6 @@ export async function buildProject(opts: BuildOptions): Promise<LineageViewModel
// Story 10.3: each message carries the numstat totals of its linked
// commits. A project outside git simply has no numbers to show.
const withChanges = attachChanges(withThoughts, commits.changes);
- const read = await readReadState(root);
const built = buildViewModel({
project: project.data,
sessions: withChanges,
@@ -358,7 +356,6 @@ export async function buildProject(opts: BuildOptions): Promise<LineageViewModel
unrecorded: config.sessionEndCatchUp ? undefined : views.unrecorded,
});
built.switcher = switcher;
- built.read = [...read].sort();
const view = await readMapView(root);
built.rowWidths = view.rowWidths;
built.openSessions = view.open;
diff --git a/packages/cli/src/commands/log.ts b/packages/cli/src/commands/log.ts
index b378c28..f0cc2b8 100644
--- a/packages/cli/src/commands/log.ts
+++ b/packages/cli/src/commands/log.ts
@@ -2,9 +2,7 @@ import { findGitRoot, projectFiles, readCommitFiles, readCommitSubjects } from "
import { CliError, type Io } from "../io.js";
import { readSessionMessages, type SessionMessage, upgradeSessionIds } from "../messages.js";
import type { LineageNode, Session } from "../schema/session.js";
-import { readProjectChanges } from "../store/changes.js";
import { applyEvents, readEvents } from "../store/events.js";
-import { readReadState } from "../store/read-state.js";
import { resolveProjectRoot } from "../store/root.js";
import { loadAllSessions, loadProject } from "../store/stores.js";
import {
@@ -13,7 +11,6 @@ import {
readCommitThought,
readThoughtTrailers,
} from "../thought.js";
-import { formatChange, messageChange, type UnreadMessage, unreadMessages } from "../view/change.js";
import { buildFileHistory, type FileSourceSession } from "../view/files.js";
import { buildMessages } from "../view/lineage.js";
import type { ViewFile, ViewNode } from "../view/model.js";
@@ -717,59 +714,6 @@ export async function log(opts: LogCommandOptions): Promise<LogModel> {
return model;
}
-export interface UnreadLogOptions {
- dir: string;
- io: Io;
- json?: boolean;
-}
-
-/**
- * `cogit log --unread` (Story 10.3): every unread message whose commits resolve
- * in git, most code first, with the same numstat numbers the map shows. The
- * mark is the user's own (`cogit open` toggles it); nothing here reads message
- * text to guess whether a message was "really" understood.
- */
-export async function logUnread(opts: UnreadLogOptions): Promise<UnreadMessage[]> {
- const root = await openProject(opts.dir);
- const sessions = await loadEffectiveSessions(root, opts.io);
- const hashes = new Set(
- sessions.flatMap((entry) => entry.messages.flatMap((message) => message.commits ?? [])),
- );
- const changes = hashes.size === 0 ? new Map() : await readProjectChanges(root, hashes);
- const read = await readReadState(root);
- const unread = unreadMessages(
- sessions.map(({ session, messages }) => ({
- sessionId: session.sessionId,
- title: session.title,
- startedAt: session.startedAt,
- nodes: messages.map((message) => ({
- ...message,
- change: messageChange(message.commits, changes),
- })),
- })),
- read,
- );
- if (opts.json === true) {
- opts.io.out(JSON.stringify(unread, null, 2));
- return unread;
- }
- for (const line of formatUnread(unread)) opts.io.out(line);
- return unread;
-}
-
-/** The plain-text `--unread` list, one line per message, most code first. */
-export function formatUnread(messages: readonly UnreadMessage[]): string[] {
- if (messages.length === 0) return ["No unread messages with linked commits."];
- return messages.map((message) => {
- const parts = [
- ` ${shortHash(message.messageId)} ${message.label} ${clock(message.at)} ` +
- `${formatChange(message.change)} ${oneLine(message.title)}`,
- ];
- parts.push(` · ${oneLine(message.sessionTitle)}`);
- return parts.join("");
- });
-}
-
/**
* `./src\a.ts` and `src/a.ts` name the same file; the model stores forward-slash
* paths without a leading `./` (Story 8.15).
diff --git a/packages/cli/src/program.ts b/packages/cli/src/program.ts
index 6679bc1..536aa59 100644
--- a/packages/cli/src/program.ts
+++ b/packages/cli/src/program.ts
@@ -15,7 +15,7 @@ import {
import { doctor } from "./commands/doctor.js";
import { hooksInstall, hooksUninstall } from "./commands/hooks.js";
import { type InitOptions, init } from "./commands/init.js";
-import { formatShow, log, logFile, logUnread, show } from "./commands/log.js";
+import { formatShow, log, logFile, show } from "./commands/log.js";
import { migrateIds } from "./commands/migrate.js";
import { openPanel, openProject } from "./commands/open.js";
import { pr } from "./commands/pr.js";
@@ -135,12 +135,8 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =
.option("-n, --number <count>", "at most this many messages", positiveCount)
.option("--branches", "only the branch summaries (the compressed view)")
.option("--file <path>", "only messages that touched this file (its history)")
- .option("--unread", "unread messages with commits, most code first")
.option("--json", "print JSON instead of text")
- .addHelpText(
- "after",
- examples("cogit log -n 10", "cogit log --file src/auth.ts", "cogit log --unread"),
- )
+ .addHelpText("after", examples("cogit log -n 10", "cogit log --file src/auth.ts"))
.action(
run(
async (
@@ -151,15 +147,10 @@ export function createProgram(makeIo: IoFactory = processIo, deps: ProgramDeps =
number?: number;
branches?: boolean;
file?: string;
- unread?: boolean;
json?: boolean;
},
) => {
const target = opts.dir ?? dir;
- if (opts.unread === true) {
- await logUnread({ dir: target, io: makeIo(false), json: opts.json === true });
- return;
- }
if (opts.file !== undefined) {
await logFile({
dir: target,
diff --git a/packages/cli/src/server.ts b/packages/cli/src/server.ts
index bd17edc..ca769bf 100644
--- a/packages/cli/src/server.ts
+++ b/packages/cli/src/server.ts
@@ -23,7 +23,6 @@ import { dismissInboxSession } from "./store/inbox-state.js";
import { LockBusyError } from "./store/lock.js";
import { MAX_OPEN, readMapView, setOpenSessions, setRowWidth } from "./store/map-view.js";
import { globalPaths, projectPaths } from "./store/paths.js";
-import { setMessageRead } from "./store/read-state.js";
import { loadConfig, loadRegistry, updateConfig } from "./store/stores.js";
import { builtBy } from "./view/lineage.js";
import {
@@ -602,71 +601,6 @@ export async function startMapServer(opts: MapServerOptions): Promise<MapServer>
void refreshOpenPages();
}
- /**
- * `POST /api/read` { dir, id, read } (Story 10.3): the map's read toggle. It
- * writes only the project's local state file; the page updates itself, and
- * the next rebuild embeds the new list. Same Host, Origin, content-type and
- * token checks as a settings write, and `dir` must be a registered project.
- */
- async function writeRead(req: IncomingMessage, res: ServerResponse, port: number): Promise<void> {
- if (
- !originAllowed(req.headers.origin, port) ||
- !tokenMatches(req.headers[CONFIG_TOKEN_HEADER])
- ) {
- respond(res, 403, "forbidden");
- return;
- }
- const type = req.headers["content-type"];
- if (
- typeof type !== "string" ||
- type.split(";")[0]?.trim().toLowerCase() !== "application/json"
- ) {
- respond(res, 415, "content-type must be application/json");
- return;
- }
- const body = await readLimitedBody(req);
- if (body === null) {
- respond(res, 413, "request body too large");
- return;
- }
- let parsed: unknown;
- try {
- parsed = JSON.parse(body);
- } catch {
- respond(res, 400, "invalid JSON");
- return;
- }
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
- respond(res, 400, "expected a JSON object");
- return;
- }
- const { dir, id, read } = parsed as Record<string, unknown>;
- if (typeof dir !== "string" || typeof id !== "string" || typeof read !== "boolean") {
- respond(res, 400, "expected { dir, id, read }");
- return;
- }
- if (!/^h[0-9a-f]{12}$/.test(id)) {
- respond(res, 400, "id must be a message id (h plus 12 hex)");
- return;
- }
- const root = await registeredRoot(env, dir);
- if (root === null) {
- respond(res, 403, "not a registered project");
- return;
- }
- try {
- await setMessageRead(root, id, read);
- } catch {
- respond(res, 500, "could not write the read state");
- return;
- }
- res.writeHead(200, {
- "content-type": "application/json",
- "cache-control": "no-store",
- });
- res.end(JSON.stringify({ ok: true, id, read }));
- }
-
/**
* `POST /api/shape/regenerate` { dir, sessionId, nodeId }: the Shape modal's
* Regenerate button. Runs the side model for that message the way the
@@ -749,7 +683,7 @@ export async function startMapServer(opts: MapServerOptions): Promise<MapServer>
* `POST /api/inbox/dismiss` { dir, sessionId, at } (Story 11.1): the inbox's
* dismiss button. It writes the project's local state file, and the turn time
* is stored so a newer agent turn brings the row back. Same Host, Origin,
- * content-type and token checks as a read mark, and `dir` must be registered.
+ * content-type and token checks as a config write, and `dir` must be registered.
*/
async function writeInboxDismiss(
req: IncomingMessage,
@@ -956,10 +890,6 @@ export async function startMapServer(opts: MapServerOptions): Promise<MapServer>
void close();
return;
}
- if (url.pathname === "/api/read") {
- await writeRead(req, res, port);
- return;
- }
if (url.pathname === "/api/inbox/dismiss") {
await writeInboxDismiss(req, res, port);
return;
diff --git a/packages/cli/src/store/paths.ts b/packages/cli/src/store/paths.ts
index 228ac43..4292ced 100644
--- a/packages/cli/src/store/paths.ts
+++ b/packages/cli/src/store/paths.ts
@@ -32,12 +32,6 @@ export function projectPaths(root: string) {
conversations: join(base, "conversations"),
conversation: (id: string) => join(base, "conversations", `${id}.jsonl.gz`),
state: (id: string) => join(base, "state", `${id}.json`),
- /**
- * Which messages this user has marked read (Story 10.3). Local per-user
- * state: never committed, never shared (`state/` stays ignored by both
- * policies).
- */
- readState: join(base, "state", "read.json"),
/** Inbox rows the user dismissed, per session (Story 11.1); also local. */
inboxState: join(base, "state", "inbox.json"),
/** How the user left the map: open sessions and dragged row widths; also local. */
diff --git a/packages/cli/src/store/read-state.ts b/packages/cli/src/store/read-state.ts
deleted file mode 100644
index a6572ad..0000000
--- a/packages/cli/src/store/read-state.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import { z } from "zod";
-import { atomicWriteJson, readJson } from "./fs.js";
-import { withLock } from "./lock.js";
-import { projectPaths } from "./paths.js";
-
-/**
- * Which messages the user has read (Story 10.3). The mark is a fact the user
- * states, not something cogit infers: no message text is read or classified.
- * It is local per-user state under `.cogit/state/`, never committed and never
- * shared, so one person's reading never marks a teammate's map.
- */
-
-export const READ_STATE_SCHEMA = 1;
-
-const MESSAGE_ID = /^h[0-9a-f]{12}$/;
-
-export const ReadState = z.object({
- schema: z.literal(READ_STATE_SCHEMA),
- /** Read message ids (`h` plus 12 hex). */
- read: z.array(z.string().regex(MESSAGE_ID)).default([]),
-});
-
-export type ReadState = z.infer<typeof ReadState>;
-
-/** The ids marked read. A missing or unreadable file is "nothing read yet". */
-export async function readReadState(root: string): Promise<Set<string>> {
- const read = await readJson(projectPaths(root).readState);
- if (!read.found || "error" in read) return new Set();
- const parsed = ReadState.safeParse(read.value);
- return new Set(parsed.success ? parsed.data.read : []);
-}
-
-/**
- * Marks one message read or unread. The file is derived state: an unreadable
- * one is replaced rather than blocking the toggle, and the list is sorted so
- * two toggles never reorder the file into a noisy diff (it stays ignored).
- */
-export async function setMessageRead(root: string, id: string, read: boolean): Promise<void> {
- if (!MESSAGE_ID.test(id)) throw new Error(`not a message id: ${id}`);
- const p = projectPaths(root);
- await withLock(
- p.lock("read-state"),
- async () => {
- const ids = await readReadState(root);
- if (read) ids.add(id);
- else ids.delete(id);
- await atomicWriteJson(p.readState, {
- schema: READ_STATE_SCHEMA,
- read: [...ids].sort(),
- });
- },
- { timeoutMs: 2000 },
- );
-}
diff --git a/packages/cli/src/view/change.ts b/packages/cli/src/view/change.ts
index 1191025..656822f 100644
--- a/packages/cli/src/view/change.ts
+++ b/packages/cli/src/view/change.ts
@@ -20,13 +20,6 @@ export interface ChangeNode {
change?: ViewChange | undefined;
}
-export interface ChangeSession {
- sessionId: string;
- title: string;
- startedAt: string;
- nodes: readonly ChangeNode[];
-}
-
/**
* One message's totals: the union of its linked commits, each commit counted
* once (its full hash decides), files deduped across commits. Undefined when no
@@ -77,88 +70,16 @@ export function attachChanges<N extends ChangeNode, S extends { nodes: readonly
});
}
-/** One unread message with code behind it, as the map view and `log --unread` list it. */
-export interface UnreadMessage {
- sessionId: string;
- sessionTitle: string;
- sessionStartedAt: string;
- messageId: string;
- label: string;
- title: string;
- at?: string | undefined;
- change: ViewChange;
-}
-
/** Total lines a change touched; the sort key ("most code first"). */
export function changeLines(change: ViewChange): number {
return change.added + change.removed;
}
-/** True for a message the user has not read whose code crossed the threshold. */
+/** True for a change whose linked commits crossed the threshold. */
export function isBigChange(change: ViewChange, threshold: number): boolean {
return changeLines(change) >= threshold;
}
-/** Messages with commits that are not marked read, most code first. */
-export function unreadMessages(
- sessions: readonly ChangeSession[],
- read: ReadonlySet<string>,
-): UnreadMessage[] {
- const out: UnreadMessage[] = [];
- for (const session of sessions) {
- for (const node of session.nodes) {
- if (node.kind !== "message" || node.change === undefined) continue;
- if (read.has(node.id)) continue;
- out.push({
- sessionId: session.sessionId,
- sessionTitle: session.title,
- sessionStartedAt: session.startedAt,
- messageId: node.id,
- label: node.label ?? node.id,
- title: node.title,
- ...(node.at === undefined ? {} : { at: node.at }),
- change: node.change,
- });
- }
- }
- return out.sort(
- (a, b) =>
- changeLines(b.change) - changeLines(a.change) ||
- b.change.files - a.change.files ||
- a.title.localeCompare(b.title) ||
- a.messageId.localeCompare(b.messageId),
- );
-}
-
-/** The page's shape: `ViewSession` carries `messages` rather than `nodes`. */
-export interface ViewChangeSession {
- sessionId: string;
- title: string;
- startedAt: string;
- messages: readonly ChangeNode[];
-}
-
-/** `unreadMessages` over the page model, which names its nodes `messages`. */
-export function unreadViewMessages(
- sessions: readonly ViewChangeSession[],
- read: ReadonlySet<string>,
-): UnreadMessage[] {
- return unreadMessages(
- sessions.map((session) => ({ ...session, nodes: session.messages })),
- read,
- );
-}
-
-/** How many unread messages crossed the threshold (the panel card's number). */
-export function countBigUnread(
- sessions: readonly ChangeSession[],
- read: ReadonlySet<string>,
- threshold: number,
-): number {
- return unreadMessages(sessions, read).filter((message) => isBigChange(message.change, threshold))
- .length;
-}
-
/** `1240` → `1 240`: thousands separated by a thin space, no locale dependency. */
export function grouped(value: number): string {
return String(Math.max(0, Math.trunc(value))).replace(/\B(?=(\d{3})+(?!\d))/g, " ");
diff --git a/packages/cli/src/view/model.ts b/packages/cli/src/view/model.ts
index 3bfa75c..66bbfec 100644
--- a/packages/cli/src/view/model.ts
+++ b/packages/cli/src/view/model.ts
@@ -331,12 +331,6 @@ export interface LineageViewModel {
* instead. Absent on pages built before 8.13.
*/
settings?: PanelSettings;
- /**
- * Message ids the user marked read (Story 10.3), from `.cogit/state/read.json`
- * at build time. Local state: the page toggles it through the local server and
- * a rebuild embeds the new list.
- */
- read?: string[];
/**
* How wide the user dragged each session's message rows, by session id, from
* `.cogit/state/map.json` at build time. Local state like `read`. Absent on
@@ -397,11 +391,6 @@ export interface PanelProject {
needsUserCount: number;
/** `file://` URL of the project's map; null when the directory is gone. */
lineageUrl: string | null;
- /**
- * Unread messages whose commits crossed `bigChangeLines` (Story 10.3), the
- * same number the map's unread view lists. Absent on pages built before 10.3.
- */
- unreadBigCount?: number;
}
/**
diff --git a/packages/cli/src/view/panel.ts b/packages/cli/src/view/panel.ts
index 728f11a..59b331d 100644
--- a/packages/cli/src/view/panel.ts
+++ b/packages/cli/src/view/panel.ts
@@ -4,14 +4,10 @@ import type { Io } from "../io.js";
import { redactDeep } from "../redact.js";
import type { Config, RegistryEntry } from "../schema/config.js";
import type { Session } from "../schema/session.js";
-import { readProjectChanges } from "../store/changes.js";
import { atomicWrite, isDirectory } from "../store/fs.js";
import { readInboxDismissed } from "../store/inbox-state.js";
import { globalPaths, projectPaths } from "../store/paths.js";
-import { readReadState } from "../store/read-state.js";
import { loadAllSessions, loadConfig, loadRegistry } from "../store/stores.js";
-import { attachThoughtTrailers, earliestSessionStart, readThoughtTrailers } from "../thought.js";
-import { countBigUnread } from "./change.js";
import {
compareInboxRows,
dismissKey,
@@ -78,42 +74,6 @@ export function panelSettings(config: Config): PanelSettings {
};
}
-/**
- * How many unread messages in this project crossed the threshold (Story 10.3).
- * The card count never fails a panel build: a missing git, a broken record or
- * an unreadable state file simply counts zero.
- */
-async function unreadBigCount(
- root: string,
- sessions: Session[],
- threshold: number,
-): Promise<number> {
- try {
- const trailers = await readThoughtTrailers(root, {
- since: earliestSessionStart(sessions),
- });
- const withThoughts = attachThoughtTrailers(sessions, trailers);
- const hashes = new Set(
- withThoughts.flatMap((session) => session.nodes.flatMap((node) => node.commits ?? [])),
- );
- if (hashes.size === 0) return 0;
- const changes = await readProjectChanges(root, hashes);
- const read = await readReadState(root);
- return countBigUnread(
- withThoughts.map((session) => ({
- sessionId: session.sessionId,
- title: session.title,
- startedAt: session.startedAt,
- nodes: session.nodes,
- })),
- read,
- threshold,
- );
- } catch {
- return 0;
- }
-}
-
/** The title of the newest message in a session, in send order. */
function lastMessageTitle(session: Session): string {
const messages = session.nodes.filter((node) => node.kind === "message");
@@ -264,7 +224,6 @@ export async function collectPanelData(
needsUserCount: 0,
lineageUrl: null,
leftOff: "",
- unreadBigCount: 0,
});
continue;
}
@@ -289,7 +248,6 @@ export async function collectPanelData(
needsUserCount: card.pending.filter((item) => item.needsUser).length,
lineageUrl: pathToFileURL(projectPaths(entry.path).html).href,
leftOff: leftOffLine(sessions),
- unreadBigCount: await unreadBigCount(entry.path, sessions, config.bigChangeLines),
});
inbox.push(...rows);
} catch (err) {
@@ -302,7 +260,6 @@ export async function collectPanelData(
needsUserCount: 0,
lineageUrl: pathToFileURL(projectPaths(entry.path).html).href,
leftOff: "",
- unreadBigCount: 0,
});
}
}
diff --git a/packages/cli/src/view/settings.ts b/packages/cli/src/view/settings.ts
index 0468682..1efa067 100644
--- a/packages/cli/src/view/settings.ts
+++ b/packages/cli/src/view/settings.ts
@@ -221,8 +221,8 @@ export const CLI_ONLY: CliSetting[] = [
label: "Big change",
help: "Lines of code after which a message counts as a big change on the map.",
details:
- "Messages whose commits changed at least this many lines get a quiet highlight in " +
- "the unread list. It never hides or ranks anything by itself.",
+ "Messages whose commits changed at least this many lines get a quiet mark on the " +
+ "map and in the message details. It never hides or ranks anything by itself.",
},
{
key: "trailerMaxAgeHours",
diff --git a/packages/cli/test/build.test.ts b/packages/cli/test/build.test.ts
index 6e0f2bc..15990e7 100644
--- a/packages/cli/test/build.test.ts
+++ b/packages/cli/test/build.test.ts
@@ -638,7 +638,6 @@ describe("cogit build", () => {
await writeFile(paths().state("s3"), "{}");
// No transcript: nothing to show. Not a session: the read state.
await writeFile(paths().state("gone"), "{}");
- await writeFile(paths().readState, "[]");
const model = await buildProject({ dir: root, io, templateHtml: TEMPLATE, quiet: true });
expect(model.sessions.map((s) => s.sessionId)).toEqual(["s3"]);
diff --git a/packages/cli/test/unread.test.ts b/packages/cli/test/changes.test.ts
similarity index 62%
rename from packages/cli/test/unread.test.ts
rename to packages/cli/test/changes.test.ts
index 0e68017..f82ddd7 100644
--- a/packages/cli/test/unread.test.ts
+++ b/packages/cli/test/changes.test.ts
@@ -4,20 +4,11 @@ import { join } from "node:path";
import { promisify } from "node:util";
import { beforeEach, describe, expect, it } from "vitest";
import { buildProject } from "../src/commands/build.js";
-import { formatUnread, logUnread } from "../src/commands/log.js";
-import { createProgram } from "../src/program.js";
import type { Session } from "../src/schema/session.js";
import { readProjectChanges } from "../src/store/changes.js";
import { projectPaths } from "../src/store/paths.js";
-import { readReadState, setMessageRead } from "../src/store/read-state.js";
import { projectJson } from "../src/store/stores.js";
-import {
- attachChanges,
- countBigUnread,
- messageChange,
- unreadMessages,
- unreadViewMessages,
-} from "../src/view/change.js";
+import { attachChanges, messageChange } from "../src/view/change.js";
import { DATA_ELEMENT_ID } from "../src/view/model.js";
import { envFor, type FakeIo, fakeIo, T0, tempDir } from "./helpers.js";
@@ -63,7 +54,6 @@ interface Embedded {
commits?: string[];
}[];
}[];
- read?: string[];
}
function embedded(html: string): Embedded {
@@ -165,79 +155,6 @@ describe("how much code landed per message (10.3)", () => {
expect(messageChange(undefined, changes)).toBeUndefined();
});
- it("round-trips the read mark and embeds it in the map", async () => {
- await createCommits();
- expect([...(await readReadState(root))]).toEqual([]);
- await setMessageRead(root, A, true);
- expect([...(await readReadState(root))]).toEqual([A]);
-
- await buildProject({ dir: root, io, templateHtml: TEMPLATE });
- const html = await readFile(projectPaths(root).html, "utf8");
- expect(embedded(html).read).toEqual([A]);
-
- await setMessageRead(root, A, false);
- expect([...(await readReadState(root))]).toEqual([]);
- });
-
- it("replaces an unreadable state file instead of blocking the toggle", async () => {
- await mkdir(join(projectPaths(root).base, "state"), { recursive: true });
- await writeFile(projectPaths(root).readState, "{not json");
- await setMessageRead(root, B, true);
- expect([...(await readReadState(root))]).toEqual([B]);
- await expect(setMessageRead(root, "not-a-message", true)).rejects.toThrow("not a message id");
- });
-
- it("lists unread messages most code first, and the threshold counts only big ones", () => {
- const sessions = [
- {
- sessionId: "s1",
- title: "Ship the parser",
- startedAt: T0,
- nodes: [
- {
- id: A,
- kind: "message",
- title: "Write the parser",
- change: { added: 900, removed: 100, files: 3 },
- },
- {
- id: B,
- kind: "message",
- title: "Add the second file",
- change: { added: 10, removed: 0, files: 1 },
- },
- { id: C, kind: "message", title: "No commits" },
- ],
- },
- ];
- const ordered = unreadMessages(sessions, new Set());
- expect(ordered.map((entry) => entry.messageId)).toEqual([A, B]);
- expect(countBigUnread(sessions, new Set(), 300)).toBe(1);
- expect(countBigUnread(sessions, new Set([A]), 300)).toBe(0);
- expect(unreadMessages(sessions, new Set([A, B])).map((entry) => entry.messageId)).toEqual([]);
- });
-
- it("prints `log --unread` most code first and drops a message once read", async () => {
- await createCommits();
- const unread = await logUnread({ dir: root, io });
- expect(unread.map((entry) => entry.messageId)).toEqual([A, B]);
- const lines = formatUnread(unread);
- expect(lines[0]).toContain("+5 −1 · 1 file");
- expect(lines[0]).toContain("Write the parser");
- expect(lines[1]).toContain("+5 −0 · 1 file");
- expect(io.lines).toEqual(lines);
-
- await setMessageRead(root, A, true);
- const after = await logUnread({ dir: root, io, json: true });
- expect(after.map((entry) => entry.messageId)).toEqual([B]);
- expect(JSON.parse(io.lines.at(-1) ?? "[]")).toHaveLength(1);
-
- // Nothing unread: one plain line, no invented numbers.
- await setMessageRead(root, B, true);
- const none = await logUnread({ dir: root, io });
- expect(none).toEqual([]);
- expect(io.lines.at(-1)).toBe("No unread messages with linked commits.");
- });
it("drops a stale number when its commit no longer resolves", () => {
const sessions = [
{
@@ -260,32 +177,6 @@ describe("how much code landed per message (10.3)", () => {
new Map([["deadbee", { full: "f".repeat(40), added: 1, removed: 1, files: ["x"] }]]),
);
expect(stale[0]?.nodes[0]?.change).toBeUndefined();
- expect(
- unreadViewMessages(
- [{ sessionId: "s1", title: "t", startedAt: T0, messages: stale[0]?.nodes ?? [] }],
- new Set(),
- ),
- ).toHaveLength(0);
- expect(
- unreadViewMessages(
- [
- {
- sessionId: "s1",
- title: "t",
- startedAt: T0,
- messages: [
- {
- id: A,
- kind: "message",
- title: "Changed",
- change: { added: 4, removed: 0, files: 1 },
- },
- ],
- },
- ],
- new Set(),
- ).map((entry) => entry.messageId),
- ).toEqual([A]);
});
it("projects numstat paths onto a project inside a larger repository", async () => {
@@ -309,14 +200,4 @@ describe("how much code landed per message (10.3)", () => {
expect(await readProjectChanges(sub, [])).toEqual(new Map());
expect(await readProjectChanges(dir, [full])).toEqual(new Map());
});
-
- it("is reachable as `cogit log --unread`", async () => {
- await createCommits();
- const program = createProgram(() => io);
- program.exitOverride();
- for (const command of program.commands) command.exitOverride();
- await program.parseAsync(["log", "--unread", "-C", root], { from: "user" });
- expect(io.lines.join("\n")).toContain("+5 −1 · 1 file");
- expect(io.lines.join("\n")).toContain("Write the parser");
- });
});
diff --git a/packages/cli/test/panel.test.ts b/packages/cli/test/panel.test.ts
index cbe94a7..601f1cf 100644
--- a/packages/cli/test/panel.test.ts
+++ b/packages/cli/test/panel.test.ts
@@ -106,7 +106,6 @@ describe("buildPanel", () => {
lastActivity: T0,
needsUserCount: 1,
lineageUrl: pathToFileURL(projectPaths(alpha).html).href,
- unreadBigCount: 0,
},
{
name: "beta",
@@ -115,7 +114,6 @@ describe("buildPanel", () => {
lastActivity: null,
needsUserCount: 0,
lineageUrl: null,
- unreadBigCount: 0,
},
],
// Story 11.1: the record's `needsUser` item is a row on its own signal.
@@ -171,7 +169,6 @@ describe("buildPanel", () => {
lastActivity: null,
needsUserCount: 0,
lineageUrl: pathToFileURL(projectPaths(root).html).href,
- unreadBigCount: 0,
},
]);
expect(io.warnings.join("\n")).toMatch(/^skipping project .*ENOTDIR/);
@@ -224,43 +221,3 @@ describe("panel refresh from build", () => {
expect(io.warnings.join("\n")).toMatch(/could not build panel\.html/);
});
});
-
-describe("panel card unread count (10.3)", () => {
- it("keeps the card at zero when the read state cannot be read", async () => {
- const dir = await tempDir();
- const env = envFor(dir);
- const root = join(dir, "proj");
- const paths = projectPaths(root);
- const session = {
- schema: 1,
- sessionId: "s1",
- agent: "claude-code",
- title: "t",
- startedAt: T0,
- updatedAt: T0,
- status: { goal: "", done: [], pending: [], next: "" },
- nodes: [
- {
- id: "h111111111111",
- parent: null,
- kind: "message",
- title: "Big",
- at: T0,
- commits: ["abcdef1"],
- },
- ],
- };
- await mkdir(paths.sessions, { recursive: true });
- await writeFile(paths.project, JSON.stringify({ schema: 1, name: "proj" }));
- await writeFile(paths.session("s1"), JSON.stringify(session));
- // A directory where read.json belongs: reading it is an error, not "empty".
- await mkdir(paths.readState, { recursive: true });
- await write(
- globalPaths(env).registry,
- JSON.stringify({ schema: 1, projects: [{ path: root, name: "proj", addedAt: T0 }] }),
- );
-
- const model = await buildPanel({ env, io: fakeIo(env), templateHtml: TEMPLATE });
- expect(model.projects[0]?.unreadBigCount).toBe(0);
- });
-});
diff --git a/packages/cli/test/server.test.ts b/packages/cli/test/server.test.ts
index b3c3f1c..f06de4c 100644
--- a/packages/cli/test/server.test.ts
+++ b/packages/cli/test/server.test.ts
@@ -33,7 +33,6 @@ import { atomicWrite } from "../src/store/fs.js";
import { readInboxDismissed } from "../src/store/inbox-state.js";
import { readMapView } from "../src/store/map-view.js";
import { globalPaths, projectPaths } from "../src/store/paths.js";
-import { readReadState } from "../src/store/read-state.js";
import { loadConfig, loadSession, updateConfig } from "../src/store/stores.js";
import { builtBy } from "../src/view/lineage.js";
import { DATA_ELEMENT_ID, LIVE_META_NAME, TOKEN_META_NAME } from "../src/view/model.js";
@@ -768,90 +767,6 @@ describe("ensureServer", () => {
});
});
-describe("read marks (10.3)", () => {
- const ID = "h111111111111";
-
- function readWrite(
- server: MapServer,
- token: string,
- payload: unknown,
- overrides: Record<string, string> = {},
- ): Promise<Reply> {
- return postConfig(`${server.url}/api/read`, JSON.stringify(payload), {
- origin: `http://127.0.0.1:${server.port}`,
- [CONFIG_TOKEN_HEADER]: token,
- ...overrides,
- });
- }
-
- it("writes a read mark for a registered project and clears it", async () => {
- const server = await start();
- const token = await panelToken(server);
- const marked = await readWrite(server, token, { dir: root, id: ID, read: true });
- expect(marked.status).toBe(200);
- expect(JSON.parse(marked.body)).toEqual({ ok: true, id: ID, read: true });
- expect([...(await readReadState(root))]).toEqual([ID]);
-
- const cleared = await readWrite(server, token, { dir: root, id: ID, read: false });
- expect(cleared.status).toBe(200);
- expect([...(await readReadState(root))]).toEqual([]);
- });
-
- it("refuses a foreign project, a bad id, a bad body and a bad token", async () => {
- const server = await start();
- const token = await panelToken(server);
- expect(
- (await readWrite(server, token, { dir: join(dir, "elsewhere"), id: ID, read: true })).status,
- ).toBe(403);
- expect((await readWrite(server, token, { dir: root, id: "m1", read: true })).status).toBe(400);
- expect((await readWrite(server, token, { dir: root, id: ID })).status).toBe(400);
- expect((await readWrite(server, token, { id: ID, read: true })).status).toBe(400);
- expect((await readWrite(server, "nope", { dir: root, id: ID, read: true })).status).toBe(403);
- expect(
- (
- await readWrite(
- server,
- token,
- { dir: root, id: ID, read: true },
- {
- "content-type": "text/plain",
- },
- )
- ).status,
- ).toBe(415);
- expect((await readWrite(server, token, { dir: root, id: ID, read: true }, {})).status).toBe(
- 200,
- );
- const raw = await postConfig(`${server.url}/api/read`, "{oops", {
- origin: `http://127.0.0.1:${server.port}`,
- [CONFIG_TOKEN_HEADER]: token,
- });
- expect(raw.status).toBe(400);
- const huge = await readWrite(server, token, {
- dir: root,
- id: ID,
- read: true,
- pad: "x".repeat(5000),
- });
- expect(huge.status).toBe(413);
-
- const array = await postConfig(`${server.url}/api/read`, "[]", {
- origin: `http://127.0.0.1:${server.port}`,
- [CONFIG_TOKEN_HEADER]: token,
- });
- expect(array.status).toBe(400);
- });
-
- it("answers 500 instead of crashing when the state cannot be written", async () => {
- const server = await start();
- const token = await panelToken(server);
- // A directory where the state file belongs makes the write fail.
- await mkdir(projectPaths(root).readState, { recursive: true });
- const reply = await readWrite(server, token, { dir: root, id: ID, read: true });
- expect(reply.status).toBe(500);
- });
-});
-
describe("shape regenerate endpoint", () => {
const NODE = "h111111111111";
@@ -974,7 +889,11 @@ process.stdin.on("end", () => {
env = { ...env, PATH: `${bin}:${process.env.PATH ?? ""}` };
const server = await start();
const token = await panelToken(server);
- const reply = await regenerateWrite(server, token, { dir: root, sessionId: "s1", nodeId: NODE });
+ const reply = await regenerateWrite(server, token, {
+ dir: root,
+ sessionId: "s1",
+ nodeId: NODE,
+ });
expect(reply.status).toBe(200);
const loaded = await loadSession(root, "s1");
if (!loaded.found || !loaded.ok) throw new Error("no record");
diff --git a/packages/template/src/GitGraph.tsx b/packages/template/src/GitGraph.tsx
index 7705306..cfc7fb3 100644
--- a/packages/template/src/GitGraph.tsx
+++ b/packages/template/src/GitGraph.tsx
@@ -32,7 +32,6 @@ function Row({
selected,
searchHit,
searchActive,
- read,
bigChangeLines,
onSelect,
onUnfold,
@@ -45,9 +44,7 @@ function Row({
searchHit: boolean;
/** The hit the ↑/↓ counter is on. */
searchActive: boolean;
- /** The user marked this message read (Story 10.3). */
- read: boolean;
- /** Unread messages at or above this many lines get the quiet highlight. */
+ /** A change at or above this many lines gets the quiet highlight. */
bigChangeLines: number;
onSelect: (row: GitMessageRow) => void;
onUnfold: (segmentId: string) => void;
@@ -75,16 +72,15 @@ function Row({
}
const message = row.message;
- // A fact, not a verdict: the row is only quiet-highlighted when the user has
- // not read it and its commits changed at least `bigChangeLines` lines.
- const unreadBig =
- message.change !== undefined && !read && isBigChange(message.change, bigChangeLines);
+ // A fact, not a verdict: the row is quiet-highlighted when its commits changed
+ // at least `bigChangeLines` lines.
+ const big = message.change !== undefined && isBigChange(message.change, bigChangeLines);
const className = [
"git-row",
selected ? "is-selected" : "",
searchHit ? "is-search-hit" : "",
searchActive ? "is-search-active" : "",
- unreadBig ? "is-unread-big" : "",
+ big ? "is-big-change" : "",
]
.filter(Boolean)
.join(" ");
@@ -128,7 +124,7 @@ function Row({
{message.change ? (
<span
className="git-change"
- title={`The commits linked to this message changed ${message.change.added} lines added, ${message.change.removed} removed${read ? " (read)" : ""}`}
+ title={`The commits linked to this message changed ${message.change.added} lines added, ${message.change.removed} removed`}
>
{formatChange(message.change)}
</span>
@@ -144,7 +140,6 @@ export function GitGraph({
selectedId,
highlightIds,
activeHitId,
- readIds,
bigChangeLines,
onSelect,
onUnfold,
@@ -157,9 +152,7 @@ export function GitGraph({
highlightIds: ReadonlySet<string> | undefined;
/** The search hit the counter is on, if it belongs to this session. */
activeHitId: string | null;
- /** Messages the user marked read (Story 10.3). */
- readIds: ReadonlySet<string>;
- /** Unread messages at or above this many lines get the quiet highlight. */
+ /** A change at or above this many lines gets the quiet highlight. */
bigChangeLines: number;
onSelect: (row: GitMessageRow) => void;
onUnfold: (segmentId: string) => void;
@@ -252,7 +245,6 @@ export function GitGraph({
selected={messageId !== null && selectedId !== null && messageId === selectedId}
searchHit={messageId !== null && highlightIds?.has(messageId) === true}
searchActive={messageId !== null && activeHitId !== null && messageId === activeHitId}
- read={messageId !== null && readIds.has(messageId)}
bigChangeLines={bigChangeLines}
onSelect={onSelect}
onUnfold={onUnfold}
diff --git a/packages/template/src/Graph.tsx b/packages/template/src/Graph.tsx
index 9caedb2..39cf91f 100644
--- a/packages/template/src/Graph.tsx
+++ b/packages/template/src/Graph.tsx
@@ -17,10 +17,9 @@ import {
useRef,
useState,
} from "react";
-import { unreadViewMessages } from "../../cli/src/view/change.js";
import type { LineageViewModel, ViewSession } from "../../cli/src/view/model.js";
import { hitMessageIds, hitSessionIds } from "../../cli/src/view/search.js";
-import { loadMapView, pageToken, saveOpenSessions, saveRead, saveRowWidth } from "./data.js";
+import { loadMapView, pageToken, saveOpenSessions, saveRowWidth } from "./data.js";
import { type FilesTarget, FilesView } from "./FilesView.js";
import { useFullscreen } from "./fullscreen.js";
import { GitGraph } from "./GitGraph.js";
@@ -36,7 +35,6 @@ import { usePageWheel } from "./scroll.js";
import { applySearchHits, storedOpen } from "./searchOpen.js";
import { layoutSessionGraph, openAtLoad, type SessionGraph } from "./sessionLayout.js";
import { useTheme } from "./ThemeButton.js";
-import { UnreadView } from "./UnreadView.js";
/**
* The project map (Story 8.7). The sessions are a git graph, one dot each;
@@ -55,9 +53,7 @@ const OPEN_EMPTY = 36;
const GraphActions = createContext<{
selection: Selection | null;
openIds: ReadonlySet<string>;
- /** Message ids the user marked read (Story 10.3). */
- readIds: ReadonlySet<string>;
- /** Unread messages at or above this many lines get the quiet highlight. */
+ /** Changes at or above this many lines get the quiet highlight. */
bigChangeLines: number;
openSession: (sessionId: string) => void;
openNode: (sessionId: string, messageId: string) => void;
@@ -72,7 +68,6 @@ const GraphActions = createContext<{
}>({
selection: null,
openIds: new Set(),
- readIds: new Set(),
bigChangeLines: 300,
openSession: () => {},
openNode: () => {},
@@ -112,17 +107,8 @@ function SessionMessages({
highlights: ReadonlySet<string> | undefined;
activeHitId: string | null;
}) {
- const {
- selection,
- readIds,
- bigChangeLines,
- openNode,
- unfold,
- resizeRows,
- storeRowWidth,
- person,
- people,
- } = useContext(GraphActions);
+ const { selection, bigChangeLines, openNode, unfold, resizeRows, storeRowWidth, person, people } =
+ useContext(GraphActions);
const own = selection?.sessionId === session.sessionId;
if (git.rows.length === 0)
return <p className="graph-status empty">No messages recorded in this session yet.</p>;
@@ -134,7 +120,6 @@ function SessionMessages({
selectedId={selection?.type === "node" && own ? selection.nodeId : null}
highlightIds={highlights}
activeHitId={activeHitId}
- readIds={readIds}
bigChangeLines={bigChangeLines}
onSelect={(row) => openNode(session.sessionId, row.message.id)}
onUnfold={unfold}
@@ -341,52 +326,13 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
);
const [openAll, setOpenAll] = useState(false);
const [showOutline, setShowOutline] = useState(true);
- // The files, unread and outline views share the left column; only one shows.
+ // The files and outline views share the left column; only one shows.
const [showFiles, setShowFiles] = useState(false);
- const [showUnread, setShowUnread] = useState(false);
const [person, setPerson] = useState<PersonFilter>(null);
const people = useMemo(() => peopleOf(model), [model]);
const personOptions = useMemo(() => people.options(), [people]);
const { expanded: fullscreen, toggle: toggleFullscreen } = useFullscreen();
- // Story 10.3: the read marks the page was built with. A live rebuild refreshes
- // them; the toggle updates this set at once so the row answers the click.
- const [readIds, setReadIds] = useState<ReadonlySet<string>>(() => new Set(model.read ?? []));
- const [readError, setReadError] = useState<string | null>(null);
- useEffect(() => {
- setReadIds(new Set(model.read ?? []));
- }, [model]);
const bigChangeLines = model.settings?.bigChangeLines ?? 300;
- const toggleRead = useCallback(
- (id: string, next: boolean) => {
- setReadError(null);
- setReadIds((previous) => {
- const copy = new Set(previous);
- if (next) copy.add(id);
- else copy.delete(id);
- return copy;
- });
- // Over `file://` there is no server to write to; the mark lasts for this
- // open page only, which is what the toggle's title says.
- const token = pageToken();
- if (token === null) return;
- void saveRead(model.project.path, id, next, token).catch((err: unknown) => {
- setReadError(err instanceof Error ? err.message : String(err));
- setReadIds((previous) => {
- const copy = new Set(previous);
- if (next) copy.delete(id);
- else copy.add(id);
- return copy;
- });
- });
- },
- [model.project.path],
- );
- const unread = useMemo(() => unreadViewMessages(model.sessions, readIds), [model, readIds]);
- const unreadBig = useMemo(
- () =>
- unread.filter((message) => message.change.added + message.change.removed >= bigChangeLines),
- [unread, bigChangeLines],
- );
const [focusedId, setFocusedId] = useState<string | null>(() => {
if (initial === null) return null;
if (initial.messageId === undefined) return `session:${initial.sessionId}`;
@@ -684,7 +630,6 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
() => ({
selection,
openIds,
- readIds,
bigChangeLines,
openSession: toggleSession,
openNode,
@@ -698,7 +643,6 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
[
selection,
openIds,
- readIds,
bigChangeLines,
toggleSession,
openNode,
@@ -825,41 +769,13 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
onClick={() => {
setShowFiles((value) => !value);
setShowOutline(false);
- setShowUnread(false);
}}
>
{showFiles ? "Hide files" : "Files"}
</button>
- <button
- type="button"
- className="outline-button"
- aria-pressed={showUnread}
- title="Unread messages with commits, most code first"
- onClick={() => {
- setShowUnread((value) => !value);
- setShowOutline(false);
- setShowFiles(false);
- }}
- >
- {showUnread
- ? "Hide unread"
- : `Unread${unreadBig.length > 0 ? ` (${unreadBig.length})` : ""}`}
- </button>
</div>
<div className="graph-wrap">
- {showUnread ? (
- <UnreadView
- messages={unread}
- bigChangeLines={bigChangeLines}
- active={
- selection?.type === "node"
- ? { sessionId: selection.sessionId, messageId: selection.nodeId }
- : null
- }
- onSelect={selectFromFiles}
- onClose={() => setShowUnread(false)}
- />
- ) : showFiles ? (
+ {showFiles ? (
<FilesView
files={model.files}
active={
@@ -900,10 +816,7 @@ function Flow({ model, search }: { model: LineageViewModel; search: MapSearchSta
selection={selection}
onClose={() => setSelection(null)}
onNavigate={selectFromOutline}
- read={selection?.type === "node" ? readIds.has(selection.nodeId) : false}
- onToggleRead={toggleRead}
bigChangeLines={bigChangeLines}
- readError={readError}
/>
</div>
</div>
diff --git a/packages/template/src/Panel.tsx b/packages/template/src/Panel.tsx
index a040503..8f50386 100644
--- a/packages/template/src/Panel.tsx
+++ b/packages/template/src/Panel.tsx
@@ -72,14 +72,6 @@ export function Panel({ model }: { model: PanelViewModel }) {
<dt>Waiting on you</dt>
<dd>{project.needsUserCount}</dd>
</div>
- {project.unreadBigCount === undefined ? null : (
- <div>
- <dt title="Unread messages whose commits changed at least the big-change threshold of lines">
- Unread big changes
- </dt>
- <dd>{project.unreadBigCount}</dd>
- </div>
- )}
</dl>
{href ? (
<a className="card-open" href={href}>
diff --git a/packages/template/src/ShapeModal.tsx b/packages/template/src/ShapeModal.tsx
index 71a6b89..a13ff7a 100644
--- a/packages/template/src/ShapeModal.tsx
+++ b/packages/template/src/ShapeModal.tsx
@@ -8,7 +8,6 @@ import {
shapePreview,
shapeState,
tableRows,
- UNIVERSAL_KINDS,
} from "../../cli/src/view/shape.js";
import { DiffView } from "./DiffView.js";
import { isLivePage, pageToken } from "./data.js";
@@ -123,44 +122,26 @@ const TEXT_CAPTION: Record<string, string> = {
interface: "Interface (as written)",
};
-/** Tools whose "?" lists every kind, so the reader can decode the symbols. */
-const KINDS_CAPTIONS = new Set(["flow", "pseudo"]);
-
/**
- * A tool's caption with a "?" that says how to read it; a Flow or Steps also
- * lists every kind, so the symbols name themselves. `reading` swaps in another
- * tool's explanation (an ordered Flow reads like a Sequence).
+ * A tool's caption with a "?" that says how to read it. The kinds a Shape uses
+ * are already named in the legend above, so the bubble only explains the tool.
+ * `reading` swaps in another tool's explanation (an ordered Flow reads like a
+ * Sequence).
*/
-function ToolCaption({
- id,
- kind,
- label,
- reading = kind,
-}: {
- id: string;
- kind: string;
- label: string;
- reading?: string;
-}) {
+function ToolCaption({ id, label, reading }: { id: string; label: string; reading: string }) {
const help = SHAPE_READING[reading];
- const listsKinds = KINDS_CAPTIONS.has(kind);
+ if (!help)
+ return (
+ <figcaption className="shape-caption">
+ <span>{label}</span>
+ </figcaption>
+ );
return (
<figcaption className="shape-caption">
<span>{label}</span>
- {help ? (
- <HelpTip id={`shape-${id}`} label={`How to read the ${label}`}>
- <span className="shape-reading">{help}</span>
- {listsKinds ? (
- <span className="shape-kinds">
- {UNIVERSAL_KINDS.map((kind) => (
- <span key={kind.id} className="shape-kind-row">
- <code>{kind.symbol}</code> {kind.name} — {kind.means}
- </span>
- ))}
- </span>
- ) : null}
- </HelpTip>
- ) : null}
+ <HelpTip id={`shape-${id}`} label={`How to read the ${label}`}>
+ <span className="shape-reading">{help}</span>
+ </HelpTip>
</figcaption>
);
}
@@ -257,7 +238,6 @@ function ShapeLayer({
{renderMermaid(source)}
<ToolCaption
id={key}
- kind={tool.kind}
label={orderedFlow ? "Sequence" : diagramLabel(tool.kind)}
reading={orderedFlow ? "sequence" : tool.kind}
/>
@@ -271,15 +251,19 @@ function ShapeLayer({
<ShapeTable columns={columns} rows={rows} />
<ToolCaption
id={key}
- kind={tool.kind}
label={tool.kind === "interface" ? "Interface" : "Before / After"}
+ reading={tool.kind}
/>
</figure>
);
return (
<figure key={key} className="shape-figure">
<pre className={`shape-source is-${tool.kind}`}>{tool.text}</pre>
- <ToolCaption id={key} kind={tool.kind} label={TEXT_CAPTION[tool.kind] ?? tool.kind} />
+ <ToolCaption
+ id={key}
+ label={TEXT_CAPTION[tool.kind] ?? tool.kind}
+ reading={tool.kind}
+ />
</figure>
);
})}
diff --git a/packages/template/src/SidePanel.tsx b/packages/template/src/SidePanel.tsx
index f0c5a37..d2a7d89 100644
--- a/packages/template/src/SidePanel.tsx
+++ b/packages/template/src/SidePanel.tsx
@@ -324,20 +324,13 @@ function NodeDetails({
model,
node,
onNavigate,
- read,
- onToggleRead,
bigChangeLines,
- readError,
}: {
model: LineageViewModel;
node: NodeDetail;
onNavigate: ((target: OutlineTarget) => void) | undefined;
- /** The user marked this message read (Story 10.3). */
- read: boolean;
- onToggleRead: ((id: string, read: boolean) => void) | undefined;
+ /** A change at or above this many lines is marked as big. */
bigChangeLines: number;
- /** A failed write of the read mark, shown and not swallowed. */
- readError: string | null;
}) {
const session = findSession(model, node.sessionId);
// Diffs are read from the local server (Story 10.5); a `file://` map has no
@@ -423,29 +416,12 @@ function NodeDetails({
<h3>Code landed</h3>
<p>
<span
- className={`git-change${
- !read && isBigChange(node.change, bigChangeLines) ? " is-big" : ""
- }`}
+ className={`git-change${isBigChange(node.change, bigChangeLines) ? " is-big" : ""}`}
>
{formatChange(node.change)}
</span>{" "}
after this message.
</p>
- <button
- type="button"
- className="read-toggle"
- aria-pressed={read}
- disabled={onToggleRead === undefined}
- onClick={() => onToggleRead?.(node.nodeId, !read)}
- >
- {read ? "Mark as unread" : "Mark as read"}
- </button>
- {typeof document !== "undefined" && isLivePage() ? null : (
- <p className="muted">
- Saved under .cogit/state by `cogit open`; this page keeps it only while open.
- </p>
- )}
- {readError === null ? null : <p className="error">{readError}</p>}
</section>
) : null}
{node.commits?.length ? (
@@ -690,21 +666,14 @@ export function DrillDown({
selection,
onClose,
onNavigate,
- read = false,
- onToggleRead,
bigChangeLines = 300,
- readError = null,
}: {
model: LineageViewModel;
selection: Selection | null;
onClose: () => void;
/** Moves the selection to another node and reveals it on the map. */
onNavigate?: (target: OutlineTarget) => void;
- /** Whether the selected message is marked read (Story 10.3). */
- read?: boolean;
- onToggleRead?: ((id: string, read: boolean) => void) | undefined;
bigChangeLines?: number;
- readError?: string | null;
}) {
useEffect(() => {
if (!selection) return;
@@ -762,10 +731,7 @@ export function DrillDown({
model={model}
node={node}
onNavigate={onNavigate}
- read={read}
- onToggleRead={onToggleRead}
bigChangeLines={bigChangeLines}
- readError={readError}
/>
</div>
</aside>
diff --git a/packages/template/src/UnreadView.tsx b/packages/template/src/UnreadView.tsx
deleted file mode 100644
index c8b04b6..0000000
--- a/packages/template/src/UnreadView.tsx
+++ /dev/null
@@ -1,82 +0,0 @@
-import { formatChange, isBigChange, type UnreadMessage } from "../../cli/src/view/change.js";
-import { formatStamp } from "./format.js";
-
-/**
- * The map's unread filter (Story 10.3): messages the user has not marked read
- * that have commits behind them, most code first. It is a list, not a verdict:
- * the numbers come from git, and a message lands here simply because nobody has
- * looked at it yet. Clicking a row opens that message on the graph, exactly as
- * its dot does.
- */
-export function UnreadView({
- messages,
- bigChangeLines,
- active,
- onSelect,
- onClose,
-}: {
- messages: readonly UnreadMessage[];
- /** The highlight threshold; big rows get a quiet mark. */
- bigChangeLines: number;
- active: { sessionId: string; messageId: string } | null;
- onSelect: (target: { sessionId: string; messageId: string }) => void;
- onClose: () => void;
-}) {
- return (
- <nav className="outline unread-view" aria-label="Unread messages, most code first">
- <header className="outline-head">
- <span className="outline-title">Unread, most code first</span>
- <span className="outline-badge">{messages.length}</span>
- <button
- type="button"
- className="drilldown-close"
- aria-label="Hide unread"
- onClick={onClose}
- >
- ×
- </button>
- </header>
- <div className="outline-scroll">
- {messages.length === 0 ? (
- <p className="empty">
- No unread messages with commits. A message appears here once a commit carries it and you
- have not marked it read.
- </p>
- ) : (
- <ul className="outline-list">
- {messages.map((message) => {
- const big = isBigChange(message.change, bigChangeLines);
- const current =
- active?.sessionId === message.sessionId && active.messageId === message.messageId;
- return (
- <li key={message.messageId}>
- <button
- type="button"
- className={`outline-item unread-row${current ? " is-active" : ""}${
- big ? " is-big" : ""
- }`}
- title={`${message.title} — ${message.sessionTitle}`}
- onClick={() =>
- onSelect({
- sessionId: message.sessionId,
- messageId: message.messageId,
- })
- }
- >
- <span className="git-change">{formatChange(message.change)}</span>
- <span className="unread-label">{message.label}</span>
- <span className="unread-title">{message.title}</span>
- <span className="muted unread-session">{message.sessionTitle}</span>
- <span className="muted unread-when">
- {message.at === undefined ? "" : formatStamp(message.at)}
- </span>
- </button>
- </li>
- );
- })}
- </ul>
- )}
- </div>
- </nav>
- );
-}
diff --git a/packages/template/src/data.ts b/packages/template/src/data.ts
index 08ce7b2..fe4fc8a 100644
--- a/packages/template/src/data.ts
+++ b/packages/template/src/data.ts
@@ -76,28 +76,6 @@ export async function loadSettings(token: string): Promise<Partial<PanelSettings
return body.settings ?? {};
}
-/**
- * Marks one message read or unread (Story 10.3). The state lives in the
- * project's `.cogit/state/`, so this needs the local server; over `file://` the
- * page has no token and the toggle stays local to the open page.
- */
-export async function saveRead(
- dir: string,
- id: string,
- read: boolean,
- token: string,
-): Promise<void> {
- const response = await fetch("/api/read", {
- method: "POST",
- headers: { "content-type": "application/json", "x-cogit-token": token },
- body: JSON.stringify({ dir, id, read }),
- });
- if (!response.ok) {
- const text = (await response.text()).trim();
- throw new Error(text || `could not save the read mark (HTTP ${response.status})`);
- }
-}
-
/**
* How the user left the map (open sessions, row widths) as stored now. The page
* embeds it at build time, but a reload right after a change can beat the
diff --git a/packages/template/src/styles.css b/packages/template/src/styles.css
index 7276eff..2f32d27 100644
--- a/packages/template/src/styles.css
+++ b/packages/template/src/styles.css
@@ -2453,8 +2453,8 @@ time {
border-radius: 3px;
}
-/* Unread and above the threshold: a quiet mark, not an alarm. */
-.git-row.is-unread-big {
+/* A change above the threshold: a quiet mark, not an alarm. */
+.git-row.is-big-change {
box-shadow: inset 2px 0 0 color-mix(in srgb, var(--warn) 55%, transparent);
}
@@ -2463,56 +2463,6 @@ time {
border-color: color-mix(in srgb, var(--warn) 45%, transparent);
}
-.unread-view .unread-row {
- display: flex;
- flex-wrap: wrap;
- align-items: baseline;
- gap: 6px;
-}
-
-.unread-view .unread-label {
- color: var(--muted);
- font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
- font-size: 11px;
-}
-
-.unread-view .unread-title {
- flex: 1 1 140px;
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.unread-view .unread-session,
-.unread-view .unread-when {
- flex: 0 1 auto;
- font-size: 10px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.unread-view .unread-row.is-big {
- box-shadow: inset 2px 0 0 color-mix(in srgb, var(--warn) 55%, transparent);
-}
-
-.read-toggle {
- padding: 3px 10px;
- color: var(--text);
- font: inherit;
- font-size: 12px;
- background: var(--chip-bg);
- border: 1px solid var(--chip-line);
- border-radius: 4px;
- cursor: pointer;
-}
-
-.read-toggle[aria-pressed="true"] {
- color: var(--muted);
- border-style: dashed;
-}
-
/* Intent, Shape and Code (Story 13.6) */
.shape-section {
margin: 14px 0;
@@ -2711,31 +2661,15 @@ time {
gap: 6px;
}
-.shape-reading,
-.shape-kinds,
-.shape-kind-row {
+.shape-reading {
display: block;
}
-.shape-kinds {
- margin-top: 8px;
- padding-top: 8px;
- border-top: 1px solid var(--line);
-}
-
-.shape-kind-row + .shape-kind-row {
- margin-top: 3px;
-}
-
.shape-caption .settings-details {
font-size: 12.5px;
line-height: 1.5;
}
-.shape-kinds code {
- font-size: 11px;
-}
-
.shape-figure {
margin: 0 0 16px;
}
diff --git a/packages/template/test/map-changes.test.tsx b/packages/template/test/map-changes.test.tsx
new file mode 100644
index 0000000..0d81cda
--- /dev/null
+++ b/packages/template/test/map-changes.test.tsx
@@ -0,0 +1,116 @@
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import { describe, expect, it } from "vitest";
+import type { LineageViewModel, ViewNode, ViewSession } from "../../cli/src/view/model.js";
+import { GitGraph } from "../src/GitGraph.js";
+import { layoutGitGraph } from "../src/gitLayout.js";
+import { DrillDown } from "../src/SidePanel.js";
+
+const T0 = "2026-10-26T10:00:00.000Z";
+
+const BIG = { added: 1200, removed: 40, files: 14 };
+const SMALL = { added: 6, removed: 2, files: 1 };
+
+function message(id: string, extra: Partial<ViewNode> = {}): ViewNode {
+ return {
+ id,
+ label: id === "h1" ? "m1" : "m2",
+ kind: "message",
+ title: `Message ${id}`,
+ at: T0,
+ parent: null,
+ ...extra,
+ };
+}
+
+const session: ViewSession = {
+ sessionId: "s1",
+ agent: "claude-code",
+ title: "Session one",
+ startedAt: T0,
+ updatedAt: T0,
+ status: { goal: "", done: [], pending: [], next: "" },
+ messages: [
+ message("h1", { change: BIG, commits: ["a".repeat(40)] }),
+ message("h2", { change: SMALL, commits: ["b".repeat(40)] }),
+ message("h3"),
+ ],
+ transcriptAvailable: false,
+};
+
+function modelOf(current: ViewSession): LineageViewModel {
+ return {
+ kind: "lineage",
+ schema: 1,
+ project: { name: "p", path: "/p", generatedAt: T0 },
+ status: { goal: "", done: [], pending: [], next: "", lastActivity: T0 },
+ sessions: [current],
+ settings: {
+ recorder: "mixed",
+ language: "auto",
+ updateEveryTurns: 15,
+ sideEveryTurns: 5,
+ sessionEndCatchUp: true,
+ sideModel: "haiku",
+ messageSummaries: false,
+ startupContext: true,
+ shareConversations: false,
+ recordCommit: "ask",
+ gitPolicy: "ignore",
+ agents: ["claude-code"],
+ bigChangeLines: 300,
+ },
+ };
+}
+
+function renderGraph(bigChangeLines = 300): string {
+ return renderToStaticMarkup(
+ createElement(GitGraph, {
+ git: layoutGitGraph(session.messages),
+ selectedId: null,
+ highlightIds: undefined,
+ activeHitId: null,
+ bigChangeLines,
+ onSelect: () => {},
+ onUnfold: () => {},
+ onContinue: () => {},
+ }),
+ );
+}
+
+describe("how much code landed on the map (10.3)", () => {
+ it("puts a numstat chip on rows that have commits", () => {
+ const html = renderGraph();
+ expect(html).toContain('class="git-change"');
+ expect(html).toContain("+1 200 −40 · 14 files");
+ expect(html).toContain("+6 −2 · 1 file");
+ // No commits: no chip, not a zero.
+ expect(html.match(/class="git-change"/g)).toHaveLength(2);
+ });
+
+ it("marks a row above the threshold, and only above it", () => {
+ expect(renderGraph()).toContain("is-big-change");
+ // The small message stays plain; a big threshold leaves every row plain.
+ expect(renderGraph(300).match(/is-big-change/g)).toHaveLength(1);
+ expect(renderGraph(10_000)).not.toContain("is-big-change");
+ });
+
+ it("shows the numbers and the big mark in the drill-down", () => {
+ const html = renderToStaticMarkup(
+ createElement(DrillDown, {
+ model: modelOf(session),
+ selection: { type: "node", sessionId: "s1", nodeId: "h1" },
+ onClose: () => {},
+ bigChangeLines: 300,
+ }),
+ );
+ expect(html).toContain("Code landed");
+ expect(html).toContain("+1 200 −40 · 14 files");
+ expect(html).toContain("after this message");
+ expect(html).toContain("is-big");
+ // The reason and the code come first; the conversation is folded at the end.
+ expect(html).toContain('<details class="chat fold"><summary>Conversation</summary>');
+ expect(html.indexOf("Code landed")).toBeLessThan(html.indexOf("Conversation"));
+ expect(html.indexOf("Conversation")).toBeLessThan(html.indexOf("drilldown-meta"));
+ });
+});
diff --git a/packages/template/test/shape-modal.test.tsx b/packages/template/test/shape-modal.test.tsx
index b834236..0e0d678 100644
--- a/packages/template/test/shape-modal.test.tsx
+++ b/packages/template/test/shape-modal.test.tsx
@@ -127,6 +127,9 @@ describe("Intent, Shape and Code", () => {
expect(html).toContain("⚡");
expect(html).toContain("Data store");
expect(html).not.toContain("Function");
+ // The "?" bubble explains how to read the tool; the legend above already
+ // names the kinds, so it must not list them a second time.
+ expect(html).not.toContain('class="shape-kinds"');
});
it("captions an ordered Flow as a Sequence and an unordered one as a Flow", () => {
diff --git a/packages/template/test/unread.test.ts b/packages/template/test/unread.test.ts
deleted file mode 100644
index a89ea68..0000000
--- a/packages/template/test/unread.test.ts
+++ /dev/null
@@ -1,236 +0,0 @@
-import { createElement } from "react";
-import { renderToStaticMarkup } from "react-dom/server";
-import { describe, expect, it } from "vitest";
-import type {
- LineageViewModel,
- PanelViewModel,
- ViewNode,
- ViewSession,
-} from "../../cli/src/view/model.js";
-import { GitGraph } from "../src/GitGraph.js";
-import { layoutGitGraph } from "../src/gitLayout.js";
-import { Panel } from "../src/Panel.js";
-import { DrillDown } from "../src/SidePanel.js";
-import { UnreadView } from "../src/UnreadView.js";
-
-const T0 = "2026-10-26T10:00:00.000Z";
-
-const BIG = { added: 1200, removed: 40, files: 14 };
-const SMALL = { added: 6, removed: 2, files: 1 };
-
-function message(id: string, extra: Partial<ViewNode> = {}): ViewNode {
- return {
- id,
- label: id === "h1" ? "m1" : "m2",
- kind: "message",
- title: `Message ${id}`,
- at: T0,
- parent: null,
- ...extra,
- };
-}
-
-const session: ViewSession = {
- sessionId: "s1",
- agent: "claude-code",
- title: "Session one",
- startedAt: T0,
- updatedAt: T0,
- status: { goal: "", done: [], pending: [], next: "" },
- messages: [
- message("h1", { change: BIG, commits: ["a".repeat(40)] }),
- message("h2", { change: SMALL, commits: ["b".repeat(40)] }),
- message("h3"),
- ],
- transcriptAvailable: false,
-};
-
-function modelOf(current: ViewSession): LineageViewModel {
- return {
- kind: "lineage",
- schema: 1,
- project: { name: "p", path: "/p", generatedAt: T0 },
- status: { goal: "", done: [], pending: [], next: "", lastActivity: T0 },
- sessions: [current],
- read: [],
- settings: {
- recorder: "mixed",
- language: "auto",
- updateEveryTurns: 15,
- sideEveryTurns: 5,
- sessionEndCatchUp: true,
- sideModel: "haiku",
- messageSummaries: false,
- startupContext: true,
- shareConversations: false,
- recordCommit: "ask",
- gitPolicy: "ignore",
- agents: ["claude-code"],
- bigChangeLines: 300,
- },
- };
-}
-
-function renderGraph(readIds: ReadonlySet<string>): string {
- return renderToStaticMarkup(
- createElement(GitGraph, {
- git: layoutGitGraph(session.messages),
- selectedId: null,
- highlightIds: undefined,
- activeHitId: null,
- readIds,
- bigChangeLines: 300,
- onSelect: () => {},
- onUnfold: () => {},
- onContinue: () => {},
- }),
- );
-}
-
-describe("how much code landed on the map (10.3)", () => {
- it("puts a numstat chip on rows that have commits", () => {
- const html = renderGraph(new Set());
- expect(html).toContain('class="git-change"');
- expect(html).toContain("+1 200 −40 · 14 files");
- expect(html).toContain("+6 −2 · 1 file");
- // No commits: no chip, not a zero.
- expect(html.match(/class="git-change"/g)).toHaveLength(2);
- });
-
- it("marks an unread row above the threshold, and drops it once read", () => {
- expect(renderGraph(new Set())).toContain("is-unread-big");
- // The small unread message is not big; a read big one is no longer marked.
- const readBig = renderGraph(new Set(["h1"]));
- expect(readBig).not.toContain("is-unread-big");
- });
-
- it("keeps the threshold a setting, not a verdict", () => {
- const html = renderToStaticMarkup(
- createElement(GitGraph, {
- git: layoutGitGraph(session.messages),
- selectedId: null,
- highlightIds: undefined,
- activeHitId: null,
- readIds: new Set(),
- bigChangeLines: 10_000,
- onSelect: () => {},
- onUnfold: () => {},
- onContinue: () => {},
- }),
- );
- expect(html).not.toContain("is-unread-big");
- });
-
- it("lists unread messages with their numbers and the big mark", () => {
- const html = renderToStaticMarkup(
- createElement(UnreadView, {
- messages: [
- {
- sessionId: "s1",
- sessionTitle: "Session one",
- sessionStartedAt: T0,
- messageId: "h1",
- label: "m1",
- title: "Message h1",
- at: T0,
- change: BIG,
- },
- {
- sessionId: "s1",
- sessionTitle: "Session one",
- sessionStartedAt: T0,
- messageId: "h2",
- label: "m2",
- title: "Message h2",
- change: SMALL,
- },
- ],
- bigChangeLines: 300,
- active: { sessionId: "s1", messageId: "h2" },
- onSelect: () => {},
- onClose: () => {},
- }),
- );
- expect(html).toContain("Unread, most code first");
- expect(html).toContain("+1 200 −40 · 14 files");
- expect(html).toContain("is-active");
- expect((html.match(/is-big/g) ?? []).length).toBeGreaterThan(0);
- // The small row is active but not big.
- expect(html).toContain("unread-row is-active");
- });
-
- it("says plainly when nothing is unread", () => {
- const html = renderToStaticMarkup(
- createElement(UnreadView, {
- messages: [],
- bigChangeLines: 300,
- active: null,
- onSelect: () => {},
- onClose: () => {},
- }),
- );
- expect(html).toContain("No unread messages with commits");
- });
-
- it("shows the numbers and a read toggle in the drill-down", () => {
- const model = modelOf(session);
- const unread = renderToStaticMarkup(
- createElement(DrillDown, {
- model,
- selection: { type: "node", sessionId: "s1", nodeId: "h1" },
- onClose: () => {},
- read: false,
- onToggleRead: () => {},
- bigChangeLines: 300,
- readError: null,
- }),
- );
- expect(unread).toContain("Code landed");
- expect(unread).toContain("+1 200 −40 · 14 files");
- expect(unread).toContain("Mark as read");
- expect(unread).toContain("after this message");
- expect(unread).toContain("is-big");
- // The reason and the code come first; the conversation is folded at the end.
- expect(unread).toContain('<details class="chat fold"><summary>Conversation</summary>');
- expect(unread.indexOf("Code landed")).toBeLessThan(unread.indexOf("Conversation"));
- expect(unread.indexOf("Conversation")).toBeLessThan(unread.indexOf("drilldown-meta"));
-
- const read = renderToStaticMarkup(
- createElement(DrillDown, {
- model,
- selection: { type: "node", sessionId: "s1", nodeId: "h1" },
- onClose: () => {},
- read: true,
- onToggleRead: () => {},
- bigChangeLines: 300,
- readError: "could not write",
- }),
- );
- expect(read).toContain("Mark as unread");
- expect(read).toContain("could not write");
- expect(read).not.toContain("is-big");
- });
-
- it("shows the card count on the panel", () => {
- const model: PanelViewModel = {
- kind: "panel",
- schema: 1,
- generatedAt: T0,
- settings: modelOf(session).settings as PanelViewModel["settings"],
- projects: [
- {
- name: "p",
- path: "/p",
- missing: false,
- lastActivity: T0,
- needsUserCount: 0,
- lineageUrl: "file:///p/.cogit/map.html",
- unreadBigCount: 3,
- },
- ],
- };
- const html = renderToStaticMarkup(createElement(Panel, { model }));
- expect(html).toContain("Unread big changes");
- expect(html).toContain("<dd>3</dd>");
- });
-});