Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Write a thread up in Docs from chat; cards' buttons in notifications; a session's card stays at the top of its thread | 1 | import assert from "node:assert/strict"; |
| 2 | import { test } from "node:test"; | |
| 3 | ||
| 4 | import { cleanTitle, threadLink, writableSpaces, writeUpAgents, writeUpMessage } from "./write-up.ts"; | |
| 5 | ||
| 6 | test("a thread's link is its conversation with ?thread=", () => { | |
| 7 | assert.equal(threadLink("https://g1t.sh/", "/acme/-/chat/launch", "msg_1"), "https://g1t.sh/acme/-/chat/launch?thread=msg_1"); | |
| 8 | assert.equal(threadLink("https://g1t.sh", "/acme/-/chat/dm/chn_1", "a b"), "https://g1t.sh/acme/-/chat/dm/chn_1?thread=a%20b"); | |
| 9 | }); | |
| 10 | ||
| 11 | test("only spaces the person can write in, not archived, the default first", () => { | |
| 12 | const spaces = writableSpaces([ | |
| 13 | { id: "s1", name: "Design", viewer_role: "edit", archived_at: null }, | |
| 14 | { id: "s2", name: "Board", viewer_role: "view", archived_at: null }, | |
| 15 | { id: "s3", name: "Old", viewer_role: "manage", archived_at: "2026-01-01T00:00:00Z" }, | |
| 16 | { id: "s4", name: "General", viewer_role: "manage", archived_at: null, is_default: true }, | |
| 17 | { id: "s5", name: "Notes", viewer_role: "comment", archived_at: null }, | |
| 18 | ]); | |
| 19 | assert.deepEqual(spaces, [ | |
| 20 | { id: "s4", name: "General" }, | |
| 21 | { id: "s1", name: "Design" }, | |
| 22 | ]); | |
| 23 | }); | |
| 24 | ||
| 25 | test("@g1t is always offered first, then the conversation's agents, once each", () => { | |
| 26 | const agents = writeUpAgents([ | |
| 27 | { kind: "user", name: "ana", display_name: "Ana" }, | |
| 28 | { kind: "agent", name: "Scribe", display_name: "Scribe" }, | |
| 29 | { kind: "agent", name: "g1t", display_name: "g1t" }, | |
| 30 | { kind: "agent", name: "scribe", display_name: "Scribe" }, | |
| 31 | { kind: "agent", name: "qa", display_name: " " }, | |
| 32 | ]); | |
| 33 | assert.deepEqual(agents, [ | |
| 34 | { handle: "g1t", name: "g1t" }, | |
| 35 | { handle: "scribe", name: "Scribe" }, | |
| 36 | { handle: "qa", name: "qa" }, | |
| 37 | ]); | |
| 38 | }); | |
| 39 | ||
| 40 | test("a title is one line without double quotes", () => { | |
| 41 | assert.equal(cleanTitle(' The "launch"\n plan '), "The 'launch' plan"); | |
| 42 | assert.equal(cleanTitle(null), ""); | |
| 43 | assert.equal(cleanTitle("x".repeat(200)).length, 120); | |
| 44 | }); | |
| 45 | ||
| 46 | test("the ask names the agent, the space, the title if any, and the thread to cite", () => { | |
| 47 | const link = "https://g1t.sh/acme/-/chat/launch?thread=msg_1"; | |
| 48 | assert.equal( | |
| 49 | writeUpMessage({ agent: "g1t", space: "Engineering", title: "Launch plan", link }), | |
| 50 | `@g1t write this thread up as a Docs page in Engineering titled "Launch plan": what was decided, why, and what's next. Link this thread as the source: ${link}`, | |
| 51 | ); | |
| 52 | assert.equal( | |
| 53 | writeUpMessage({ agent: "@Scribe", space: " Product notes ", title: " ", link }), | |
| 54 | `@scribe write this thread up as a Docs page in Product notes: what was decided, why, and what's next. Link this thread as the source: ${link}`, | |
| 55 | ); | |
| 56 | }); |