@kabmo-labs/kabmo 0.58.0 → 0.58.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 +457 -444
- package/dist/client/static/js/{Body-karkrzkc.js → Body-ysmhxbvk.js} +3 -3
- package/dist/client/static/js/{CsvGrid-j03knmbe.js → CsvGrid-w90pxyn2.js} +1 -1
- package/dist/client/static/js/{DocxView-e8408vzs.js → DocxView-evxn6kaq.js} +1 -1
- package/dist/client/static/js/{DrawioView-fj4mfzch.js → DrawioView-tmdevwf4.js} +1 -1
- package/dist/client/static/js/{HtmlPreview-9g8xwzgw.js → HtmlPreview-bpsn2z9p.js} +1 -1
- package/dist/client/static/js/{ImageView-sz4fzz9k.js → ImageView-ssazqckj.js} +1 -1
- package/dist/client/static/js/{LayoutWrapper-q6q4h04a.js → LayoutWrapper-qwpfq4dq.js} +2 -2
- package/dist/client/static/js/MergeDiffView-en6aazw8.js +1 -0
- package/dist/client/static/js/{Modal-ahecatp5.js → Modal-zjnhj9nb.js} +19 -19
- package/dist/client/static/js/{PdfView-8jtdx5hd.js → PdfView-txxn6qff.js} +1 -1
- package/dist/client/static/js/{SessionsView-jwp8xvw5.js → SessionsView-eryjtmb2.js} +1 -1
- package/dist/client/static/js/{SheetView-hwx8s864.js → SheetView-52b33e6f.js} +1 -1
- package/dist/client/static/js/{SvgPreview-ete36nzv.js → SvgPreview-hrk4pfm1.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-7nsqzz6z.js → abnfDiagram-O67JEVCF-at77sybc.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-v05ap4e3.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-xvpkfq2f.js → architectureDiagram-NJMV4G6O-raw33jgg.js} +3 -3
- package/dist/client/static/js/{astro-rsrqgjjx.js → astro-qha7sceh.js} +1 -1
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-0saahcs6.js → blockDiagram-BEXU5L5S-b6e90fbk.js} +6 -6
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-ktpqnb4a.js → c4Diagram-YGBWAQC7-msg9y1c6.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-x67cz3ms.js → classDiagram-v2-NBCMYWYE-jmrd1h8r.js} +5 -5
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-9wzmhkz8.js → cose-bilkent-JH36ORCC-na65ebq3.js} +1 -1
- package/dist/client/static/js/css-q2k6afe3.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-sqv0ze38.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-dmmgmv99.js → cynefinDiagram-VND7K2PF-9xkkw71m.js} +1 -1
- package/dist/client/static/js/{dagre-6A5THRUB-ygkkms1t.js → dagre-6A5THRUB-p59f19tv.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-qxj0pqb4.js → diagram-22UHCM2B-2e2rcvn7.js} +8 -8
- package/dist/client/static/js/{diagram-3UASUU5V-77k8w5dt.js → diagram-3UASUU5V-r9ds8vgr.js} +2 -2
- package/dist/client/static/js/{diagram-ATOU4E4O-m0h86vf4.js → diagram-ATOU4E4O-jgwxv7v8.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-5v28kaeg.js → diagram-CDSNMT55-20m35eqq.js} +4 -4
- package/dist/client/static/js/{diagram-MLGK6HIB-zgcg9gaz.js → diagram-MLGK6HIB-vt3kxt2m.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-10c9s6e6.js → diagram-MPIPVDR6-c47rgxf1.js} +1 -1
- package/dist/client/static/js/{dockerfile-dr9sdsqp.js → dockerfile-gtcyey0q.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-mz4022dz.js → ebnfDiagram-ZINNZB2B-aszw3xy3.js} +1 -1
- package/dist/client/static/js/{elixir-3dy25ex8.js → elixir-w92v180e.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-ccerbsag.js → elk-276RUBZZ-gbvr3gry.js} +1 -1
- package/dist/client/static/js/{erDiagram-OPXOYQCR-a8vjyrrw.js → erDiagram-OPXOYQCR-1hqca8qe.js} +2 -2
- package/dist/client/static/js/eventmodeling-NTZA5JFV-t4dzf5s7.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-c16xmjyv.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-sz1g29fp.js → ganttDiagram-FUAMR5RP-07v22te5.js} +2 -2
- package/dist/client/static/js/gitGraph-4MIJSDKK-0jq8y0qd.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-efqk42q0.js → gitGraphDiagram-X574FWY7-y068jtz9.js} +8 -8
- package/dist/client/static/js/graphql-qx4tt6ze.js +1 -0
- package/dist/client/static/js/html-5e0g8664.js +1 -0
- package/dist/client/static/js/{index-gw4c5n3a.js → index-007sewcn.js} +1 -1
- package/dist/client/static/js/{index-qbqm3c91.js → index-1e0rt7c6.js} +2 -2
- package/dist/client/static/js/{index-6qqsy78z.js → index-1e710snk.js} +1 -1
- package/dist/client/static/js/{index-kc5yt2cd.js → index-2s17netq.js} +2 -2
- package/dist/client/static/js/{index-7s4dge1z.js → index-374xq5a4.js} +1 -1
- package/dist/client/static/js/index-4ddgpqm0.css +1 -0
- package/dist/client/static/js/{index-6h46r2de.js → index-5g2j626a.js} +1 -1
- package/dist/client/static/js/{index-5tp3emtg.js → index-5hvt233n.js} +1 -1
- package/dist/client/static/js/{index-ssepzdaz.js → index-5xxbbzqa.js} +5 -5
- package/dist/client/static/js/{index-jnxmvxb8.js → index-7sq6cjt1.js} +11 -11
- package/dist/client/static/js/{index-q0k1am0g.js → index-80kx6dm6.js} +2 -2
- package/dist/client/static/js/{index-2f6psebk.js → index-8d8ce00v.js} +1 -1
- package/dist/client/static/js/{index-gqsnyh8k.js → index-94d416ee.js} +1 -1
- package/dist/client/static/js/{index-2a0b9ya2.js → index-an7fq7f6.js} +1 -1
- package/dist/client/static/js/{index-6ey6y9em.js → index-azz46nwc.js} +2 -2
- package/dist/client/static/js/{index-bkwax812.js → index-c9aqx3ht.js} +1 -1
- package/dist/client/static/js/{index-rr79n77k.js → index-cc7qbfvn.js} +155 -148
- package/dist/client/static/js/{index-wnk9k57k.js → index-cmjyet7w.js} +50 -50
- package/dist/client/static/js/{index-f31c6jg8.js → index-cpp43af3.js} +8 -8
- package/dist/client/static/js/{index-dz18nn65.js → index-dxq1tbwm.js} +1 -1
- package/dist/client/static/js/{index-8aqjj2x2.js → index-e0kahttb.js} +1 -1
- package/dist/client/static/js/{index-ts8rhd06.js → index-e4nge3f4.js} +1 -1
- package/dist/client/static/js/{index-k4qshngy.js → index-f27wvdky.js} +3 -3
- package/dist/client/static/js/{index-7ma44af3.js → index-f61c25vn.js} +1 -1
- package/dist/client/static/js/{index-nzq51nbb.js → index-fe92hqmb.js} +5 -5
- package/dist/client/static/js/{index-k56patms.js → index-fv7nybnf.js} +2 -2
- package/dist/client/static/js/{index-xfyxmaj1.js → index-gqrt766t.js} +44 -44
- package/dist/client/static/js/{index-mkp3gwag.js → index-hb7a7m9m.js} +1 -1
- package/dist/client/static/js/{index-qkcmspxq.js → index-j830qk07.js} +1 -1
- package/dist/client/static/js/{index-6ac860yz.js → index-kzzvrqnv.js} +1 -1
- package/dist/client/static/js/{index-x7h04xzf.js → index-m5n0zsft.js} +1 -1
- package/dist/client/static/js/{index-q5q8a3qn.js → index-medk4f18.js} +1 -1
- package/dist/client/static/js/{index-tnxp90ac.js → index-nptbz7sv.js} +1 -1
- package/dist/client/static/js/{index-r1wrke3j.js → index-qefssj0m.js} +1 -1
- package/dist/client/static/js/{index-mpyd7qxj.js → index-r8d4bk86.js} +2 -2
- package/dist/client/static/js/{index-vf01q99d.js → index-rqt8mem9.js} +2 -2
- package/dist/client/static/js/{index-zh550byg.js → index-s4dpkds5.js} +1 -1
- package/dist/client/static/js/index-s9k82stc.js +2 -0
- package/dist/client/static/js/{index-xygk0v3e.js → index-skwem10a.js} +2 -2
- package/dist/client/static/js/{index-k1576e2m.js → index-tv9rn2nd.js} +1 -1
- package/dist/client/static/js/{index-dqf0srrp.js → index-vny4ymjf.js} +2 -2
- package/dist/client/static/js/{index-w5j1wgcz.js → index-vw8b29ek.js} +1 -1
- package/dist/client/static/js/{index-e42ys2q3.js → index-wn28m9h7.js} +7 -7
- package/dist/client/static/js/{index-tc07gd33.js → index-wxqcnsrq.js} +2 -2
- package/dist/client/static/js/{index-j863hg0d.js → index-xmg1x6zv.js} +6 -6
- package/dist/client/static/js/{index-t71k3b28.js → index-zhgh7a31.js} +1 -1
- package/dist/client/static/js/{index-vb5a3g01.js → index-zs7kw0be.js} +3 -3
- package/dist/client/static/js/info-A6RAGUB7-szttx3v5.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-rykcacj5.js → infoDiagram-VRGFBTTK-1x83h4k4.js} +2 -2
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rj752kd8.js → ishikawaDiagram-OU5B5YK6-et6z3c28.js} +2 -2
- package/dist/client/static/js/javascript-av46zx4c.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-mtetwn6f.js → journeyDiagram-ZHPQQLJL-sw669e7a.js} +3 -3
- package/dist/client/static/js/{julia-mxe3pnz3.js → julia-z14p8jsx.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-4h5pw5mm.js → kanban-definition-PNTS6WVX-aqxg95kx.js} +7 -7
- package/dist/client/static/js/{mermaid.core-bs542jma.js → mermaid.core-6cgqsgcf.js} +3 -3
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-67s4xy7h.js → mindmap-definition-NLK3R4M7-530anpc4.js} +4 -4
- package/dist/client/static/js/one-dark-pro-9hnhtkpr.js +1 -0
- package/dist/client/static/js/one-light-2n5y8592.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-401149bv.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-qykb6ssk.js → pegDiagram-GJSIUBJH-5zar6hvy.js} +1 -1
- package/dist/client/static/js/{perl-a8eeaqkn.js → perl-1na2x6yd.js} +1 -1
- package/dist/client/static/js/{php-6gq92zt8.js → php-x75tt7w3.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-bgfv8tfz.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-mymrrvck.js → pieDiagram-5QR66LMP-3bx8syvw.js} +2 -2
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-6f8ahd40.js → quadrantDiagram-O4NWA36T-yaarpr2e.js} +2 -2
- package/dist/client/static/js/radar-RG4KPBEZ-pw720590.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-n2a30ngs.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-rn5rx9qt.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-t4yryhtd.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-c4ebgvrr.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-c3habpvw.js → railroadDiagram-XR7U4H2S-ag41q4nt.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-nysqy6te.js → requirementDiagram-PLB6GJNP-g8sr48h4.js} +4 -4
- package/dist/client/static/js/{ruby-mc826p2e.js → ruby-3h22qahv.js} +1 -1
- package/dist/client/static/js/{rust-m4f4vpvn.js → rust-r27demr5.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-s5dtfp3z.js → sankeyDiagram-IPEJSGJF-t1wbd1hh.js} +1 -1
- package/dist/client/static/js/{scss-9wz47c6t.js → scss-c04ezwnn.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-bb3yp049.js → sequenceDiagram-PO4LG4MO-407mjqty.js} +5 -5
- package/dist/client/static/js/{sizeCapture-INFHLROL-0m2msee7.js → sizeCapture-INFHLROL-w38zb9ky.js} +1 -1
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-cd0qgj6t.js → stateDiagram-v2-GCMORJYK-4cvgymkc.js} +3 -3
- package/dist/client/static/js/{svelte-5vrwkc13.js → svelte-egg3x4tw.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-rpb01f7p.js → swimlanes-2SLR337P-w7ts2rzw.js} +1 -1
- package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-zx36y2c8.js → swimlanesDiagram-TC7HE7FX-v82nym6b.js} +1 -1
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-tqw2e6y1.js → timeline-definition-EJHVYXUP-nq46nzy9.js} +4 -4
- package/dist/client/static/js/treeView-Q6P3EWNA-bxgt5yhm.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-hh3595m0.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-dhf4d5xg.js → usecaseDiagram-POWQR4AR-q144snzb.js} +22 -22
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-ztkk79dv.js → vennDiagram-UO4OBE2U-2wemak2p.js} +5 -5
- package/dist/client/static/js/{vue-gmjnxjm3.js → vue-d7p4wv35.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-6bza7h1b.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-ahre5tmv.js → wardleyDiagram-VNRHLVJA-bb2qvvgr.js} +2 -2
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-vak2c50n.js → xychartDiagram-PMCCYNJV-9dr05fdq.js} +4 -4
- package/package.json +4 -4
- package/src/client/components/common/anchored-menu/index.tsx +11 -4
- package/src/client/components/common/session-row/TrailingSlot.tsx +6 -2
- package/src/client/components/common/session-row/index.tsx +32 -16
- package/src/client/components/common/session-row/session-row.test.tsx +56 -18
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +24 -3
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +20 -0
- package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +5 -0
- package/src/client/components/workspace/chat-timeline/OrchestrationNotice.tsx +81 -162
- package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +7 -3
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +12 -4
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/UserTurn.test.tsx +24 -6
- package/src/client/components/workspace/chat-timeline/UserTurn.tsx +17 -4
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +16 -0
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.test.ts +66 -10
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +103 -41
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +54 -35
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.test.tsx +110 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +51 -32
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +62 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +15 -3
- package/src/client/components/workspace/chat-timeline/chat-input/access-capability.test.tsx +151 -0
- package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
- package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.test.tsx +21 -5
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +100 -71
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.test.tsx +9 -9
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +83 -66
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.test.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +36 -15
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolRowActions.tsx +10 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +11 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +5 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +19 -12
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/parity.test.tsx +50 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/props.ts +2 -0
- package/src/client/hooks/chat/timeline/access-ladder-wiring.test.ts +111 -0
- package/src/client/hooks/chat/timeline/access-ladder.test.ts +66 -0
- package/src/client/hooks/chat/timeline/access-ladder.ts +72 -0
- package/src/client/hooks/chat/timeline/access-mode.ts +11 -1
- package/src/client/hooks/chat/timeline/index.ts +4 -5
- package/src/client/hooks/chat/timeline/modes-contract.ts +10 -1
- package/src/client/hooks/chat/timeline/modes.ts +10 -2
- package/src/server/lib/realtime/topics/session-data.server.ts +6 -5
- package/src/server/lib/realtime/topics/session-data.test.ts +35 -0
- package/src/shared/lib/chat/orchestration/outcome-markdown.test.ts +57 -0
- package/src/shared/lib/chat/orchestration/outcome-markdown.ts +74 -0
- package/dist/client/static/js/MergeDiffView-b8f013ws.js +0 -1
- package/dist/client/static/js/architecture-7GRP2DOG-dc7zys46.js +0 -1
- package/dist/client/static/js/css-9gak6bze.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-9fx59e89.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-61d2ee91.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-104ywb7w.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-zkb30q0t.js +0 -1
- package/dist/client/static/js/graphql-2ntm7jyh.js +0 -1
- package/dist/client/static/js/html-mt2yb43b.js +0 -1
- package/dist/client/static/js/index-f44k9k8d.css +0 -1
- package/dist/client/static/js/index-ver116ed.js +0 -2
- package/dist/client/static/js/info-A6RAGUB7-xxvyt8p8.js +0 -1
- package/dist/client/static/js/javascript-0mqgcvps.js +0 -1
- package/dist/client/static/js/one-dark-pro-541ed4b7.js +0 -1
- package/dist/client/static/js/one-light-nr79mykt.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-cm8jeesg.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-8b9xgcxv.js +0 -1
- package/dist/client/static/js/radar-RG4KPBEZ-fxr2x2mf.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-5qd45xk1.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-6fa00vpk.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-pcbtg7tj.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-r0fdhdtp.js +0 -1
- package/dist/client/static/js/treeView-Q6P3EWNA-9sn2h4ea.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-9fzms0pq.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-vy6rp5gp.js +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { useRef, useState } from 'preact/hooks';
|
|
1
|
+
import { useCallback, useRef, useState } from 'preact/hooks';
|
|
2
2
|
import { Check, ChevronDown, LockKeyhole } from 'lucide-preact';
|
|
3
|
-
import {
|
|
3
|
+
import { AnchoredMenu } from '@/client/components/common/anchored-menu';
|
|
4
|
+
import { anchorRectOf, type AnchorRect } from '@/shared/lib/ui/menu-anchor';
|
|
4
5
|
import type { ApprovalMode } from '@kabmo-labs/kabmo-omp/access-mode';
|
|
5
6
|
import { APPROVAL_MODES } from '@kabmo-labs/kabmo-omp/access-mode';
|
|
7
|
+
import type { SessionModeState } from '@kabmo-labs/kabmo-harness/session-modes';
|
|
6
8
|
import { accessLevelCopy } from '@/client/components/workspace/chat-timeline/chat-input/access-levels';
|
|
7
9
|
|
|
8
10
|
export interface AccessDropdownProps {
|
|
@@ -21,27 +23,63 @@ export interface AccessDropdownProps {
|
|
|
21
23
|
* second mechanism for one fact is how the chip and its neighbour disagreed.
|
|
22
24
|
*/
|
|
23
25
|
iconOnly?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The agent's own permission ladder, when it has one (`claude`'s Manual /
|
|
28
|
+
* Accept edits / Bypass permissions, codex's sandbox modes, …). Those values
|
|
29
|
+
* ARE access policies, so this control owns them: the composer must not draw
|
|
30
|
+
* Kabmo's three tiers beside them, and must not draw a second Session Mode
|
|
31
|
+
* chip for the same list. Selecting a row sends `set_mode` to the agent.
|
|
32
|
+
*/
|
|
33
|
+
ladder?: SessionModeState | null;
|
|
34
|
+
onSelectLadder?: (value: string) => void;
|
|
24
35
|
}
|
|
25
36
|
|
|
26
|
-
export function AccessDropdown({ value, onSelect, harness, iconOnly = false }: AccessDropdownProps) {
|
|
37
|
+
export function AccessDropdown({ value, onSelect, harness, iconOnly = false, ladder, onSelectLadder }: AccessDropdownProps) {
|
|
27
38
|
const [showAccess, setShowAccess] = useState(false);
|
|
28
|
-
const
|
|
39
|
+
const [anchor, setAnchor] = useState<AnchorRect | null>(null);
|
|
40
|
+
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
29
41
|
const listboxId = useRef(`access-listbox-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
30
|
-
|
|
42
|
+
const close = useCallback(() => {
|
|
43
|
+
setShowAccess(false);
|
|
44
|
+
setAnchor(null);
|
|
45
|
+
}, []);
|
|
46
|
+
// The chip is the RIGHT-most of the toolbar cluster on a phone, so a panel
|
|
47
|
+
// hung from its `left-0` ran past the window edge and was clipped by the app
|
|
48
|
+
// shell (measured at 320px: panel right 346). `AnchoredMenu` places it from
|
|
49
|
+
// the trigger's rect and clamps it inside the viewport, so the panel is
|
|
50
|
+
// readable at every width and contributes nothing to the row's layout.
|
|
51
|
+
const toggle = () => {
|
|
52
|
+
if (showAccess) {
|
|
53
|
+
close();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const trigger = triggerRef.current;
|
|
57
|
+
if (!trigger) return;
|
|
58
|
+
setAnchor(anchorRectOf(trigger));
|
|
59
|
+
setShowAccess(true);
|
|
60
|
+
};
|
|
31
61
|
const copy = accessLevelCopy(harness);
|
|
62
|
+
// A ladder with no values (or no handler) is not a control: fall back to the
|
|
63
|
+
// tiers rather than draw an empty list.
|
|
64
|
+
const activeLadder = ladder && onSelectLadder && ladder.values.length > 0 ? ladder : null;
|
|
65
|
+
const currentLadder = activeLadder?.values.find((choice) => choice.value === activeLadder.currentValue);
|
|
66
|
+
const label = activeLadder
|
|
67
|
+
? currentLadder?.name ?? (activeLadder.currentValue || 'Access')
|
|
68
|
+
: copy.labels[value];
|
|
32
69
|
|
|
33
70
|
// Selection is owned by ChatInput; this dropdown only reports user choices.
|
|
34
71
|
const handleSelect = (mode: ApprovalMode) => {
|
|
35
72
|
onSelect(mode);
|
|
36
|
-
|
|
73
|
+
close();
|
|
37
74
|
};
|
|
38
75
|
|
|
39
76
|
return (
|
|
40
|
-
<div
|
|
77
|
+
<div>
|
|
41
78
|
<button
|
|
79
|
+
ref={triggerRef}
|
|
42
80
|
type="button"
|
|
43
|
-
onClick={
|
|
44
|
-
aria-label={`Access control: ${
|
|
81
|
+
onClick={toggle}
|
|
82
|
+
aria-label={`Access control: ${label}`}
|
|
45
83
|
aria-haspopup="listbox"
|
|
46
84
|
aria-expanded={showAccess}
|
|
47
85
|
aria-controls={showAccess ? listboxId : undefined}
|
|
@@ -52,40 +90,64 @@ export function AccessDropdown({ value, onSelect, harness, iconOnly = false }: A
|
|
|
52
90
|
clipped to a letter and never allowed to wrap: `whitespace-nowrap`
|
|
53
91
|
is what kept `Always ask` off two lines, and the flag is what keeps
|
|
54
92
|
the row from being squeezed into overlap. */}
|
|
55
|
-
{!iconOnly && <span className="whitespace-nowrap">{
|
|
93
|
+
{!iconOnly && <span className="whitespace-nowrap">{label}</span>}
|
|
56
94
|
<ChevronDown size={11} className={`flex-shrink-0 text-ink/40 transition-transform ${showAccess ? 'rotate-180' : ''}`} />
|
|
57
95
|
</button>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
96
|
+
<AnchoredMenu
|
|
97
|
+
anchor={showAccess ? anchor : null}
|
|
98
|
+
id={listboxId}
|
|
99
|
+
role="listbox"
|
|
100
|
+
ariaLabel="Access control"
|
|
101
|
+
className={`${copy.note || activeLadder ? 'w-56' : 'w-40'} max-w-[calc(100vw-1rem)] bg-paper border border-ink/20 rounded-md shadow-lg py-1 text-xs`}
|
|
102
|
+
onClose={close}
|
|
103
|
+
>
|
|
104
|
+
<div className="px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/40 font-semibold border-b border-ink/5 mb-1">Access Control</div>
|
|
105
|
+
{activeLadder
|
|
106
|
+
? activeLadder.values.map((choice) => (
|
|
107
|
+
<button
|
|
108
|
+
key={choice.value}
|
|
109
|
+
type="button"
|
|
110
|
+
role="option"
|
|
111
|
+
aria-selected={choice.value === activeLadder.currentValue}
|
|
112
|
+
onClick={() => {
|
|
113
|
+
onSelectLadder?.(choice.value);
|
|
114
|
+
close();
|
|
115
|
+
}}
|
|
116
|
+
title={choice.name}
|
|
117
|
+
className={`w-full text-left px-3 py-1.5 flex items-center justify-between transition-colors hover:bg-ink/5 ${
|
|
118
|
+
choice.value === activeLadder.currentValue ? 'bg-ink/10 font-medium text-ink' : 'text-ink/75'
|
|
119
|
+
}`}
|
|
120
|
+
>
|
|
121
|
+
<span>{choice.name}</span>
|
|
122
|
+
{choice.value === activeLadder.currentValue && <Check size={12} className="text-ink shrink-0" />}
|
|
123
|
+
</button>
|
|
124
|
+
))
|
|
125
|
+
: APPROVAL_MODES.map((mode) => (
|
|
126
|
+
<button
|
|
127
|
+
key={mode}
|
|
128
|
+
type="button"
|
|
129
|
+
role="option"
|
|
130
|
+
aria-selected={value === mode}
|
|
131
|
+
onClick={() => handleSelect(mode)}
|
|
132
|
+
title={copy.descriptions[mode]}
|
|
133
|
+
className={`w-full text-left px-3 py-1.5 flex items-center justify-between transition-colors hover:bg-ink/5 ${
|
|
134
|
+
value === mode ? 'bg-ink/10 font-medium text-ink' : 'text-ink/75'
|
|
135
|
+
}`}
|
|
136
|
+
>
|
|
137
|
+
<span>{copy.labels[mode]}</span>
|
|
138
|
+
{value === mode && <Check size={12} className="text-ink shrink-0" />}
|
|
139
|
+
</button>
|
|
140
|
+
))}
|
|
141
|
+
{activeLadder ? (
|
|
142
|
+
<p className="px-3 pt-1.5 pb-1 text-[10px] leading-snug text-ink/45 border-t border-ink/10 mt-1">
|
|
143
|
+
This agent’s own access modes; the pick applies to the session.
|
|
144
|
+
</p>
|
|
145
|
+
) : copy.note && (
|
|
146
|
+
<p className="px-3 pt-1.5 pb-1 text-[10px] leading-snug text-ink/45 border-t border-ink/10 mt-1">
|
|
147
|
+
{copy.note}
|
|
148
|
+
</p>
|
|
149
|
+
)}
|
|
150
|
+
</AnchoredMenu>
|
|
89
151
|
</div>
|
|
90
152
|
);
|
|
91
153
|
}
|
|
@@ -113,7 +113,9 @@ export function composerRows({
|
|
|
113
113
|
onFilesSelected={input.onFilesSelected}
|
|
114
114
|
onRemove={input.onRemoveAttachment}
|
|
115
115
|
// The phone hosts the mode toggles here; the desktop keeps them in the
|
|
116
|
-
// bottom toolbar, which has room. `showAccess` gates both hosts
|
|
116
|
+
// bottom toolbar, which has room. `showAccess` gates both hosts — the
|
|
117
|
+
// APPROVAL capability does not, because Goal is Kabmo-owned and runs on
|
|
118
|
+
// an agent that never asks for permission.
|
|
117
119
|
modes={input.isMobile && input.showAccess ? input.modes : undefined}
|
|
118
120
|
onOpenGoal={input.onOpenGoal}
|
|
119
121
|
// Only the chat's own composer stretches; a caller that owns its size
|
package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx
CHANGED
|
@@ -72,7 +72,7 @@ describe('SessionModeDropdown', () => {
|
|
|
72
72
|
await act(async () => {
|
|
73
73
|
(trigger as HTMLButtonElement).click();
|
|
74
74
|
});
|
|
75
|
-
const options =
|
|
75
|
+
const options = document.body.querySelectorAll('[role="option"]');
|
|
76
76
|
expect(options).toHaveLength(2);
|
|
77
77
|
expect(options[0]?.getAttribute('aria-selected')).toBe('true');
|
|
78
78
|
|
|
@@ -80,7 +80,7 @@ describe('SessionModeDropdown', () => {
|
|
|
80
80
|
(options[1] as HTMLButtonElement).click();
|
|
81
81
|
});
|
|
82
82
|
expect(picks).toEqual(['code']);
|
|
83
|
-
expect(
|
|
83
|
+
expect(document.body.querySelector('[role="listbox"]')).toBeNull();
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
test('a chat that has not spawned says "Mode", not an empty chip', async () => {
|
|
@@ -13,12 +13,15 @@
|
|
|
13
13
|
* or a one-value ladder — and `ModeToggles` then keeps the Plan button.
|
|
14
14
|
*
|
|
15
15
|
* The popover mirrors `AccessDropdown`: a chip, a list, a check on the current
|
|
16
|
-
* value, and dismissal on outside press.
|
|
16
|
+
* value, and dismissal on outside press. It is PORTALLED for the same reason:
|
|
17
|
+
* the chip lives in the composer's attachment row, and an `absolute left-0`
|
|
18
|
+
* panel ran past a phone's right edge (measured at 320px: 346px).
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
|
-
import { useRef, useState } from 'preact/hooks';
|
|
21
|
+
import { useCallback, useRef, useState } from 'preact/hooks';
|
|
20
22
|
import { Check, ChevronDown, Layers } from 'lucide-preact';
|
|
21
|
-
import {
|
|
23
|
+
import { AnchoredMenu } from '@/client/components/common/anchored-menu';
|
|
24
|
+
import { anchorRectOf, type AnchorRect } from '@/shared/lib/ui/menu-anchor';
|
|
22
25
|
import type { SessionModeState } from '@kabmo-labs/kabmo-harness/session-modes';
|
|
23
26
|
|
|
24
27
|
export interface SessionModeDropdownProps {
|
|
@@ -32,8 +35,12 @@ export interface SessionModeDropdownProps {
|
|
|
32
35
|
|
|
33
36
|
export function SessionModeDropdown({ mode, pending, onSelect, iconOnly = false }: SessionModeDropdownProps) {
|
|
34
37
|
const [open, setOpen] = useState(false);
|
|
35
|
-
const
|
|
36
|
-
|
|
38
|
+
const [anchor, setAnchor] = useState<AnchorRect | null>(null);
|
|
39
|
+
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
40
|
+
const close = useCallback(() => {
|
|
41
|
+
setOpen(false);
|
|
42
|
+
setAnchor(null);
|
|
43
|
+
}, []);
|
|
37
44
|
|
|
38
45
|
if (!mode || mode.values.length < 2) return null;
|
|
39
46
|
const current = mode.values.find((choice) => choice.value === mode.currentValue);
|
|
@@ -42,11 +49,23 @@ export function SessionModeDropdown({ mode, pending, onSelect, iconOnly = false
|
|
|
42
49
|
// a broken chip beside a working list.
|
|
43
50
|
const label = current?.name ?? (mode.currentValue || 'Mode');
|
|
44
51
|
|
|
52
|
+
const toggle = () => {
|
|
53
|
+
if (open) {
|
|
54
|
+
close();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const trigger = triggerRef.current;
|
|
58
|
+
if (!trigger) return;
|
|
59
|
+
setAnchor(anchorRectOf(trigger));
|
|
60
|
+
setOpen(true);
|
|
61
|
+
};
|
|
62
|
+
|
|
45
63
|
return (
|
|
46
|
-
<div
|
|
64
|
+
<div>
|
|
47
65
|
<button
|
|
66
|
+
ref={triggerRef}
|
|
48
67
|
type="button"
|
|
49
|
-
onClick={
|
|
68
|
+
onClick={toggle}
|
|
50
69
|
disabled={pending}
|
|
51
70
|
aria-haspopup="listbox"
|
|
52
71
|
aria-expanded={open}
|
|
@@ -58,35 +77,35 @@ export function SessionModeDropdown({ mode, pending, onSelect, iconOnly = false
|
|
|
58
77
|
{!iconOnly && <span className="max-w-[9rem] truncate">{label}</span>}
|
|
59
78
|
<ChevronDown size={11} className={`flex-shrink-0 text-ink/40 transition-transform ${open ? 'rotate-180' : ''}`} />
|
|
60
79
|
</button>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{mode.values.map((choice) => (
|
|
71
|
-
<button
|
|
72
|
-
key={choice.value}
|
|
73
|
-
type="button"
|
|
74
|
-
role="option"
|
|
75
|
-
aria-selected={choice.value === mode.currentValue}
|
|
76
|
-
onClick={() => {
|
|
77
|
-
setOpen(false);
|
|
78
|
-
onSelect(choice.value);
|
|
79
|
-
}}
|
|
80
|
-
className={`w-full text-left px-3 py-1.5 flex items-center justify-between gap-2 transition-colors hover:bg-ink/5 ${
|
|
81
|
-
choice.value === mode.currentValue ? 'bg-ink/10 font-medium text-ink' : 'text-ink/75'
|
|
82
|
-
}`}
|
|
83
|
-
>
|
|
84
|
-
<span className="truncate">{choice.name}</span>
|
|
85
|
-
{choice.value === mode.currentValue && <Check size={12} className="text-ink shrink-0" />}
|
|
86
|
-
</button>
|
|
87
|
-
))}
|
|
80
|
+
<AnchoredMenu
|
|
81
|
+
anchor={open ? anchor : null}
|
|
82
|
+
role="listbox"
|
|
83
|
+
ariaLabel="Session mode"
|
|
84
|
+
className="w-44 max-w-[calc(100vw-1rem)] bg-paper border border-ink/20 rounded-md shadow-lg py-1 text-xs"
|
|
85
|
+
onClose={close}
|
|
86
|
+
>
|
|
87
|
+
<div className="px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/40 font-semibold border-b border-ink/5 mb-1">
|
|
88
|
+
Session Mode
|
|
88
89
|
</div>
|
|
89
|
-
|
|
90
|
+
{mode.values.map((choice) => (
|
|
91
|
+
<button
|
|
92
|
+
key={choice.value}
|
|
93
|
+
type="button"
|
|
94
|
+
role="option"
|
|
95
|
+
aria-selected={choice.value === mode.currentValue}
|
|
96
|
+
onClick={() => {
|
|
97
|
+
close();
|
|
98
|
+
onSelect(choice.value);
|
|
99
|
+
}}
|
|
100
|
+
className={`w-full text-left px-3 py-1.5 flex items-center justify-between gap-2 transition-colors hover:bg-ink/5 ${
|
|
101
|
+
choice.value === mode.currentValue ? 'bg-ink/10 font-medium text-ink' : 'text-ink/75'
|
|
102
|
+
}`}
|
|
103
|
+
>
|
|
104
|
+
<span className="truncate">{choice.name}</span>
|
|
105
|
+
{choice.value === mode.currentValue && <Check size={12} className="text-ink shrink-0" />}
|
|
106
|
+
</button>
|
|
107
|
+
))}
|
|
108
|
+
</AnchoredMenu>
|
|
90
109
|
</div>
|
|
91
110
|
);
|
|
92
111
|
}
|
package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.test.tsx
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The thinking chip's list.
|
|
8
|
+
*
|
|
9
|
+
* The panel is PORTALLED (`AnchoredMenu`): this chip sits in the composer's
|
|
10
|
+
* bottom row beside the access control, and an `absolute left-0` panel there
|
|
11
|
+
* ran past a phone's right edge — measured at 320px, the access panel ended at
|
|
12
|
+
* 346. The test asserts the STRUCTURE (rows live in `document.body`, the panel
|
|
13
|
+
* is `fixed`) because a row-only assertion would stay green with the overflow
|
|
14
|
+
* restored.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
18
|
+
import { Window } from 'happy-dom';
|
|
19
|
+
import { h, render } from 'preact';
|
|
20
|
+
import { act } from 'preact/test-utils';
|
|
21
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
22
|
+
import { ThinkingLevelDropdown } from '@/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown';
|
|
23
|
+
|
|
24
|
+
const mounted: HTMLElement[] = [];
|
|
25
|
+
|
|
26
|
+
beforeAll(() => {
|
|
27
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
afterEach(() => {
|
|
31
|
+
for (const host of mounted.splice(0)) {
|
|
32
|
+
render(null, host);
|
|
33
|
+
host.remove();
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterAll(() => {
|
|
38
|
+
restoreDomGlobals();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
async function mount(node: h.JSX.Element): Promise<HTMLElement> {
|
|
42
|
+
const host = document.createElement('div');
|
|
43
|
+
document.body.appendChild(host);
|
|
44
|
+
await act(async () => {
|
|
45
|
+
render(node, host);
|
|
46
|
+
});
|
|
47
|
+
mounted.push(host);
|
|
48
|
+
return host;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe('ThinkingLevelDropdown', () => {
|
|
52
|
+
test('opens a portalled listbox of the model’s levels', async () => {
|
|
53
|
+
const host = await mount(
|
|
54
|
+
h(ThinkingLevelDropdown, {
|
|
55
|
+
thinkingLevels: ['low', 'high'],
|
|
56
|
+
currentThinking: 'low',
|
|
57
|
+
onSelect: () => {},
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
await act(async () => {
|
|
62
|
+
(host.querySelector('button') as HTMLButtonElement).click();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Inside the row an absolute panel widened the scroll area; the portal keeps
|
|
66
|
+
// the list out of that layout and lets `placeMenu` clamp it.
|
|
67
|
+
expect(host.querySelector('[role="listbox"]')).toBeNull();
|
|
68
|
+
const listbox = document.body.querySelector('[role="listbox"]');
|
|
69
|
+
expect(listbox?.getAttribute('aria-label')).toBe('Thinking level');
|
|
70
|
+
expect(listbox?.className).toContain('fixed');
|
|
71
|
+
expect([...document.body.querySelectorAll('[role="option"]')].map((row) => row.textContent)).toEqual([
|
|
72
|
+
'low',
|
|
73
|
+
'high',
|
|
74
|
+
]);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('picking a level reports it and closes the list', async () => {
|
|
78
|
+
const picked: string[] = [];
|
|
79
|
+
const host = await mount(
|
|
80
|
+
h(ThinkingLevelDropdown, {
|
|
81
|
+
thinkingLevels: ['low', 'high'],
|
|
82
|
+
currentThinking: 'low',
|
|
83
|
+
onSelect: (level) => picked.push(level),
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
await act(async () => {
|
|
88
|
+
(host.querySelector('button') as HTMLButtonElement).click();
|
|
89
|
+
});
|
|
90
|
+
await act(async () => {
|
|
91
|
+
(document.body.querySelectorAll('[role="option"]')[1] as HTMLButtonElement).click();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
expect(picked).toEqual(['high']);
|
|
95
|
+
expect(document.body.querySelector('[role="listbox"]')).toBeNull();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('stays disabled when the model exposes no levels', async () => {
|
|
99
|
+
const host = await mount(
|
|
100
|
+
h(ThinkingLevelDropdown, { thinkingLevels: [], currentThinking: 'Default', onSelect: () => {} }),
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const trigger = host.querySelector('button') as HTMLButtonElement;
|
|
104
|
+
expect(trigger.disabled).toBe(true);
|
|
105
|
+
await act(async () => {
|
|
106
|
+
trigger.click();
|
|
107
|
+
});
|
|
108
|
+
expect(document.body.querySelector('[role="listbox"]')).toBeNull();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useRef, useState } from 'preact/hooks';
|
|
1
|
+
import { useCallback, useRef, useState } from 'preact/hooks';
|
|
2
2
|
import { Brain, Check, ChevronDown } from 'lucide-preact';
|
|
3
|
-
import {
|
|
3
|
+
import { AnchoredMenu } from '@/client/components/common/anchored-menu';
|
|
4
|
+
import { anchorRectOf, type AnchorRect } from '@/shared/lib/ui/menu-anchor';
|
|
4
5
|
|
|
5
6
|
interface ThinkingLevelDropdownProps {
|
|
6
7
|
thinkingLevels: string[];
|
|
@@ -12,19 +13,37 @@ interface ThinkingLevelDropdownProps {
|
|
|
12
13
|
|
|
13
14
|
export function ThinkingLevelDropdown({ thinkingLevels, currentThinking, onSelect, iconOnly = false }: ThinkingLevelDropdownProps) {
|
|
14
15
|
const [showThinking, setShowThinking] = useState(false);
|
|
15
|
-
const
|
|
16
|
+
const [anchor, setAnchor] = useState<AnchorRect | null>(null);
|
|
17
|
+
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
16
18
|
const listboxId = useRef(`thinking-listbox-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
17
|
-
|
|
19
|
+
const close = useCallback(() => {
|
|
20
|
+
setShowThinking(false);
|
|
21
|
+
setAnchor(null);
|
|
22
|
+
}, []);
|
|
23
|
+
// Portalled for the same measured reason as `AccessDropdown`: this chip sits
|
|
24
|
+
// in the composer's bottom row, whose rightmost controls leave no room for an
|
|
25
|
+
// `absolute left-0` panel on a phone. `placeMenu` clamps it to the viewport.
|
|
26
|
+
const toggle = () => {
|
|
27
|
+
if (showThinking) {
|
|
28
|
+
close();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const trigger = triggerRef.current;
|
|
32
|
+
if (!trigger) return;
|
|
33
|
+
setAnchor(anchorRectOf(trigger));
|
|
34
|
+
setShowThinking(true);
|
|
35
|
+
};
|
|
18
36
|
|
|
19
37
|
const handleSelect = (level: string) => {
|
|
20
|
-
|
|
38
|
+
close();
|
|
21
39
|
onSelect(level);
|
|
22
40
|
};
|
|
23
41
|
|
|
24
42
|
return (
|
|
25
|
-
<div
|
|
43
|
+
<div>
|
|
26
44
|
<button
|
|
27
|
-
|
|
45
|
+
ref={triggerRef}
|
|
46
|
+
onClick={toggle}
|
|
28
47
|
disabled={thinkingLevels.length === 0}
|
|
29
48
|
aria-label={`Thinking level: ${currentThinking}`}
|
|
30
49
|
aria-haspopup="listbox"
|
|
@@ -37,31 +56,31 @@ export function ThinkingLevelDropdown({ thinkingLevels, currentThinking, onSelec
|
|
|
37
56
|
{!iconOnly && <span className="whitespace-nowrap">{currentThinking}</span>}
|
|
38
57
|
<ChevronDown size={11} className={`flex-shrink-0 text-ink/40 transition-transform ${showThinking ? 'rotate-180' : ''}`} />
|
|
39
58
|
</button>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
<AnchoredMenu
|
|
60
|
+
anchor={showThinking && thinkingLevels.length > 0 ? anchor : null}
|
|
61
|
+
id={listboxId}
|
|
62
|
+
role="listbox"
|
|
63
|
+
ariaLabel="Thinking level"
|
|
64
|
+
className="w-40 max-w-[calc(100vw-1rem)] bg-paper border border-ink/20 rounded-md shadow-lg py-1 text-xs"
|
|
65
|
+
onClose={close}
|
|
66
|
+
>
|
|
67
|
+
<div className="px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/40 font-semibold border-b border-ink/5 mb-1">Thinking Level</div>
|
|
68
|
+
{thinkingLevels.map(level => (
|
|
69
|
+
<button
|
|
70
|
+
key={level}
|
|
71
|
+
type="button"
|
|
72
|
+
role="option"
|
|
73
|
+
aria-selected={currentThinking === level}
|
|
74
|
+
onClick={() => handleSelect(level)}
|
|
75
|
+
className={`w-full text-left px-3 py-1.5 flex items-center justify-between transition-colors hover:bg-ink/5 ${
|
|
76
|
+
currentThinking === level ? 'bg-ink/10 font-medium text-ink' : 'text-ink/75'
|
|
77
|
+
}`}
|
|
78
|
+
>
|
|
79
|
+
<span>{level}</span>
|
|
80
|
+
{currentThinking === level && <Check size={12} className="text-ink shrink-0" />}
|
|
81
|
+
</button>
|
|
82
|
+
))}
|
|
83
|
+
</AnchoredMenu>
|
|
65
84
|
</div>
|
|
66
85
|
);
|
|
67
86
|
}
|
|
@@ -257,3 +257,65 @@ describe('composer toolbar Plan/Goal host', () => {
|
|
|
257
257
|
expect(el.querySelectorAll(plan).length).toBe(0);
|
|
258
258
|
});
|
|
259
259
|
});
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Access Control exists only where the agent can ASK.
|
|
263
|
+
*
|
|
264
|
+
* The three tiers answer `session/request_permission`; an agent that never
|
|
265
|
+
* sends one (measured: `jcode`, and `pi-acp` behind `pi`/`omo`) leaves every
|
|
266
|
+
* position of the chip inert, so the chip is not drawn — and with it the
|
|
267
|
+
* Plan/Goal cluster that shares the same `showAccess` gate.
|
|
268
|
+
*/
|
|
269
|
+
describe('composer toolbar Access Control capability gate', () => {
|
|
270
|
+
const access = '[aria-label^="Access control:"]';
|
|
271
|
+
const plan = '[aria-label="Enter plan mode"]';
|
|
272
|
+
|
|
273
|
+
async function mountFor(harness: string): Promise<HTMLElement> {
|
|
274
|
+
container = document.createElement('div');
|
|
275
|
+
document.body.appendChild(container);
|
|
276
|
+
await act(async () => {
|
|
277
|
+
render(
|
|
278
|
+
h(ComposerToolbar, {
|
|
279
|
+
isMobile: false,
|
|
280
|
+
selectedModel: null,
|
|
281
|
+
onSelectModel: () => {},
|
|
282
|
+
thinkingLevels: [],
|
|
283
|
+
currentThinking: 'auto',
|
|
284
|
+
onSelectThinking: () => {},
|
|
285
|
+
isGenerating: false,
|
|
286
|
+
onSend: () => {},
|
|
287
|
+
sendDisabled: false,
|
|
288
|
+
showModel: false,
|
|
289
|
+
showThinking: false,
|
|
290
|
+
showAccess: true,
|
|
291
|
+
accessMode: 'always-ask',
|
|
292
|
+
onSelectAccess: () => {},
|
|
293
|
+
modes: MODES,
|
|
294
|
+
onOpenGoal: () => {},
|
|
295
|
+
harness,
|
|
296
|
+
}),
|
|
297
|
+
container,
|
|
298
|
+
);
|
|
299
|
+
});
|
|
300
|
+
return container;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
test('draws the chip for a harness that raises approvals', async () => {
|
|
304
|
+
const el = await mountFor('claude');
|
|
305
|
+
expect(el.querySelectorAll(access).length).toBe(1);
|
|
306
|
+
expect(el.querySelectorAll(plan).length).toBe(1);
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
test('omits it for a harness that never asks', async () => {
|
|
310
|
+
const el = await mountFor('jcode');
|
|
311
|
+
expect(el.querySelectorAll(access).length).toBe(0);
|
|
312
|
+
expect(el.textContent).not.toContain('Always ask');
|
|
313
|
+
// Goal is Kabmo-owned and still runs on this agent, so the mode cluster
|
|
314
|
+
// stays: the approval capability gates the chip alone.
|
|
315
|
+
expect(el.querySelectorAll(plan).length).toBe(1);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
test('omp keeps it: its own transports gate tools themselves', async () => {
|
|
319
|
+
expect((await mountFor('omp-rpc')).querySelectorAll(access).length).toBe(1);
|
|
320
|
+
});
|
|
321
|
+
});
|