Public: anyone can read this; the crew can change it.
A Talk conversation downloads as one Markdown file through a plain link #13606
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13589-a-talk-conversation-downloads-as-one-mar → main 2 commits fork
3 files
changed +16
−2
docs/features/talk.md +1 −1
| @@ -135,6 +135,6 @@ After you confirm a held action, the thread shows a receipt: the verb, the objec | ||
| 135 | 135 | |
| 136 | 136 | ## Download |
| 137 | 137 | |
| 138 | `GET /talk/:id/download` (the Download link beside Archive) returns the conversation as one `text/markdown` attachment: a title, then each turn under `## who · when` in the order written, attachments as links. Only its owner gets it; anyone else sees not found. The MCP `say` tool with `action: download` and `conversation` returns the same text as `markdown`. Code: `src/core/conversation_markdown.ts`; test: `test/conversation-download.test.ts`. | |
| 138 | `GET /talk/:id.md` (also `/talk/:id/download`; the Download link beside Archive) returns the conversation as one `text/markdown` attachment: a title, then each turn under `## who · when` in the order written, attachments as links. Only its owner gets it; anyone else sees not found. The MCP `say` tool with `action: download` and `conversation` returns the same text as `markdown`. Code: `src/core/conversation_markdown.ts`; test: `test/conversation-download.test.ts`. | |
| 139 | 139 | |
| 140 | 140 | The terminal's Talk screen reads the same file: `d` on the list or in a chat shows the conversation as the Markdown `/talk/:id/download` serves (`conversationMarkdown`), its owner's alone. Each turn's words sit in a fenced block, so no message can forge a turn heading; past a million characters the earliest turns are left out and the file says so. The MCP `say` tool's `download` with no `conversation` takes the latest one. |
src/web/pages/talk.ts +4 −1
| @@ -326,7 +326,7 @@ function chats(ctx: Ctx, conversation: Conversation, showArchived: boolean, type | ||
| 326 | 326 | ${btn("Save")} |
| 327 | 327 | </form> |
| 328 | 328 | </details> |
| 329 | <a class="btn" href="${urlOf(conversation)}/download" download>Download</a> | |
| 329 | <a class="btn" href="${urlOf(conversation)}.md" download>Download</a> | |
| 330 | 330 | <form method="post" action="${urlOf(conversation)}/archive"> |
| 331 | 331 | <input type="hidden" name="archived" value="${archived ? "0" : "1"}" /> |
| 332 | 332 | ${btn(archived ? "Restore" : "Archive")} |
| @@ -432,6 +432,9 @@ const conversationOf = (ctx: Ctx, user: { readonly id: string }): Conversation | | ||
| 432 | 432 | // GET /talk and GET /talk/:id |
| 433 | 433 | export function talkView(ctx: Ctx): Response | Promise<Response> { |
| 434 | 434 | if (ctx.auth.user === undefined) return signInFirst(ctx); |
| 435 | // /talk/<id>.md is the same file as /talk/<id>/download, behind the same owner gate. | |
| 436 | const id = ctx.params["id"]; | |
| 437 | if (id !== undefined && id.endsWith(".md")) return talkDownload({ ...ctx, params: { ...ctx.params, id: id.slice(0, -3) } }); | |
| 435 | 438 | notePhase(ctx.request, "session", takeSessionTime(ctx.request)); |
| 436 | 439 | const before = ctx.url.searchParams.get("before"); |
| 437 | 440 | const conversation = conversationOf(ctx, ctx.auth.user); |
test/conversation-download.test.ts +11
| @@ -136,3 +136,14 @@ test("the MCP say tool returns the same text, to the owner alone", async () => { | ||
| 136 | 136 | expect(JSON.parse(mine.text).markdown).toBe(page); |
| 137 | 137 | expect((await mcp(bob, { action: "download", conversation: convo })).error).toBe(true); |
| 138 | 138 | }); |
| 139 | ||
| 140 | test("/talk/<id>.md is the same file, the owner's alone", async () => { | |
| 141 | const a = await get(alice, `/talk/${convo}.md`); | |
| 142 | expect(a.status).toBe(200); | |
| 143 | expect(a.headers.get("content-type")).toContain("text/markdown"); | |
| 144 | expect(a.headers.get("content-disposition")).toContain("attachment"); | |
| 145 | expect(await a.text()).toBe(await (await get(alice, `/talk/${convo}/download`)).text()); | |
| 146 | expect((await get(bob, `/talk/${convo}.md`)).status).toBe(404); | |
| 147 | expect((await get(alice, `/talk/nope.md`)).status).toBe(404); | |
| 148 | expect((await fetch(`${servers.url}/talk/${convo}.md`, { redirect: "manual" })).status).toBe(303); | |
| 149 | }); |
new above
offline