@kabmo-labs/kabmo 0.55.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 +466 -466
- package/dist/client/static/js/{Body-a4dwe3hh.js → Body-k96gtstv.js} +1 -1
- package/dist/client/static/js/{CsvGrid-ppj80brw.js → CsvGrid-t84xmbk9.js} +1 -1
- package/dist/client/static/js/{DocxView-ef0bd2pg.js → DocxView-4jda3szm.js} +1 -1
- package/dist/client/static/js/{DrawioView-44tpkzbd.js → DrawioView-9qvvtnvt.js} +1 -1
- package/dist/client/static/js/{HtmlPreview-w654aykz.js → HtmlPreview-4pba1ys5.js} +1 -1
- package/dist/client/static/js/{ImageView-kg0skt5s.js → ImageView-0gf5xdsv.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-qepkrtd8.js → LayoutWrapper-pwbq5syv.js} +2 -2
- package/dist/client/static/js/MergeDiffView-m4jkr786.js +1 -0
- package/dist/client/static/js/{Modal-8d299emm.js → Modal-yjszc3vy.js} +12 -12
- package/dist/client/static/js/{PdfView-eq7fnqa2.js → PdfView-sny55sne.js} +1 -1
- package/dist/client/static/js/{SessionsView-tedh2es3.js → SessionsView-q3800n83.js} +1 -1
- package/dist/client/static/js/{SheetView-5xm33kgk.js → SheetView-ezqak2b4.js} +1 -1
- package/dist/client/static/js/{SvgPreview-tp1m8r4t.js → SvgPreview-q1cvdf4s.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-xppr9jf1.js → abnfDiagram-O67JEVCF-ftm2qwa3.js} +1 -1
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-s23e6vtk.js → architectureDiagram-NJMV4G6O-j8kqfzmf.js} +3 -3
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-7ws8yq9e.js → blockDiagram-BEXU5L5S-m3zpsp9h.js} +3 -3
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-517yhfzj.js → c4Diagram-YGBWAQC7-myshvbrx.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-tcad3rst.js → classDiagram-v2-NBCMYWYE-s0cwmsj4.js} +1 -1
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-a76vf82p.js → cose-bilkent-JH36ORCC-t5t02sfr.js} +1 -1
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-9kety453.js → cynefinDiagram-VND7K2PF-6yxd72sh.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-6g6gsp6b.js → dagre-6A5THRUB-vft5103m.js} +1 -1
- package/dist/client/static/js/{diagram-22UHCM2B-ngj4fyg3.js → diagram-22UHCM2B-yy2jfvxt.js} +1 -1
- package/dist/client/static/js/{diagram-3UASUU5V-xw2m99qa.js → diagram-3UASUU5V-1xqhzq20.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-hz3bd083.js → diagram-ATOU4E4O-f11cxgvm.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-vfhtemve.js → diagram-CDSNMT55-gqmkfcp7.js} +3 -3
- package/dist/client/static/js/{diagram-MLGK6HIB-22cjvj5g.js → diagram-MLGK6HIB-1fg7304a.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-xv8fsecp.js → diagram-MPIPVDR6-mem80369.js} +1 -1
- package/dist/client/static/js/{dockerfile-491tyqmj.js → dockerfile-jarjwxp9.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-m6mkn986.js → ebnfDiagram-ZINNZB2B-4rcbvfrj.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-jccw706n.js → elk-276RUBZZ-ykd0stxz.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-rxk86jsf.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-veweech7.js → ganttDiagram-FUAMR5RP-64p5r7cx.js} +2 -2
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-7dyqcj8r.js → gitGraphDiagram-X574FWY7-z3yc333r.js} +1 -1
- package/dist/client/static/js/{index-wa234c7k.js → index-1mm7kyjd.js} +1 -1
- package/dist/client/static/js/{index-sx5x2q80.js → index-2gf593e3.js} +1 -1
- package/dist/client/static/js/{index-xm3691yp.js → index-3w18s59k.js} +1 -1
- package/dist/client/static/js/{index-60fjqzdw.js → index-3x3nhs8n.js} +1 -1
- package/dist/client/static/js/{index-2asa0faw.js → index-5m0se6fk.js} +2 -2
- package/dist/client/static/js/{index-tk1vr8q2.js → index-6m5n8b6w.js} +4 -4
- package/dist/client/static/js/{index-2cfw7wem.js → index-77wznmg5.js} +1 -1
- package/dist/client/static/js/{index-e6tjaccf.js → index-bwwgtesb.js} +1 -1
- package/dist/client/static/js/{index-5701gj1f.js → index-c2vc6znd.js} +1 -1
- package/dist/client/static/js/{index-d9dz0wt0.js → index-dxx49b9m.js} +1 -1
- package/dist/client/static/js/{index-4kchzh9y.js → index-e4yj4kbe.js} +8 -8
- package/dist/client/static/js/{index-twjq786a.js → index-ebnd5hnr.js} +1 -1
- package/dist/client/static/js/{index-zjc8yfbe.js → index-ep353yxd.js} +1 -1
- package/dist/client/static/js/{index-wvqwzgpx.js → index-ewtv8gg7.js} +1 -1
- package/dist/client/static/js/{index-na95tr1k.js → index-g71wn1pr.js} +2 -2
- package/dist/client/static/js/{index-bhst1c2x.js → index-gr07t5c4.js} +1 -1
- package/dist/client/static/js/{index-r51fqzb5.js → index-h4qmywn5.js} +1 -1
- package/dist/client/static/js/{index-x3g8fwkc.js → index-hge0y4vn.js} +2 -2
- package/dist/client/static/js/{index-nzjc24v9.js → index-hmjb96kb.js} +1 -1
- package/dist/client/static/js/{index-gsw1zh30.js → index-jd2h5tvh.js} +1 -1
- package/dist/client/static/js/{index-637my5h0.js → index-k57bandz.js} +1 -1
- package/dist/client/static/js/{index-xq78fj64.js → index-k6wms0kx.js} +1 -1
- package/dist/client/static/js/{index-39mr4tym.js → index-k9v6477a.js} +1 -1
- package/dist/client/static/js/{index-pqmvhqmj.js → index-kbaffwp1.js} +21 -21
- package/dist/client/static/js/{index-3x88fxzj.js → index-mdmtxh1c.js} +1 -1
- package/dist/client/static/js/{index-cz80n8yc.js → index-mv83hpva.js} +1 -1
- package/dist/client/static/js/{index-xbvjpa60.js → index-n71ffk62.js} +3 -3
- package/dist/client/static/js/{index-7ckzdf4r.js → index-nr5gwny1.js} +178 -178
- package/dist/client/static/js/{index-j0qt8gaj.js → index-q9gbwqbe.js} +3 -3
- package/dist/client/static/js/{index-0qmpqtp2.js → index-rqpbva78.js} +1 -1
- package/dist/client/static/js/{index-0xh8402w.js → index-sw370sk7.js} +1 -1
- package/dist/client/static/js/{index-0ak5wdz1.js → index-t415df0c.js} +1 -1
- package/dist/client/static/js/index-taz2nfym.css +1 -0
- package/dist/client/static/js/{index-dg714jam.js → index-w659dhe5.js} +1 -1
- package/dist/client/static/js/{index-trpn9gxs.js → index-wgcgshdh.js} +1 -1
- package/dist/client/static/js/{index-kfcpkx7h.js → index-x6945djv.js} +1 -1
- package/dist/client/static/js/{index-088gwjbz.js → index-y5mf2w81.js} +1 -1
- package/dist/client/static/js/{index-wp7tsava.js → index-y69cbdvd.js} +1 -1
- package/dist/client/static/js/{index-bfy437re.js → index-y6qtx68e.js} +1 -1
- package/dist/client/static/js/{index-4m94cbms.js → index-yktwxghr.js} +1 -1
- package/dist/client/static/js/{index-7ehep28z.js → index-zj65csnm.js} +2 -2
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-ksz9cvq3.js → infoDiagram-VRGFBTTK-59xq3n1b.js} +2 -2
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-g8symmrp.js → ishikawaDiagram-OU5B5YK6-v18q4qt7.js} +2 -2
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-qs2e3hdf.js → journeyDiagram-ZHPQQLJL-etazj0p8.js} +2 -2
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-pzef80sz.js → kanban-definition-PNTS6WVX-ph15e5p2.js} +1 -1
- package/dist/client/static/js/{mermaid.core-chfcvkkc.js → mermaid.core-7ygd161b.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-sds2e243.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-m8199cy0.js → pegDiagram-GJSIUBJH-09nvb70v.js} +1 -1
- package/dist/client/static/js/{pieDiagram-5QR66LMP-wqz5k5w6.js → pieDiagram-5QR66LMP-6ymh1960.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-rjszd8an.js → quadrantDiagram-O4NWA36T-hk61avw2.js} +2 -2
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-qv0be7dh.js → railroadDiagram-XR7U4H2S-3jvqrfnb.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-b87kqbr7.js → requirementDiagram-PLB6GJNP-zthfj48k.js} +1 -1
- package/dist/client/static/js/{rust-m7ma3tq9.js → rust-q7n7q6dy.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-dh5we479.js → sankeyDiagram-IPEJSGJF-nh5d6xte.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-e6fg0x45.js → sequenceDiagram-PO4LG4MO-crej9b40.js} +4 -4
- package/dist/client/static/js/{sizeCapture-INFHLROL-mam6cagq.js → sizeCapture-INFHLROL-nvvxw58j.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-htwar22v.js → stateDiagram-v2-GCMORJYK-e6tztjnj.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-5g26cnkr.js → swimlanes-2SLR337P-xhdqjqmf.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-rseba3zs.js → swimlanesDiagram-TC7HE7FX-hbwg3m3k.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-5km8n8mj.js → timeline-definition-EJHVYXUP-9cve31zc.js} +1 -1
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-0vt6ms5g.js → usecaseDiagram-POWQR4AR-asycstwe.js} +1 -1
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-k425105a.js → vennDiagram-UO4OBE2U-gbzk6era.js} +4 -4
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-s0gd4jg1.js → wardleyDiagram-VNRHLVJA-1swwfszr.js} +2 -2
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-2nrdzp7p.js → xychartDiagram-PMCCYNJV-v7qkwv0b.js} +3 -3
- package/package.json +4 -4
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +5 -3
- package/src/client/components/workspace/chat-timeline/index.tsx +1 -1
- 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/GroupedAsk.tsx +41 -21
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +16 -3
- 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/components/workspace/chat-timeline/tool-renderers/ask-panel/index.test.ts +105 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +59 -8
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AgentAdmin.test.tsx +0 -13
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AgentAdmin.tsx +6 -23
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/agent-admin-rows.test.ts +1 -39
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/agent-admin-rows.ts +11 -46
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +36 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +10 -5
- package/src/client/data/settings/omp-schema.json +59 -7
- package/src/client/hooks/chat/timeline/ask-frame-buckets.ts +14 -4
- package/src/client/hooks/chat/timeline/ask-frames-context.ts +3 -1
- package/src/client/hooks/chat/timeline/ask-frames-form.test.ts +29 -0
- package/src/client/hooks/chat/timeline/ask-frames-grouped.test.ts +31 -0
- package/src/client/hooks/chat/timeline/ask-frames.ts +12 -3
- package/src/client/hooks/chat/timeline/send-props.ts +1 -2
- package/src/server/lib/harness/acp/client-capabilities.test.ts +3 -2
- package/src/server/lib/sessions/last-opened.server.test.ts +26 -7
- package/src/server/lib/sessions/last-opened.server.ts +19 -4
- 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/chat/ask-questions.test.ts +29 -0
- package/src/shared/lib/chat/ask-questions.ts +44 -3
- package/src/shared/lib/chat/ask-results.test.ts +66 -0
- package/src/shared/lib/chat/ask-results.ts +58 -0
- package/src/shared/lib/chat/timeline/block-chrome.ts +4 -4
- 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/tsconfig.json +6 -0
- package/dist/client/static/js/MergeDiffView-n2h8vv0j.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-aegwx04w.js +0 -1
- package/dist/client/static/js/index-4m2d73m3.css +0 -1
- package/dist/client/static/js/one-dark-pro-5fvhpb1t.js +0 -1
- package/dist/client/static/js/one-light-pwj40vbr.js +0 -1
|
@@ -48,7 +48,9 @@ export interface AskFramesHandle {
|
|
|
48
48
|
orphanAsks: AskFramesSplit['orphanAsks'];
|
|
49
49
|
/** The ask's whole-form dialog, when it has one (see `formByTool`). */
|
|
50
50
|
formByTool: AskFramesSplit['formByTool'];
|
|
51
|
-
/**
|
|
51
|
+
/** The chat's harness. An ACP chat has no ask dialog frames; an `ask`
|
|
52
|
+
* tool call there answers from the next user message, not the card. */
|
|
53
|
+
harness?: string; /** Answer one ask dialog and drop it from the pending queue. */
|
|
52
54
|
respond: (request: ExtensionUiDialogRequest, response: ExtensionDialogResponse) => void;
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -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>');
|
|
@@ -104,6 +104,37 @@ describe('splitAskFrames with a grouped ask frame', () => {
|
|
|
104
104
|
expect(split.modalRequest).toBeNull();
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
+
test('an ACP elicitation claims its tool call by toolCallId', () => {
|
|
108
|
+
// opencode sends `question` as a normal tool call and the form separately;
|
|
109
|
+
// its schema ids (`q0`) are not the tool's arguments. The explicit
|
|
110
|
+
// toolCallId is the only exact key, and it must win over text matching.
|
|
111
|
+
const tool = {
|
|
112
|
+
id: 'call-question',
|
|
113
|
+
type: 'custom' as const,
|
|
114
|
+
title: 'question',
|
|
115
|
+
name: 'question',
|
|
116
|
+
status: 'running' as const,
|
|
117
|
+
input: { questions: [{ question: 'Which color should I use?', options: [{ label: 'Red' }, { label: 'Blue' }] }] },
|
|
118
|
+
};
|
|
119
|
+
const frame: ExtensionUiDialogRequest = {
|
|
120
|
+
type: 'extension_ui_request',
|
|
121
|
+
id: '9',
|
|
122
|
+
method: 'ask',
|
|
123
|
+
title: 'Questions',
|
|
124
|
+
toolCallId: 'call-question',
|
|
125
|
+
questions: [
|
|
126
|
+
{ id: 'q0', question: 'Which color should I use?', options: [{ label: 'Red' }, { label: 'Blue' }] },
|
|
127
|
+
{ id: 'q0_custom', question: 'Type your own answer', options: [] },
|
|
128
|
+
],
|
|
129
|
+
};
|
|
130
|
+
const history = { id: 'm1', role: 'ai', content: '', toolCalls: [tool] } as unknown as ChatMessageData;
|
|
131
|
+
|
|
132
|
+
const split = splitAskFrames([history], [frame], true);
|
|
133
|
+
expect(split.framesByTool.get('call-question')?.flat()).toEqual([frame]);
|
|
134
|
+
expect(split.orphanAsks).toEqual([]);
|
|
135
|
+
expect(split.modalRequest).toBeNull();
|
|
136
|
+
});
|
|
137
|
+
|
|
107
138
|
test('a grouped frame matches its card by question text when ids differ', () => {
|
|
108
139
|
const retitled: ExtensionUiDialogRequest = {
|
|
109
140
|
...grouped,
|
|
@@ -105,10 +105,19 @@ export function splitAskFrames(
|
|
|
105
105
|
continue;
|
|
106
106
|
}
|
|
107
107
|
if (grouped) {
|
|
108
|
+
// The ACP elicitation names the tool call outright; that is the exact
|
|
109
|
+
// owner and it survives a schema whose question text differs from the
|
|
110
|
+
// tool's own arguments.
|
|
111
|
+
const addressed = typeof request.toolCallId === 'string' ? request.toolCallId : '';
|
|
108
112
|
const ids = new Set(grouped.map((question) => question.id).filter(Boolean));
|
|
109
|
-
let groupedOwner =
|
|
110
|
-
|
|
111
|
-
|
|
113
|
+
let groupedOwner = addressed
|
|
114
|
+
? [...openAsks].reverse().find((candidate) => candidate.toolId === addressed)
|
|
115
|
+
: undefined;
|
|
116
|
+
if (!groupedOwner) {
|
|
117
|
+
groupedOwner = [...openAsks].reverse().find((candidate) =>
|
|
118
|
+
candidate.questions.some((question) => question.id && ids.has(question.id)),
|
|
119
|
+
);
|
|
120
|
+
}
|
|
112
121
|
// The id walk is the exact key, but it is not the only one omp gives us:
|
|
113
122
|
// a call whose questions carry no `id` (measured on 2 of 161 real `ask`
|
|
114
123
|
// calls) yields an empty id set, and the frame then matched nothing and
|
|
@@ -25,10 +25,11 @@ describe('client capabilities', () => {
|
|
|
25
25
|
expect(KABMO_CLIENT_CAPABILITIES.session.notices).toEqual({});
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
test('
|
|
28
|
+
test('advertises the form elicitation the ask card can draw, but not URL mode', () => {
|
|
29
29
|
const advertised = KABMO_CLIENT_CAPABILITIES as Record<string, unknown>;
|
|
30
30
|
expect(advertised.terminal).toBeUndefined();
|
|
31
|
-
expect(advertised.elicitation).
|
|
31
|
+
expect(advertised.elicitation).toEqual({ form: {} });
|
|
32
|
+
expect((advertised.elicitation as { url?: unknown }).url).toBeUndefined();
|
|
32
33
|
});
|
|
33
34
|
});
|
|
34
35
|
|
|
@@ -30,6 +30,8 @@ import {
|
|
|
30
30
|
const SESSION_ID = '42';
|
|
31
31
|
const CLIENT = '11111111-2222-4333-8444-555555555555';
|
|
32
32
|
const OTHER_CLIENT = '99999999-8888-4777-8666-555555555555';
|
|
33
|
+
/** No session is held by another process in these cases; ownership has its own. */
|
|
34
|
+
const free = async () => false;
|
|
33
35
|
let db: DbClient;
|
|
34
36
|
let priorMock: string | undefined;
|
|
35
37
|
|
|
@@ -58,13 +60,13 @@ afterAll(() => {
|
|
|
58
60
|
|
|
59
61
|
describe('lastOpenedSession', () => {
|
|
60
62
|
test('no record yet means no session to restore', async () => {
|
|
61
|
-
expect(await lastOpenedSession(CLIENT)).toBeNull();
|
|
63
|
+
expect(await lastOpenedSession(CLIENT, free)).toBeNull();
|
|
62
64
|
});
|
|
63
65
|
|
|
64
66
|
test('a recorded session that still exists is restored', async () => {
|
|
65
67
|
expect(await recordLastOpenedSession(CLIENT, SESSION_ID)).toBe(true);
|
|
66
68
|
expect(await readLastOpenedSessionId(CLIENT)).toBe(SESSION_ID);
|
|
67
|
-
expect(await lastOpenedSession(CLIENT)).toBe(SESSION_ID);
|
|
69
|
+
expect(await lastOpenedSession(CLIENT, free)).toBe(SESSION_ID);
|
|
68
70
|
});
|
|
69
71
|
|
|
70
72
|
test('two clients keep separate pointers at one console', async () => {
|
|
@@ -72,15 +74,32 @@ describe('lastOpenedSession', () => {
|
|
|
72
74
|
|
|
73
75
|
// The second install never opened anything, so it restores the landing even
|
|
74
76
|
// though the first install has a record.
|
|
75
|
-
expect(await lastOpenedSession(OTHER_CLIENT)).toBeNull();
|
|
77
|
+
expect(await lastOpenedSession(OTHER_CLIENT, free)).toBeNull();
|
|
76
78
|
expect(await readLastOpenedSessionId(OTHER_CLIENT)).toBeNull();
|
|
77
79
|
});
|
|
78
80
|
|
|
81
|
+
// A session another instance is running must not be restored HERE: the tab
|
|
82
|
+
// would be redirected to that owner, and a password-protected owner turns the
|
|
83
|
+
// shell's launch into a navigation the user cannot complete — the reported
|
|
84
|
+
// reload loop. The row is NOT deleted: the session is valid, just unavailable
|
|
85
|
+
// until the writer lets it go.
|
|
86
|
+
test('a session another instance is writing is skipped and kept', async () => {
|
|
87
|
+
await recordLastOpenedSession(CLIENT, SESSION_ID);
|
|
88
|
+
expect(await lastOpenedSession(CLIENT, async () => true)).toBeNull();
|
|
89
|
+
expect(await readLastOpenedSessionId(CLIENT)).toBe(SESSION_ID);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('the same record restores once the other instance releases it', async () => {
|
|
93
|
+
await recordLastOpenedSession(CLIENT, SESSION_ID);
|
|
94
|
+
expect(await lastOpenedSession(CLIENT, async () => true)).toBeNull();
|
|
95
|
+
expect(await lastOpenedSession(CLIENT, free)).toBe(SESSION_ID);
|
|
96
|
+
});
|
|
97
|
+
|
|
79
98
|
test('an archived session is refused and its record cleared', async () => {
|
|
80
99
|
await recordLastOpenedSession(CLIENT, SESSION_ID);
|
|
81
100
|
await db.run('INSERT OR IGNORE INTO archived_sessions (session_id) VALUES (?)', [SESSION_ID]);
|
|
82
101
|
|
|
83
|
-
expect(await lastOpenedSession(CLIENT)).toBeNull();
|
|
102
|
+
expect(await lastOpenedSession(CLIENT, free)).toBeNull();
|
|
84
103
|
expect(await readLastOpenedSessionId(CLIENT)).toBeNull();
|
|
85
104
|
});
|
|
86
105
|
|
|
@@ -88,7 +107,7 @@ describe('lastOpenedSession', () => {
|
|
|
88
107
|
await recordLastOpenedSession(CLIENT, SESSION_ID);
|
|
89
108
|
await db.run('INSERT OR IGNORE INTO deleted_sessions (session_id) VALUES (?)', [SESSION_ID]);
|
|
90
109
|
|
|
91
|
-
expect(await lastOpenedSession(CLIENT)).toBeNull();
|
|
110
|
+
expect(await lastOpenedSession(CLIENT, free)).toBeNull();
|
|
92
111
|
expect(await readLastOpenedSessionId(CLIENT)).toBeNull();
|
|
93
112
|
});
|
|
94
113
|
|
|
@@ -96,14 +115,14 @@ describe('lastOpenedSession', () => {
|
|
|
96
115
|
await recordLastOpenedSession(CLIENT, SESSION_ID);
|
|
97
116
|
await db.run('DELETE FROM sessions WHERE id = ?', [SESSION_ID]);
|
|
98
117
|
|
|
99
|
-
expect(await lastOpenedSession(CLIENT)).toBeNull();
|
|
118
|
+
expect(await lastOpenedSession(CLIENT, free)).toBeNull();
|
|
100
119
|
expect(await readLastOpenedSessionId(CLIENT)).toBeNull();
|
|
101
120
|
});
|
|
102
121
|
|
|
103
122
|
test('clearing leaves the next launch on the empty workspace', async () => {
|
|
104
123
|
await recordLastOpenedSession(CLIENT, SESSION_ID);
|
|
105
124
|
await clearLastOpenedSession(CLIENT);
|
|
106
|
-
expect(await lastOpenedSession(CLIENT)).toBeNull();
|
|
125
|
+
expect(await lastOpenedSession(CLIENT, free)).toBeNull();
|
|
107
126
|
});
|
|
108
127
|
});
|
|
109
128
|
|
|
@@ -46,6 +46,7 @@ import { isMockMode } from '@kabmo-labs/kabmo-runtime-flags';
|
|
|
46
46
|
import { isSinglePathSegment } from '@kabmo-labs/kabmo-paths/path-segment';
|
|
47
47
|
import { getDb } from '@/server/db.server';
|
|
48
48
|
import { isSessionArchived, sessionExists } from '@/server/lib/sessions/resolve.server';
|
|
49
|
+
import { isSessionOwnedElsewhere } from '@/server/lib/omp/session/ownership.server';
|
|
49
50
|
|
|
50
51
|
/** The stored id for one client, or null when there is none. */
|
|
51
52
|
export async function readLastOpenedSessionId(clientId: string): Promise<string | null> {
|
|
@@ -119,11 +120,25 @@ async function sessionCanOpen(sessionId: string): Promise<boolean> {
|
|
|
119
120
|
*
|
|
120
121
|
* A stale record is DELETED, not merely skipped: every later launch would
|
|
121
122
|
* otherwise repeat the same check for a session that can never come back.
|
|
123
|
+
*
|
|
124
|
+
* A session another process is WRITING is skipped but KEPT. Restoring it would
|
|
125
|
+
* bounce the tab to the owning instance — and when that peer is a
|
|
126
|
+
* password-protected Kabmo, the shell's launch has already been consumed by a
|
|
127
|
+
* navigation the user cannot complete, which reads as a reload loop on every
|
|
128
|
+
* start. The answer is the empty workspace, and the next launch after the owner
|
|
129
|
+
* lets the session go restores it again: the record is still valid, only
|
|
130
|
+
* unavailable now.
|
|
122
131
|
*/
|
|
123
|
-
export async function lastOpenedSession(
|
|
132
|
+
export async function lastOpenedSession(
|
|
133
|
+
clientId: string,
|
|
134
|
+
ownedElsewhere: (sessionId: string) => Promise<boolean> = isSessionOwnedElsewhere,
|
|
135
|
+
): Promise<string | null> {
|
|
124
136
|
const sessionId = await readLastOpenedSessionId(clientId);
|
|
125
137
|
if (!sessionId) return null;
|
|
126
|
-
if (await sessionCanOpen(sessionId))
|
|
127
|
-
|
|
128
|
-
|
|
138
|
+
if (!(await sessionCanOpen(sessionId))) {
|
|
139
|
+
await clearLastOpenedSession(clientId);
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
if (await ownedElsewhere(sessionId)) return null;
|
|
143
|
+
return sessionId;
|
|
129
144
|
}
|
|
@@ -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
|
+
}
|
|
@@ -30,7 +30,7 @@ export interface DraftOption {
|
|
|
30
30
|
|
|
31
31
|
export interface DraftField {
|
|
32
32
|
name: string;
|
|
33
|
-
kind: 'choice' | 'text';
|
|
33
|
+
kind: 'choice' | 'text' | 'card';
|
|
34
34
|
multi: boolean;
|
|
35
35
|
select: boolean;
|
|
36
36
|
label: string;
|
|
@@ -44,6 +44,10 @@ export interface DraftField {
|
|
|
44
44
|
/** The control carries `required`. Since omp 19.2.0 it is a hint: the form
|
|
45
45
|
* handler flags the empty control but still submits, so it never blocks. */
|
|
46
46
|
required: boolean;
|
|
47
|
+
/** Card only: the side labels, each already resolved per-card over the
|
|
48
|
+
* deck's — what swiping right and left mean. */
|
|
49
|
+
yes?: string;
|
|
50
|
+
no?: string;
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
/** Named fields, in document order, as the questions the card renders. */
|
|
@@ -51,6 +55,27 @@ export function toQuestions(fields: DraftField[]): AskQuestion[] {
|
|
|
51
55
|
const questions: AskQuestion[] = [];
|
|
52
56
|
for (const field of fields) {
|
|
53
57
|
if (!field.name) continue;
|
|
58
|
+
if (field.kind === 'card') {
|
|
59
|
+
// omp's card deck: the question is the card's first text block (here its
|
|
60
|
+
// caption — the walker hands text blocks to `caption` — else its name),
|
|
61
|
+
// and the three verdict rows ride as options, yes/no/skip in order, so
|
|
62
|
+
// the existing `OptionRow` picks and the same Submit carry them. The
|
|
63
|
+
// verdict values are the fixed words omp submits as booleans for, never
|
|
64
|
+
// the labels, which the user may have relabelled.
|
|
65
|
+
const question = oneLine(field.label) || field.caption || field.section || field.name;
|
|
66
|
+
questions.push({
|
|
67
|
+
id: field.name,
|
|
68
|
+
question,
|
|
69
|
+
options: [
|
|
70
|
+
{ label: field.yes ?? 'Yes', value: 'yes' },
|
|
71
|
+
{ label: field.no ?? 'No', value: 'no' },
|
|
72
|
+
{ label: 'Skip', value: 'skip' },
|
|
73
|
+
],
|
|
74
|
+
multi: false,
|
|
75
|
+
kind: 'card',
|
|
76
|
+
});
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
54
79
|
const lone = field.kind === 'choice' && field.options.length === 1 ? oneLine(field.options[0].label) : '';
|
|
55
80
|
const question = oneLine(field.label) || field.caption || field.section || lone || field.name;
|
|
56
81
|
const options: AskOption[] = field.options.map((option) => ({
|