@kabmo-labs/kabmo 0.42.0 → 0.42.1
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 +592 -593
- package/dist/client/static/js/{CsvGrid-20k047ht.js → CsvGrid-8gdp5b49.js} +1 -1
- package/dist/client/static/js/{DocxView-qpvhfcmg.js → DocxView-j9sphgra.js} +2 -2
- package/dist/client/static/js/{DrawioView-178skky8.js → DrawioView-xsgjc7d8.js} +1 -1
- package/dist/client/static/js/{ImageView-460th5qa.js → ImageView-ve9hc519.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-5cv0dty8.js → LayoutWrapper-5mqffvkc.js} +2 -2
- package/dist/client/static/js/{Modal-wks6p4r5.js → Modal-50whypff.js} +10 -10
- package/dist/client/static/js/{PdfView-y51g03nr.js → PdfView-afd5cg54.js} +1 -1
- package/dist/client/static/js/{SessionsView-rsmvn7ks.js → SessionsView-7719nvy0.js} +1 -1
- package/dist/client/static/js/{SheetView-z7yvb05v.js → SheetView-gfzgxb4r.js} +1 -1
- package/dist/client/static/js/{SvgPreview-yehgzhem.js → SvgPreview-225pkb99.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-6zxpcy8b.js → abnfDiagram-O67JEVCF-z70sk69m.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-cagtcfhk.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-m98sgh3c.js → architectureDiagram-NJMV4G6O-pf1gpkje.js} +3 -3
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-cp7rervg.js → blockDiagram-BEXU5L5S-sr25kbn6.js} +2 -2
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-t31recqm.js → c4Diagram-YGBWAQC7-znstpg86.js} +1 -1
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fy8x3dkx.js → classDiagram-v2-NBCMYWYE-7n0pdcd8.js} +3 -3
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-va7ybm9e.js → cose-bilkent-JH36ORCC-zn3qw4c4.js} +1 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-6g2ydrss.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-4k0k429c.js → cynefinDiagram-VND7K2PF-3z41vtzs.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-ykdhxq6t.js → dagre-6A5THRUB-5j3zn883.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-5nvwx7b6.js → diagram-22UHCM2B-ryw1w2kh.js} +4 -4
- package/dist/client/static/js/{diagram-3UASUU5V-hc7zsjgw.js → diagram-3UASUU5V-p91q4gkh.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-97ae07y7.js → diagram-ATOU4E4O-22dn73g4.js} +1 -1
- package/dist/client/static/js/{diagram-CDSNMT55-b56nnbbs.js → diagram-CDSNMT55-589p9n53.js} +3 -3
- package/dist/client/static/js/{diagram-MLGK6HIB-37rygr9k.js → diagram-MLGK6HIB-ezw06wbx.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-wv3vhhfk.js → diagram-MPIPVDR6-cfwrsvk1.js} +1 -1
- package/dist/client/static/js/{dockerfile-0efb1z6e.js → dockerfile-r4k7q34y.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-13fv7vxg.js → ebnfDiagram-ZINNZB2B-3rv2wvbf.js} +1 -1
- package/dist/client/static/js/{elixir-mabagxwa.js → elixir-szk51ehr.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-xam60ktz.js → elk-276RUBZZ-ma40kneq.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-24ctv2ee.js → erDiagram-OPXOYQCR-xwstsfqa.js} +2 -2
- package/dist/client/static/js/eventmodeling-NTZA5JFV-b774qbn2.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-evp84v09.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-766a8fqw.js → ganttDiagram-FUAMR5RP-qxyx9tr9.js} +2 -2
- package/dist/client/static/js/gitGraph-4MIJSDKK-b047d6vk.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-fmwjkgh6.js → gitGraphDiagram-X574FWY7-v6sg7bkh.js} +1 -1
- package/dist/client/static/js/html-tbz83eke.js +1 -0
- package/dist/client/static/js/{index-xxe52zrm.js → index-001vebsp.js} +1 -1
- package/dist/client/static/js/{index-4j8rgr4p.js → index-0nca2nhp.js} +1 -1
- package/dist/client/static/js/{index-nbexks3x.js → index-0p43qr4k.js} +1 -1
- package/dist/client/static/js/{index-yvxa7hd8.js → index-2w9j2nj4.js} +1 -1
- package/dist/client/static/js/{index-2x9eqztp.js → index-313ctswm.js} +1 -1
- package/dist/client/static/js/{index-ka2rc2cr.js → index-3d40c0a7.js} +3 -3
- package/dist/client/static/js/{index-sq3r1xhf.js → index-4y0ayjfx.js} +1 -1
- package/dist/client/static/js/{index-qj34r6d0.js → index-5599dngt.js} +1 -1
- package/dist/client/static/js/{index-hzwr5fm9.js → index-5asf5625.js} +3 -3
- package/dist/client/static/js/{index-dydwcp3n.js → index-6dxs0tvg.js} +1 -1
- package/dist/client/static/js/{index-a9t9gdew.js → index-6eq445nn.js} +4 -4
- package/dist/client/static/js/{index-4z4ax55k.js → index-869bpqcs.js} +6 -6
- package/dist/client/static/js/{index-97qst4k9.js → index-8fvmyv7t.js} +1 -1
- package/dist/client/static/js/{index-vcn1kcpy.js → index-8pdz41yh.js} +3 -3
- package/dist/client/static/js/{index-zvazj4va.js → index-9hzfvjrb.js} +1 -1
- package/dist/client/static/js/{index-9vdbnvmk.js → index-9ss64g4g.js} +1 -1
- package/dist/client/static/js/{index-zjydzxhm.js → index-b0v6gwym.js} +2 -2
- package/dist/client/static/js/{index-ejdnjh5c.js → index-b37ewyvk.js} +1 -1
- package/dist/client/static/js/{index-z6kpc98a.js → index-b3d2k7ec.js} +1 -1
- package/dist/client/static/js/{index-grczkttn.js → index-b42t14wk.js} +7 -7
- package/dist/client/static/js/{index-1c0pnsjd.js → index-cqaz1281.js} +1 -1
- package/dist/client/static/js/{index-sx809d6d.js → index-df4yxfzd.js} +1 -1
- package/dist/client/static/js/{index-2hpy58d0.js → index-gsxebrq9.js} +2 -2
- package/dist/client/static/js/{index-sz3mxjvy.js → index-kh6vp5w5.js} +1 -1
- package/dist/client/static/js/{index-x7f5ysch.js → index-mphhvgm9.js} +1 -1
- package/dist/client/static/js/{index-13xbwcbz.js → index-mq6s2faf.js} +1 -1
- package/dist/client/static/js/{index-xe5cqwnf.js → index-mvykbyhe.js} +1 -1
- package/dist/client/static/js/{index-czagykbq.js → index-pxtff3ez.js} +2 -2
- package/dist/client/static/js/{index-tqycj126.js → index-q3qpm7jn.js} +1 -1
- package/dist/client/static/js/{index-6ge6gk9w.js → index-qh753ynv.js} +1 -1
- package/dist/client/static/js/{index-8hgm0abr.js → index-rt6ac0kk.js} +175 -171
- package/dist/client/static/js/{index-b4y5g48d.js → index-sr7sdm2t.js} +1 -1
- package/dist/client/static/js/{index-8jqawh3r.js → index-v5dbrq83.js} +1 -1
- package/dist/client/static/js/{index-1rxa9zxp.js → index-w5q9ymf4.js} +1 -1
- package/dist/client/static/js/{index-4mstdh41.js → index-x7a5jpvq.js} +1 -1
- package/dist/client/static/js/{index-7t63akyt.js → index-x7m6dmt4.js} +1 -1
- package/dist/client/static/js/{index-13dr1t1r.js → index-xsts4pqm.js} +23 -23
- package/dist/client/static/js/{index-95en3p3g.js → index-y1p3bdsw.js} +4 -4
- package/dist/client/static/js/info-A6RAGUB7-n495k952.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-tqytmzp1.js → infoDiagram-VRGFBTTK-0anekyhb.js} +2 -2
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rp77ff6m.js → ishikawaDiagram-OU5B5YK6-zxpmfkjb.js} +2 -2
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-c7bxrhf1.js → journeyDiagram-ZHPQQLJL-1e86fzra.js} +2 -2
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-j2pxewqq.js → kanban-definition-PNTS6WVX-e85hhmr1.js} +4 -4
- package/dist/client/static/js/{mermaid.core-cqqe1krg.js → mermaid.core-jpcrnzyw.js} +2 -2
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-s03k32p9.js → mindmap-definition-NLK3R4M7-xwy5928e.js} +1 -1
- package/dist/client/static/js/one-dark-pro-r0tswz8r.js +1 -0
- package/dist/client/static/js/one-light-xzcfrptf.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-zajj62z6.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-dfg2j0zc.js → pegDiagram-GJSIUBJH-7dy6pw26.js} +1 -1
- package/dist/client/static/js/{perl-5vxax0nr.js → perl-dtn1fccw.js} +1 -1
- package/dist/client/static/js/{php-hgrgdq63.js → php-7av78hch.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-1ve78y5f.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-pshd1j79.js → pieDiagram-5QR66LMP-nrv2t5yn.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-cvvvmtk2.js → quadrantDiagram-O4NWA36T-3nt63xr8.js} +1 -1
- package/dist/client/static/js/radar-RG4KPBEZ-8rqadb58.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-v6ppm8dy.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-9j6bae14.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-56cpyt0g.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-yfdmspf4.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-h53p3sha.js → railroadDiagram-XR7U4H2S-evm05hzp.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-bdv2fkxd.js → requirementDiagram-PLB6GJNP-tzrcmktj.js} +1 -1
- package/dist/client/static/js/{ruby-8pxcn21w.js → ruby-s2bqr910.js} +1 -1
- package/dist/client/static/js/{rust-j80dxgjg.js → rust-pcvgybk3.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-xqnnvmhy.js → sankeyDiagram-IPEJSGJF-jvjd5rz8.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3p67305f.js → sequenceDiagram-PO4LG4MO-0zvjwx29.js} +3 -3
- package/dist/client/static/js/{sizeCapture-INFHLROL-f87525h7.js → sizeCapture-INFHLROL-6t6g0edv.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-e5st1fy3.js → stateDiagram-v2-GCMORJYK-nb13b23a.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-ceghkbez.js → swimlanes-2SLR337P-ef8vmg6f.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-vc8hvfya.js → swimlanesDiagram-TC7HE7FX-f4sx355z.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-f7evs443.js → timeline-definition-EJHVYXUP-3bfph698.js} +3 -3
- package/dist/client/static/js/treeView-Q6P3EWNA-vwpg3wp8.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-htfxwd32.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-0gpn21p7.js → usecaseDiagram-POWQR4AR-vj6yj6tc.js} +7 -7
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-4spzy428.js → vennDiagram-UO4OBE2U-9xyyabaq.js} +2 -2
- package/dist/client/static/js/{vue-xm1dxpmy.js → vue-cbqm4bed.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-hapfjkzq.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-745xr2pa.js → wardleyDiagram-VNRHLVJA-zpcwgv9d.js} +2 -2
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7dr9qwx5.js → xychartDiagram-PMCCYNJV-pdr2rms2.js} +3 -3
- package/package.json +1 -1
- package/src/cli/lib/commands/session.js +12 -1
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -123
- package/src/client/components/workspace/chat-timeline/OrchestrationNotice.tsx +214 -0
- package/src/client/components/workspace/chat-timeline/UserTurn.test.tsx +126 -0
- package/src/client/components/workspace/chat-timeline/UserTurn.tsx +183 -0
- package/src/client/hooks/chat/timeline/composer-modes.ts +10 -7
- package/src/client/hooks/chat/timeline/plan-review-republish.test.ts +121 -0
- package/src/client/hooks/chat/timeline/plan-review.ts +12 -3
- package/src/server/lib/harness/acp/acp-audit.server.ts +1 -1
- package/src/server/lib/harness/acp/session-exit.ts +39 -5
- package/src/server/lib/harness/acp/session-turns.ts +67 -12
- package/src/server/lib/harness/acp/session.test.ts +61 -0
- package/src/server/lib/harness/acp/session.ts +15 -25
- package/src/server/lib/harness/acp/turn-outcome.server.test.ts +97 -0
- package/src/server/lib/harness/acp/turn-outcome.server.ts +71 -0
- package/src/server/lib/harness/acp/turn-silence.ts +52 -0
- package/src/server/lib/harness/acp/turn.test.ts +85 -3
- package/src/server/lib/harness/acp/turn.ts +62 -4
- package/src/server/lib/lifecycle/after-listen.ts +10 -0
- package/src/server/lib/omp/rpc/frame-fold-contract.ts +21 -0
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +4 -0
- package/src/server/lib/omp/rpc/frame-fold.ts +25 -2
- package/src/server/lib/omp/rpc/manager.ts +9 -8
- package/src/server/lib/omp/rpc/retry-saga.ts +54 -0
- package/src/server/lib/omp/rpc/run-settle.server.ts +38 -5
- package/src/server/lib/omp/rpc/run-settle.test.ts +5 -2
- package/src/server/lib/omp/rpc/session-commands-dialog.test.ts +6 -20
- package/src/server/lib/omp/rpc/session-commands-mapping.test.ts +131 -0
- package/src/server/lib/omp/rpc/session-commands.test.ts +95 -116
- package/src/server/lib/omp/rpc/session-commands.ts +38 -17
- package/src/server/lib/omp/rpc/terminal-settle.test.ts +223 -0
- package/src/server/lib/omp/rpc/terminal-settle.ts +127 -29
- package/src/server/lib/sessions/notify.server.test.ts +11 -3
- package/src/server/lib/sessions/notify.server.ts +67 -42
- package/src/server/lib/sessions/spawn.server.test.ts +5 -1
- package/src/server/lib/sessions/spawn.server.ts +8 -3
- package/src/server/routes/sessions/answer.test.ts +62 -0
- package/src/server/routes/sessions/answer.ts +13 -2
- package/src/shared/lib/chat/composer/delegation.ts +11 -7
- package/src/shared/lib/chat/export-markdown.ts +19 -0
- package/src/shared/lib/chat/orchestration/notice.test.ts +118 -0
- package/src/shared/lib/chat/orchestration/notice.ts +183 -0
- package/src/shared/lib/chat/timeline/omp-callbacks.ts +6 -1
- package/src/shared/lib/icons/tint-hues.generated.ts +36 -36
- package/dist/client/static/js/architecture-7GRP2DOG-9q06651f.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-w7a38g4g.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-6wrjccyw.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-19vjkg84.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-4je2p50v.js +0 -1
- package/dist/client/static/js/html-bwyt0ayy.js +0 -1
- package/dist/client/static/js/info-A6RAGUB7-k0z5qdew.js +0 -1
- package/dist/client/static/js/one-dark-pro-9tt0a020.js +0 -1
- package/dist/client/static/js/one-light-5fg4r0ra.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-6cnvmb2z.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-m9z1mztn.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-8m9rkex6.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-wc55emj8.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-2y2rnrzq.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-zzcc9x0v.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-z82na5nb.js +0 -1
- package/dist/client/static/js/treeView-Q6P3EWNA-kzh6cm3f.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-wz5ed560.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-zewbfccz.js +0 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A row Kabmo wrote must not read as a row a person wrote.
|
|
8
|
+
*
|
|
9
|
+
* Both halves are pinned through the rendered DOM, because the bug was a
|
|
10
|
+
* decision made at a call site: a delegating message is an orchestration
|
|
11
|
+
* contract PREPENDED to the operator's sentence, and a child outcome is a card
|
|
12
|
+
* with no operator text at all. Drawing either as a user bubble put Kabmo's own
|
|
13
|
+
* machinery — a shell heredoc, a worker report from a session nobody is looking
|
|
14
|
+
* at — in the mouth of the person reading the transcript.
|
|
15
|
+
*
|
|
16
|
+
* Rendered with `h()` against happy-dom, the same way the notice and gutter
|
|
17
|
+
* suites do.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
21
|
+
import { Window } from 'happy-dom';
|
|
22
|
+
import { h, render } from 'preact';
|
|
23
|
+
import { act } from 'preact/test-utils';
|
|
24
|
+
import { UserTurn } from '@/client/components/workspace/chat-timeline/UserTurn';
|
|
25
|
+
import {
|
|
26
|
+
ORCHESTRATION_CONTRACT,
|
|
27
|
+
WORKER_BRIEF,
|
|
28
|
+
renderChildOutcomeNotice,
|
|
29
|
+
} from '@/shared/lib/chat/orchestration/notice';
|
|
30
|
+
import type { ChatMessageData } from '@/shared/types';
|
|
31
|
+
|
|
32
|
+
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event'] as const;
|
|
33
|
+
const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
34
|
+
|
|
35
|
+
beforeAll(() => {
|
|
36
|
+
const win = new Window({ url: 'http://localhost' });
|
|
37
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
38
|
+
for (const key of DOM_GLOBALS) {
|
|
39
|
+
if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
|
|
40
|
+
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
afterAll(() => {
|
|
45
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
46
|
+
for (const key of DOM_GLOBALS) {
|
|
47
|
+
if (nativeGlobals[key] === undefined) delete target[key];
|
|
48
|
+
else target[key] = nativeGlobals[key];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
let container: HTMLElement | null = null;
|
|
53
|
+
|
|
54
|
+
afterEach(() => {
|
|
55
|
+
if (container) {
|
|
56
|
+
act(() => render(null, container as HTMLElement));
|
|
57
|
+
container.remove();
|
|
58
|
+
container = null;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
function mount(content: string): HTMLElement {
|
|
63
|
+
container = document.body.appendChild(document.createElement('div'));
|
|
64
|
+
const msg = { id: 'm1', role: 'user', content } as ChatMessageData;
|
|
65
|
+
act(() =>
|
|
66
|
+
render(
|
|
67
|
+
h(UserTurn, {
|
|
68
|
+
msg,
|
|
69
|
+
content,
|
|
70
|
+
isMobile: false,
|
|
71
|
+
userActions: true,
|
|
72
|
+
canFork: false,
|
|
73
|
+
className: '',
|
|
74
|
+
}),
|
|
75
|
+
container as HTMLElement,
|
|
76
|
+
),
|
|
77
|
+
);
|
|
78
|
+
return container;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
describe('an injected prompt renders as a card, not a bubble', () => {
|
|
82
|
+
test('a child outcome has no operator bubble at all', () => {
|
|
83
|
+
const root = mount(
|
|
84
|
+
renderChildOutcomeNotice([
|
|
85
|
+
{ sessionId: 'c1', status: 'failed', failure: '400 The model is unavailable.' },
|
|
86
|
+
]),
|
|
87
|
+
);
|
|
88
|
+
const text = root.textContent ?? '';
|
|
89
|
+
expect(text).toContain('Worker outcome');
|
|
90
|
+
expect(text).toContain('Failed');
|
|
91
|
+
// The card's subtitle names the worker; no bubble and no toolbar, because
|
|
92
|
+
// the operator wrote none of this row.
|
|
93
|
+
expect(root.querySelector('button[aria-label="Undo this message"]')).toBeNull();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('the operator keeps their own words beside the contract', () => {
|
|
97
|
+
const content = [
|
|
98
|
+
ORCHESTRATION_CONTRACT.open,
|
|
99
|
+
'You are the orchestrator for this message.',
|
|
100
|
+
ORCHESTRATION_CONTRACT.close,
|
|
101
|
+
'',
|
|
102
|
+
'koordinasikan timnya',
|
|
103
|
+
].join('\n');
|
|
104
|
+
const root = mount(content);
|
|
105
|
+
const text = root.textContent ?? '';
|
|
106
|
+
expect(text).toContain('Orchestration');
|
|
107
|
+
expect(text).toContain('koordinasikan timnya');
|
|
108
|
+
// The contract's own instructions never become the visible bubble text.
|
|
109
|
+
expect(root.innerHTML).not.toContain('You are the orchestrator for this message.');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('a worker brief is one card and never a bubble', () => {
|
|
113
|
+
const root = mount(
|
|
114
|
+
`${WORKER_BRIEF.open}\nYou are session c1.\n\nTASK\ncheck the log\n${WORKER_BRIEF.close}`,
|
|
115
|
+
);
|
|
116
|
+
expect(root.textContent).toContain('Dispatched worker');
|
|
117
|
+
expect(root.querySelector('button[aria-label="Undo this message"]')).toBeNull();
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
test('an ordinary user message keeps its bubble and its toolbar', () => {
|
|
121
|
+
const root = mount('just fix the test please');
|
|
122
|
+
const text = root.textContent ?? '';
|
|
123
|
+
expect(text).toContain('just fix the test please');
|
|
124
|
+
expect(root.querySelector('button[aria-label="Undo this message"]')).not.toBeNull();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One `role: "user"` row.
|
|
8
|
+
*
|
|
9
|
+
* Split out of `MessageItem` when the orchestration card landed: the row now
|
|
10
|
+
* has two halves — the text Kabmo injected and the text the operator typed —
|
|
11
|
+
* and keeping both in the assistant renderer pushed that file past the repo's
|
|
12
|
+
* ceiling.
|
|
13
|
+
*
|
|
14
|
+
* The split is the point. A delegating message is an orchestration contract
|
|
15
|
+
* PREPENDED to what the person wrote, and a child outcome is a notice with no
|
|
16
|
+
* operator text at all. Drawing either as a bubble made Kabmo's own machinery
|
|
17
|
+
* look like something a human said, so the injected half renders as a card
|
|
18
|
+
* (`OrchestrationNotice`) and only the operator's words keep the bubble.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useMemo } from 'preact/hooks';
|
|
22
|
+
import { Bot, GitFork, MessageSquarePlus, Undo2, User } from 'lucide-preact';
|
|
23
|
+
import type { Attachment, ChatMessageData } from '@/shared/types';
|
|
24
|
+
import type { ForkAnchorRole } from '@/shared/lib/chat/timeline/fork-anchor';
|
|
25
|
+
import { toAttachmentList } from '@/shared/lib/chat/attachments';
|
|
26
|
+
import { MarkdownRenderer } from '@/client/components/common/MarkdownRenderer';
|
|
27
|
+
import { AttachmentChips } from '@/client/components/workspace/chat-timeline/AttachmentChips';
|
|
28
|
+
import { CopyButton } from '@/client/components/common/CopyButton';
|
|
29
|
+
import { PluginMessageActions } from '@/client/components/workspace/chat-timeline/PluginMessageActions';
|
|
30
|
+
import { OrchestrationNotice } from '@/client/components/workspace/chat-timeline/OrchestrationNotice';
|
|
31
|
+
import { formatMessageStamp } from '@/shared/lib/format/time';
|
|
32
|
+
import { transcriptBlockPadding, transcriptGutter } from '@/shared/lib/chat/timeline/gutter';
|
|
33
|
+
import { parseOrchestrationBlock } from '@/shared/lib/chat/orchestration/notice';
|
|
34
|
+
|
|
35
|
+
export interface UserTurnProps {
|
|
36
|
+
msg: ChatMessageData | any;
|
|
37
|
+
/** The row's display text, already resolved by the caller. */
|
|
38
|
+
content: unknown;
|
|
39
|
+
isMobile: boolean;
|
|
40
|
+
/** Whether this row offers Undo / New-chat (a chat turn, not a BTW question). */
|
|
41
|
+
userActions: boolean;
|
|
42
|
+
canFork: boolean;
|
|
43
|
+
className: string;
|
|
44
|
+
onUndo?: (msgId: string, content?: string) => void;
|
|
45
|
+
onNewChat?: (content: string, attachments?: Attachment[]) => void;
|
|
46
|
+
onFork?: (msgId: string, role: ForkAnchorRole) => void;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function UserTurn({
|
|
50
|
+
msg,
|
|
51
|
+
content,
|
|
52
|
+
isMobile,
|
|
53
|
+
userActions,
|
|
54
|
+
canFork,
|
|
55
|
+
className,
|
|
56
|
+
onUndo,
|
|
57
|
+
onNewChat,
|
|
58
|
+
onFork,
|
|
59
|
+
}: UserTurnProps) {
|
|
60
|
+
const isAgentAttributed = msg.attribution === 'agent';
|
|
61
|
+
const raw = typeof content === 'string' ? content : '';
|
|
62
|
+
const orchestration = useMemo(() => parseOrchestrationBlock(raw), [raw]);
|
|
63
|
+
// What the operator actually wrote. For a delegating turn that is the text
|
|
64
|
+
// after the contract; for a notice it is nothing, and the row is the card.
|
|
65
|
+
const operatorText = orchestration ? orchestration.rest : raw;
|
|
66
|
+
const showBubble = !orchestration || operatorText.length > 0;
|
|
67
|
+
const displayText = useMemo(() => operatorText.trim(), [operatorText]);
|
|
68
|
+
|
|
69
|
+
const handleNewChat = (e?: Event) => {
|
|
70
|
+
if (e) e.preventDefault();
|
|
71
|
+
if (!onNewChat) return;
|
|
72
|
+
// Committed rows carry the persisted display fields only (no `File`), which
|
|
73
|
+
// is what the composer and the send path both expect on a replay.
|
|
74
|
+
const attachments = toAttachmentList(msg.attachments);
|
|
75
|
+
onNewChat(displayText, attachments.length ? attachments : undefined);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div id={msg.id} className={`flex flex-col space-y-1.5 w-full max-w-full ${className}`}>
|
|
80
|
+
{orchestration && <OrchestrationNotice block={orchestration} isMobile={isMobile} />}
|
|
81
|
+
|
|
82
|
+
{showBubble && (
|
|
83
|
+
<div className="flex flex-col items-end space-y-1.5 w-full max-w-full">
|
|
84
|
+
{/* User bubble - standardized to text-[13px] with markdown support */}
|
|
85
|
+
<div className={`bg-paper ${transcriptBlockPadding(isMobile)} sm:p-4 rounded-xl border border-ink/15 text-[13px] text-ink shadow-xs max-w-[92%] sm:max-w-[85%] break-words overflow-hidden flex flex-col space-y-2 font-sans select-text ${transcriptGutter(isMobile)}`} style={{ lineHeight: 'var(--markdown-body-line-height)' }}>
|
|
86
|
+
{isAgentAttributed && (
|
|
87
|
+
<div className="flex items-center space-x-1.5 pb-1.5 mb-1 border-b border-ink/10 text-[11px] font-mono text-ink/70">
|
|
88
|
+
<Bot size={12} className="text-ink shrink-0" />
|
|
89
|
+
<span className="font-semibold text-ink">Subagent Assignment</span>
|
|
90
|
+
<span className="text-[10px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-ink/5 text-ink/60">Delegated</span>
|
|
91
|
+
</div>
|
|
92
|
+
)}
|
|
93
|
+
<MarkdownRenderer content={displayText} />
|
|
94
|
+
|
|
95
|
+
<AttachmentChips
|
|
96
|
+
attachments={msg.attachments || []}
|
|
97
|
+
onOpenFile={(att: { name?: string; content?: string }) => {
|
|
98
|
+
window.dispatchEvent(new CustomEvent('omp:open-file', {
|
|
99
|
+
detail: { path: att.name ?? 'attachment', content: att.content }
|
|
100
|
+
}));
|
|
101
|
+
}}
|
|
102
|
+
/>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
{/* User Metadata & Toolbar (Undo on the left of Copy) */}
|
|
106
|
+
<div className="flex items-center space-x-2.5 text-[11px] text-ink/60 px-1 font-mono">
|
|
107
|
+
<div className="flex items-center space-x-1.5 border-r border-ink/15 pr-2.5">
|
|
108
|
+
{isAgentAttributed ? (
|
|
109
|
+
<>
|
|
110
|
+
<Bot size={11} className="text-ink/70 shrink-0" />
|
|
111
|
+
<span className="text-[10px] uppercase font-semibold tracking-wider text-ink/60">Agent</span>
|
|
112
|
+
</>
|
|
113
|
+
) : (
|
|
114
|
+
<User size={11} className="text-ink/70 shrink-0" />
|
|
115
|
+
)}
|
|
116
|
+
{formatMessageStamp(msg) && <span>{formatMessageStamp(msg)}</span>}
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<div className="flex items-center space-x-1">
|
|
120
|
+
{/* Undo Button (to the left of copy button) */}
|
|
121
|
+
{userActions && (
|
|
122
|
+
<button
|
|
123
|
+
type="button"
|
|
124
|
+
className="flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer"
|
|
125
|
+
title="Undo / Edit message"
|
|
126
|
+
aria-label="Undo this message"
|
|
127
|
+
onClick={() => onUndo?.(msg.id, displayText)}
|
|
128
|
+
>
|
|
129
|
+
<Undo2 size={12} />
|
|
130
|
+
</button>
|
|
131
|
+
)}
|
|
132
|
+
|
|
133
|
+
{/* Copy Button — the operator's words, never the injected contract. */}
|
|
134
|
+
<CopyButton
|
|
135
|
+
text={displayText}
|
|
136
|
+
className="flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer"
|
|
137
|
+
iconSize={12}
|
|
138
|
+
title="Copy prompt"
|
|
139
|
+
ariaLabel="Copy prompt"
|
|
140
|
+
emptyTitle="Nothing to copy — attachment-only prompt"
|
|
141
|
+
/>
|
|
142
|
+
|
|
143
|
+
{/* Fork Button — branches the session at this row, leaving the
|
|
144
|
+
source untouched. Separate from New Chat: a fork carries the
|
|
145
|
+
history, a new chat does not. */}
|
|
146
|
+
{userActions && canFork && (
|
|
147
|
+
<button
|
|
148
|
+
type="button"
|
|
149
|
+
className="flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer"
|
|
150
|
+
title="Fork from here"
|
|
151
|
+
aria-label="Fork this session from this message"
|
|
152
|
+
onClick={(e) => {
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
onFork?.(msg.id, 'user');
|
|
155
|
+
}}
|
|
156
|
+
>
|
|
157
|
+
<GitFork size={12} />
|
|
158
|
+
</button>
|
|
159
|
+
)}
|
|
160
|
+
|
|
161
|
+
{/* New Chat Button */}
|
|
162
|
+
{userActions && (
|
|
163
|
+
<button
|
|
164
|
+
type="button"
|
|
165
|
+
className="flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer"
|
|
166
|
+
title="New Chat from here"
|
|
167
|
+
aria-label="Start a new chat from this message"
|
|
168
|
+
onClick={handleNewChat}
|
|
169
|
+
>
|
|
170
|
+
<MessageSquarePlus size={12} />
|
|
171
|
+
</button>
|
|
172
|
+
)}
|
|
173
|
+
|
|
174
|
+
{/* Plugin contributions, in store order. The empty slot renders
|
|
175
|
+
nothing, so a Kabmo with no plugins keeps this strip intact. */}
|
|
176
|
+
<PluginMessageActions messageId={String(msg.id)} role="user" text={displayText} />
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
)}
|
|
181
|
+
</div>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
@@ -40,13 +40,16 @@ export function useComposerModes(sessionId: string | null, harness?: string | nu
|
|
|
40
40
|
// is picked. `omp-acp` is excluded for the reason `GET /modes` excludes it:
|
|
41
41
|
// its selectors are default/plan, which the dedicated Plan toggle expresses.
|
|
42
42
|
const modeChoices = harness && harness !== 'omp-acp' && probe?.modes.length ? probe.modes : undefined;
|
|
43
|
+
const modes = useChatTimelineModes(sessionId, {
|
|
44
|
+
harness,
|
|
45
|
+
...(modeValues ? { modeValues } : {}),
|
|
46
|
+
...(modeChoices ? { modeChoices } : {}),
|
|
47
|
+
...(modeChoices && probe?.currentMode ? { modeCurrent: probe.currentMode } : {}),
|
|
48
|
+
});
|
|
43
49
|
return {
|
|
44
|
-
modes
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
...(modeChoices && probe?.currentMode ? { modeCurrent: probe.currentMode } : {}),
|
|
49
|
-
}),
|
|
50
|
-
planReview: usePlanReview(sessionId),
|
|
50
|
+
modes,
|
|
51
|
+
// The republish probe is a PLAN-MODE question: a proposal can only be
|
|
52
|
+
// parked by that path, so a chat outside plan mode must not dispatch it.
|
|
53
|
+
planReview: usePlanReview(sessionId, modes.plan),
|
|
51
54
|
};
|
|
52
55
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The plan-review republish probe is a PLAN-MODE question.
|
|
8
|
+
*
|
|
9
|
+
* A proposal can only be parked by the plan-mode approval path, so a chat that
|
|
10
|
+
* is not in plan mode has nothing to re-send. The probe used to fire on every
|
|
11
|
+
* mount, which made a normal chat dispatch a `/kabmo-mode` prompt every time it
|
|
12
|
+
* was opened — and that prompt re-armed the run (a `stream` row plus
|
|
13
|
+
* `promptRunning` for the 10 s watchdog) over a session that had already
|
|
14
|
+
* finished. Both directions are pinned here: no plan mode, no request; plan
|
|
15
|
+
* mode, one GET then one POST.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
19
|
+
import { Window } from 'happy-dom';
|
|
20
|
+
import type { h as PreactH, render as PreactRender } from 'preact';
|
|
21
|
+
import type { act as PreactAct } from 'preact/test-utils';
|
|
22
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
23
|
+
import type { usePlanReview as UsePlanReview, PlanReviewState } from '@/client/hooks/chat/timeline/plan-review';
|
|
24
|
+
|
|
25
|
+
let usePlanReview: typeof UsePlanReview;
|
|
26
|
+
let h: typeof PreactH;
|
|
27
|
+
let render: typeof PreactRender;
|
|
28
|
+
let act: typeof PreactAct;
|
|
29
|
+
|
|
30
|
+
const realFetch = globalThis.fetch;
|
|
31
|
+
|
|
32
|
+
beforeAll(async () => {
|
|
33
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
34
|
+
// Static imports cannot work here: Preact binds its environment at module
|
|
35
|
+
// evaluation time, so these must load after the DOM globals are installed.
|
|
36
|
+
({ usePlanReview } = await import('@/client/hooks/chat/timeline/plan-review'));
|
|
37
|
+
({ h, render } = await import('preact'));
|
|
38
|
+
({ act } = await import('preact/test-utils'));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
afterAll(() => {
|
|
42
|
+
restoreDomGlobals();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterEach(() => {
|
|
46
|
+
globalThis.fetch = realFetch;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
interface ProbeProps {
|
|
50
|
+
sessionId: string;
|
|
51
|
+
planActive: boolean;
|
|
52
|
+
holder: { current: PlanReviewState | null };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function Probe({ sessionId, planActive, holder }: ProbeProps) {
|
|
56
|
+
holder.current = usePlanReview(sessionId, planActive);
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Mount the hook and return a re-render that changes its inputs. */
|
|
61
|
+
async function mountProbe(sessionId: string, planActive: boolean) {
|
|
62
|
+
const holder: ProbeProps['holder'] = { current: null };
|
|
63
|
+
const node = document.createElement('div');
|
|
64
|
+
document.body.appendChild(node);
|
|
65
|
+
const draw = async (nextPlanActive: boolean) => {
|
|
66
|
+
await act(async () => {
|
|
67
|
+
render(h(Probe, { sessionId, planActive: nextPlanActive, holder }), node);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
await draw(planActive);
|
|
71
|
+
return { draw, holder };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Let the effect's fetch chain settle. */
|
|
75
|
+
async function flush(): Promise<void> {
|
|
76
|
+
for (let turn = 0; turn < 20; turn += 1) await Promise.resolve();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
describe('usePlanReview republish', () => {
|
|
80
|
+
test('a chat outside plan mode never dispatches the probe', async () => {
|
|
81
|
+
const calls: { url: string; method: string }[] = [];
|
|
82
|
+
globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
83
|
+
calls.push({ url: String(input), method: init?.method ?? 'GET' });
|
|
84
|
+
return new Response(JSON.stringify({ running: true }), { status: 200 });
|
|
85
|
+
}) as typeof fetch;
|
|
86
|
+
|
|
87
|
+
await mountProbe('sess-1', false);
|
|
88
|
+
await flush();
|
|
89
|
+
expect(calls).toEqual([]);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('plan mode probes once: a GET, then the republish POST', async () => {
|
|
93
|
+
const calls: { url: string; method: string; body?: string }[] = [];
|
|
94
|
+
globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
|
|
95
|
+
calls.push({ url: String(input), method: init?.method ?? 'GET', body: init?.body as string | undefined });
|
|
96
|
+
return new Response(JSON.stringify({ running: true }), { status: 200 });
|
|
97
|
+
}) as typeof fetch;
|
|
98
|
+
|
|
99
|
+
await mountProbe('sess-1', true);
|
|
100
|
+
await flush();
|
|
101
|
+
expect(calls.map((call) => call.method)).toEqual(['GET', 'POST']);
|
|
102
|
+
expect(calls[1]?.url).toContain('/api/agent/sess-1');
|
|
103
|
+
expect(calls[1]?.body).toContain('"kabmo_mode"');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('entering plan mode after mount fires the probe', async () => {
|
|
107
|
+
const calls: { method: string }[] = [];
|
|
108
|
+
globalThis.fetch = (async (_input: RequestInfo | URL, init?: RequestInit) => {
|
|
109
|
+
calls.push({ method: init?.method ?? 'GET' });
|
|
110
|
+
return new Response(JSON.stringify({ running: true }), { status: 200 });
|
|
111
|
+
}) as typeof fetch;
|
|
112
|
+
|
|
113
|
+
const probe = await mountProbe('sess-1', false);
|
|
114
|
+
await flush();
|
|
115
|
+
expect(calls).toEqual([]);
|
|
116
|
+
|
|
117
|
+
await probe.draw(true);
|
|
118
|
+
await flush();
|
|
119
|
+
expect(calls.map((call) => call.method)).toEqual(['GET', 'POST']);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -43,7 +43,7 @@ export function proposalFromMarkerPayload(payload: Record<string, unknown>): Pla
|
|
|
43
43
|
return { title, planFilePath, planContent };
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export function usePlanReview(sessionId: string | null): PlanReviewState {
|
|
46
|
+
export function usePlanReview(sessionId: string | null, planActive = false): PlanReviewState {
|
|
47
47
|
const [proposal, setProposal] = useState<PlanProposal | null>(null);
|
|
48
48
|
const [deciding, setDeciding] = useState(false);
|
|
49
49
|
const [error, setError] = useState<string | null>(null);
|
|
@@ -65,9 +65,18 @@ export function usePlanReview(sessionId: string | null): PlanReviewState {
|
|
|
65
65
|
// Kabmo's lazy-spawn path, and opening a finished session to READ it must
|
|
66
66
|
// not boot an omp process for a question the answer to which is "nothing is
|
|
67
67
|
// parked" (the same rule the observer-only commands follow).
|
|
68
|
+
//
|
|
69
|
+
// And only while PLAN MODE is active: a proposal can only be parked by the
|
|
70
|
+
// plan-mode approval path, so a chat that is not in plan mode has nothing to
|
|
71
|
+
// re-send. The probe used to fire on every mount, which made a normal chat
|
|
72
|
+
// dispatch a `/kabmo-mode` prompt every time it was opened — and that prompt
|
|
73
|
+
// re-armed the run (a `stream` row plus `promptRunning` for the 10 s
|
|
74
|
+
// watchdog) over a session that had already finished. `planActive` is the
|
|
75
|
+
// live mode state (`useChatTimelineModes`), so entering plan mode still
|
|
76
|
+
// re-probes; leaving it stops the probe.
|
|
68
77
|
useEffect(() => {
|
|
69
78
|
const current = sessionId;
|
|
70
|
-
if (!current || isPendingSessionId(current)) return;
|
|
79
|
+
if (!current || !planActive || isPendingSessionId(current)) return;
|
|
71
80
|
let cancelled = false;
|
|
72
81
|
fetch(`/api/agent/${encodeURIComponent(current)}`)
|
|
73
82
|
.then((res) => (res.ok ? (res.json() as Promise<{ running?: boolean }>) : null))
|
|
@@ -83,7 +92,7 @@ export function usePlanReview(sessionId: string | null): PlanReviewState {
|
|
|
83
92
|
return () => {
|
|
84
93
|
cancelled = true;
|
|
85
94
|
};
|
|
86
|
-
}, [sessionId]);
|
|
95
|
+
}, [sessionId, planActive]);
|
|
87
96
|
|
|
88
97
|
useEffect(() => subscribeClientSignal(KABMO_MODE_SIGNAL, (detail) => {
|
|
89
98
|
const marker = detail?.marker as ParsedMarker | undefined;
|
|
@@ -72,7 +72,7 @@ export async function runAcpGoalAudit(request: AcpGoalAuditRequest): Promise<Goa
|
|
|
72
72
|
);
|
|
73
73
|
// A disposable reader: no stream row, no turn settle, no queue, no title.
|
|
74
74
|
session.markStream = () => {};
|
|
75
|
-
session.onTurnEnded = () => {};
|
|
75
|
+
session.onTurnEnded = async () => {};
|
|
76
76
|
|
|
77
77
|
const events: AgentEvent[] = [];
|
|
78
78
|
session.onEvent((event) => events.push(event));
|
|
@@ -13,19 +13,53 @@
|
|
|
13
13
|
|
|
14
14
|
import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
|
|
15
15
|
import type { HarnessId } from '@/shared/lib/harness/catalog';
|
|
16
|
+
import { noteChildOutcome } from '@/server/lib/sessions/notify.server';
|
|
16
17
|
|
|
17
18
|
export interface AcpExitInfo {
|
|
18
19
|
code: number | null;
|
|
19
20
|
stderrTail: string;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
/** The sentence an exit reports, for the operator AND for a coordinator. */
|
|
24
|
+
export function acpExitFailureMessage(harness: HarnessId, info: AcpExitInfo): string {
|
|
23
25
|
const detail = info.stderrTail.trim().split('\n').slice(-3).join(' · ');
|
|
26
|
+
return detail || `The ${harness} agent exited (code ${info.code ?? 'signal'})`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function acpExitFailureFrames(harness: HarnessId, info: AcpExitInfo): AgentEvent[] {
|
|
24
30
|
return [
|
|
25
|
-
{
|
|
26
|
-
type: 'prompt_error',
|
|
27
|
-
errorMessage: detail || `The ${harness} agent exited (code ${info.code ?? 'signal'})`,
|
|
28
|
-
},
|
|
31
|
+
{ type: 'prompt_error', errorMessage: acpExitFailureMessage(harness, info) },
|
|
29
32
|
{ type: 'agent_end', isTerminal: true },
|
|
30
33
|
];
|
|
31
34
|
}
|
|
35
|
+
|
|
36
|
+
/** What the exit path reads off the session. */
|
|
37
|
+
export interface AcpExitHost {
|
|
38
|
+
harness: HarnessId;
|
|
39
|
+
sessionId: string;
|
|
40
|
+
isStreaming: boolean;
|
|
41
|
+
isPromptRunning: boolean;
|
|
42
|
+
emit(event: AgentEvent): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The unwelcome exit: show the operator why, and tell a coordinator its worker
|
|
47
|
+
* stopped. The frames reach CLIENTS only, so without the notice a delegated
|
|
48
|
+
* worker that died mid-turn left its coordinator waiting for work that had
|
|
49
|
+
* already ended. Reported only while a turn is OPEN — a process that exits
|
|
50
|
+
* between turns has no outcome to report.
|
|
51
|
+
*
|
|
52
|
+
* Returns the notice write so a caller can await it; the process callback
|
|
53
|
+
* ignores the value.
|
|
54
|
+
*/
|
|
55
|
+
export function reportAcpExit(host: AcpExitHost, info: AcpExitInfo): Promise<void> {
|
|
56
|
+
for (const event of acpExitFailureFrames(host.harness, info)) host.emit(event);
|
|
57
|
+
if (!host.isStreaming && !host.isPromptRunning) return Promise.resolve();
|
|
58
|
+
return noteChildOutcome({
|
|
59
|
+
sessionId: host.sessionId,
|
|
60
|
+
status: 'failed',
|
|
61
|
+
failure: acpExitFailureMessage(host.harness, info),
|
|
62
|
+
}).catch((error: unknown) => {
|
|
63
|
+
console.error('[sessions] could not record an ACP child outcome:', error);
|
|
64
|
+
});
|
|
65
|
+
}
|