@kabmo-labs/kabmo 0.56.0 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +2 -2
- package/dist/client/static/js/{Body-jfy4bhk2.js → Body-k96gtstv.js} +1 -1
- package/dist/client/static/js/{CsvGrid-4c5t668z.js → CsvGrid-t84xmbk9.js} +1 -1
- package/dist/client/static/js/{DocxView-3x7whtvq.js → DocxView-4jda3szm.js} +1 -1
- package/dist/client/static/js/{DrawioView-tbkc5dfz.js → DrawioView-9qvvtnvt.js} +1 -1
- package/dist/client/static/js/{HtmlPreview-egxkayya.js → HtmlPreview-4pba1ys5.js} +1 -1
- package/dist/client/static/js/{ImageView-swhzvw2p.js → ImageView-0gf5xdsv.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-sangsrt5.js → LayoutWrapper-pwbq5syv.js} +1 -1
- package/dist/client/static/js/MergeDiffView-m4jkr786.js +1 -0
- package/dist/client/static/js/{Modal-1fj8kvme.js → Modal-yjszc3vy.js} +12 -12
- package/dist/client/static/js/{PdfView-0k2egsbz.js → PdfView-sny55sne.js} +1 -1
- package/dist/client/static/js/{SessionsView-t547rqeb.js → SessionsView-q3800n83.js} +1 -1
- package/dist/client/static/js/{SheetView-anb3gavm.js → SheetView-ezqak2b4.js} +1 -1
- package/dist/client/static/js/{SvgPreview-e2wrj2hj.js → SvgPreview-q1cvdf4s.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-0rs86b68.js → abnfDiagram-O67JEVCF-ftm2qwa3.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-0k3zzxz1.js → architectureDiagram-NJMV4G6O-j8kqfzmf.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-t1n1fx96.js → blockDiagram-BEXU5L5S-m3zpsp9h.js} +3 -3
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-93b7eds9.js → c4Diagram-YGBWAQC7-myshvbrx.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-bnf85z0f.js → classDiagram-v2-NBCMYWYE-s0cwmsj4.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-e290161f.js → cose-bilkent-JH36ORCC-t5t02sfr.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-s13ra9ag.js → cynefinDiagram-VND7K2PF-6yxd72sh.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-83wshh5e.js → dagre-6A5THRUB-vft5103m.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-ywh4wqna.js → diagram-22UHCM2B-yy2jfvxt.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-cb53z698.js → diagram-3UASUU5V-1xqhzq20.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-btf55c44.js → diagram-ATOU4E4O-f11cxgvm.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-p6tbbm1n.js → diagram-CDSNMT55-gqmkfcp7.js} +3 -3
- package/dist/client/static/js/{diagram-MLGK6HIB-6kzssf4y.js → diagram-MLGK6HIB-1fg7304a.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-4v0yncvv.js → diagram-MPIPVDR6-mem80369.js} +1 -1
- package/dist/client/static/js/{dockerfile-r422htmd.js → dockerfile-jarjwxp9.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-mw1gh30z.js → ebnfDiagram-ZINNZB2B-4rcbvfrj.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-1pe786ap.js → elk-276RUBZZ-ykd0stxz.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-x7rk70q6.js → erDiagram-OPXOYQCR-b2th9bk4.js} +1 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-f3bdtc1z.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-j3m5km4p.js → ganttDiagram-FUAMR5RP-64p5r7cx.js} +2 -2
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-fd1kebdy.js → gitGraphDiagram-X574FWY7-z3yc333r.js} +1 -1
- package/dist/client/static/js/{index-004x0a3p.js → index-1mm7kyjd.js} +1 -1
- package/dist/client/static/js/{index-4dzvjfkd.js → index-2gf593e3.js} +1 -1
- package/dist/client/static/js/{index-4jg10xtp.js → index-3w18s59k.js} +1 -1
- package/dist/client/static/js/{index-tcp5cp53.js → index-3x3nhs8n.js} +1 -1
- package/dist/client/static/js/{index-j1prebvy.js → index-5m0se6fk.js} +1 -1
- package/dist/client/static/js/{index-kbk0vmex.js → index-6m5n8b6w.js} +1 -1
- package/dist/client/static/js/{index-bnamrpm6.js → index-77wznmg5.js} +1 -1
- package/dist/client/static/js/{index-cbbwq25c.js → index-bwwgtesb.js} +1 -1
- package/dist/client/static/js/{index-zkef5q39.js → index-c2vc6znd.js} +1 -1
- package/dist/client/static/js/{index-4acka5fn.js → index-dxx49b9m.js} +1 -1
- package/dist/client/static/js/{index-bxhszdcz.js → index-ebnd5hnr.js} +1 -1
- package/dist/client/static/js/{index-g84dwmvr.js → index-ep353yxd.js} +1 -1
- package/dist/client/static/js/{index-s6nv35dv.js → index-ewtv8gg7.js} +1 -1
- package/dist/client/static/js/{index-jtyzeynv.js → index-g71wn1pr.js} +1 -1
- package/dist/client/static/js/{index-473wm10a.js → index-gr07t5c4.js} +1 -1
- package/dist/client/static/js/{index-drsy400d.js → index-h4qmywn5.js} +1 -1
- package/dist/client/static/js/{index-s4v3vcsn.js → index-hmjb96kb.js} +1 -1
- package/dist/client/static/js/{index-q4t5j3x7.js → index-jd2h5tvh.js} +1 -1
- package/dist/client/static/js/{index-0mhxw0a1.js → index-k57bandz.js} +1 -1
- package/dist/client/static/js/{index-dfha2z56.js → index-k6wms0kx.js} +1 -1
- package/dist/client/static/js/{index-7tsdw8wt.js → index-k9v6477a.js} +1 -1
- package/dist/client/static/js/{index-4fpyzg5e.js → index-kbaffwp1.js} +20 -20
- package/dist/client/static/js/{index-3k45gspr.js → index-mdmtxh1c.js} +1 -1
- package/dist/client/static/js/{index-hgsjynb0.js → index-mv83hpva.js} +1 -1
- package/dist/client/static/js/{index-qdabc51h.js → index-n71ffk62.js} +2 -2
- package/dist/client/static/js/{index-qrwjxqdh.js → index-nr5gwny1.js} +176 -176
- package/dist/client/static/js/{index-rm5b3kn8.js → index-q9gbwqbe.js} +3 -3
- package/dist/client/static/js/{index-4nyajpeg.js → index-rqpbva78.js} +1 -1
- package/dist/client/static/js/{index-q178zgxp.js → index-sw370sk7.js} +1 -1
- package/dist/client/static/js/{index-8e66p2a7.js → index-t415df0c.js} +1 -1
- package/dist/client/static/js/index-taz2nfym.css +1 -0
- package/dist/client/static/js/{index-22frp78d.js → index-w659dhe5.js} +1 -1
- package/dist/client/static/js/{index-29b1ysz6.js → index-wgcgshdh.js} +1 -1
- package/dist/client/static/js/{index-72v57e07.js → index-x6945djv.js} +1 -1
- package/dist/client/static/js/{index-satnfvaz.js → index-y5mf2w81.js} +1 -1
- package/dist/client/static/js/{index-jbaceghb.js → index-y69cbdvd.js} +1 -1
- package/dist/client/static/js/{index-3hrvhyym.js → index-y6qtx68e.js} +1 -1
- package/dist/client/static/js/{index-5fxm2tpg.js → index-yktwxghr.js} +1 -1
- package/dist/client/static/js/{index-8n4qwd64.js → index-zj65csnm.js} +2 -2
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-1m0br602.js → infoDiagram-VRGFBTTK-59xq3n1b.js} +2 -2
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-zryzhpq6.js → ishikawaDiagram-OU5B5YK6-v18q4qt7.js} +2 -2
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-6apqr7h4.js → journeyDiagram-ZHPQQLJL-etazj0p8.js} +2 -2
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-am385c1e.js → kanban-definition-PNTS6WVX-ph15e5p2.js} +1 -1
- package/dist/client/static/js/{mermaid.core-k937exrm.js → mermaid.core-7ygd161b.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-hx8qq866.js → mindmap-definition-NLK3R4M7-j5xsftrf.js} +1 -1
- package/dist/client/static/js/one-dark-pro-4s2rr12v.js +1 -0
- package/dist/client/static/js/one-light-3bkk59ww.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-1hasj2h7.js → pegDiagram-GJSIUBJH-09nvb70v.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-x5nwff8r.js → pieDiagram-5QR66LMP-6ymh1960.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-gmrcr5jb.js → quadrantDiagram-O4NWA36T-hk61avw2.js} +2 -2
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-rdznfhfb.js → railroadDiagram-XR7U4H2S-3jvqrfnb.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-v9wb3ppf.js → requirementDiagram-PLB6GJNP-zthfj48k.js} +1 -1
- package/dist/client/static/js/{rust-9cgnbbcs.js → rust-q7n7q6dy.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-3p4ddd2h.js → sankeyDiagram-IPEJSGJF-nh5d6xte.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-wfcqxjfq.js → sequenceDiagram-PO4LG4MO-crej9b40.js} +4 -4
- package/dist/client/static/js/{sizeCapture-INFHLROL-g02k0k8x.js → sizeCapture-INFHLROL-nvvxw58j.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-7k449yvg.js → stateDiagram-v2-GCMORJYK-e6tztjnj.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-zkf2bgm8.js → swimlanes-2SLR337P-xhdqjqmf.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-yex8g4fx.js → swimlanesDiagram-TC7HE7FX-hbwg3m3k.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-qsfpjr1c.js → timeline-definition-EJHVYXUP-9cve31zc.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-b2vprhsr.js → usecaseDiagram-POWQR4AR-asycstwe.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-x0ffeg2t.js → vennDiagram-UO4OBE2U-gbzk6era.js} +4 -4
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-hsnhaf4f.js → wardleyDiagram-VNRHLVJA-1swwfszr.js} +2 -2
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-90f9aadp.js → xychartDiagram-PMCCYNJV-v7qkwv0b.js} +3 -3
- package/package.json +3 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormAsk.tsx +25 -62
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormDialog.test.tsx +40 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FormDialog.tsx +41 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionList.tsx +117 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/SwipeDeck.tsx +220 -0
- package/src/client/data/settings/omp-schema.json +59 -7
- package/src/client/hooks/chat/timeline/ask-frames-form.test.ts +29 -0
- package/src/shared/lib/chat/ask-form/data.ts +25 -6
- package/src/shared/lib/chat/ask-form/deck.ts +80 -0
- package/src/shared/lib/chat/ask-form/fields.ts +26 -1
- package/src/shared/lib/chat/ask-form/index.ts +18 -310
- package/src/shared/lib/chat/ask-form/types.ts +14 -2
- package/src/shared/lib/chat/ask-form/walker.ts +350 -0
- package/src/shared/lib/chat/ask-form.test.ts +41 -0
- package/src/shared/lib/omp/config/schema-releases-19-4.test.ts +47 -0
- package/src/shared/lib/omp/config/schema-releases.test.ts +4 -2
- package/dist/client/static/js/MergeDiffView-bv00y63x.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-kfwaac44.js +0 -1
- package/dist/client/static/js/index-gedsa0z7.css +0 -1
- package/dist/client/static/js/one-dark-pro-phxqe9mx.js +0 -1
- package/dist/client/static/js/one-light-vhwh499y.js +0 -1
package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionList.tsx
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The question list of the grouped `ask` form (`FormAsk`): every question at
|
|
8
|
+
* once, with swipe decks (`<booldeck>` cards) drawn as one deck per run.
|
|
9
|
+
*
|
|
10
|
+
* Split out of `FormAsk` at the 350-line ceiling: the submit state machine
|
|
11
|
+
* owns the rest of that file. The deck run detection lives here because a run
|
|
12
|
+
* needs every card of the run: only the run's first card renders the
|
|
13
|
+
* `SwipeDeck`, the rest are its stack.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { AnswerList, QuestionCard } from '@/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionCard';
|
|
17
|
+
import { OptionRow } from '@/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OptionRow';
|
|
18
|
+
import { SwipeDeck } from '@/client/components/workspace/chat-timeline/tool-renderers/ask-panel/SwipeDeck';
|
|
19
|
+
import { partsFor, type Pick } from '@/client/components/workspace/chat-timeline/tool-renderers/ask-panel/form-picks';
|
|
20
|
+
import { isOtherOption } from '@/shared/lib/chat/ask-questions';
|
|
21
|
+
import type { AskAnswer, AskQuestion } from '@/shared/lib/chat/ask-form/types';
|
|
22
|
+
|
|
23
|
+
interface QuestionListProps {
|
|
24
|
+
questions: AskQuestion[];
|
|
25
|
+
picks: Record<number, Pick>;
|
|
26
|
+
recorded: (AskAnswer | null)[];
|
|
27
|
+
/** Whether the machine is sending — controls render inert only then. */
|
|
28
|
+
sending: boolean;
|
|
29
|
+
/** The live frame's answer for one question, or null while unanswered. */
|
|
30
|
+
answerFor: (index: number) => AskAnswer | null;
|
|
31
|
+
onToggle: (index: number, label: string, multi: boolean) => void;
|
|
32
|
+
onText: (index: number, text: string) => void;
|
|
33
|
+
onUndo: () => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function QuestionList({ questions, picks, recorded, sending, answerFor, onToggle, onText, onUndo }: QuestionListProps) {
|
|
37
|
+
return (
|
|
38
|
+
<>
|
|
39
|
+
{questions.map((question, index) => {
|
|
40
|
+
if (question.kind === 'card') {
|
|
41
|
+
const prev = questions[index - 1];
|
|
42
|
+
if (prev && prev.kind === 'card') return null;
|
|
43
|
+
const cards: AskQuestion[] = [];
|
|
44
|
+
for (let at = index; at < questions.length && questions[at].kind === 'card'; at += 1) cards.push(questions[at]);
|
|
45
|
+
return (
|
|
46
|
+
<SwipeDeck
|
|
47
|
+
key={question.id ?? index}
|
|
48
|
+
cards={cards}
|
|
49
|
+
picks={picks}
|
|
50
|
+
offset={index}
|
|
51
|
+
onVerdict={(verdictIndex, label) => onToggle(verdictIndex, label, false)}
|
|
52
|
+
disabled={sending}
|
|
53
|
+
onUndo={onUndo}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
const answer = answerFor(index);
|
|
58
|
+
const pick = picks[index] ?? { selected: [], text: '' };
|
|
59
|
+
return (
|
|
60
|
+
<QuestionCard
|
|
61
|
+
key={question.id ?? index}
|
|
62
|
+
index={index}
|
|
63
|
+
total={questions.length}
|
|
64
|
+
header={question.header}
|
|
65
|
+
question={question.question}
|
|
66
|
+
multi={question.multi === true}
|
|
67
|
+
answered={answer !== null}
|
|
68
|
+
>
|
|
69
|
+
{answer !== null ? (
|
|
70
|
+
<AnswerList parts={partsFor(question, pick, recorded[index] ?? null)} />
|
|
71
|
+
) : (
|
|
72
|
+
<>
|
|
73
|
+
{question.kind === 'text' ? (
|
|
74
|
+
<textarea
|
|
75
|
+
rows={3}
|
|
76
|
+
value={pick.text}
|
|
77
|
+
disabled={sending}
|
|
78
|
+
placeholder="Type your answer…"
|
|
79
|
+
aria-label={`Your answer for question ${index + 1}`}
|
|
80
|
+
onInput={(event) => onText(index, event.currentTarget.value)}
|
|
81
|
+
className="mt-2 w-full rounded-md border border-ink/15 bg-canvas/40 px-2 py-1 font-mono text-[11.5px] text-ink outline-none focus:border-ink disabled:opacity-50"
|
|
82
|
+
/>
|
|
83
|
+
) : (
|
|
84
|
+
<>
|
|
85
|
+
<div className="mt-2 space-y-1" role={question.multi === true ? 'group' : 'radiogroup'}>
|
|
86
|
+
{question.options.filter((option) => !isOtherOption(option.label)).map((option, optionIndex) => (
|
|
87
|
+
<OptionRow
|
|
88
|
+
key={option.label}
|
|
89
|
+
label={option.label}
|
|
90
|
+
description={option.description}
|
|
91
|
+
multi={question.multi === true}
|
|
92
|
+
checked={pick.selected.includes(option.label)}
|
|
93
|
+
suggested={question.recommended === optionIndex}
|
|
94
|
+
disabled={sending}
|
|
95
|
+
onClick={() => onToggle(index, option.label, question.multi === true)}
|
|
96
|
+
/>
|
|
97
|
+
))}
|
|
98
|
+
</div>
|
|
99
|
+
<input
|
|
100
|
+
type="text"
|
|
101
|
+
value={pick.text}
|
|
102
|
+
disabled={sending}
|
|
103
|
+
placeholder="Or type your own…"
|
|
104
|
+
aria-label={`Your own answer for question ${index + 1}`}
|
|
105
|
+
onInput={(event) => onText(index, event.currentTarget.value)}
|
|
106
|
+
className="mt-2 w-full rounded-md border border-ink/15 bg-canvas/40 px-2 py-1 text-[11.5px] text-ink outline-none focus:border-ink disabled:opacity-50"
|
|
107
|
+
/>
|
|
108
|
+
</>
|
|
109
|
+
)}
|
|
110
|
+
</>
|
|
111
|
+
)}
|
|
112
|
+
</QuestionCard>
|
|
113
|
+
);
|
|
114
|
+
})}
|
|
115
|
+
</>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The `<booldeck>` swipe deck (omp 19.4.0), drawn in the timeline instead of a
|
|
8
|
+
* modal — the same surface every other `ask` question uses.
|
|
9
|
+
*
|
|
10
|
+
* omp's terminal deck shows one card from a stack: swipe right for yes, left
|
|
11
|
+
* for no, up to skip, with a pip per card and a tally (`7 Keep · 2 Drop · 1
|
|
12
|
+
* skipped`) once every card is decided. A card it cannot animate is the same
|
|
13
|
+
* deck without flight: the top card first with its three verdict buttons
|
|
14
|
+
* (`♥` yes, `✕` no, `↑` skip) and `↺` undo, a pip per card, the next card
|
|
15
|
+
* waiting under it, and the tally when the deck is done. Verdicts ride as the
|
|
16
|
+
* question's `options` (values `yes`/`no`/`skip`), so the one-Submit form
|
|
17
|
+
* builder carries them without a second convention.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { useEffect, useRef } from 'preact/hooks';
|
|
21
|
+
import { CheckCircle2 } from 'lucide-preact';
|
|
22
|
+
import type { AskQuestion } from '@/shared/lib/chat/ask-form/types';
|
|
23
|
+
import type { FormPick } from '@/shared/lib/chat/ask-form/data';
|
|
24
|
+
|
|
25
|
+
/** One card verdict, in omp's order: yes, no, skip. */
|
|
26
|
+
export type Verdict = 'yes' | 'no' | 'skip';
|
|
27
|
+
|
|
28
|
+
/** The verdict a picked row carries, by its fixed value (never its label). */
|
|
29
|
+
export function verdictOf(question: AskQuestion, picked: readonly string[]): Verdict | undefined {
|
|
30
|
+
const option = question.options.find(
|
|
31
|
+
(candidate) => candidate.value === picked[0] || candidate.label === picked[0],
|
|
32
|
+
);
|
|
33
|
+
const value = option?.value ?? picked[0];
|
|
34
|
+
return value === 'yes' || value === 'no' || value === 'skip' ? value : undefined;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** omp's label for a verdict: the side's own label, `Skip` for a skip. */
|
|
38
|
+
export function verdictLabel(question: AskQuestion, verdict: Verdict): string {
|
|
39
|
+
if (verdict === 'skip') return 'Skip';
|
|
40
|
+
return question.options.find((candidate) => candidate.value === verdict)?.label ?? (verdict === 'yes' ? 'Yes' : 'No');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** omp's tally: `7 Keep · 2 Drop · 1 skipped`, skipping zero verdicts. */
|
|
44
|
+
export function tallyOf(cards: readonly AskQuestion[], picks: Record<number, FormPick>, offset: number): string | undefined {
|
|
45
|
+
const counts: Record<Verdict, number> = { yes: 0, no: 0, skip: 0 };
|
|
46
|
+
for (const [index, card] of cards.entries()) {
|
|
47
|
+
const verdict = verdictOf(card, picks[offset + index]?.selected ?? []);
|
|
48
|
+
if (verdict) counts[verdict] += 1;
|
|
49
|
+
}
|
|
50
|
+
const parts: string[] = [];
|
|
51
|
+
for (const verdict of ['yes', 'no', 'skip'] as const satisfies readonly Verdict[]) {
|
|
52
|
+
if (counts[verdict] === 0) continue;
|
|
53
|
+
const labels = [...new Set(cards.map((card) => verdictLabel(card, verdict)))];
|
|
54
|
+
const label = labels.length === 1 ? labels[0] : verdict === 'yes' ? 'Yes' : 'No';
|
|
55
|
+
parts.push(`${counts[verdict]} ${verdict === 'skip' ? 'skipped' : label}`);
|
|
56
|
+
}
|
|
57
|
+
return parts.length ? parts.join(' · ') : undefined;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface SwipeDeckProps {
|
|
61
|
+
/** Every card question of the deck, in form order. */
|
|
62
|
+
cards: AskQuestion[];
|
|
63
|
+
/** Picks by question index (the timeline answers read these). */
|
|
64
|
+
picks: Record<number, FormPick>;
|
|
65
|
+
/** Offset of the deck's first card in the form's question list. */
|
|
66
|
+
offset: number;
|
|
67
|
+
/** Choose a verdict for one card. */
|
|
68
|
+
onVerdict: (index: number, label: string) => void;
|
|
69
|
+
/** Disable every control once the answers are on the wire. */
|
|
70
|
+
disabled?: boolean;
|
|
71
|
+
/** Drop the last verdict (omp's `↺`). */
|
|
72
|
+
onUndo?: () => void;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The deck: the first undecided card on top with its three verdicts, a pip per
|
|
77
|
+
* card, the cards under it, and the tally when every card is decided.
|
|
78
|
+
*/
|
|
79
|
+
export function SwipeDeck({ cards, picks, offset, onVerdict, disabled, onUndo }: SwipeDeckProps) {
|
|
80
|
+
const focusRef = useRef<HTMLDivElement>(null);
|
|
81
|
+
|
|
82
|
+
// The deck owns the keyboard while it is on screen: arrows decide the top
|
|
83
|
+
// card, Enter submits once every card is decided. Mirrors the terminal
|
|
84
|
+
// deck's key map without overriding the app's shortcuts.
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (disabled || !focusRef.current) return;
|
|
87
|
+
const node = focusRef.current;
|
|
88
|
+
const onKey = (event: KeyboardEvent) => {
|
|
89
|
+
const verdicts = cards.map((card, index) => verdictOf(card, picks[offset + index]?.selected ?? []));
|
|
90
|
+
const top = verdicts.findIndex((verdict) => verdict === undefined);
|
|
91
|
+
const verdictByKey: Record<string, Verdict> = {
|
|
92
|
+
ArrowRight: 'yes',
|
|
93
|
+
ArrowLeft: 'no',
|
|
94
|
+
ArrowUp: 'skip',
|
|
95
|
+
};
|
|
96
|
+
const verdict = verdictByKey[event.key];
|
|
97
|
+
if (verdict && top >= 0) {
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
onVerdict(offset + top, verdictLabel(cards[top], verdict));
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (event.key === 'Backspace' && onUndo) {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
onUndo();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
node.addEventListener('keydown', onKey);
|
|
108
|
+
return () => node.removeEventListener('keydown', onKey);
|
|
109
|
+
}, [cards, picks, offset, onVerdict, disabled, onUndo]);
|
|
110
|
+
|
|
111
|
+
const verdicts = cards.map((card, index) => verdictOf(card, picks[offset + index]?.selected ?? []));
|
|
112
|
+
const top = verdicts.findIndex((verdict) => verdict === undefined);
|
|
113
|
+
const done = top === -1;
|
|
114
|
+
const visible = cards
|
|
115
|
+
.map((card, index) => ({ card, index, verdict: verdicts[index] }))
|
|
116
|
+
.filter(({ index }) => done || index >= top - 1)
|
|
117
|
+
.slice(0, 3);
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<div ref={focusRef} tabIndex={disabled ? undefined : 0} className="space-y-1.5 outline-none" aria-label="Swipe deck">
|
|
121
|
+
<div className="flex items-center gap-1" aria-hidden="true">
|
|
122
|
+
{cards.map((card, index) => {
|
|
123
|
+
const verdict = verdicts[index];
|
|
124
|
+
const tone =
|
|
125
|
+
verdict === 'yes'
|
|
126
|
+
? 'text-success'
|
|
127
|
+
: verdict === 'no'
|
|
128
|
+
? 'text-error'
|
|
129
|
+
: verdict === 'skip'
|
|
130
|
+
? 'text-ink/40'
|
|
131
|
+
: index === top
|
|
132
|
+
? 'text-accent'
|
|
133
|
+
: 'text-ink/25';
|
|
134
|
+
return (
|
|
135
|
+
<span key={card.id ?? index} className={`text-[10px] ${tone}`}>
|
|
136
|
+
{verdict ? '●' : index === top ? '◉' : '○'}
|
|
137
|
+
</span>
|
|
138
|
+
);
|
|
139
|
+
})}
|
|
140
|
+
<span className="ml-auto font-mono text-[10px] text-ink/40">
|
|
141
|
+
{done ? `${cards.length} of ${cards.length}` : `${top + 1} of ${cards.length}`}
|
|
142
|
+
</span>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
{visible.map(({ card, index, verdict }) => (
|
|
146
|
+
<div
|
|
147
|
+
key={card.id ?? index}
|
|
148
|
+
className={`rounded-lg border bg-paper p-2.5 ${index === top ? 'border-ink/25 shadow-xs' : 'border-ink/10 opacity-70'}`}
|
|
149
|
+
>
|
|
150
|
+
<div className="text-[12.5px] leading-relaxed text-ink/90 select-text">{card.question}</div>
|
|
151
|
+
<div className="mt-1.5 flex items-center gap-1.5">
|
|
152
|
+
{(['yes', 'no', 'skip'] as const satisfies readonly Verdict[]).map((candidate) => {
|
|
153
|
+
const label = verdictLabel(card, candidate);
|
|
154
|
+
const active = verdict === candidate;
|
|
155
|
+
const tone =
|
|
156
|
+
candidate === 'yes'
|
|
157
|
+
? active
|
|
158
|
+
? 'border-success/40 bg-success/10 text-success'
|
|
159
|
+
: 'border-ink/15 text-ink/70 hover:border-success/40 hover:text-success'
|
|
160
|
+
: candidate === 'no'
|
|
161
|
+
? active
|
|
162
|
+
? 'border-error/40 bg-error/10 text-error'
|
|
163
|
+
: 'border-ink/15 text-ink/70 hover:border-error/40 hover:text-error'
|
|
164
|
+
: active
|
|
165
|
+
? 'border-ink/30 bg-ink/5 text-ink'
|
|
166
|
+
: 'border-ink/15 text-ink/70 hover:border-ink/40 hover:text-ink';
|
|
167
|
+
const glyph = candidate === 'yes' ? '♥' : candidate === 'no' ? '✕' : '↑';
|
|
168
|
+
return (
|
|
169
|
+
<button
|
|
170
|
+
key={candidate}
|
|
171
|
+
type="button"
|
|
172
|
+
disabled={disabled}
|
|
173
|
+
onClick={() => onVerdict(offset + index, label)}
|
|
174
|
+
aria-label={`${label} — ${card.question}`}
|
|
175
|
+
aria-pressed={active}
|
|
176
|
+
className={`flex min-h-8 flex-1 cursor-pointer items-center justify-center gap-1 rounded-md border px-2 text-[11.5px] font-medium transition-colors disabled:cursor-default disabled:opacity-40 ${tone}`}
|
|
177
|
+
>
|
|
178
|
+
<span aria-hidden="true">{glyph}</span>
|
|
179
|
+
{label}
|
|
180
|
+
</button>
|
|
181
|
+
);
|
|
182
|
+
})}
|
|
183
|
+
{verdict && (
|
|
184
|
+
<span className="flex shrink-0 items-center gap-1 text-[10.5px] font-medium text-ink/60">
|
|
185
|
+
<CheckCircle2 size={11} className="text-success" />
|
|
186
|
+
{verdictLabel(card, verdict)}
|
|
187
|
+
</span>
|
|
188
|
+
)}
|
|
189
|
+
{onUndo && verdict !== undefined && index === verdicts.length - 1 && (
|
|
190
|
+
<button
|
|
191
|
+
type="button"
|
|
192
|
+
disabled={disabled}
|
|
193
|
+
onClick={onUndo}
|
|
194
|
+
aria-label="Undo the last verdict"
|
|
195
|
+
title="Undo (Backspace)"
|
|
196
|
+
className="shrink-0 cursor-pointer rounded-md border border-ink/15 px-2 py-1 text-[11.5px] text-ink/70 transition-colors hover:border-ink/40 hover:text-ink disabled:cursor-default disabled:opacity-40"
|
|
197
|
+
>
|
|
198
|
+
↺
|
|
199
|
+
</button>
|
|
200
|
+
)}
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
))}
|
|
204
|
+
|
|
205
|
+
{onUndo && verdicts.some((verdict) => verdict !== undefined) && !done && (
|
|
206
|
+
<div className="text-[10.5px] text-ink/45">
|
|
207
|
+
<span className="font-mono">←</span> no · <span className="font-mono">→</span> yes ·{' '}
|
|
208
|
+
<span className="font-mono">↑</span> skip · <span className="font-mono">⌫</span> undo
|
|
209
|
+
</div>
|
|
210
|
+
)}
|
|
211
|
+
|
|
212
|
+
{done && (
|
|
213
|
+
<div className="rounded-lg border border-ink/10 bg-paper p-2.5 text-center">
|
|
214
|
+
<div className="text-[12.5px] font-medium text-ink/90">That’s every card</div>
|
|
215
|
+
<div className="mt-1 text-[11.5px] text-ink/70">{tallyOf(cards, picks, offset)}</div>
|
|
216
|
+
</div>
|
|
217
|
+
)}
|
|
218
|
+
</div>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"source": "@oh-my-pi/pi-coding-agent 10 tabs /
|
|
2
|
+
"source": "@oh-my-pi/pi-coding-agent 10 tabs / 662 settings",
|
|
3
3
|
"tabs": [
|
|
4
4
|
{
|
|
5
5
|
"id": "appearance",
|
|
@@ -280,6 +280,16 @@
|
|
|
280
280
|
"description": "Show a live generation tok/s readout: on the working row next to the session title, or in the native composer bar right after the thinking level, where the last reading stays between turns. Estimated from streamed deltas and corrected by the provider's billed output count as each message completes."
|
|
281
281
|
}
|
|
282
282
|
},
|
|
283
|
+
"composer.providerIcon": {
|
|
284
|
+
"type": "boolean",
|
|
285
|
+
"default": false,
|
|
286
|
+
"ui": {
|
|
287
|
+
"tab": "appearance",
|
|
288
|
+
"group": "Composer",
|
|
289
|
+
"label": "Provider Icon",
|
|
290
|
+
"description": "In the native composer bar, lead the model name with the provider's icon: the one set in the /model hub (`providerIcons` in models.yml), else Tern's logo for it."
|
|
291
|
+
}
|
|
292
|
+
},
|
|
283
293
|
"statusLine.preset": {
|
|
284
294
|
"type": "enum",
|
|
285
295
|
"default": "default",
|
|
@@ -659,6 +669,16 @@
|
|
|
659
669
|
"description": "Render Mermaid fenced code blocks as ASCII diagrams"
|
|
660
670
|
}
|
|
661
671
|
},
|
|
672
|
+
"tui.codeFrame": {
|
|
673
|
+
"type": "boolean",
|
|
674
|
+
"default": false,
|
|
675
|
+
"ui": {
|
|
676
|
+
"tab": "appearance",
|
|
677
|
+
"group": "Display",
|
|
678
|
+
"label": "Frame Code Blocks",
|
|
679
|
+
"description": "Draw code blocks between a dashed hairline carrying the language and a bare one, instead of literal ``` rows (indented blocks included). Selecting the code rows copies the same text; selecting the whole block copies the hairlines, not ``` fences. Plain terminal only; the native view ignores it."
|
|
680
|
+
}
|
|
681
|
+
},
|
|
662
682
|
"tui.renderSvg": {
|
|
663
683
|
"type": "boolean",
|
|
664
684
|
"default": true,
|
|
@@ -7084,6 +7104,38 @@
|
|
|
7084
7104
|
]
|
|
7085
7105
|
}
|
|
7086
7106
|
},
|
|
7107
|
+
"act.enabled": {
|
|
7108
|
+
"type": "enum",
|
|
7109
|
+
"default": "auto",
|
|
7110
|
+
"values": [
|
|
7111
|
+
"auto",
|
|
7112
|
+
"on",
|
|
7113
|
+
"off"
|
|
7114
|
+
],
|
|
7115
|
+
"ui": {
|
|
7116
|
+
"tab": "tools",
|
|
7117
|
+
"group": "Available Tools",
|
|
7118
|
+
"label": "Act (judge-picked clicks)",
|
|
7119
|
+
"description": "Enable tab.act/tab.expect in browser use and win.act/win.expect in computer use: the judge model role picks the element an intent names, or checks the screen. Auto enables them when the first usable judge is native",
|
|
7120
|
+
"options": [
|
|
7121
|
+
{
|
|
7122
|
+
"value": "auto",
|
|
7123
|
+
"label": "Auto",
|
|
7124
|
+
"description": "Enable when the first usable judge is native"
|
|
7125
|
+
},
|
|
7126
|
+
{
|
|
7127
|
+
"value": "on",
|
|
7128
|
+
"label": "On",
|
|
7129
|
+
"description": "Always enable, whichever model the judge role resolves to"
|
|
7130
|
+
},
|
|
7131
|
+
{
|
|
7132
|
+
"value": "off",
|
|
7133
|
+
"label": "Off",
|
|
7134
|
+
"description": "Disable the act helpers"
|
|
7135
|
+
}
|
|
7136
|
+
]
|
|
7137
|
+
}
|
|
7138
|
+
},
|
|
7087
7139
|
"find.timeoutMs": {
|
|
7088
7140
|
"type": "number",
|
|
7089
7141
|
"default": 20000,
|
|
@@ -7379,7 +7431,7 @@
|
|
|
7379
7431
|
"tab": "tools",
|
|
7380
7432
|
"group": "GitHub",
|
|
7381
7433
|
"label": "GitHub View Cache",
|
|
7382
|
-
"description": "Cache
|
|
7434
|
+
"description": "Cache forge overviews and diffs in ~/.omp/cache/github-cache.db"
|
|
7383
7435
|
}
|
|
7384
7436
|
},
|
|
7385
7437
|
"github.cache.softTtlSec": {
|
|
@@ -7389,7 +7441,7 @@
|
|
|
7389
7441
|
"tab": "tools",
|
|
7390
7442
|
"group": "GitHub",
|
|
7391
7443
|
"label": "GitHub Cache Soft TTL",
|
|
7392
|
-
"description": "
|
|
7444
|
+
"description": "Revalidate cached forge overviews after this many seconds; diffs check revisions on every live read"
|
|
7393
7445
|
}
|
|
7394
7446
|
},
|
|
7395
7447
|
"github.cache.hardTtlSec": {
|
|
@@ -7399,7 +7451,7 @@
|
|
|
7399
7451
|
"tab": "tools",
|
|
7400
7452
|
"group": "GitHub",
|
|
7401
7453
|
"label": "GitHub Cache Hard TTL",
|
|
7402
|
-
"description": "
|
|
7454
|
+
"description": "Maximum age of cached forge rows and retained diff snapshots (seconds; default 7 days)"
|
|
7403
7455
|
}
|
|
7404
7456
|
},
|
|
7405
7457
|
"web_search.enabled": {
|
|
@@ -7796,7 +7848,7 @@
|
|
|
7796
7848
|
"tab": "shell",
|
|
7797
7849
|
"group": "Bash",
|
|
7798
7850
|
"label": "Reap Background Processes",
|
|
7799
|
-
"description": "Remind the agent about processes its bash calls left running (`cmd &`, `nohup`) when it stops, and kill the `&` ones at session end unless registered as services; off in RPC
|
|
7851
|
+
"description": "Remind the agent about processes its bash calls left running (`cmd &`, `nohup`) when it stops, and kill the `&` ones at session end unless registered as services; off in non-interactive runs (print, RPC, ACP)"
|
|
7800
7852
|
}
|
|
7801
7853
|
},
|
|
7802
7854
|
"bash.gitGuard": {
|
|
@@ -8476,7 +8528,7 @@
|
|
|
8476
8528
|
},
|
|
8477
8529
|
"task.maxRecursionDepth": {
|
|
8478
8530
|
"type": "number",
|
|
8479
|
-
"default":
|
|
8531
|
+
"default": 1,
|
|
8480
8532
|
"ui": {
|
|
8481
8533
|
"tab": "tasks",
|
|
8482
8534
|
"group": "Subagents",
|
|
@@ -9046,7 +9098,7 @@
|
|
|
9046
9098
|
"tab": "tools",
|
|
9047
9099
|
"group": "Grep & Browser",
|
|
9048
9100
|
"label": "Freeze Browser Tabs On Turn End",
|
|
9049
|
-
"description": "Freeze OMP-owned headless Chromium tabs when a turn settles so animated pages stop burning CPU/GPU while idle
|
|
9101
|
+
"description": "Freeze OMP-owned headless Chromium tabs when a turn settles so animated pages stop burning CPU/GPU while idle. WebKit tabs are not frozen: their pages keep animating until closed or reaped by browser.idleCloseSec. Tabs unfreeze automatically on next use; pass persist:true on open to opt a tab out."
|
|
9050
9102
|
}
|
|
9051
9103
|
},
|
|
9052
9104
|
"browser.idleCloseSec": {
|
|
@@ -169,6 +169,35 @@ describe('buildFormData', () => {
|
|
|
169
169
|
});
|
|
170
170
|
});
|
|
171
171
|
|
|
172
|
+
describe('buildFormData for swipe cards', () => {
|
|
173
|
+
const questions = parseAskForm(
|
|
174
|
+
'<form><booldeck><card name="a">First?</card><card name="b">Second?</card></booldeck></form>',
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
test('yes submits true, no submits false, skip is omitted', () => {
|
|
178
|
+
// omp's `parseFormDialogResponse` rejects a card value that is not a
|
|
179
|
+
// boolean and reads an absent entry as skipped.
|
|
180
|
+
const built = buildFormData(questions, {
|
|
181
|
+
0: { selected: ['Yes'], text: '' },
|
|
182
|
+
1: { selected: ['No'], text: '' },
|
|
183
|
+
});
|
|
184
|
+
expect(built).toEqual({ data: { a: true, b: false } });
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test('a skipped card alone submits nothing', () => {
|
|
188
|
+
const built = buildFormData(questions, { 0: { selected: ['Skip'], text: '' } });
|
|
189
|
+
expect(built).toEqual({ missing: 'Answer at least one question.' });
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test('a relabelled side still submits by its verdict value', () => {
|
|
193
|
+
const relabelled = parseAskForm(
|
|
194
|
+
'<form><booldeck yes="Fix" no="Ignore"><card name="x">Leak?</card></booldeck></form>',
|
|
195
|
+
);
|
|
196
|
+
const built = buildFormData(relabelled, { 0: { selected: ['Fix'], text: '' } });
|
|
197
|
+
expect(built).toEqual({ data: { x: true } });
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
|
|
172
201
|
describe('AskQuestion required flag', () => {
|
|
173
202
|
test('is absent on a form whose controls are all optional', () => {
|
|
174
203
|
const questions: AskQuestion[] = parseAskForm('<form><label>Note <input name="note"></label></form>');
|
|
@@ -45,8 +45,12 @@ export interface FormPick {
|
|
|
45
45
|
export interface FormAnswer {
|
|
46
46
|
/** The control name (`AskQuestion.id`). */
|
|
47
47
|
name: string;
|
|
48
|
-
/**
|
|
49
|
-
|
|
48
|
+
/**
|
|
49
|
+
* `string` for a single choice or text field, `string[]` for a group,
|
|
50
|
+
* `boolean` for a swipe card (`<booldeck>`, omp 19.4.0): yes is `true`,
|
|
51
|
+
* no is `false`, skip is absent (`undefined`) so `buildFormData` omits it.
|
|
52
|
+
*/
|
|
53
|
+
value: string | string[] | boolean | undefined;
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
/** Whether a question takes an array (checkbox group or multi-select). */
|
|
@@ -71,12 +75,22 @@ function optionFor(question: AskQuestion, label: string): { value: string; disab
|
|
|
71
75
|
* compares against those, never the visible label — and a disabled option is
|
|
72
76
|
* dropped rather than sent (omp refuses the whole frame for it).
|
|
73
77
|
*/
|
|
74
|
-
export function answerForQuestion(question: AskQuestion, pick: FormPick | undefined): string | string[] | undefined {
|
|
78
|
+
export function answerForQuestion(question: AskQuestion, pick: FormPick | undefined): string | string[] | boolean | undefined {
|
|
75
79
|
const selected = pick?.selected ?? [];
|
|
76
80
|
const text = pick?.text.trim() ?? '';
|
|
77
81
|
|
|
78
82
|
if (question.kind === 'text') return text ? text : undefined;
|
|
79
83
|
|
|
84
|
+
if (question.kind === 'card') {
|
|
85
|
+
// A swipe card's verdict rides as the picked option's VALUE (the fixed
|
|
86
|
+
// words `yes`/`no`/`skip`, never the labels — the user may have
|
|
87
|
+
// relabelled them). Skip means unanswered: omp omits it.
|
|
88
|
+
const verdict = selected[0] ? optionFor(question, selected[0])?.value : undefined;
|
|
89
|
+
if (verdict === 'yes') return true;
|
|
90
|
+
if (verdict === 'no') return false;
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
80
94
|
const values: string[] = [];
|
|
81
95
|
for (const label of selected) {
|
|
82
96
|
const option = optionFor(question, label);
|
|
@@ -103,8 +117,11 @@ export function answerForQuestion(question: AskQuestion, pick: FormPick | undefi
|
|
|
103
117
|
* user leaves partly empty still submits what it holds.
|
|
104
118
|
*/
|
|
105
119
|
export function formAnswers(questions: AskQuestion[], picks: Record<number, FormPick>): FormAnswer[] {
|
|
120
|
+
// A skipped swipe card is unanswered and must be omitted — omp reads an
|
|
121
|
+
// absent entry as "skipped" — never sent as "" or [].
|
|
106
122
|
return questions.map((question, index) => {
|
|
107
123
|
const value = answerForQuestion(question, picks[index]);
|
|
124
|
+
if (question.kind === 'card' && value === undefined) return { name: question.id ?? '', value: undefined };
|
|
108
125
|
return {
|
|
109
126
|
name: question.id ?? '',
|
|
110
127
|
value: value ?? (isArrayQuestion(question) ? [] : ''),
|
|
@@ -112,6 +129,7 @@ export function formAnswers(questions: AskQuestion[], picks: Record<number, Form
|
|
|
112
129
|
});
|
|
113
130
|
}
|
|
114
131
|
|
|
132
|
+
|
|
115
133
|
/** The `data` object to send, or the reason it cannot be sent.
|
|
116
134
|
*
|
|
117
135
|
* At least one entry is mandatory: omp throws on an empty object ("at least
|
|
@@ -121,12 +139,13 @@ export function formAnswers(questions: AskQuestion[], picks: Record<number, Form
|
|
|
121
139
|
export function buildFormData(
|
|
122
140
|
questions: AskQuestion[],
|
|
123
141
|
picks: Record<number, FormPick>,
|
|
124
|
-
): { data: Record<string, string | string[]> } | { missing: string } {
|
|
125
|
-
const data: Record<string, string | string[]> = {};
|
|
142
|
+
): { data: Record<string, string | string[] | boolean> } | { missing: string } {
|
|
143
|
+
const data: Record<string, string | string[] | boolean> = {};
|
|
126
144
|
for (const answer of formAnswers(questions, picks)) {
|
|
127
145
|
if (!answer.name) continue;
|
|
128
146
|
const value = answer.value;
|
|
129
|
-
if (
|
|
147
|
+
if (value === undefined) continue;
|
|
148
|
+
if (typeof value === 'string' ? value.trim() === '' : typeof value !== 'boolean' && value.length === 0) continue;
|
|
130
149
|
data[answer.name] = value;
|
|
131
150
|
}
|
|
132
151
|
if (Object.keys(data).length === 0) return { missing: 'Answer at least one question.' };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `<booldeck>` deck collection for the `ask` form parser (`walker.ts`): each
|
|
8
|
+
* nested `<card name="…">` becomes a `card` field whose verdict submits as a
|
|
9
|
+
* boolean. Split out of the walker at the 350-line ceiling.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import type { DraftField } from '@/shared/lib/chat/ask-form/fields';
|
|
13
|
+
import type { WalkContext } from '@/shared/lib/chat/ask-form/walker';
|
|
14
|
+
import { flush } from '@/shared/lib/chat/ask-form/walker';
|
|
15
|
+
import { BLOCK, HEADING, matchingClose, oneLine, textOf } from '@/shared/lib/chat/ask-form/tokens';
|
|
16
|
+
|
|
17
|
+
/** A card carries its question in the caption it was collected with. */
|
|
18
|
+
export function addCardField(ctx: WalkContext, field: DraftField): void {
|
|
19
|
+
ctx.fields.push(field);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function sideLabel(attrs: Record<string, string>, name: 'yes' | 'no'): string | undefined {
|
|
23
|
+
const label = oneLine(attrs[name] ?? '');
|
|
24
|
+
return label ? label : undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* One `<booldeck>` deck (omp 19.4.0): each nested `<card name="…">` becomes a
|
|
29
|
+
* `card` field. The side labels resolve per-card over the deck's over
|
|
30
|
+
* `Yes`/`No`. The card's question is its first text block (omp's
|
|
31
|
+
* `cardQuestion`); later blocks are context, not the question.
|
|
32
|
+
*/
|
|
33
|
+
export function addDeck(ctx: WalkContext, deckAttrs: Record<string, string>, start: number, close: number): void {
|
|
34
|
+
const deckYes = sideLabel(deckAttrs, 'yes');
|
|
35
|
+
const deckNo = sideLabel(deckAttrs, 'no');
|
|
36
|
+
for (let index = start; index <= close; index += 1) {
|
|
37
|
+
const token = ctx.tokens[index];
|
|
38
|
+
if (token.kind !== 'open' || token.tag !== 'card' || token.selfClosing) continue;
|
|
39
|
+
const cardClose = Math.min(matchingClose(ctx.tokens, index, 'card'), close);
|
|
40
|
+
// The surrounding caption must not leak into the card.
|
|
41
|
+
const outerCaption = ctx.caption;
|
|
42
|
+
ctx.caption = '';
|
|
43
|
+
flush(ctx);
|
|
44
|
+
let cardCaption = '';
|
|
45
|
+
for (let at = index + 1; at <= cardClose; at += 1) {
|
|
46
|
+
const inner = ctx.tokens[at];
|
|
47
|
+
const innerTag = inner.kind === 'open' ? inner.tag : '';
|
|
48
|
+
if (innerTag !== '' && !innerTag.startsWith('/') && (BLOCK[innerTag] || HEADING[innerTag])) {
|
|
49
|
+
const blockClose = Math.min(matchingClose(ctx.tokens, at, innerTag), cardClose);
|
|
50
|
+
const text = oneLine(textOf(ctx.tokens, at + 1, blockClose));
|
|
51
|
+
if (text) {
|
|
52
|
+
cardCaption = text;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (inner.kind === 'text' && oneLine(inner.text)) {
|
|
57
|
+
cardCaption = oneLine(inner.text);
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
ctx.inline = '';
|
|
62
|
+
ctx.caption = outerCaption;
|
|
63
|
+
addCardField(ctx, {
|
|
64
|
+
name: token.attrs.name ?? '',
|
|
65
|
+
kind: 'card',
|
|
66
|
+
multi: false,
|
|
67
|
+
select: false,
|
|
68
|
+
label: '',
|
|
69
|
+
options: [],
|
|
70
|
+
value: '',
|
|
71
|
+
multiline: false,
|
|
72
|
+
caption: cardCaption,
|
|
73
|
+
section: ctx.section,
|
|
74
|
+
required: false,
|
|
75
|
+
yes: sideLabel(token.attrs, 'yes') ?? deckYes ?? 'Yes',
|
|
76
|
+
no: sideLabel(token.attrs, 'no') ?? deckNo ?? 'No',
|
|
77
|
+
});
|
|
78
|
+
index = cardClose;
|
|
79
|
+
}
|
|
80
|
+
}
|