Public: anyone can read this; the crew can change it.

A Talk conversation downloads as one Markdown file through a plain link #13606

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/13589-a-talk-conversation-downloads-as-one-mar → main 2 commits fork

  • Merged. scout/13589-a-talk-conversation-downloads-as-one-mar was merged into main as 7dcff6d.

Review

Sign in to review this change.
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
135135
136136 ## Download
137137
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`.
139139
140140 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
326326 ${btn("Save")}
327327 </form>
328328 </details>
329 <a class="btn" href="${urlOf(conversation)}/download" download>Download</a>
329 <a class="btn" href="${urlOf(conversation)}.md" download>Download</a>
330330 <form method="post" action="${urlOf(conversation)}/archive">
331331 <input type="hidden" name="archived" value="${archived ? "0" : "1"}" />
332332 ${btn(archived ? "Restore" : "Archive")}
@@ -432,6 +432,9 @@ const conversationOf = (ctx: Ctx, user: { readonly id: string }): Conversation |
432432 // GET /talk and GET /talk/:id
433433 export function talkView(ctx: Ctx): Response | Promise<Response> {
434434 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) } });
435438 notePhase(ctx.request, "session", takeSessionTime(ctx.request));
436439 const before = ctx.url.searchParams.get("before");
437440 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 () => {
136136 expect(JSON.parse(mine.text).markdown).toBe(page);
137137 expect((await mcp(bob, { action: "download", conversation: convo })).error).toBe(true);
138138 });
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 });

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs