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(inbox): quiet the "Your turn" inbox by default

Eren4fd875464aa1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3983ab6..599ce33 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The README states what recording costs: about 3–7% of a session's tokens in measured sessions.
### Changed
+- The "Your turn" inbox is quieter: `inboxMaxAgeDays` now defaults to 1 day (a config that already holds a value keeps it), and a row shows the agent's last message as plain text — bold, inline code, headings, list markers and links are stripped and line breaks stay — so no `**` or backticks reach the page.
- The main agent's record interval defaults to 15 turns (was 5), and the side model records every 5 turns in between; the README states the measured cost of each mode (about 1–2% of a session with the mixed default, 3–7% with `recorder: agent`).
- The "Your turn" inbox: each row closes with an × in its top-right corner (hidden until the agent writes in that session again), rows of different projects carry their own lane colour on the left, and on a project's map the inbox starts folded to one "Your turn" line so it no longer pushes the map off the page.
diff --git a/README.md b/README.md
index 18dc64a..85fdb51 100644
--- a/README.md
+++ b/README.md
@@ -190,6 +190,7 @@ under `gitPolicy: ignore` the description says the hashes resolve only on the au
| `gitPolicy` | `commit` | Whether new projects commit the record |
| `shareConversations` | `false` | Commit the raw conversation too |
| `recordCommit` | `ask` | What to do with messages after the last code commit |
+| `inboxMaxAgeDays` | `1` | Days a waiting session stays in the "Your turn" inbox; older ones are hidden, not deleted |
| `trailerMaxAgeHours` | `6` | How old `.cogit/HEAD` may be for a `Thought:` trailer |
| `serverPort` | `4747` | Port for the local map server |
diff --git a/docs/schema/config.json b/docs/schema/config.json
index 2ff586b..ad66b35 100644
--- a/docs/schema/config.json
+++ b/docs/schema/config.json
@@ -100,7 +100,7 @@
"type": "boolean"
},
"inboxMaxAgeDays": {
- "default": 7,
+ "default": 1,
"type": "integer",
"minimum": 1,
"maximum": 3650
diff --git a/packages/cli/src/schema/config.ts b/packages/cli/src/schema/config.ts
index c33305d..685c81c 100644
--- a/packages/cli/src/schema/config.ts
+++ b/packages/cli/src/schema/config.ts
@@ -71,10 +71,13 @@ export const Config = z.object({
*/
tryBeforeNotes: z.boolean().default(true),
/**
- * How many days a session stays in the "your turn" inbox (Story 11.1). Older
- * sessions are hidden; nothing is deleted.
+ * How many days a session stays in the "your turn" inbox (Stories 11.1,
+ * 12.2). One day by default: the inbox is for work that is still fresh, not
+ * an archive. Raise it to keep rows longer. A config that holds an older value
+ * keeps it; only the default changed. Older sessions are hidden, nothing is
+ * deleted.
*/
- inboxMaxAgeDays: z.int().min(1).max(3650).default(7),
+ inboxMaxAgeDays: z.int().min(1).max(3650).default(1),
agents: z.array(z.string().min(1)).default(["claude-code"]),
/** Project roots ("don't ask again" in this project) where the setup hint stays silent. */
setupHintOff: z.array(z.string().min(1)).default([]),
diff --git a/packages/cli/src/view/inbox.ts b/packages/cli/src/view/inbox.ts
index 825ab8f..7229a88 100644
--- a/packages/cli/src/view/inbox.ts
+++ b/packages/cli/src/view/inbox.ts
@@ -20,7 +20,7 @@ export interface InboxCandidate {
mapUrl: string;
sessionId: string;
sessionTitle: string;
- /** The agent's last turn, when the transcript ends with it. */
+ /** The agent's last turn, when the transcript ends with it; `text` is raw Markdown. */
turn: { at: string; text: string } | null;
/** The newest time the record knows about, for a record-only row. */
lastActivity: string | null;
@@ -52,6 +52,70 @@ export function clipMessage(text: string, limit = INBOX_MESSAGE_LIMIT): string {
return text.length <= limit ? text : `${text.slice(0, limit - 1)}…`;
}
+/** Lines that are markup for a reader of the rendered message, not its words. */
+const FENCE = /^\s{0,3}(?:`{3,}|~{3,})/;
+const HEADING = /^\s{0,3}#{1,6}(?:\s+|$)/;
+const HEADING_CLOSE = /\s+#+\s*$/;
+const QUOTE = /^(?:\s{0,3}>\s?)+/;
+const RULE = /^\s{0,3}([-*_])(?:\s*\1){2,}\s*$/;
+const LIST = /^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s+/;
+const TASK = /^\[[ xX]\]\s+/;
+
+/** Inline markers: links keep their text, code its content, emphasis its words. */
+function stripInline(line: string): string {
+ let text = line;
+ // Images first, so their alt text survives the link rule as words.
+ text = text.replace(/!\[([^\]]*)\]\([^)]*\)/g, "$1");
+ text = text.replace(/\[([^\]]+)\]\([^)]*\)/g, "$1");
+ text = text.replace(/\[([^\]]+)\]\[[^\]]*\]/g, "$1");
+ text = text.replace(/<(https?:\/\/[^>\s]+)>/g, "$1");
+ // Inline code keeps what it quotes; paired or not, the backticks are markup.
+ text = text.replace(/`+/g, "");
+ // Strongest first, so nested emphasis unwinds inside out.
+ text = text.replace(/(\*\*\*|___)(?=\S)([\s\S]*?\S)\1/g, "$2");
+ text = text.replace(/(\*\*|__)(?=\S)([\s\S]*?\S)\1/g, "$2");
+ text = text.replace(/~~(?=\S)([\s\S]*?\S)~~/g, "$1");
+ // A single marker only when it pairs around words; `*.ts` and `snake_case`
+ // are text, not emphasis.
+ text = text.replace(/(^|[^\w*])\*(?=\S)([^*\n]*?\S)\*(?![\w*])/g, "$1$2");
+ text = text.replace(/(^|[^\w_])_(?=\S)([^_\n]*?\S)_(?![\w_])/g, "$1$2");
+ // Unclosed double markers are markup too (a turn cut mid-word still reads).
+ text = text.replace(/\*\*/g, "").replace(/~~/g, "");
+ return text;
+}
+
+function stripLine(line: string): string {
+ if (RULE.test(line)) return "";
+ let text = line.replace(HEADING, "").replace(QUOTE, "");
+ text = text.replace(LIST, "").replace(TASK, "");
+ return stripInline(text.replace(HEADING_CLOSE, ""));
+}
+
+/**
+ * The agent's last message as plain text for a row (Story 12.2). A chat turn is
+ * written in Markdown, but a row needs the words, not the markup: bold, inline
+ * code, headings, list markers and links are stripped and line breaks stay.
+ * Fenced code keeps its lines. The result is a string, never HTML — the page
+ * renders it as text.
+ */
+export function stripMarkdown(text: string): string {
+ const lines = text.replace(/\r\n?/g, "\n").split("\n");
+ const out: string[] = [];
+ let inFence = false;
+ for (const line of lines) {
+ if (FENCE.test(line)) {
+ inFence = !inFence;
+ out.push("");
+ continue;
+ }
+ out.push(inFence ? line : stripLine(line));
+ }
+ return out
+ .join("\n")
+ .replace(/\n{3,}/g, "\n\n")
+ .trim();
+}
+
/**
* The rows a page shows, oldest first. A candidate is a row when it has a turn
* or a `needsUser` item; a session older than `maxAgeDays` is hidden, and so is
@@ -92,7 +156,7 @@ export function inboxRows(
signal,
at,
...(turnAt !== null && candidate.turn !== null
- ? { lastMessage: clipMessage(candidate.turn.text) }
+ ? { lastMessage: clipMessage(stripMarkdown(candidate.turn.text)) }
: {}),
goal: candidate.goal,
lastDecision: candidate.lastDecision,
diff --git a/packages/cli/src/view/model.ts b/packages/cli/src/view/model.ts
index 7f937e0..fc46371 100644
--- a/packages/cli/src/view/model.ts
+++ b/packages/cli/src/view/model.ts
@@ -263,7 +263,10 @@ export interface ViewInboxRow {
signal: "turn" | "record" | "both";
/** Newest signal time (ISO): the agent's last turn, else the record's activity. */
at: string;
- /** The agent's last written message, first ~300 characters, verbatim. */
+ /**
+ * The agent's last written message as plain text (Markdown stripped), first
+ * ~300 characters (Story 12.2).
+ */
lastMessage?: string;
/** Where-were-we, as the record wrote it; the page labels it as the record's. */
goal: string;
diff --git a/packages/cli/test/inbox.test.ts b/packages/cli/test/inbox.test.ts
index 04f700d..a3c088c 100644
--- a/packages/cli/test/inbox.test.ts
+++ b/packages/cli/test/inbox.test.ts
@@ -15,6 +15,7 @@ import {
INBOX_MESSAGE_LIMIT,
type InboxCandidate,
inboxRows,
+ stripMarkdown,
timeSince,
} from "../src/view/inbox.js";
import { DATA_ELEMENT_ID, type PanelViewModel } from "../src/view/model.js";
@@ -297,6 +298,61 @@ describe("inboxRows", () => {
expect(row?.lastMessage?.endsWith("…")).toBe(true);
expect(row?.pending).toEqual([{ text: "decide", needsUser: true }]);
});
+
+ it("shows the agent's message as plain text, never its Markdown", async () => {
+ const [row] = inboxRows(
+ [candidate({ turn: { at: at(10), text: "**Done** — `npm test` is green." } })],
+ new Map(),
+ now,
+ 7,
+ );
+ expect(row?.lastMessage).toBe("Done — npm test is green.");
+ });
+});
+
+describe("stripMarkdown", () => {
+ it("strips bold, italic, code and unclosed markers", () => {
+ expect(stripMarkdown("**bold** and __also bold__")).toBe("bold and also bold");
+ expect(stripMarkdown("~~gone~~")).toBe("gone");
+ expect(stripMarkdown("run `npm test` and ``npm run build``")).toBe(
+ "run npm test and npm run build",
+ );
+ expect(stripMarkdown("**open and `unclosed")).toBe("open and unclosed");
+ expect(stripMarkdown("**bold *and italic***")).toBe("bold and italic");
+ });
+
+ it("keeps a glob or an underscore name, which is text rather than emphasis", () => {
+ expect(stripMarkdown("*.ts and snake_case stay")).toBe("*.ts and snake_case stay");
+ });
+
+ it("turns links and images into their text", () => {
+ expect(stripMarkdown("see [the docs](https://example.com/a) now")).toBe("see the docs now");
+ expect(stripMarkdown("![a diagram](x.png)")).toBe("a diagram");
+ expect(stripMarkdown("[ref link][r] and <https://example.com>")).toBe(
+ "ref link and https://example.com",
+ );
+ });
+
+ it("strips headings, quote and list markers and task boxes", () => {
+ expect(stripMarkdown("## Title ##")).toBe("Title");
+ expect(stripMarkdown("#hashtag is not a heading")).toBe("#hashtag is not a heading");
+ expect(stripMarkdown("> quoted\n> > nested")).toBe("quoted\nnested");
+ expect(stripMarkdown("- one\n* two\n1. three\n2) four")).toBe("one\ntwo\nthree\nfour");
+ expect(stripMarkdown("- [ ] todo\n- [x] done")).toBe("todo\ndone");
+ expect(stripMarkdown("---")).toBe("");
+ });
+
+ it("keeps line breaks readable and drops fenced-code fences", () => {
+ expect(stripMarkdown("first\nsecond\n\n\nafter a gap")).toBe("first\nsecond\n\nafter a gap");
+ expect(stripMarkdown("before\n```ts\nconst a = 1;\n```\nafter")).toBe(
+ "before\n\nconst a = 1;\n\nafter",
+ );
+ });
+
+ it("never builds HTML from the message", () => {
+ // The stripper returns text; the page renders it as a text node.
+ expect(stripMarkdown("<b>hi</b>")).toBe("<b>hi</b>");
+ });
});
describe("timeSince", () => {
@@ -480,19 +536,20 @@ describe("panel and map inbox", () => {
expect(model.inbox?.map((row) => row.sessionId)).toEqual(["sb", "sa"]);
});
- it("honours inboxMaxAgeDays from the config", async () => {
+ it("honours inboxMaxAgeDays from the config, one day by default", async () => {
const root = join(dir, "old");
await initProject(root, env);
+ // Three days before the panel's clock (T0): past the default, inside a week.
await writeTranscript(env, "s1", [
userLine("Old", "2026-10-18T10:00:00.000Z"),
agentLine("Old reply", "2026-10-18T10:05:00.000Z"),
]);
await writeSession(root, { sessionId: "s1", at: "2026-10-18T10:00:00.000Z" });
let model = await buildPanel({ env, io: fakeIo(env), templateHtml: TEMPLATE });
- expect(model.inbox?.map((row) => row.sessionId)).toEqual(["s1"]);
- await configSet("inboxMaxAgeDays", "1", fakeIo(env));
- model = await buildPanel({ env, io: fakeIo(env), templateHtml: TEMPLATE });
expect(model.inbox).toEqual([]);
+ await configSet("inboxMaxAgeDays", "7", fakeIo(env));
+ model = await buildPanel({ env, io: fakeIo(env), templateHtml: TEMPLATE });
+ expect(model.inbox?.map((row) => row.sessionId)).toEqual(["s1"]);
});
it("keeps another project's rows off the map", async () => {
diff --git a/packages/cli/test/schema.test.ts b/packages/cli/test/schema.test.ts
index cc2db70..5038822 100644
--- a/packages/cli/test/schema.test.ts
+++ b/packages/cli/test/schema.test.ts
@@ -116,6 +116,7 @@ describe("Project and Config schemas", () => {
gitPolicy: "commit",
shareConversations: false,
recordCommit: "ask",
+ inboxMaxAgeDays: 1,
});
});
});
diff --git a/packages/template/src/Inbox.tsx b/packages/template/src/Inbox.tsx
index a91866c..c5f5e3c 100644
--- a/packages/template/src/Inbox.tsx
+++ b/packages/template/src/Inbox.tsx
@@ -9,8 +9,9 @@ import { ResumeButton } from "./ResumeButton.js";
* The "your turn" inbox (Story 11.1): one row per session whose transcript ends
* with the agent, or whose record has `needsUser` items. The two signals stay
* apart — the turn is a transcript fact, the record summary is labelled as the
- * record's — and the agent's last message is shown verbatim so the user judges
- * it, never a guess about whether it asked a question.
+ * record's — and the agent's last message is shown as plain text (Markdown
+ * stripped, Story 12.2) so the user judges it, never a guess about whether it
+ * asked a question.
*/
/** The map of the row's project, opened at the session's newest message. */