{"draft":null,"from":34,"to":35,"files":[{"path":"client/src/issues.ts","added":46,"removed":13,"diff":"--- a/client/src/issues.ts\n+++ b/client/src/issues.ts\n@@ -69,7 +69,7 @@\n \treturn `  ${String(i.id).padStart(3)}  ${i.status.padEnd(11)}  ${q(i.title)}${detail.length > 0 ? ` (${detail.join(\"; \")})` : \"\"}`;\n }\n \n-function askLine(a: Ask & { title?: string | null }): string {\n+function askLine(a: Ask & { title?: string | null }, api?: Pick<Api, \"attachmentUrl\">): string {\n \tconst what = a.review ? \"a review\" : a.kind === \"task\" ? \"a task\" : \"a question\";\n \tconst where = a.issue === null ? \"\" : ` on issue ${a.issue}${a.title ? ` (${q(a.title)})` : \"\"}`;\n \tconst extra = [\n@@ -82,12 +82,13 @@\n \t\ta.blocks.length > 0 ? `blocks ${a.blocks.join(\", \")}` : \"\",\n \t].filter((x) => x !== \"\");\n \tconst head = `  ask ${a.id}: ${a.by}, ${shortWhen(a.at)}, asks ${a.of} ${what}${where}${extra.length > 0 ? ` (${extra.join(\"; \")})` : \"\"}: ${q(a.question)}`;\n-\tconst lines = [head];\n+\tconst lines = [head, ...attachmentLines(api, a.attachments, \"    \")];\n \tif (a.options.length > 0) lines.push(`    options: ${a.options.map((o, i) => `${i + 1}. ${q(o)}`).join(\", \")}`);\n \tif (a.recommendation) lines.push(`    ${a.recommendation.by} recommends: ${q(a.recommendation.text)}`);\n \tif (a.answer && a.outcome === \"withdrawn\") {\n \t\tif (a.answer.words !== \"\") lines.push(`    why: ${q(a.answer.words)}`);\n-\t} else if (a.answer) lines.push(`    answer: ${q(a.answer.words)}`);\n+\t} else if (a.answer)\n+\t\tlines.push(`    answer: ${q(a.answer.words)}`, ...attachmentLines(api, a.answer.attachments, \"      \"));\n \treturn lines.join(\"\\n\");\n }\n \n@@ -128,6 +129,20 @@\n \t\t\t\t.filter((v) => v !== \"\");\n }\n \n+/** \" with 2 attachments (a…, a…)\" after a write that carried some; nothing otherwise. */\n+function withFiles(ids: readonly string[]): string {\n+\treturn ids.length > 0 ? ` with ${plural(ids.length, \"attachment\")} (${ids.join(\", \")})` : \"\";\n+}\n+\n+/**\n+ * What to say when a write sent files the server didn't keep: an Issues server from before asks carried\n+ * attachments takes the words and leaves the files out. Nothing to say when it kept them, or none were sent.\n+ */\n+function notKept(sent: readonly string[], kept: readonly string[] | undefined, what: string): string | undefined {\n+\tif (sent.length === 0 || (kept !== undefined && sent.every((id) => kept.includes(id)))) return undefined;\n+\treturn `The Issues server didn't keep the ${sent.length === 1 ? \"file\" : \"files\"} on ${what}: it is older than this client. The words went; the ${sent.length === 1 ? \"file goes\" : \"files go\"} on a comment instead (abso issue <N> --comment \"...\" --attach ...).`;\n+}\n+\n /** The most one attachment may be: the Issues Worker's cap, checked here before sending (abso issue 171). */\n const ATTACH_MAX = 10 * 1024 * 1024;\n \n@@ -184,8 +199,8 @@\n }\n \n /**\n- * abso issue N --save-attachments <folder>: every attachment on the issue and\n- * its comments, written to that folder as <id>-<name>; an svg's own file\n+ * abso issue N --save-attachments <folder>: every attachment on the issue, its\n+ * comments and its asks and answers, written to that folder as <id>-<name>; an svg's own file\n  * beside the png drawn from it. Not into the abso folder unless abso leaves\n  * that place out, or the images would be recorded as edits.\n  */\n@@ -197,9 +212,11 @@\n \t\t\t`${dir} is inside this abso folder, so abso would record the images as your edits. Save them outside the folder, or into a folder .absoignore leaves out`,\n \t\t);\n \tconst seen = new Set<string>();\n-\tconst all = [...(page.issue.attachments ?? []), ...page.comments.flatMap((c) => c.attachments ?? [])].filter(\n-\t\t(a) => !seen.has(a.id) && seen.add(a.id),\n-\t);\n+\tconst all = [\n+\t\t...(page.issue.attachments ?? []),\n+\t\t...page.comments.flatMap((c) => c.attachments ?? []),\n+\t\t...page.asks.flatMap((a) => [...(a.attachments ?? []), ...(a.answer?.attachments ?? [])]),\n+\t].filter((a) => !seen.has(a.id) && seen.add(a.id));\n \tif (all.length === 0)\n \t\treturn {\n \t\t\ttext: `Issue ${page.issue.id} has no attachments.`,\n@@ -247,7 +264,7 @@\n \t\t...(i.lines ? [`From ${i.lines.file} lines ${i.lines.from}-${i.lines.to} at version ${i.lines.version}.`] : []),\n \t\t...(i.description !== \"\" ? [\"\", ...i.description.split(\"\\n\").map((l) => `  ${l}`)] : []),\n \t\t...attachmentLines(api, i.attachments, \"  \"),\n-\t\t...(p.asks.length > 0 ? [\"\", \"Asks:\", ...p.asks.map(askLine)] : []),\n+\t\t...(p.asks.length > 0 ? [\"\", \"Asks:\", ...p.asks.map((a) => askLine(a, api))] : []),\n \t\t...(p.comments.length > 0\n \t\t\t? [\n \t\t\t\t\t\"\",\n@@ -602,6 +619,7 @@\n \tconst issue = str(args, \"issue\");\n \tconst blocks = str(args, \"blocks\");\n \tconst options = str(args, \"options\");\n+\tconst attachments = await uploadAttachments(api, env.cwd, str(args, \"attach\"));\n \tconst r = await api.ask({\n \t\tof,\n \t\tquestion: words.join(\" \"),\n@@ -618,13 +636,18 @@\n \t\t\t\t\t\t.filter((o) => o !== \"\"),\n \t\t\t\t}\n \t\t\t: {}),\n+\t\t...(attachments.length > 0 ? { attachments } : {}),\n \t});\n-\treturn { text: `Asked ${of} (ask ${r.id}). They hear it; abso waiting shows what's open.`, json: { id: r.id } };\n+\tconst lost = notKept(attachments, r.attachments, `ask ${r.id}`);\n+\treturn {\n+\t\ttext: `Asked ${of} (ask ${r.id})${withFiles(attachments)}. They hear it; abso waiting shows what's open.${lost ? ` ${lost}` : \"\"}`,\n+\t\tjson: { id: r.id, ...(attachments.length > 0 ? { attachments } : {}), ...(lost ? { notKept: lost } : {}) },\n+\t};\n }\n \n /** abso ask --withdraw <ask> [--note \"why\"]: the asker takes an ask back. It closes like an answer, and the one asked hears it. */\n async function withdrawAsk(args: Parsed, env: Env, word: string): Promise<Output> {\n-\tconst others = [\"issue\", \"due\", \"blocks\", \"options\"].filter((f) => str(args, f) !== undefined);\n+\tconst others = [\"issue\", \"due\", \"blocks\", \"options\", \"attach\"].filter((f) => str(args, f) !== undefined);\n \tif (args.positionals.length > 0 || others.length > 0 || bool(args, \"review\") || bool(args, \"task\"))\n \t\tthrow new UsageError('abso ask --withdraw <ask> [--note \"why\"] takes nothing else: it takes back an ask you made');\n \tconst id = issueNumber(word, \"the ask number\");\n@@ -682,7 +705,7 @@\n \t\t\t\t? `Nothing is waiting${of ? ` on ${of}` : \"\"}.`\n \t\t\t\t: [\n \t\t\t\t\t\t`${plural(asks.length, \"open ask\")}${of ? ` of ${of}` : \"\"}, soonest due first:`,\n-\t\t\t\t\t\t...asks.map(askLine),\n+\t\t\t\t\t\t...asks.map((a) => askLine(a, api)),\n \t\t\t\t\t\t'abso answer <ask> \"...\" answers one asked of you.',\n \t\t\t\t\t].join(\"\\n\"),\n \t\tjson: { asks },\n@@ -698,11 +721,21 @@\n \t\tthrow new UsageError('abso answer <ask> \"<words>\" | --option <N> [--note \"...\"] | --done [--note \"...\"]');\n \tconst { api } = openIssues(env);\n \tconst note = str(args, \"note\");\n+\tconst attachments = await uploadAttachments(api, env.cwd, str(args, \"attach\"));\n \tconst r = await api.answer(id, {\n \t\t...(words.length > 0 ? { words: words.join(\" \") } : {}),\n \t\t...(option !== undefined ? { option: /^\\d+$/.test(option) ? Number(option) - 1 : option } : {}),\n \t\t...(done ? { done: true } : {}),\n \t\t...(note !== undefined ? { note } : {}),\n+\t\t...(attachments.length > 0 ? { attachments } : {}),\n \t});\n-\treturn { text: `Answered ask ${id}. ${r.ask.by} hears it.`, json: { ask: r.ask } };\n+\tconst lost = notKept(\n+\t\tattachments,\n+\t\tr.ask.answer?.attachments?.map((a) => a.id),\n+\t\t`your answer to ask ${id}`,\n+\t);\n+\treturn {\n+\t\ttext: `Answered ask ${id}${withFiles(attachments)}. ${r.ask.by} hears it.${lost ? ` ${lost}` : \"\"}`,\n+\t\tjson: { ask: r.ask, ...(lost ? { notKept: lost } : {}) },\n+\t};\n }"}],"unmatched":[]}