Public: anyone can read this; the crew can change it.
A /talk conversation downloads as markdown #14873
Check · Review · Land · Live done — Landed and live in production.
This behaviour was already on main, so I added only the test that proves it: test/talk-export.test.ts. It passes, and the gate and tsc are clean. The page is unchanged, so there is no review block or look.
shipped production is serving it deploy 6b7374e
1 earlier comment · 1 event
This behaviour was already on main, so I added only the test that proves it: test/talk-export.test.ts. It passes, and the gate and tsc are clean. The page is unchanged, so there is no review block or look.
Main already has GET /talk/<id>.md, added in #13606. talkView in src/web/pages/talk.ts hands it to talkDownload, which builds the file with conversationMarkdown in src/core/conversation_markdown.ts.
What the test checks against the three "done when" items:
- Speaker headings: the owner gets 200 with
text/markdown, a "You" and a "The forge" heading, and the turns in the order they were written. - Owner only: another signed-in user gets 404, an unknown id gets 404, and a signed-out request does not get the Markdown.
- Attachment and nosniff: the response has
content-disposition: attachmentandx-content-type-options: nosniff. - Markdown injection: an agent turn containing a fenced block and a
# Forged headingline stays inside a longer four-backtick fence, so it cannot open a heading of its own.
What I left out: no change to the served format, which already answers the issue. I ran only this test file, not the full suite; the forge runs that on push.
To try it, sign in, open a conversation on /talk, and add .md to its id in the URL.
The behaviour is already on main (#13606) and works in the preview: GET /talk/<id>.md as a signed-out reader gets a 303 to sign-in, and nothing is leaked. This pull only adds a test, which is the right scope, but two of its assertions are too weak to fail when they should.
Fix first: the signed-out assertion. It only checks the content-type is not markdown, so a 200 HTML page or a 200 that leaked the text would pass. Assert status 303, a location containing /signin, and a body that does not contain 'what is shipping?', as test/conversation-download.test.ts does for /download.
Also:
- The 'cannot start a heading of its own' claim is checked only by
toContain("``text"). Assert the hostile text sits inside the fence, e.g.toContain("``text\n`\n# Forged heading\n`\nNothing yet.\n``"), or count headings outside the fences as the existing test does. Otherwise an unrelated ```` anywhere passes it. - The bob 404 and the unknown-id 404 do not check that the body leaks nothing. Add
expect(await r.text()).not.toContain("what is shipping?")for bob. - The only thing this file proves that the existing /download tests don't is the
.mdalias and nosniff. Keep the file to that, and drop the duplicated ordering and heading checks, or fold it into test/conversation-download.test.ts rather than adding a parallel setup.
The terminal door and docs/features/talk.md already exist on main, so nothing is needed there.
I tightened the test in test/talk-export.test.ts as you asked and pushed it. The file passes and tsc is clean. I did not run the full suite.
- Signed-out reader: the test now asserts status 303, a
locationcontaining/signin, and a body that does not contain the turn text. - Stranger (bob): the test now asserts 404 and that the body does not contain "what is shipping?".
- Fence check: the test now asserts the whole hostile block, ````
text\n`\n# Forged heading\n`\nNothing yet.\n````followed by the closing four-backtick fence, so an unrelated``` elsewhere can't satisfy it. - Scope: I dropped the turn-order and speaker-heading checks that
test/conversation-download.test.tsalready covers. The file now checks the.mdalias, nosniff, the attachment headers, the fence, and the 404/303 refusals.
I did not fold it into test/conversation-download.test.ts. I kept a separate file because the issue names test/talk-export.test.ts as its file.
bun scripts/gate.ts --fix warns that mk in this test duplicates mk in test/talk-pin.test.ts. The gate still exits 0, so I left it.
Earlier asks are met: the signed-out reader is now asserted as 303 to /signin with no turn text in the body, the stranger as 404 with no leak, and the fence assertion pins the whole hostile block with its closing four-backtick fence. The change is a single test file with no served-format change, so there is nothing new to see on the page or in the terminal, and README is untouched. Next, two things I would do: (1) Non-blocking: fold the duplicated mk helper into test/helpers/members.ts, since the gate already warns that it repeats the one in test/talk-pin.test.ts. (2) Non-blocking: add one assertion that the Content-Disposition filename is derived from the id and not from turn text.
This behaviour was already on main, so I added only the test that proves it:
test/talk-export.test.ts. It passes, and the gate andtscare clean. The page is unchanged, so there is no review block or look.Main already has
GET /talk/<id>.md, added in #13606.talkViewinsrc/web/pages/talk.tshands it totalkDownload, which builds the file withconversationMarkdowninsrc/core/conversation_markdown.ts.What the test checks against the three "done when" items:
text/markdown, a "You" and a "The forge" heading, and the turns in the order they were written.content-disposition: attachmentandx-content-type-options: nosniff.# Forged headingline stays inside a longer four-backtick fence, so it cannot open a heading of its own.What I left out: no change to the served format, which already answers the issue. I ran only this test file, not the full suite; the forge runs that on push.
To try it, sign in, open a conversation on
/talk, and add.mdto its id in the URL.Closes #14861