A team of long-lived bots for DeepSeek Harness, with main bots, bot-to-bot messages and group chats.
Fold settled cards to their result, as the chat reads them later
Fei241114991c821c01
diff --git a/ds-bot/client.js b/ds-bot/client.jsindex e415f1a9..6dd0945d 100644--- a/ds-bot/client.js+++ b/ds-bot/client.js@@ -812,7 +812,6 @@ var ZH = {Dismissed: "已关闭","Answered by message": "已用消息回答","Your answer": "你的回答",- Options: "选项",// ViewsView: "视图",Confirm: "确认",@@ -2922,6 +2921,10 @@ button.bt-q-opt:active{background:var(--bt-active)}.bt-q-check svg{width:16px;height:16px}.bt-q-settled .bt-key{opacity:.4}.bt-q-settled .bt-q-label{color:color-mix(in srgb,var(--bt-ink) 45%,transparent)}+.bt-q-answered .bt-q-title{color:var(--bt-ink-2)}+.bt-q-answered .bt-key{opacity:1;background:var(--bt-accent);color:var(--bt-accent-ink)}+.bt-q-answered .bt-q-label{color:var(--bt-ink)}+.bt-q-answered .bt-q-opt+.bt-q-opt::before{display:none}.bt-q-dismissed .bt-q-title{color:var(--bt-ink-2)}.bt-q.bt-q-settled{gap:6px;padding:12px 16px}.bt-q-settled .bt-q-title{font-size:14px;line-height:20px;font-weight:500}@@ -4941,38 +4944,25 @@ function SettledQuestion({ question, answer, closed }) {const selected = Array.isArray(answer?.selected) ? answer.selected : [];const custom = typeof answer?.custom === "string" ? answer.custom.trim() : "";const answered = closed === void 0 && (selected.length > 0 || custom !== "");- const row = (key, label, { letter, description, chosen }) => (0, import_react8.createElement)(- "div",- { key, className: "bt-q-opt" },- letter ? (0, import_react8.createElement)("span", { className: "bt-key", "aria-hidden": true }, letter) : null,- (0, import_react8.createElement)(- "span",- { className: "bt-q-body" },- (0, import_react8.createElement)("span", { className: "bt-q-label" }, label),- description ? (0, import_react8.createElement)("span", { className: "bt-q-desc" }, description) : null- ),- chosen ? (0, import_react8.createElement)("span", { className: "bt-q-check", title: t("Selected") }, (0, import_react8.createElement)(CheckIcon)) : null- );- const rows2 = options.map((option, index) => row(`o-${index}`, option.label, { letter: keyLetter(index), description: option.description, chosen: answered && selected.includes(option.label) }));- if (answered) {- selected.filter((label) => !options.some((option) => option.label === label)).forEach((label, index) => rows2.push(row(`s-${index}`, label, { chosen: true })));- if (custom !== "") rows2.push(row("own", custom, { chosen: true }));- }+ const chosen = answered ? [+ ...selected.map((label) => ({ label, at: options.findIndex((option) => option.label === label) })),+ ...custom !== "" ? [{ label: custom, at: options.length }] : []+ ] : [];return (0, import_react8.createElement)("div",- { className: answered ? "bt-q bt-q-settled" : "bt-q bt-q-settled bt-q-dismissed", role: "group", "aria-label": prompt },+ { className: answered ? "bt-q bt-q-settled bt-q-answered" : "bt-q bt-q-settled bt-q-dismissed", role: "group", "aria-label": prompt },(0, import_react8.createElement)("div",{ className: "bt-q-head" },- (0, import_react8.createElement)(- "div",- { className: "bt-q-text" },- prompt ? (0, import_react8.createElement)("p", { className: "bt-q-title" }, prompt) : null,- question?.detail ? (0, import_react8.createElement)("div", { className: "bt-q-detail" }, question.detail) : null- ),+ (0, import_react8.createElement)("div", { className: "bt-q-text" }, prompt ? (0, import_react8.createElement)("p", { className: "bt-q-title" }, prompt) : null),answered ? null : (0, import_react8.createElement)("span", { className: "bt-q-badge" }, closedLabel(closed))),- rows2.length > 0 ? (0, import_react8.createElement)("div", { className: "bt-q-list", role: "group", "aria-label": t(answered ? "Your answer" : "Options") }, rows2) : null+ chosen.length > 0 ? (0, import_react8.createElement)("div", { className: "bt-q-list", role: "group", "aria-label": t("Your answer") }, chosen.map(({ label, at }, index) => (0, import_react8.createElement)(+ "div",+ { key: `${label}-${index}`, className: "bt-q-opt", title: t("Selected") },+ at >= 0 ? (0, import_react8.createElement)("span", { className: "bt-key", "aria-hidden": true }, keyLetter(at)) : null,+ (0, import_react8.createElement)("span", { className: "bt-q-body" }, (0, import_react8.createElement)("span", { className: "bt-q-label" }, label))+ ))) : null);}function QuestionCard({ matched }) {@@ -8031,13 +8021,12 @@ function WidgetCell({ sessionId, callId, args, done, isError, roster, actions, hif (shown.interactive || args?.value?.("await_reply") === true) {const closed = callId === void 0 ? void 0 : roster.closedCards?.[sessionId]?.[callId];if (closed === void 0) return (0, import_react15.createElement)(CellEmpty, { className: "bt-q-gone" });- return (0, import_react15.createElement)(ClosedView, { title: shown.title, view: shown.view, closed });+ return (0, import_react15.createElement)(ClosedView, { title: shown.title, closed });}return (0, import_react15.createElement)("div", { className: "bt-q-inline" }, (0, import_react15.createElement)(Card, { title: shown.title, view: shown.view }));}-function ClosedView({ title, view, closed }) {- const head = (0, import_react15.createElement)("span", { className: "bt-view-closed" }, (0, import_react15.createElement)("span", { className: "bt-view-closed-title" }, title ?? ""), (0, import_react15.createElement)("span", { className: "bt-q-badge" }, closedLabel(closed)));- return (0, import_react15.createElement)("div", { className: "bt-q-inline" }, (0, import_react15.createElement)(Card, { title: head, view, settled: true }));+function ClosedView({ title, closed }) {+ return (0, import_react15.createElement)("div", { className: "bt-q-inline" }, (0, import_react15.createElement)(SettledQuestion, { question: { question: title || t("View") }, closed }));}function WidgetDock({ sessionId, useRoster, useCards, useHeldCards, actions }) {const view = useRoster((value) => value.views?.[sessionId]);@@ -8100,8 +8089,16 @@ body{.bt-q-inline .dv-q{margin:0;max-width:min(550px,86%);order:0}body[data-bt-layout=flat] .bt-q-inline .dv-view{max-width:calc(var(--bt-flat-w,1) * 100%)}.bt-q-inline:has(>.dv-view-bare){margin:8px 0 12px}-.bt-view-closed{display:flex;align-items:flex-start;gap:8px}-.bt-view-closed-title{flex:1 1 0;min-width:0}+/* An answered options view keeps only the chosen rows, each under its card letter+ (a counter, since the core draws no letters on a settled card), like ds-bot's+ own answered question card. Unchosen rows stay in the flow, invisible and+ zero-height, so they still count their letters. */+.dv-q-settled .dv-q-list:has(.dv-q-check){counter-reset:bt-opt}+.dv-q-settled .dv-q-list:has(.dv-q-check)>.dv-q-opt{counter-increment:bt-opt;gap:16px;align-items:center}+.dv-q-settled .dv-q-list:has(.dv-q-check)>.dv-q-opt:not(:has(.dv-q-check)){visibility:hidden;height:0;min-height:0;padding-block:0;overflow:hidden}+.dv-q-settled .dv-q-list:has(.dv-q-check)>.dv-q-opt::before{content:counter(bt-opt,upper-alpha);position:static;inset:auto;opacity:1;flex:none;width:24px;height:24px;border-radius:8px;background:var(--bt-accent);color:var(--bt-accent-ink);font-size:12px;line-height:24px;font-weight:500;text-align:center}+.dv-q-settled .dv-q-list:has(.dv-q-check)>.dv-q-opt .dv-q-label{color:var(--bt-ink)}+.dv-q-settled .dv-q-list:has(.dv-q-check)>.dv-q-opt .dv-q-desc,.dv-q-settled .dv-q-list:has(.dv-q-check) .dv-q-check{display:none}/* A row of segmented options is only as wide as its labels; at phone widths afew longer ones would spill past the card. Let them wrap and let a label wrapinside its own button instead. */@@ -24373,6 +24370,7 @@ function ProposalCard({ proposal, initialError = "", onFailure, onResolved, acticonst outcome = proposal.outcome;const [busy, setBusy] = (0, import_react56.useState)(false);const [error, setError] = (0, import_react56.useState)(initialError);+ const [open, setOpen] = (0, import_react56.useState)(false);const busyRef = (0, import_react56.useRef)(false);const titleId = (0, import_react56.useId)();const answer = (approve) => {@@ -24390,34 +24388,45 @@ function ProposalCard({ proposal, initialError = "", onFailure, onResolved, acti});};const update = proposal.action === "update";+ const agents = proposal.kind === "agents";const rows2 = (0, import_react56.useMemo)(() => lineDiff(update ? proposal.previous?.content : "", proposal.content), [update, proposal.previous?.content, proposal.content]);- if (proposal.kind === "agents") {- const blocks = proposal.edits.map((edit) => [+ const change = agents ? [+ (0, import_react56.createElement)(FileBox, { key: "file", name: "AGENTS.md", path: proposal.folder, state: proposal.exists === false ? "Added" : "Modified", blocks: proposal.edits.map((edit) => [...(edit.op === "add" ? [] : editLines(edit.old)).map((line) => ({ kind: "removed", line })),...(edit.op === "remove" ? [] : editLines(edit.text)).map((line) => ({ kind: "added", line }))- ]);+ ]) }),+ ...proposal.edits.map((edit, index) => edit.why ? (0, import_react56.createElement)("p", { className: "bt-learning-why", key: `why-${index}` }, edit.why) : null)+ ] : [+ (0, import_react56.createElement)(FileBox, { key: "file", name: "SKILL.md", path: `skills/${proposal.name}`, state: update ? "Updated" : "Added", blocks: [rows2] }),+ proposal.why ? (0, import_react56.createElement)("p", { className: "bt-learning-why", key: "why" }, proposal.why) : null+ ];+ const kind = t(agents ? "AGENTS.md update" : update ? "Skill update" : "New skill");+ if (outcome) {+ const what = agents ? proposal.folder : proposal.name;return (0, import_react56.createElement)("section",- { className: "bt-q bt-learning-card", role: "group", "aria-labelledby": titleId, "aria-busy": busy, "data-outcome": outcome },- (0, import_react56.createElement)(ProposalHead, { titleId, icon: PencilIcon, title: t("AGENTS.md update"), outcome }),- (0, import_react56.createElement)(FileBox, { name: "AGENTS.md", path: proposal.folder, state: proposal.exists === false ? "Added" : "Modified", blocks }),- proposal.edits.map((edit, index) => edit.why ? (0, import_react56.createElement)("p", { className: "bt-learning-why", key: index }, edit.why) : null),- error ? (0, import_react56.createElement)("div", { className: "bt-learning-error", role: "alert" }, error) : null,- outcome ? null : (0, import_react56.createElement)(ProposalFoot, { busy, answer })+ { className: "bt-q bt-q-settled bt-learning-card bt-learning-settled", role: "group", "aria-label": `${kind} · ${what}`, "data-outcome": outcome },+ (0, import_react56.createElement)(+ "button",+ { type: "button", className: "bt-learning-fold", "aria-expanded": open, onClick: () => setOpen(!open) },+ (0, import_react56.createElement)("span", { className: "bt-learning-icon", "aria-hidden": true }, (0, import_react56.createElement)(agents ? PencilIcon : MemoryIcon)),+ (0, import_react56.createElement)("span", { className: "bt-learning-kind" }, kind),+ (0, import_react56.createElement)("span", { className: "bt-learning-sum" }, `${t(outcome === "approved" ? "Approved" : "Declined")} · ${what}`)+ ),+ open ? change : null);}const oldDetail = update && typeof proposal.previous?.description === "string" && proposal.previous.description !== proposal.description ? proposal.previous.description : void 0;return (0, import_react56.createElement)("section",- { className: "bt-q bt-learning-card", role: "group", "aria-labelledby": titleId, "aria-busy": busy, "data-outcome": outcome },- (0, import_react56.createElement)(ProposalHead, { titleId, title: proposal.name, kind: t(update ? "Skill update" : "New skill"), detail: proposal.description, oldDetail, outcome }),- (0, import_react56.createElement)(FileBox, { name: "SKILL.md", path: `skills/${proposal.name}`, state: update ? "Updated" : "Added", blocks: [rows2] }),- proposal.why ? (0, import_react56.createElement)("p", { className: "bt-learning-why" }, proposal.why) : null,+ { className: "bt-q bt-learning-card", role: "group", "aria-labelledby": titleId, "aria-busy": busy },+ agents ? (0, import_react56.createElement)(ProposalHead, { titleId, icon: PencilIcon, title: kind }) : (0, import_react56.createElement)(ProposalHead, { titleId, title: proposal.name, kind, detail: proposal.description, oldDetail }),+ change,error ? (0, import_react56.createElement)("div", { className: "bt-learning-error", role: "alert" }, error) : null,- outcome ? null : (0, import_react56.createElement)(ProposalFoot, { busy, answer })+ (0, import_react56.createElement)(ProposalFoot, { busy, answer }));}-function ProposalHead({ titleId, icon: icon2 = MemoryIcon, title, kind, detail, oldDetail, outcome }) {+function ProposalHead({ titleId, icon: icon2 = MemoryIcon, title, kind, detail, oldDetail }) {return (0, import_react56.createElement)("div",{ className: "bt-q-head" },@@ -24430,7 +24439,7 @@ function ProposalHead({ titleId, icon: icon2 = MemoryIcon, title, kind, detail,oldDetail ? (0, import_react56.createElement)("p", { className: "bt-learning-description bt-learning-old" }, (0, import_react56.createElement)("del", null, oldDetail)) : null,detail ? (0, import_react56.createElement)("p", { className: "bt-learning-description" }, detail) : null),- outcome ? (0, import_react56.createElement)("span", { className: "bt-q-badge" }, t(outcome === "approved" ? "Approved" : "Declined")) : (0, import_react56.createElement)("span", { className: "bt-q-badge bt-learning-status" }, (0, import_react56.createElement)("span", { className: "bt-learning-dot", "aria-hidden": true }), t("Awaiting approval"))+ (0, import_react56.createElement)("span", { className: "bt-q-badge bt-learning-status" }, (0, import_react56.createElement)("span", { className: "bt-learning-dot", "aria-hidden": true }), t("Awaiting approval")));}function ProposalFoot({ busy, answer }) {@@ -24591,6 +24600,13 @@ var LEARNING_CSS = `.bt-learning-btn:active:not(:disabled){scale:.96}.bt-learning-btn:focus-visible{outline:2px solid var(--bt-accent);outline-offset:2px}@media (prefers-reduced-motion:reduce){.bt-learning-btn{transition:background-color .12s ease,opacity .12s ease}.bt-learning-btn:active:not(:disabled){scale:none}}+.bt-learning-settled{gap:10px}+.bt-learning-fold{display:flex;align-items:center;gap:10px;min-width:0;width:100%;margin:-4px 0;padding:4px 0;border:0;background:none;font:inherit;text-align:start;color:var(--bt-ink);cursor:pointer}+.bt-learning-fold .bt-learning-icon{width:28px;height:28px;border-radius:8px}+.bt-learning-fold .bt-learning-icon svg{width:16px;height:16px}+.bt-learning-kind{flex:none;font-size:14px;line-height:20px;font-weight:600}+.bt-learning-sum{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;line-height:20px;color:var(--bt-ink-2)}+.bt-learning-fold:focus-visible{outline:2px solid var(--bt-accent);outline-offset:2px;border-radius:8px}.bt-learning-error{font-size:12px;line-height:16px;color:var(--bt-danger)}`;diff --git a/ds-bot/src/client/i18n.js b/ds-bot/src/client/i18n.jsindex 412a0eef..43f8f1c2 100644--- a/ds-bot/src/client/i18n.js+++ b/ds-bot/src/client/i18n.js@@ -759,7 +759,6 @@ const ZH = {Dismissed: '已关闭','Answered by message': '已用消息回答','Your answer': '你的回答',- Options: '选项',// ViewsView: '视图',diff --git a/ds-bot/src/client/learning-card.js b/ds-bot/src/client/learning-card.jsindex 1287668b..59561e12 100644--- a/ds-bot/src/client/learning-card.js+++ b/ds-bot/src/client/learning-card.js@@ -8,11 +8,13 @@ import { spring, SPRING_TAP } from './motion.js'const failedAnswers = new Map()-// `proposal.outcome` set: an answered card, read-only, with how it ended.+// `proposal.outcome` set: an answered card, read-only and folded to one row (what+// it was, how it ended, its name); the row opens the change.function ProposalCard({ proposal, initialError = '', onFailure, onResolved, actions }) {const outcome = proposal.outcomeconst [busy, setBusy] = useState(false)const [error, setError] = useState(initialError)+ const [open, setOpen] = useState(false)const busyRef = useRef(false)const titleId = useId()const answer = approve => {@@ -32,29 +34,41 @@ function ProposalCard({ proposal, initialError = '', onFailure, onResolved, acti})}const update = proposal.action === 'update'+ const agents = proposal.kind === 'agents'const rows = useMemo(() => lineDiff(update ? proposal.previous?.content : '', proposal.content), [update, proposal.previous?.content, proposal.content])- if (proposal.kind === 'agents') {- const blocks = proposal.edits.map(edit => [- ...(edit.op === 'add' ? [] : editLines(edit.old)).map(line => ({ kind: 'removed', line })),- ...(edit.op === 'remove' ? [] : editLines(edit.text)).map(line => ({ kind: 'added', line })),- ])- return h('section', { className: 'bt-q bt-learning-card', role: 'group', 'aria-labelledby': titleId, 'aria-busy': busy, 'data-outcome': outcome },- h(ProposalHead, { titleId, icon: PencilIcon, title: t('AGENTS.md update'), outcome }),- h(FileBox, { name: 'AGENTS.md', path: proposal.folder, state: proposal.exists === false ? 'Added' : 'Modified', blocks }),- proposal.edits.map((edit, index) => edit.why ? h('p', { className: 'bt-learning-why', key: index }, edit.why) : null),- error ? h('div', { className: 'bt-learning-error', role: 'alert' }, error) : null,- outcome ? null : h(ProposalFoot, { busy, answer }))+ const change = agents+ ? [+ h(FileBox, { key: 'file', name: 'AGENTS.md', path: proposal.folder, state: proposal.exists === false ? 'Added' : 'Modified', blocks: proposal.edits.map(edit => [+ ...(edit.op === 'add' ? [] : editLines(edit.old)).map(line => ({ kind: 'removed', line })),+ ...(edit.op === 'remove' ? [] : editLines(edit.text)).map(line => ({ kind: 'added', line })),+ ]) }),+ ...proposal.edits.map((edit, index) => edit.why ? h('p', { className: 'bt-learning-why', key: `why-${index}` }, edit.why) : null),+ ]+ : [+ h(FileBox, { key: 'file', name: 'SKILL.md', path: `skills/${proposal.name}`, state: update ? 'Updated' : 'Added', blocks: [rows] }),+ proposal.why ? h('p', { className: 'bt-learning-why', key: 'why' }, proposal.why) : null,+ ]+ const kind = t(agents ? 'AGENTS.md update' : update ? 'Skill update' : 'New skill')+ if (outcome) {+ const what = agents ? proposal.folder : proposal.name+ return h('section', { className: 'bt-q bt-q-settled bt-learning-card bt-learning-settled', role: 'group', 'aria-label': `${kind} · ${what}`, 'data-outcome': outcome },+ h('button', { type: 'button', className: 'bt-learning-fold', 'aria-expanded': open, onClick: () => setOpen(!open) },+ h('span', { className: 'bt-learning-icon', 'aria-hidden': true }, h(agents ? PencilIcon : MemoryIcon)),+ h('span', { className: 'bt-learning-kind' }, kind),+ h('span', { className: 'bt-learning-sum' }, `${t(outcome === 'approved' ? 'Approved' : 'Declined')} · ${what}`)),+ open ? change : null)}const oldDetail = update && typeof proposal.previous?.description === 'string' && proposal.previous.description !== proposal.description ? proposal.previous.description : undefined- return h('section', { className: 'bt-q bt-learning-card', role: 'group', 'aria-labelledby': titleId, 'aria-busy': busy, 'data-outcome': outcome },- h(ProposalHead, { titleId, title: proposal.name, kind: t(update ? 'Skill update' : 'New skill'), detail: proposal.description, oldDetail, outcome }),- h(FileBox, { name: 'SKILL.md', path: `skills/${proposal.name}`, state: update ? 'Updated' : 'Added', blocks: [rows] }),- proposal.why ? h('p', { className: 'bt-learning-why' }, proposal.why) : null,+ return h('section', { className: 'bt-q bt-learning-card', role: 'group', 'aria-labelledby': titleId, 'aria-busy': busy },+ agents+ ? h(ProposalHead, { titleId, icon: PencilIcon, title: kind })+ : h(ProposalHead, { titleId, title: proposal.name, kind, detail: proposal.description, oldDetail }),+ change,error ? h('div', { className: 'bt-learning-error', role: 'alert' }, error) : null,- outcome ? null : h(ProposalFoot, { busy, answer }))+ h(ProposalFoot, { busy, answer }))}-function ProposalHead({ titleId, icon = MemoryIcon, title, kind, detail, oldDetail, outcome }) {+function ProposalHead({ titleId, icon = MemoryIcon, title, kind, detail, oldDetail }) {return h('div', { className: 'bt-q-head' },h('span', { className: 'bt-learning-icon', 'aria-hidden': true }, h(icon)),h('div', { className: 'bt-q-text' },@@ -62,9 +76,7 @@ function ProposalHead({ titleId, icon = MemoryIcon, title, kind, detail, oldDetakind ? h('div', { className: 'bt-q-detail' }, kind) : null,oldDetail ? h('p', { className: 'bt-learning-description bt-learning-old' }, h('del', null, oldDetail)) : null,detail ? h('p', { className: 'bt-learning-description' }, detail) : null),- outcome- ? h('span', { className: 'bt-q-badge' }, t(outcome === 'approved' ? 'Approved' : 'Declined'))- : h('span', { className: 'bt-q-badge bt-learning-status' }, h('span', { className: 'bt-learning-dot', 'aria-hidden': true }), t('Awaiting approval')))+ h('span', { className: 'bt-q-badge bt-learning-status' }, h('span', { className: 'bt-learning-dot', 'aria-hidden': true }), t('Awaiting approval')))}function ProposalFoot({ busy, answer }) {@@ -205,5 +217,12 @@ export const LEARNING_CSS = `.bt-learning-btn:active:not(:disabled){scale:.96}.bt-learning-btn:focus-visible{outline:2px solid var(--bt-accent);outline-offset:2px}@media (prefers-reduced-motion:reduce){.bt-learning-btn{transition:background-color .12s ease,opacity .12s ease}.bt-learning-btn:active:not(:disabled){scale:none}}+.bt-learning-settled{gap:10px}+.bt-learning-fold{display:flex;align-items:center;gap:10px;min-width:0;width:100%;margin:-4px 0;padding:4px 0;border:0;background:none;font:inherit;text-align:start;color:var(--bt-ink);cursor:pointer}+.bt-learning-fold .bt-learning-icon{width:28px;height:28px;border-radius:8px}+.bt-learning-fold .bt-learning-icon svg{width:16px;height:16px}+.bt-learning-kind{flex:none;font-size:14px;line-height:20px;font-weight:600}+.bt-learning-sum{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;line-height:20px;color:var(--bt-ink-2)}+.bt-learning-fold:focus-visible{outline:2px solid var(--bt-accent);outline-offset:2px;border-radius:8px}.bt-learning-error{font-size:12px;line-height:16px;color:var(--bt-danger)}`diff --git a/ds-bot/src/client/questions.js b/ds-bot/src/client/questions.jsindex f6e41a57..beeb36d4 100644--- a/ds-bot/src/client/questions.js+++ b/ds-bot/src/client/questions.js@@ -142,34 +142,28 @@ function QuestionView({ question, onAnswer, onDismiss, onInteract, busy = false,// How a card closed without an answer on it reads on its badge.export const closedLabel = closed => t(closed === 'replied' ? 'Answered by message' : 'Dismissed')-// The settled card left in the transcript, read-only: every option, muted, with a-// check on the chosen ones and the user's own answer below them. A card closed-// without an answer (`closed`, or no answer) keeps its options and gets a badge.+// The settled card left in the transcript, read-only and compact: the question,+// muted, and only what the user chose, each under the letter it had on the card;+// an own answer takes the letter after the options. A card closed without an+// answer (`closed`, or no answer) keeps only the question and a badge.export function SettledQuestion({ question, answer, closed }) {const options = optionsOf(question)const prompt = question?.question ?? ''const selected = Array.isArray(answer?.selected) ? answer.selected : []const custom = typeof answer?.custom === 'string' ? answer.custom.trim() : ''const answered = closed === undefined && (selected.length > 0 || custom !== '')- const row = (key, label, { letter, description, chosen }) => h('div', { key, className: 'bt-q-opt' },- letter ? h('span', { className: 'bt-key', 'aria-hidden': true }, letter) : null,- h('span', { className: 'bt-q-body' },- h('span', { className: 'bt-q-label' }, label),- description ? h('span', { className: 'bt-q-desc' }, description) : null),- chosen ? h('span', { className: 'bt-q-check', title: t('Selected') }, h(CheckIcon)) : null)- const rows = options.map((option, index) => row(`o-${index}`, option.label, { letter: keyLetter(index), description: option.description, chosen: answered && selected.includes(option.label) }))- // A chosen label the options no longer list still shows as chosen.- if (answered) {- selected.filter(label => !options.some(option => option.label === label)).forEach((label, index) => rows.push(row(`s-${index}`, label, { chosen: true })))- if (custom !== '') rows.push(row('own', custom, { chosen: true }))- }- return h('div', { className: answered ? 'bt-q bt-q-settled' : 'bt-q bt-q-settled bt-q-dismissed', role: 'group', 'aria-label': prompt },+ const chosen = answered ? [+ ...selected.map(label => ({ label, at: options.findIndex(option => option.label === label) })),+ ...(custom !== '' ? [{ label: custom, at: options.length }] : []),+ ] : []+ return h('div', { className: answered ? 'bt-q bt-q-settled bt-q-answered' : 'bt-q bt-q-settled bt-q-dismissed', role: 'group', 'aria-label': prompt },h('div', { className: 'bt-q-head' },- h('div', { className: 'bt-q-text' },- prompt ? h('p', { className: 'bt-q-title' }, prompt) : null,- question?.detail ? h('div', { className: 'bt-q-detail' }, question.detail) : null),+ h('div', { className: 'bt-q-text' }, prompt ? h('p', { className: 'bt-q-title' }, prompt) : null),answered ? null : h('span', { className: 'bt-q-badge' }, closedLabel(closed))),- rows.length > 0 ? h('div', { className: 'bt-q-list', role: 'group', 'aria-label': t(answered ? 'Your answer' : 'Options') }, rows) : null)+ chosen.length > 0 ? h('div', { className: 'bt-q-list', role: 'group', 'aria-label': t('Your answer') }, chosen.map(({ label, at }, index) =>+ h('div', { key: `${label}-${index}`, className: 'bt-q-opt', title: t('Selected') },+ at >= 0 ? h('span', { className: 'bt-key', 'aria-hidden': true }, keyLetter(at)) : null,+ h('span', { className: 'bt-q-body' }, h('span', { className: 'bt-q-label' }, label))))) : null)}export function QuestionCard({ matched }) {diff --git a/ds-bot/src/client/styles.js b/ds-bot/src/client/styles.jsindex 8d079f24..12bf7266 100644--- a/ds-bot/src/client/styles.js+++ b/ds-bot/src/client/styles.js@@ -289,6 +289,10 @@ button.bt-q-opt:active{background:var(--bt-active)}.bt-q-check svg{width:16px;height:16px}.bt-q-settled .bt-key{opacity:.4}.bt-q-settled .bt-q-label{color:color-mix(in srgb,var(--bt-ink) 45%,transparent)}+.bt-q-answered .bt-q-title{color:var(--bt-ink-2)}+.bt-q-answered .bt-key{opacity:1;background:var(--bt-accent);color:var(--bt-accent-ink)}+.bt-q-answered .bt-q-label{color:var(--bt-ink)}+.bt-q-answered .bt-q-opt+.bt-q-opt::before{display:none}.bt-q-dismissed .bt-q-title{color:var(--bt-ink-2)}.bt-q.bt-q-settled{gap:6px;padding:12px 16px}.bt-q-settled .bt-q-title{font-size:14px;line-height:20px;font-weight:500}diff --git a/ds-bot/src/client/widget-cell.js b/ds-bot/src/client/widget-cell.jsindex d089bbf3..82d83a9c 100644--- a/ds-bot/src/client/widget-cell.js+++ b/ds-bot/src/client/widget-cell.js@@ -2,7 +2,7 @@ import { createElement as h, useRef, useState } from 'react'import { MarkdownText } from './dsh-primitives.js'import { CellEmpty } from './cell-empty.js'import { t } from './i18n.js'-import { AnsweredCell, closedLabel } from './questions.js'+import { AnsweredCell, SettledQuestion } from './questions.js'import { useDockHold } from './card-hold.js'import { SettledHandoff } from './handoff-card.js'import { SettledComputerHandoff } from './computer.js'@@ -66,16 +66,15 @@ export function WidgetCell({ sessionId, callId, args, done, isError, roster, actif (shown.interactive || args?.value?.('await_reply') === true) {const closed = callId === undefined ? undefined : roster.closedCards?.[sessionId]?.[callId]if (closed === undefined) return h(CellEmpty, { className: 'bt-q-gone' })- return h(ClosedView, { title: shown.title, view: shown.view, closed })+ return h(ClosedView, { title: shown.title, closed })}return h('div', { className: 'bt-q-inline' }, h(Card, { title: shown.title, view: shown.view }))}-// A view closed without an answer on it: settled with nothing chosen, and a badge-// beside its title for how it closed.-export function ClosedView({ title, view, closed }) {- const head = h('span', { className: 'bt-view-closed' }, h('span', { className: 'bt-view-closed-title' }, title ?? ''), h('span', { className: 'bt-q-badge' }, closedLabel(closed)))- return h('div', { className: 'bt-q-inline' }, h(Card, { title: head, view, settled: true }))+// A view closed without an answer on it: compact like a closed question card, its+// title (or "View") and a badge for how it closed.+export function ClosedView({ title, closed }) {+ return h('div', { className: 'bt-q-inline' }, h(SettledQuestion, { question: { question: title || t('View') }, closed }))}// Views asked by a call the transcript does not draw wait above the composer,@@ -142,8 +141,16 @@ body{.bt-q-inline .dv-q{margin:0;max-width:min(550px,86%);order:0}body[data-bt-layout=flat] .bt-q-inline .dv-view{max-width:calc(var(--bt-flat-w,1) * 100%)}.bt-q-inline:has(>.dv-view-bare){margin:8px 0 12px}-.bt-view-closed{display:flex;align-items:flex-start;gap:8px}-.bt-view-closed-title{flex:1 1 0;min-width:0}+/* An answered options view keeps only the chosen rows, each under its card letter+ (a counter, since the core draws no letters on a settled card), like ds-bot's+ own answered question card. Unchosen rows stay in the flow, invisible and+ zero-height, so they still count their letters. */+.dv-q-settled .dv-q-list:has(.dv-q-check){counter-reset:bt-opt}+.dv-q-settled .dv-q-list:has(.dv-q-check)>.dv-q-opt{counter-increment:bt-opt;gap:16px;align-items:center}+.dv-q-settled .dv-q-list:has(.dv-q-check)>.dv-q-opt:not(:has(.dv-q-check)){visibility:hidden;height:0;min-height:0;padding-block:0;overflow:hidden}+.dv-q-settled .dv-q-list:has(.dv-q-check)>.dv-q-opt::before{content:counter(bt-opt,upper-alpha);position:static;inset:auto;opacity:1;flex:none;width:24px;height:24px;border-radius:8px;background:var(--bt-accent);color:var(--bt-accent-ink);font-size:12px;line-height:24px;font-weight:500;text-align:center}+.dv-q-settled .dv-q-list:has(.dv-q-check)>.dv-q-opt .dv-q-label{color:var(--bt-ink)}+.dv-q-settled .dv-q-list:has(.dv-q-check)>.dv-q-opt .dv-q-desc,.dv-q-settled .dv-q-list:has(.dv-q-check) .dv-q-check{display:none}/* A row of segmented options is only as wide as its labels; at phone widths afew longer ones would spill past the card. Let them wrap and let a label wrapinside its own button instead. */diff --git a/ds-bot/test/tool-cells.test.js b/ds-bot/test/tool-cells.test.jsindex 4f72a7e0..30557ce8 100644--- a/ds-bot/test/tool-cells.test.js+++ b/ds-bot/test/tool-cells.test.js@@ -898,9 +898,8 @@ test('a question or view card closed without an answer on it stays at its call,const dismissed = show(call('ask_user', 'q-dismissed', { args: asked }), { roster })assert.equal(find(dismissed, node => node.props?.className === 'bt-q-gone'), undefined)assert.equal(text(find(dismissed, node => node.props?.className === 'bt-q-badge')), 'Dismissed')- assert.deepEqual(findAll(dismissed, node => node.props?.className === 'bt-q-label').map(text), ['Short', 'Long'])- assert.match(text(dismissed), /Which draft\?.*Pick one.*One page/)- assert.equal(find(dismissed, node => node.props?.className === 'bt-q-check'), undefined)+ // Compact: the question and the badge, no options and nothing to press.+ assert.equal(text(dismissed), 'Which draft?Dismissed')assert.equal(find(dismissed, node => node.type === 'button'), undefined)const replied = show(call('ask_user', 'q-replied', { args: asked }), { roster })assert.equal(text(find(replied, node => node.props?.className === 'bt-q-badge')), 'Answered by message')@@ -908,18 +907,17 @@ test('a question or view card closed without an answer on it stays at its call,const answered = show(call('ask_user', 'q-answered', { args: asked }), { roster })assert.ok(find(answered, node => node.props?.className === 'bt-q-gone') !== undefined)const view = show(call('show_view', 'v-dismissed', { args: pick }), { roster })- assert.match(text(view), /Pick a lane.*Dismissed.*Ship now.*One more pass/)- assert.ok(find(view, node => typeof node.props?.className === 'string' && node.props.className.includes('dv-q-settled')) !== undefined)- assert.equal(find(view, node => node.type === 'button' && !node.props?.disabled), undefined)+ assert.equal(text(view), 'Pick a laneDismissed')+ assert.equal(find(view, node => node.type === 'button'), undefined)assert.ok(find(show(call('show_view', 'v-answered', { args: pick }), { roster }), node => node.props?.className === 'bt-q-gone') !== undefined)})-test('an answered question card keeps every option, with a check on the chosen one and the own answer below', () => {+test('an answered question card keeps only the chosen rows, each under its card letter, and the own answer after them', () => {const question = { id: 'q', question: 'Which draft?', options: [{ label: 'Short' }, { label: 'Long' }, { label: 'None' }] }const out = expand(SettledQuestion({ question, answer: { selected: ['Long'], custom: 'Both, really' } }))+ assert.match(out.props.className, /bt-q-answered/)const rows = findAll(out, node => node.props?.className === 'bt-q-opt')- assert.deepEqual(rows.map(row => text(find(row, node => node.props?.className === 'bt-q-label'))), ['Short', 'Long', 'None', 'Both, really'])- assert.deepEqual(rows.map(row => find(row, node => node.props?.className === 'bt-q-check') !== undefined), [false, true, false, true])+ assert.deepEqual(rows.map(row => [text(find(row, node => node.props?.className === 'bt-key')), text(find(row, node => node.props?.className === 'bt-q-label'))]), [['B', 'Long'], ['D', 'Both, really']])assert.equal(find(out, node => node.props?.className === 'bt-q-badge'), undefined)})