@kabmo-labs/kabmo 0.58.0 → 0.59.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 +520 -489
- package/dist/client/static/js/{Body-karkrzkc.js → Body-jqq4654r.js} +3 -3
- package/dist/client/static/js/{CsvGrid-j03knmbe.js → CsvGrid-avw0taqb.js} +2 -2
- package/dist/client/static/js/{DocxView-e8408vzs.js → DocxView-d221vr6g.js} +3 -3
- package/dist/client/static/js/{DrawioView-fj4mfzch.js → DrawioView-gjsy7p01.js} +2 -2
- package/dist/client/static/js/{HtmlPreview-9g8xwzgw.js → HtmlPreview-949393v1.js} +1 -1
- package/dist/client/static/js/ImageView-pan9pqtm.js +1 -0
- package/dist/client/static/js/LayoutWrapper-p0qmghgt.js +2 -0
- package/dist/client/static/js/MergeDiffView-swt467g7.js +1 -0
- package/dist/client/static/js/Modal-4spmcn44.js +60 -0
- package/dist/client/static/js/{PdfView-8jtdx5hd.js → PdfView-dzj2s6rj.js} +1 -1
- package/dist/client/static/js/SessionsView-b6szjdg5.js +1 -0
- package/dist/client/static/js/{SheetView-hwx8s864.js → SheetView-jpc178g5.js} +11 -11
- package/dist/client/static/js/{SvgPreview-ete36nzv.js → SvgPreview-94fap32p.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-7nsqzz6z.js → abnfDiagram-O67JEVCF-a6eyfzrj.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-bwn1drdz.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-xvpkfq2f.js → architectureDiagram-NJMV4G6O-pgmyfncy.js} +3 -3
- package/dist/client/static/js/{astro-rsrqgjjx.js → astro-ryr2ajmg.js} +1 -1
- package/dist/client/static/js/bash-zknkkwkw.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-0saahcs6.js → blockDiagram-BEXU5L5S-rf51jyb2.js} +6 -6
- package/dist/client/static/js/c-0w02jkxb.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-ktpqnb4a.js → c4Diagram-YGBWAQC7-0faj48jp.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-x67cz3ms.js → classDiagram-v2-NBCMYWYE-bvzsws8x.js} +6 -6
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-9wzmhkz8.js → cose-bilkent-JH36ORCC-j1amnd3m.js} +1 -1
- package/dist/client/static/js/cpp-p5b4vean.js +1 -0
- package/dist/client/static/js/css-9jzbvdyz.js +1 -0
- package/dist/client/static/js/css-sn00sq6v.js +1 -0
- package/dist/client/static/js/cynefin-OW5HDTMX-jbc50ks8.js +1 -0
- package/dist/client/static/js/{cynefinDiagram-VND7K2PF-dmmgmv99.js → cynefinDiagram-VND7K2PF-f73w6zzz.js} +2 -2
- package/dist/client/static/js/{dagre-6A5THRUB-ygkkms1t.js → dagre-6A5THRUB-a5vgvjsg.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-qxj0pqb4.js → diagram-22UHCM2B-6y9efamp.js} +12 -12
- package/dist/client/static/js/{diagram-3UASUU5V-77k8w5dt.js → diagram-3UASUU5V-2mycy7xm.js} +2 -2
- package/dist/client/static/js/{diagram-ATOU4E4O-m0h86vf4.js → diagram-ATOU4E4O-10zgjb66.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-5v28kaeg.js → diagram-CDSNMT55-bewa52yf.js} +4 -4
- package/dist/client/static/js/{diagram-MLGK6HIB-zgcg9gaz.js → diagram-MLGK6HIB-mh3b7gd3.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-10c9s6e6.js → diagram-MPIPVDR6-gvdrbdm5.js} +2 -2
- package/dist/client/static/js/{dockerfile-dr9sdsqp.js → dockerfile-6bn19kg0.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-mz4022dz.js → ebnfDiagram-ZINNZB2B-2prre93c.js} +1 -1
- package/dist/client/static/js/{elixir-3dy25ex8.js → elixir-fyxw6d70.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-ccerbsag.js → elk-276RUBZZ-9t6t9kc6.js} +2 -2
- package/dist/client/static/js/{erDiagram-OPXOYQCR-a8vjyrrw.js → erDiagram-OPXOYQCR-etcggr5n.js} +6 -6
- package/dist/client/static/js/{erlang-v7344938.js → erlang-97ayje6m.js} +1 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-b37ey01t.js +1 -0
- package/dist/client/static/js/flowDiagram-KWPJA3E3-7c2ncsw7.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-sz1g29fp.js → ganttDiagram-FUAMR5RP-cdc4mwhs.js} +3 -3
- package/dist/client/static/js/gitGraph-4MIJSDKK-mvqq7tcs.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-efqk42q0.js → gitGraphDiagram-X574FWY7-55d0fa7x.js} +8 -8
- package/dist/client/static/js/graphql-xzykn0ba.js +1 -0
- package/dist/client/static/js/html-2zc3shky.js +1 -0
- package/dist/client/static/js/{index-mpyd7qxj.js → index-10vzyga1.js} +2 -2
- package/dist/client/static/js/{index-2f6psebk.js → index-27gwghmp.js} +2 -2
- package/dist/client/static/js/{index-t71k3b28.js → index-2f6afhze.js} +2 -2
- package/dist/client/static/js/{index-tnxp90ac.js → index-3akjcs82.js} +1 -1
- package/dist/client/static/js/{index-fhtnvqgf.js → index-3j2he86h.js} +2 -2
- package/dist/client/static/js/index-461ga40v.js +2 -0
- package/dist/client/static/js/{index-9qf2h9jb.js → index-51rbgeh9.js} +12 -12
- package/dist/client/static/js/{index-zh550byg.js → index-537m8a3x.js} +2 -2
- package/dist/client/static/js/{index-tdg7hz80.js → index-58z2hatp.js} +2 -2
- package/dist/client/static/js/{index-4tbdws4r.js → index-5e4e18tg.js} +2 -2
- package/dist/client/static/js/{index-xfyxmaj1.js → index-60cxxnpk.js} +62 -62
- package/dist/client/static/js/{index-th61y26d.js → index-69mnn71v.js} +2 -2
- package/dist/client/static/js/{index-8aqjj2x2.js → index-6bsez5n6.js} +1 -1
- package/dist/client/static/js/{index-gaa39w5q.js → index-8tzt0dek.js} +2 -2
- package/dist/client/static/js/{index-vb5a3g01.js → index-8z9aqgf3.js} +4 -4
- package/dist/client/static/js/{index-ewryzs4g.js → index-92h38pwg.js} +2 -2
- package/dist/client/static/js/{index-7ma44af3.js → index-9rvjegmy.js} +3 -3
- package/dist/client/static/js/{index-q0k1am0g.js → index-a3bpmw2r.js} +2 -2
- package/dist/client/static/js/{index-j863hg0d.js → index-a5ecn5yx.js} +6 -6
- package/dist/client/static/js/{index-6ey6y9em.js → index-ax8gaayq.js} +2 -2
- package/dist/client/static/js/{index-e42ys2q3.js → index-c253x7vt.js} +7 -7
- package/dist/client/static/js/{index-y0f3wbc3.js → index-d9sfavx1.js} +2 -2
- package/dist/client/static/js/{index-5tp3emtg.js → index-db6s66jr.js} +2 -2
- package/dist/client/static/js/index-eggbcdwx.js +481 -0
- package/dist/client/static/js/{index-ts8rhd06.js → index-f13ern5e.js} +1 -1
- package/dist/client/static/js/{index-ver116ed.js → index-f6t91mpp.js} +1 -1
- package/dist/client/static/js/{index-tc07gd33.js → index-fr91ghwb.js} +2 -2
- package/dist/client/static/js/{index-tq3t3qm4.js → index-fsa18ns9.js} +2 -2
- package/dist/client/static/js/{index-k56patms.js → index-fyt8m8ah.js} +2 -2
- package/dist/client/static/js/{index-gw4c5n3a.js → index-gcad7b6g.js} +2 -2
- package/dist/client/static/js/{index-rxt8sf9a.js → index-h1xbx74w.js} +2 -2
- package/dist/client/static/js/{index-q5q8a3qn.js → index-j1ksa4x2.js} +2 -2
- package/dist/client/static/js/{index-sxag9ptg.js → index-jct0jryd.js} +2 -2
- package/dist/client/static/js/{index-r1wrke3j.js → index-jpvng27a.js} +1 -1
- package/dist/client/static/js/{index-w5j1wgcz.js → index-me0b6wkw.js} +1 -1
- package/dist/client/static/js/{index-6x0kn8pb.js → index-mhrkjbjq.js} +2 -2
- package/dist/client/static/js/{index-nzq51nbb.js → index-mngpcca7.js} +5 -5
- package/dist/client/static/js/index-mttx9327.css +1 -0
- package/dist/client/static/js/{index-ssepzdaz.js → index-mx5y9vt9.js} +7 -7
- package/dist/client/static/js/{index-3ymw778n.js → index-ndqtff48.js} +2 -2
- package/dist/client/static/js/{index-wnk9k57k.js → index-nf4hq5tg.js} +55 -55
- package/dist/client/static/js/{index-f31c6jg8.js → index-njhrm5qa.js} +10 -10
- package/dist/client/static/js/index-nnwcbp2d.js +2 -0
- package/dist/client/static/js/{index-3p732mvs.js → index-np2rfq06.js} +2 -2
- package/dist/client/static/js/{index-kc5yt2cd.js → index-nwbr15b3.js} +2 -2
- package/dist/client/static/js/{index-2a0b9ya2.js → index-pa70qj4p.js} +1 -1
- package/dist/client/static/js/index-pe5f2gmn.js +1 -0
- package/dist/client/static/js/{index-qbqm3c91.js → index-pgy7ree5.js} +5 -5
- package/dist/client/static/js/index-pzwf6hwe.js +4 -0
- package/dist/client/static/js/{index-jnxmvxb8.js → index-q3k8r0ms.js} +11 -11
- package/dist/client/static/js/{index-qkcmspxq.js → index-rw84kefb.js} +2 -2
- package/dist/client/static/js/{index-gqsnyh8k.js → index-s9ts6qbj.js} +2 -2
- package/dist/client/static/js/{index-dqf0srrp.js → index-sg65xdey.js} +2 -2
- package/dist/client/static/js/{index-mkp3gwag.js → index-skvfxcd8.js} +1 -1
- package/dist/client/static/js/{index-6qqsy78z.js → index-sx2yz2wx.js} +1 -1
- package/dist/client/static/js/{index-6ac860yz.js → index-trq7bdvk.js} +2 -2
- package/dist/client/static/js/{index-v8xhgfeq.js → index-vs2y8gxr.js} +2 -2
- package/dist/client/static/js/index-wwyjzhgs.js +2 -0
- package/dist/client/static/js/{index-7s4dge1z.js → index-xe447cw3.js} +1 -1
- package/dist/client/static/js/index-y09de44h.js +2 -0
- package/dist/client/static/js/{index-jxsha63v.js → index-y4cx8cqf.js} +2 -2
- package/dist/client/static/js/{index-bkwax812.js → index-yg38s8t3.js} +1 -1
- package/dist/client/static/js/{index-dz18nn65.js → index-yh7gngsh.js} +2 -2
- package/dist/client/static/js/{index-3m1dksmy.js → index-yrwm437g.js} +2 -2
- package/dist/client/static/js/{index-7ynf3s2w.js → index-z82nd2bd.js} +2 -2
- package/dist/client/static/js/info-A6RAGUB7-zkv4crz7.js +1 -0
- package/dist/client/static/js/{infoDiagram-VRGFBTTK-rykcacj5.js → infoDiagram-VRGFBTTK-9xph6cr5.js} +2 -2
- package/dist/client/static/js/ini-62r3vxaf.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rj752kd8.js → ishikawaDiagram-OU5B5YK6-3gshs3v8.js} +2 -2
- package/dist/client/static/js/java-kacycary.js +1 -0
- package/dist/client/static/js/javascript-zc1qnyyp.js +1 -0
- package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-mtetwn6f.js → journeyDiagram-ZHPQQLJL-fa8x56mf.js} +3 -3
- package/dist/client/static/js/json-yrwpn6bd.js +1 -0
- package/dist/client/static/js/jsx-b40ag8q1.js +1 -0
- package/dist/client/static/js/{julia-mxe3pnz3.js → julia-agc5kfvg.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-4h5pw5mm.js → kanban-definition-PNTS6WVX-fybp2hh4.js} +5 -5
- package/dist/client/static/js/lua-bk961f37.js +1 -0
- package/dist/client/static/js/markdown-b7rgzgd6.js +1 -0
- package/dist/client/static/js/mermaid.core-jjh5ggp0.js +12 -0
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-67s4xy7h.js → mindmap-definition-NLK3R4M7-gtfbg619.js} +5 -5
- package/dist/client/static/js/one-dark-pro-vht9rv39.js +1 -0
- package/dist/client/static/js/one-light-arxc5whh.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-dgpge627.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-qykb6ssk.js → pegDiagram-GJSIUBJH-1a51sbqv.js} +1 -1
- package/dist/client/static/js/{perl-a8eeaqkn.js → perl-v5vbtzgf.js} +1 -1
- package/dist/client/static/js/{php-6gq92zt8.js → php-83qwy98t.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-b8pgsqrd.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-mymrrvck.js → pieDiagram-5QR66LMP-zd9svyyn.js} +3 -3
- package/dist/client/static/js/properties-k8gbzggp.js +1 -0
- package/dist/client/static/js/python-343tspad.js +1 -0
- package/dist/client/static/js/{quadrantDiagram-O4NWA36T-6f8ahd40.js → quadrantDiagram-O4NWA36T-5gtw2m6s.js} +3 -3
- package/dist/client/static/js/r-ycdwmv8g.js +1 -0
- package/dist/client/static/js/radar-RG4KPBEZ-fmfe5y27.js +1 -0
- package/dist/client/static/js/railroad-74A4TZTK-b5tks4ce.js +1 -0
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-0sf4m0ze.js +1 -0
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-pjfy3pt7.js +1 -0
- package/dist/client/static/js/railroad-peg-WCYAUIDC-nr8ngt42.js +1 -0
- package/dist/client/static/js/{railroadDiagram-XR7U4H2S-c3habpvw.js → railroadDiagram-XR7U4H2S-3ccwpfzz.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-nysqy6te.js → requirementDiagram-PLB6GJNP-sasndrrp.js} +4 -4
- package/dist/client/static/js/{ruby-mc826p2e.js → ruby-994n5j6e.js} +1 -1
- package/dist/client/static/js/{rust-m4f4vpvn.js → rust-n9z2c9m3.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-s5dtfp3z.js → sankeyDiagram-IPEJSGJF-2ahb4sda.js} +3 -3
- package/dist/client/static/js/{sass-8bq5r2tz.js → sass-p6g7qdv2.js} +1 -1
- package/dist/client/static/js/{scss-9wz47c6t.js → scss-4j4t3r6y.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-bb3yp049.js → sequenceDiagram-PO4LG4MO-bfj90kz1.js} +7 -7
- package/dist/client/static/js/{sizeCapture-INFHLROL-0m2msee7.js → sizeCapture-INFHLROL-5tygxmtc.js} +1 -1
- package/dist/client/static/js/sql-kwpd5w07.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-cd0qgj6t.js → stateDiagram-v2-GCMORJYK-533xw76e.js} +3 -3
- package/dist/client/static/js/{svelte-5vrwkc13.js → svelte-bek3h1sz.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-rpb01f7p.js → swimlanes-2SLR337P-gd3d04pk.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-xxmvdyg4.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-tqw2e6y1.js → timeline-definition-EJHVYXUP-fvqvgqvg.js} +3 -3
- package/dist/client/static/js/treeView-Q6P3EWNA-23r9fa68.js +1 -0
- package/dist/client/static/js/treemap-WGGIJYW6-mxxzdrj6.js +1 -0
- package/dist/client/static/js/tsx-gjxfjnbk.js +1 -0
- package/dist/client/static/js/typescript-4dchbnya.js +1 -0
- package/dist/client/static/js/{usecaseDiagram-POWQR4AR-dhf4d5xg.js → usecaseDiagram-POWQR4AR-tm1f0m4x.js} +25 -25
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-ztkk79dv.js → vennDiagram-UO4OBE2U-2vdvv1hd.js} +4 -4
- package/dist/client/static/js/{vue-gmjnxjm3.js → vue-y44m889c.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-cbqtax1x.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-ahre5tmv.js → wardleyDiagram-VNRHLVJA-7avcjznx.js} +4 -4
- package/dist/client/static/js/xml-xs6qz3ya.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-vak2c50n.js → xychartDiagram-PMCCYNJV-g39y526n.js} +4 -4
- package/dist/client/static/js/yaml-174nk5bn.js +1 -0
- package/package.json +7 -7
- package/src/client/borders.css +15 -3
- package/src/client/components/common/ComposerTextarea.test.tsx +13 -1
- package/src/client/components/common/ComposerTextarea.tsx +8 -2
- package/src/client/components/common/MarkdownRenderer.tsx +11 -2
- package/src/client/components/common/anchored-menu/index.tsx +11 -4
- package/src/client/components/common/harness-glyph/harness-glyph.test.ts +0 -4
- package/src/client/components/common/harness-glyph/index.tsx +4 -5
- package/src/client/components/common/markdown-inline-file.test.tsx +90 -15
- package/src/client/components/common/session-actions-menu/index.test.tsx +45 -0
- package/src/client/components/common/session-actions-menu/index.tsx +6 -1
- 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/desktop-layout/RightColumn.tsx +4 -1
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +28 -35
- package/src/client/components/layout/desktop-layout/index.tsx +5 -3
- package/src/client/components/layout/desktop-layout/resizer/index.tsx +13 -3
- package/src/client/components/layout/desktop-layout/resizer/panel.test.ts +41 -0
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +21 -1
- package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +1 -0
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -2
- package/src/client/components/layout/session-sidebar/ClassicView.tsx +2 -0
- package/src/client/components/layout/session-sidebar/SessionList.tsx +4 -0
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +22 -1
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +46 -8
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +9 -3
- package/src/client/components/layout/session-sidebar/modern/index.tsx +2 -0
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +36 -0
- package/src/client/components/layout/session-sidebar/search-results.test.tsx +29 -16
- package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +1 -0
- package/src/client/components/layout/session-sidebar/variant-props.ts +2 -0
- package/src/client/components/mobile/LayoutWrapper.tsx +9 -0
- package/src/client/components/mobile/SessionSidebar.tsx +4 -0
- package/src/client/components/mobile/left-drawer-nav.test.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/Body.tsx +4 -0
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +3 -0
- package/src/client/components/mobile/mobile-session-sidebar/Item.test.tsx +85 -0
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +30 -14
- package/src/client/components/mobile/mobile-session-sidebar/List.tsx +4 -0
- package/src/client/components/settings/apply-side-effects.test.ts +31 -0
- package/src/client/components/settings/apply-side-effects.ts +7 -0
- package/src/client/components/settings/categories/appearance-settings/BorderStyleSection.tsx +3 -2
- package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.test.tsx +95 -0
- package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +35 -0
- package/src/client/components/workspace/chat-timeline/ChatOverlays.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.gutter.test.ts +26 -0
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +6 -3
- 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.test.tsx +17 -0
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +21 -7
- 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 +104 -11
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +120 -43
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +28 -21
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.wait.test.tsx +48 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ComposerRows.tsx +47 -22
- package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +24 -0
- package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.tsx +44 -18
- package/src/client/components/workspace/chat-timeline/chat-input/GoalSurfaces.tsx +2 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +35 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +33 -12
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +26 -2
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +67 -37
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +86 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +90 -135
- package/src/client/components/workspace/chat-timeline/chat-input/VoiceButton.tsx +58 -0
- package/src/client/components/workspace/chat-timeline/chat-input/access-capability.test.tsx +151 -0
- package/src/client/components/workspace/chat-timeline/chat-input/action-base.ts +42 -0
- package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +1 -0
- package/src/client/components/workspace/chat-timeline/chat-input/mode-icons.test.ts +108 -0
- package/src/client/components/workspace/chat-timeline/chat-input/mode-icons.tsx +122 -0
- package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
- package/src/client/components/workspace/chat-timeline/chat-input/narrow.test.tsx +78 -20
- package/src/client/components/workspace/chat-timeline/chat-input/styles/index.tsx +11 -5
- package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +19 -0
- package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +9 -0
- package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/index.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/ask-panel/OptionRow.test.tsx +125 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OptionRow.tsx +84 -27
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.test.tsx +18 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.tsx +14 -5
- 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/components/workspace/model-dropdown/HarnessTabs.tsx +31 -10
- package/src/client/components/workspace/model-dropdown/Header.tsx +13 -5
- package/src/client/components/workspace/model-dropdown/Panel.tsx +18 -0
- package/src/client/components/workspace/model-dropdown/ThinkingLevels.tsx +51 -0
- package/src/client/components/workspace/model-dropdown/Trigger.tsx +99 -0
- package/src/client/components/workspace/model-dropdown/bands.ts +51 -0
- package/src/client/components/workspace/model-dropdown/harness-tabs.test.tsx +21 -5
- package/src/client/components/workspace/model-dropdown/index.tsx +20 -47
- package/src/client/components/workspace/model-dropdown/thinking-levels.test.tsx +108 -0
- package/src/client/components/workspace/model-dropdown/trigger.test.ts +54 -8
- package/src/client/hooks/chat/composer/attachments.test.ts +12 -0
- package/src/client/hooks/chat/composer/attachments.ts +16 -4
- package/src/client/hooks/chat/composer/pipeline.test.ts +14 -0
- package/src/client/hooks/chat/composer/pipeline.ts +15 -6
- package/src/client/hooks/chat/omp/session-list.activity.test.ts +20 -0
- package/src/client/hooks/chat/omp/session-merges.ts +18 -6
- package/src/client/hooks/chat/omp/session-sidebar-controller.ts +4 -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/client/hooks/chat/timeline/scope.test.ts +17 -0
- package/src/client/hooks/chat/timeline/scope.ts +6 -1
- package/src/client/hooks/chat/timeline/send-refusal.test.ts +19 -0
- package/src/client/hooks/chat/timeline/send-steer.test.ts +17 -0
- package/src/client/hooks/chat/timeline/send.ts +17 -0
- package/src/client/hooks/editor/quick-open.ts +41 -0
- package/src/client/hooks/ui/border-style.test.ts +13 -0
- package/src/client/hooks/ui/markdown-render.ts +11 -6
- package/src/client/hooks/ui/open-inline-file.test.ts +16 -0
- package/src/client/hooks/ui/open-inline-file.ts +4 -2
- package/src/client/hooks/ui/show-more.ts +11 -1
- package/src/client/hooks/ui/ui-feedback.test.ts +11 -0
- package/src/client/hooks/ui/verified-inline-files.test.tsx +143 -0
- package/src/client/hooks/ui/verified-inline-files.ts +165 -0
- package/src/client/hooks/workspace/mobile-workspace-panels.test.tsx +116 -0
- package/src/client/hooks/workspace/mobile-workspace-panels.ts +73 -0
- package/src/client/hooks/workspace/panel-resize.test.ts +127 -0
- package/src/client/hooks/workspace/panel-resize.ts +81 -0
- package/src/client/hooks/workspace/session-list-limit.test.ts +80 -0
- package/src/client/hooks/workspace/session-list-limit.ts +69 -0
- package/src/client/hooks/workspace/session-pin.ts +58 -0
- package/src/client/hooks/workspace/workspace-panels-mode.test.tsx +87 -0
- package/src/client/hooks/workspace/workspace-panels-mode.ts +76 -0
- package/src/client/lib/router/branch-params.test.ts +17 -1
- package/src/client/lib/router/branch-params.ts +18 -0
- package/src/client/lib/ui/pressed.ts +15 -0
- package/src/client/tailwind.css +30 -10
- package/src/server/lib/connect/cloudflared.lifecycle.test.ts +25 -9
- package/src/server/lib/db/schema.test.ts +1 -1
- package/src/server/lib/db/schema.ts +17 -0
- package/src/server/lib/harness/activity.server.test.ts +81 -0
- package/src/server/lib/harness/activity.server.ts +55 -0
- package/src/server/lib/harness/spawn.server.ts +9 -0
- package/src/server/lib/omp/session/delete.server.ts +4 -2
- package/src/server/lib/omp/session/sidebar-activity.server.test.ts +24 -2
- package/src/server/lib/omp/session/sidebar-data.canonical.test.ts +14 -0
- 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/server/lib/sessions/last-opened.server.test.ts +17 -0
- package/src/server/lib/sessions/last-opened.server.ts +18 -1
- package/src/server/routes/sessions/index.ts +3 -2
- package/src/server/routes/sessions/routes.test.ts +29 -46
- package/src/server/routes/sessions/session.ts +40 -62
- package/src/server/routes/sessions/state.test.ts +89 -0
- package/src/server/routes/sessions/state.ts +86 -0
- package/src/shared/lib/chat/attachment-budget.test.ts +74 -0
- package/src/shared/lib/chat/attachment-budget.ts +111 -0
- package/src/shared/lib/chat/attachments.test.ts +0 -17
- package/src/shared/lib/chat/attachments.ts +0 -53
- package/src/shared/lib/chat/orchestration/outcome-markdown.test.ts +57 -0
- package/src/shared/lib/chat/orchestration/outcome-markdown.ts +74 -0
- package/src/shared/lib/chat/timeline/block-chrome.test.ts +35 -0
- package/src/shared/lib/chat/timeline/block-chrome.ts +21 -0
- package/src/shared/lib/markdown/degenerate-emphasis.test.ts +64 -0
- package/src/shared/lib/markdown/degenerate-emphasis.ts +90 -0
- package/src/shared/lib/markdown/inline-file.test.ts +79 -22
- package/src/shared/lib/markdown/inline-file.ts +57 -25
- package/src/shared/lib/markdown/marked.ts +5 -1
- package/src/shared/lib/settings/defaults.ts +2 -0
- package/src/shared/lib/theme/border-style.ts +1 -1
- package/src/shared/lib/workspace/active-project.test.ts +17 -1
- package/src/shared/lib/workspace/active-project.ts +9 -0
- package/src/shared/lib/workspace/project-settings-delete.test.ts +97 -0
- package/src/shared/lib/workspace/project-settings.test.ts +2 -34
- package/src/shared/lib/workspace/project-settings.ts +6 -0
- package/src/shared/lib/workspace/session-list-limit.test.ts +31 -0
- package/src/shared/lib/workspace/session-list-limit.ts +32 -0
- package/src/shared/lib/workspace/sidebar-sort.test.ts +21 -0
- package/src/shared/lib/workspace/workspace-panel-widths.ts +1 -1
- package/src/shared/lib/workspace/workspace-session.test.ts +34 -0
- package/src/shared/lib/workspace/workspace-session.ts +40 -0
- package/src/shared/types/settings/state.ts +10 -0
- package/dist/client/static/js/ImageView-sz4fzz9k.js +0 -1
- package/dist/client/static/js/LayoutWrapper-q6q4h04a.js +0 -2
- package/dist/client/static/js/MergeDiffView-b8f013ws.js +0 -1
- package/dist/client/static/js/Modal-ahecatp5.js +0 -60
- package/dist/client/static/js/SessionsView-jwp8xvw5.js +0 -1
- package/dist/client/static/js/architecture-7GRP2DOG-dc7zys46.js +0 -1
- package/dist/client/static/js/bash-n5d0esqg.js +0 -1
- package/dist/client/static/js/c-pk766wx0.js +0 -1
- package/dist/client/static/js/cpp-3pt91jvm.js +0 -1
- package/dist/client/static/js/css-9gak6bze.js +0 -1
- package/dist/client/static/js/css-sp1cgdbr.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-6h46r2de.js +0 -1
- package/dist/client/static/js/index-f44k9k8d.css +0 -1
- package/dist/client/static/js/index-k1576e2m.js +0 -2
- package/dist/client/static/js/index-k4qshngy.js +0 -4
- package/dist/client/static/js/index-rr79n77k.js +0 -470
- package/dist/client/static/js/index-vf01q99d.js +0 -2
- package/dist/client/static/js/index-x7h04xzf.js +0 -2
- package/dist/client/static/js/index-xygk0v3e.js +0 -2
- package/dist/client/static/js/info-A6RAGUB7-xxvyt8p8.js +0 -1
- package/dist/client/static/js/ini-bdk46a3d.js +0 -1
- package/dist/client/static/js/java-3g3925cf.js +0 -1
- package/dist/client/static/js/javascript-0mqgcvps.js +0 -1
- package/dist/client/static/js/json-hdyzmffz.js +0 -1
- package/dist/client/static/js/jsx-y8r9mrdq.js +0 -1
- package/dist/client/static/js/lua-wf5k6p3r.js +0 -1
- package/dist/client/static/js/markdown-9bf16dx7.js +0 -1
- package/dist/client/static/js/mermaid.core-bs542jma.js +0 -12
- 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/properties-xk4dn00p.js +0 -1
- package/dist/client/static/js/python-7sgz05n4.js +0 -1
- package/dist/client/static/js/r-w4qxm0pv.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/sql-sd00wgem.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-zx36y2c8.js +0 -8
- 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/tsx-h5yzg80q.js +0 -1
- package/dist/client/static/js/typescript-qy1sbhea.js +0 -1
- package/dist/client/static/js/wardley-WFR3VGLG-vy6rp5gp.js +0 -1
- package/dist/client/static/js/xml-mrk4xakv.js +0 -1
- package/dist/client/static/js/yaml-xaza6dra.js +0 -1
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +0 -67
|
@@ -35,9 +35,8 @@ import { removeDir } from '@/test-support/remove-dir';
|
|
|
35
35
|
import {
|
|
36
36
|
archiveSession,
|
|
37
37
|
getSessionModes,
|
|
38
|
-
getSessionState,
|
|
39
38
|
markSeen,
|
|
40
|
-
|
|
39
|
+
pinSession,
|
|
41
40
|
renameSession,
|
|
42
41
|
} from '@/server/routes/sessions/session';
|
|
43
42
|
|
|
@@ -123,14 +122,6 @@ function formPost(body: Record<string, string>, url = 'http://localhost/api/x'):
|
|
|
123
122
|
for (const [key, value] of Object.entries(body)) form.append(key, value);
|
|
124
123
|
return new Request(url, { method: 'POST', body: form });
|
|
125
124
|
}
|
|
126
|
-
function jsonRequest(method: string, body: unknown, url = 'http://localhost/api/x'): Request {
|
|
127
|
-
return new Request(url, {
|
|
128
|
-
method,
|
|
129
|
-
headers: { 'content-type': 'application/json' },
|
|
130
|
-
body: JSON.stringify(body),
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
|
|
134
125
|
/** The loader args a route needs: `params` plus the request every session
|
|
135
126
|
* route reads (the peer-relay guard inspects its headers). */
|
|
136
127
|
function loaderArgs(sessionId: string): LoaderFunctionArgs {
|
|
@@ -267,6 +258,34 @@ describe('archiveSession', () => {
|
|
|
267
258
|
});
|
|
268
259
|
});
|
|
269
260
|
|
|
261
|
+
describe('pinSession', () => {
|
|
262
|
+
test('a wrong verb is a 405', async () => {
|
|
263
|
+
const res = (await pinSession({ request: new Request('http://localhost/api/x', { method: 'GET' }), params: { sessionId: SESSION_ID } } as unknown as ActionFunctionArgs) as unknown as Response);
|
|
264
|
+
expect(res.status).toBe(405);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
test('a missing id is a 400', async () => {
|
|
268
|
+
const res = (await pinSession({ request: formPost({ pinned: 'true' }), params: {} } as unknown as ActionFunctionArgs) as unknown as Response);
|
|
269
|
+
expect(res.status).toBe(400);
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
test('pinning inserts the row and unpinning removes it', async () => {
|
|
273
|
+
const pin = async (pinned: boolean): Promise<Response> =>
|
|
274
|
+
pinSession({ request: formPost({ pinned: String(pinned) }), params: { sessionId: SESSION_ID } } as unknown as ActionFunctionArgs) as unknown as Response;
|
|
275
|
+
|
|
276
|
+
expect(await (await pin(true)).json()).toMatchObject({ success: true, sessionId: SESSION_ID, pinned: true });
|
|
277
|
+
expect(await db.get('SELECT session_id FROM pinned_sessions WHERE session_id = ?', [SESSION_ID])).toBeTruthy();
|
|
278
|
+
expect(await (await pin(false)).json()).toMatchObject({ success: true, sessionId: SESSION_ID, pinned: false });
|
|
279
|
+
expect(await db.get('SELECT session_id FROM pinned_sessions WHERE session_id = ?', [SESSION_ID])).toBeNull();
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
test('a pending chat cannot be pinned', async () => {
|
|
283
|
+
const res = (await pinSession({ request: formPost({ pinned: 'true' }), params: { sessionId: 'new-123' } } as unknown as ActionFunctionArgs) as unknown as Response);
|
|
284
|
+
expect(res.status).toBe(400);
|
|
285
|
+
expect(await res.json()).toMatchObject({ code: 'session_pending' });
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
|
|
270
289
|
describe('renameSession', () => {
|
|
271
290
|
const rename = async (name: string, sessionId = UNKNOWN): Promise<Response> =>
|
|
272
291
|
renameSession({ request: formPost({ name }), params: { sessionId } } as unknown as ActionFunctionArgs) as unknown as Response;
|
|
@@ -301,42 +320,6 @@ describe('renameSession', () => {
|
|
|
301
320
|
});
|
|
302
321
|
});
|
|
303
322
|
|
|
304
|
-
describe('per-session UI state', () => {
|
|
305
|
-
const put = async (body: unknown): Promise<Response> =>
|
|
306
|
-
putSessionState({ request: jsonRequest('POST', body), params: { sessionId: 'state-test' } } as unknown as ActionFunctionArgs) as unknown as Response;
|
|
307
|
-
|
|
308
|
-
test('a missing id is a 400', async () => {
|
|
309
|
-
const res = (await putSessionState({ request: jsonRequest('POST', { state: {} }),
|
|
310
|
-
params: {},
|
|
311
|
-
} as unknown as ActionFunctionArgs) as unknown as Response);
|
|
312
|
-
expect(res.status).toBe(400);
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
test('a wrong verb is a 405', async () => {
|
|
316
|
-
const res = (await putSessionState({ request: jsonRequest('PUT', { state: {} }),
|
|
317
|
-
params: { sessionId: 'state-test' },
|
|
318
|
-
} as unknown as ActionFunctionArgs) as unknown as Response);
|
|
319
|
-
expect(res.status).toBe(405);
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
test('only an object state is accepted', async () => {
|
|
323
|
-
for (const body of [{}, { state: null }, { state: [] }, { state: 'x' }, []]) {
|
|
324
|
-
expect((await put(body)).status).toBe(400);
|
|
325
|
-
}
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
test('a valid state round-trips through the store', async () => {
|
|
329
|
-
const res: Response = await put({ state: { sidebar: 'open', n: 3 } });
|
|
330
|
-
expect(res.status).toBe(200);
|
|
331
|
-
const read = (await getSessionState({ params: { sessionId: 'state-test' } } as unknown as ActionFunctionArgs) as unknown as Response);
|
|
332
|
-
expect(await read.json()).toMatchObject({ sessionId: 'state-test', state: { sidebar: 'open', n: 3 } });
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
test('a missing id on the read is a 400', async () => {
|
|
336
|
-
expect((await getSessionState({ params: {} } as unknown as ActionFunctionArgs)).status).toBe(400);
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
|
|
340
323
|
describe('markSeen', () => {
|
|
341
324
|
test('a missing id is a 400', async () => {
|
|
342
325
|
expect((await markSeen({ params: {} } as unknown as ActionFunctionArgs)).status).toBe(400);
|
|
@@ -158,6 +158,46 @@ export async function archiveSession({ request, params }: ActionFunctionArgs) {
|
|
|
158
158
|
return json({ success: true, sessionId, archived });
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
/**
|
|
162
|
+
* POST /api/sessions/:sessionId/pin — toggle whether a session leads its
|
|
163
|
+
* folder's list.
|
|
164
|
+
*
|
|
165
|
+
* The row itself is never touched: this is an order preference, keyed by the
|
|
166
|
+
* session id in `pinned_sessions` (numeric in mock mode, omp UUID in real
|
|
167
|
+
* mode). Persisting it here is what makes the pin survive a reload, a closed
|
|
168
|
+
* tab and a second Kabmo instance — a client-side flag would not.
|
|
169
|
+
*/
|
|
170
|
+
export async function pinSession({ request, params }: ActionFunctionArgs) {
|
|
171
|
+
if (request.method !== 'POST') {
|
|
172
|
+
return methodNotAllowed({ request, params });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const db = await getDb();
|
|
176
|
+
const sessionId = params.sessionId;
|
|
177
|
+
if (!sessionId) {
|
|
178
|
+
return json({ error: 'Missing session id' }, { status: 400 });
|
|
179
|
+
}
|
|
180
|
+
// A pending `new-…` chat has no row on any future scan; pinning the
|
|
181
|
+
// placeholder id would store a preference that can never apply.
|
|
182
|
+
if (sessionId.startsWith('new-')) {
|
|
183
|
+
return json({ error: 'This chat has not been created yet.', code: 'session_pending' }, { status: 400 });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const formData = await request.formData();
|
|
187
|
+
const pinned = formData.get('pinned') === 'true';
|
|
188
|
+
|
|
189
|
+
if (pinned) {
|
|
190
|
+
await db.run('INSERT OR IGNORE INTO pinned_sessions (session_id) VALUES (?)', [sessionId]);
|
|
191
|
+
} else {
|
|
192
|
+
await db.run('DELETE FROM pinned_sessions WHERE session_id = ?', [sessionId]);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// The row moved inside its folder, so the structure the sidebar renders
|
|
196
|
+
// changed.
|
|
197
|
+
emitRealtimeSignal('sidebar-structure');
|
|
198
|
+
return json({ success: true, sessionId, pinned });
|
|
199
|
+
}
|
|
200
|
+
|
|
161
201
|
const MAX_SESSION_NAME_LENGTH = 200;
|
|
162
202
|
|
|
163
203
|
/**
|
|
@@ -270,68 +310,6 @@ export async function renameWithAi({ request, params }: ActionFunctionArgs) {
|
|
|
270
310
|
return json({ success: true, sessionId, name: result.title });
|
|
271
311
|
}
|
|
272
312
|
|
|
273
|
-
/**
|
|
274
|
-
* GET /api/sessions/:sessionId/state — load the persisted per-session UI
|
|
275
|
-
* state blob. Keyed by the session id (numeric in mock mode, omp session
|
|
276
|
-
* UUID string in real mode), same keying as `archived_sessions`.
|
|
277
|
-
*/
|
|
278
|
-
export async function getSessionState({ params }: LoaderFunctionArgs) {
|
|
279
|
-
const sessionId = params.sessionId;
|
|
280
|
-
if (!sessionId) {
|
|
281
|
-
return json({ error: 'Missing session id' }, { status: 400 });
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
const db = await getDb();
|
|
285
|
-
const row = await db.get(
|
|
286
|
-
'SELECT state FROM session_ui_state WHERE session_id = ?',
|
|
287
|
-
[sessionId],
|
|
288
|
-
);
|
|
289
|
-
|
|
290
|
-
let state: Record<string, unknown> = {};
|
|
291
|
-
if (row && typeof row.state === 'string' && row.state) {
|
|
292
|
-
try {
|
|
293
|
-
const parsed = JSON.parse(row.state);
|
|
294
|
-
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
295
|
-
state = parsed as Record<string, unknown>;
|
|
296
|
-
}
|
|
297
|
-
} catch {
|
|
298
|
-
// Corrupt blob — treat as empty state so the session still opens.
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return json({ sessionId, state });
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* POST /api/sessions/:sessionId/state — persist the per-session UI state
|
|
307
|
-
* blob. The body is `{ state: <arbitrary JSON object> }`; the client sends
|
|
308
|
-
* its full state map so the endpoint stays a dumb key/value store.
|
|
309
|
-
*/
|
|
310
|
-
export async function putSessionState({ request, params }: ActionFunctionArgs) {
|
|
311
|
-
if (request.method !== 'POST') {
|
|
312
|
-
return methodNotAllowed({ request, params });
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const sessionId = params.sessionId;
|
|
316
|
-
if (!sessionId) {
|
|
317
|
-
return json({ error: 'Missing session id' }, { status: 400 });
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const body = (await request.json()) as { state?: unknown };
|
|
321
|
-
if (!body || typeof body !== 'object' || Array.isArray(body) || typeof body.state !== 'object' || body.state === null || Array.isArray(body.state)) {
|
|
322
|
-
return json({ error: 'Invalid body: expected { state: object }' }, { status: 400 });
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
const db = await getDb();
|
|
326
|
-
await db.run(
|
|
327
|
-
`INSERT OR REPLACE INTO session_ui_state (session_id, state, updated_at)
|
|
328
|
-
VALUES (?, ?, CURRENT_TIMESTAMP)`,
|
|
329
|
-
[sessionId, JSON.stringify(body.state)],
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
return json({ success: true, sessionId });
|
|
333
|
-
}
|
|
334
|
-
|
|
335
313
|
/**
|
|
336
314
|
* POST /api/sessions/:sessionId/stream-seen — acknowledge the session's
|
|
337
315
|
* one-shot stream badge (`finish` / `abort`). Called when the
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The two keyspaces of the client-owned UI state: a real chat stores in
|
|
8
|
+
* `session_ui_state`, a folder workspace session stores in
|
|
9
|
+
* `workspace_ui_state`. One route, one shape, and never the other table.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
13
|
+
import { getDb } from '@/server/db.server';
|
|
14
|
+
import type { DbClient } from '@kabmo-labs/kabmo-db/client';
|
|
15
|
+
import type { ActionFunctionArgs } from '@kabmo-labs/kabmo-http';
|
|
16
|
+
import { getSessionState, putSessionState } from '@/server/routes/sessions/state';
|
|
17
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
18
|
+
|
|
19
|
+
let db: DbClient;
|
|
20
|
+
|
|
21
|
+
beforeEach(async () => {
|
|
22
|
+
await isolateDb();
|
|
23
|
+
db = await getDb();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
afterEach(async () => {
|
|
27
|
+
await releaseDb();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
function jsonRequest(method: string, body: unknown): Request {
|
|
31
|
+
return new Request('http://localhost/api/x', {
|
|
32
|
+
method,
|
|
33
|
+
headers: { 'content-type': 'application/json' },
|
|
34
|
+
body: JSON.stringify(body),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe('per-session UI state', () => {
|
|
39
|
+
const put = async (body: unknown): Promise<Response> =>
|
|
40
|
+
putSessionState({ request: jsonRequest('POST', body), params: { sessionId: 'state-test' } } as unknown as ActionFunctionArgs) as unknown as Response;
|
|
41
|
+
|
|
42
|
+
test('a missing id is a 400', async () => {
|
|
43
|
+
const res = (await putSessionState({ request: jsonRequest('POST', { state: {} }),
|
|
44
|
+
params: {},
|
|
45
|
+
} as unknown as ActionFunctionArgs) as unknown as Response);
|
|
46
|
+
expect(res.status).toBe(400);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test('a wrong verb is a 405', async () => {
|
|
50
|
+
const res = (await putSessionState({ request: jsonRequest('PUT', { state: {} }),
|
|
51
|
+
params: { sessionId: 'state-test' },
|
|
52
|
+
} as unknown as ActionFunctionArgs) as unknown as Response);
|
|
53
|
+
expect(res.status).toBe(405);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('only an object state is accepted', async () => {
|
|
57
|
+
for (const body of [{}, { state: null }, { state: [] }, { state: 'x' }, []]) {
|
|
58
|
+
expect((await put(body)).status).toBe(400);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test('a valid state round-trips through the store', async () => {
|
|
63
|
+
const res: Response = await put({ state: { sidebar: 'open', n: 3 } });
|
|
64
|
+
expect(res.status).toBe(200);
|
|
65
|
+
const read = (await getSessionState({ params: { sessionId: 'state-test' } } as unknown as ActionFunctionArgs) as unknown as Response);
|
|
66
|
+
expect(await read.json()).toMatchObject({ sessionId: 'state-test', state: { sidebar: 'open', n: 3 } });
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('a missing id on the read is a 400', async () => {
|
|
70
|
+
expect((await getSessionState({ params: {} } as unknown as ActionFunctionArgs)).status).toBe(400);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('a workspace id round-trips through its own table', async () => {
|
|
74
|
+
const workspaceId = 'workspace-4242';
|
|
75
|
+
const write = (await putSessionState({
|
|
76
|
+
request: jsonRequest('POST', { state: { layout: { activeRightPanel: 'git' } } }),
|
|
77
|
+
params: { sessionId: workspaceId },
|
|
78
|
+
} as unknown as ActionFunctionArgs)) as Response;
|
|
79
|
+
expect(write.status).toBe(200);
|
|
80
|
+
|
|
81
|
+
const read = (await getSessionState({ params: { sessionId: workspaceId } } as unknown as ActionFunctionArgs)) as Response;
|
|
82
|
+
expect(await read.json()).toMatchObject({
|
|
83
|
+
sessionId: workspaceId,
|
|
84
|
+
state: { layout: { activeRightPanel: 'git' } },
|
|
85
|
+
});
|
|
86
|
+
expect(await db.get('SELECT state FROM workspace_ui_state WHERE workspace_id = ?', [workspaceId])).toBeTruthy();
|
|
87
|
+
expect(await db.get('SELECT state FROM session_ui_state WHERE session_id = ?', [workspaceId])).toBeNull();
|
|
88
|
+
});
|
|
89
|
+
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The client-owned UI state blob, under one route for two keyspaces.
|
|
8
|
+
*
|
|
9
|
+
* A real chat stores in `session_ui_state`; a folder's workspace session
|
|
10
|
+
* (`workspace-<folderId>`) stores the same shape in `workspace_ui_state`, so
|
|
11
|
+
* the client keeps one store and one debounce, and a folder's panel state can
|
|
12
|
+
* never be mistaken for a session's by delete, archive or the sidebar scan.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { json } from '@kabmo-labs/kabmo-http';
|
|
16
|
+
import type { ActionFunctionArgs, LoaderFunctionArgs } from '@kabmo-labs/kabmo-http';
|
|
17
|
+
import { methodNotAllowed } from '@/server/lib/route-adapter';
|
|
18
|
+
import { getDb } from '@/server/db.server';
|
|
19
|
+
import { isWorkspaceSessionId } from '@/shared/lib/workspace/workspace-session';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* GET /api/sessions/:sessionId/state — load the persisted UI-state blob, by
|
|
23
|
+
* session id or by the synthetic workspace id.
|
|
24
|
+
*/
|
|
25
|
+
export async function getSessionState({ params }: LoaderFunctionArgs) {
|
|
26
|
+
const sessionId = params.sessionId;
|
|
27
|
+
if (!sessionId) {
|
|
28
|
+
return json({ error: 'Missing session id' }, { status: 400 });
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const db = await getDb();
|
|
32
|
+
const workspace = isWorkspaceSessionId(sessionId);
|
|
33
|
+
const row = await db.get(
|
|
34
|
+
workspace
|
|
35
|
+
? 'SELECT state FROM workspace_ui_state WHERE workspace_id = ?'
|
|
36
|
+
: 'SELECT state FROM session_ui_state WHERE session_id = ?',
|
|
37
|
+
[sessionId],
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
let state: Record<string, unknown> = {};
|
|
41
|
+
if (row && typeof row.state === 'string' && row.state) {
|
|
42
|
+
try {
|
|
43
|
+
const parsed = JSON.parse(row.state);
|
|
44
|
+
if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
|
|
45
|
+
state = parsed as Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
} catch {
|
|
48
|
+
// Corrupt blob — treat as empty state so the session still opens.
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return json({ sessionId, state });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* POST /api/sessions/:sessionId/state — persist the per-session UI state
|
|
57
|
+
* blob. The body is `{ state: <arbitrary JSON object> }`; the client sends
|
|
58
|
+
* its full state map so the endpoint stays a dumb key/value store.
|
|
59
|
+
*/
|
|
60
|
+
export async function putSessionState({ request, params }: ActionFunctionArgs) {
|
|
61
|
+
if (request.method !== 'POST') {
|
|
62
|
+
return methodNotAllowed({ request, params });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const sessionId = params.sessionId;
|
|
66
|
+
if (!sessionId) {
|
|
67
|
+
return json({ error: 'Missing session id' }, { status: 400 });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const body = (await request.json()) as { state?: unknown };
|
|
71
|
+
if (!body || typeof body !== 'object' || Array.isArray(body) || typeof body.state !== 'object' || body.state === null || Array.isArray(body.state)) {
|
|
72
|
+
return json({ error: 'Invalid body: expected { state: object }' }, { status: 400 });
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const db = await getDb();
|
|
76
|
+
await db.run(
|
|
77
|
+
isWorkspaceSessionId(sessionId)
|
|
78
|
+
? `INSERT OR REPLACE INTO workspace_ui_state (workspace_id, state, updated_at)
|
|
79
|
+
VALUES (?, ?, CURRENT_TIMESTAMP)`
|
|
80
|
+
: `INSERT OR REPLACE INTO session_ui_state (session_id, state, updated_at)
|
|
81
|
+
VALUES (?, ?, CURRENT_TIMESTAMP)`,
|
|
82
|
+
[sessionId, JSON.stringify(body.state)],
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return json({ success: true, sessionId });
|
|
86
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the composer will accept: the per-file byte ceiling and the text-inline
|
|
8
|
+
* budget.
|
|
9
|
+
*
|
|
10
|
+
* Both are read on two different paths — a live upload (`addFiles`) and a
|
|
11
|
+
* REPLAY of persisted state (a seeded New Chat row, a queued item, a retry) —
|
|
12
|
+
* and a limit that only one path enforced is how an attachment sat as a chip
|
|
13
|
+
* until the send failed.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { describe, expect, test } from 'bun:test';
|
|
17
|
+
import type { Attachment } from '@/shared/types';
|
|
18
|
+
import {
|
|
19
|
+
applyTextAttachmentBudget,
|
|
20
|
+
describeOversizedAttachments,
|
|
21
|
+
isOversizedAttachment,
|
|
22
|
+
MAX_ATTACHMENT_BYTES,
|
|
23
|
+
oversizedAttachments,
|
|
24
|
+
} from '@/shared/lib/chat/attachment-budget';
|
|
25
|
+
|
|
26
|
+
function liveFile(name: string, body: string, type = ''): File {
|
|
27
|
+
return new File([body], name, { type });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** What the queue row and committed history actually hold. */
|
|
31
|
+
function replayed(attachments: Attachment[]): Attachment[] {
|
|
32
|
+
return JSON.parse(JSON.stringify(attachments)) as Attachment[];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe('inline budget', () => {
|
|
36
|
+
test('counts replayed attachments, so repeated drops stop at the cap', () => {
|
|
37
|
+
const existing = Array.from({ length: 10 }, (_, i) => ({ name: `f${i}.md`, type: 'text/markdown', size: 10, content: 'x' }));
|
|
38
|
+
const { accepted, skipped } = applyTextAttachmentBudget([liveFile('extra.md', 'x', 'text/markdown')], existing);
|
|
39
|
+
expect(accepted).toEqual([]);
|
|
40
|
+
expect(skipped.map((f) => f.name)).toEqual(['extra.md']);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('lets an image through when the text budget is spent', () => {
|
|
44
|
+
const existing = Array.from({ length: 10 }, (_, i) => ({ name: `f${i}.md`, type: 'text/markdown', size: 10, content: 'x' }));
|
|
45
|
+
const { accepted, skipped } = applyTextAttachmentBudget([liveFile('shot.png', 'x', 'image/png')], existing);
|
|
46
|
+
expect(accepted.map((f) => f.name)).toEqual(['shot.png']);
|
|
47
|
+
expect(skipped).toEqual([]);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('per-file byte ceiling', () => {
|
|
52
|
+
const limit = `${Math.round(MAX_ATTACHMENT_BYTES / 1024 / 1024)} MB`;
|
|
53
|
+
|
|
54
|
+
test('accepts exactly the ceiling and refuses the next byte', () => {
|
|
55
|
+
expect(isOversizedAttachment({ size: MAX_ATTACHMENT_BYTES })).toBe(false);
|
|
56
|
+
expect(isOversizedAttachment({ size: MAX_ATTACHMENT_BYTES + 1 })).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('names one refused file and counts a batch', () => {
|
|
60
|
+
const big = liveFile('photo.jpg', 'x', 'image/jpeg');
|
|
61
|
+
expect(describeOversizedAttachments([])).toBeNull();
|
|
62
|
+
expect(describeOversizedAttachments([big])).toBe(`"photo.jpg" was not attached — the largest allowed file is ${limit}.`);
|
|
63
|
+
expect(describeOversizedAttachments([big, big])).toBe(`2 files were not attached — the largest allowed file is ${limit}.`);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('reads a replayed attachment by its persisted size, not a live File', () => {
|
|
67
|
+
const rows = replayed([
|
|
68
|
+
{ id: 'ok', name: 'ok.jpg', type: 'image/jpeg', size: MAX_ATTACHMENT_BYTES, preview: '' },
|
|
69
|
+
{ id: 'big', name: 'big.jpg', type: 'image/jpeg', size: MAX_ATTACHMENT_BYTES + 1, preview: '' },
|
|
70
|
+
]);
|
|
71
|
+
expect(oversizedAttachments(rows)).toEqual([{ name: 'big.jpg' }]);
|
|
72
|
+
expect(oversizedAttachments([])).toEqual([]);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* What the composer will accept as an attachment.
|
|
8
|
+
*
|
|
9
|
+
* Two different ceilings, for two different reasons:
|
|
10
|
+
*
|
|
11
|
+
* - `MAX_ATTACHMENT_BYTES` is per FILE and applies to every attachment. A
|
|
12
|
+
* binary is refused at attach time, because an image travels base64-inline
|
|
13
|
+
* to the omp RPC (20 MB decoded per image there) and a file that only fails
|
|
14
|
+
* after the prompt is typed is a prompt the user cannot send. 10 MB decoded
|
|
15
|
+
* stays under that ceiling once base64 adds its third.
|
|
16
|
+
* - The TEXT budget is about the prompt, not the wire: text contents are
|
|
17
|
+
* inlined, so a directory drop could otherwise push megabytes into one
|
|
18
|
+
* request.
|
|
19
|
+
*
|
|
20
|
+
* The same sentence is used by every refusal path — the composer's notice and
|
|
21
|
+
* the send-time gate on a replayed attachment — so the two cannot name
|
|
22
|
+
* different limits.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import type { Attachment } from '@/shared/types';
|
|
26
|
+
import { attachmentName, attachmentSize, isTextAttachment } from '@/shared/lib/chat/attachments';
|
|
27
|
+
|
|
28
|
+
export const MAX_ATTACHED_TEXT_BYTES = 256 * 1024;
|
|
29
|
+
export const MAX_ATTACHED_TEXT_FILES = 10;
|
|
30
|
+
|
|
31
|
+
/** Largest single file the composer accepts. See the module header. */
|
|
32
|
+
export const MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;
|
|
33
|
+
|
|
34
|
+
export interface AttachmentBudget {
|
|
35
|
+
/** Files that fit the inline budget and may be attached. */
|
|
36
|
+
accepted: File[];
|
|
37
|
+
/** Text files refused because the budget was already spent. */
|
|
38
|
+
skipped: File[];
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Whether one file is larger than the composer accepts at all. */
|
|
42
|
+
export function isOversizedAttachment(file: Pick<File, 'size'>): boolean {
|
|
43
|
+
return file.size > MAX_ATTACHMENT_BYTES;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** User-facing reason files were refused for their size, or null when none were. */
|
|
47
|
+
export function describeOversizedAttachments(oversized: { name: string }[]): string | null {
|
|
48
|
+
if (oversized.length === 0) return null;
|
|
49
|
+
const limit = `${Math.round(MAX_ATTACHMENT_BYTES / 1024 / 1024)} MB`;
|
|
50
|
+
if (oversized.length === 1) return `"${oversized[0].name}" was not attached — the largest allowed file is ${limit}.`;
|
|
51
|
+
return `${oversized.length} files were not attached — the largest allowed file is ${limit}.`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Attachments past the per-file ceiling, with the name a refusal names.
|
|
56
|
+
*
|
|
57
|
+
* The composer refuses an oversized upload at attach time. This second read
|
|
58
|
+
* exists for the replay paths — a seeded New Chat row, a queued item, a retry —
|
|
59
|
+
* which carry the persisted `size` and no live `File`, so `addFiles` never saw
|
|
60
|
+
* them.
|
|
61
|
+
*/
|
|
62
|
+
export function oversizedAttachments(
|
|
63
|
+
attachments: Pick<Attachment, 'name' | 'size' | 'file'>[],
|
|
64
|
+
): { name: string }[] {
|
|
65
|
+
return attachments
|
|
66
|
+
.filter((attachment) => attachmentSize(attachment) > MAX_ATTACHMENT_BYTES)
|
|
67
|
+
.map((attachment) => ({ name: attachmentName(attachment) }));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** User-facing reason for a refusal, shared by every composer attach path. */
|
|
71
|
+
export function describeAttachmentBudget(skipped: File[]): string {
|
|
72
|
+
const limit = `${MAX_ATTACHED_TEXT_FILES} text files / ${Math.round(MAX_ATTACHED_TEXT_BYTES / 1024)} KB total`;
|
|
73
|
+
if (skipped.length === 1) return `"${skipped[0].name}" was not attached — inline limit is ${limit}.`;
|
|
74
|
+
return `${skipped.length} text files were not attached — inline limit is ${limit}.`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Gate a batch of incoming files against the text-inline budget.
|
|
79
|
+
*
|
|
80
|
+
* Only text files are gated: their contents are inlined into the prompt, so a
|
|
81
|
+
* directory drop can otherwise push megabytes into a single request. Images and
|
|
82
|
+
* other binaries travel as payloads and are capped by the per-file ceiling.
|
|
83
|
+
*
|
|
84
|
+
* The budget spans the whole composer, not the batch — `existing` counts too,
|
|
85
|
+
* so three successive drops of four text files stop at ten.
|
|
86
|
+
*/
|
|
87
|
+
export function applyTextAttachmentBudget(
|
|
88
|
+
files: File[],
|
|
89
|
+
existing: { name?: string; type?: string; size?: number; file?: File }[],
|
|
90
|
+
): AttachmentBudget {
|
|
91
|
+
const accepted: File[] = [];
|
|
92
|
+
const skipped: File[] = [];
|
|
93
|
+
let textFiles = existing.filter((a) => isTextAttachment(a)).length;
|
|
94
|
+
let textBytes = existing.reduce((total, a) => (isTextAttachment(a) ? attachmentSize(a) : total), 0);
|
|
95
|
+
|
|
96
|
+
for (const file of files) {
|
|
97
|
+
if (!isTextAttachment({ name: file.name, type: file.type, file })) {
|
|
98
|
+
accepted.push(file);
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (textFiles >= MAX_ATTACHED_TEXT_FILES || textBytes + file.size > MAX_ATTACHED_TEXT_BYTES) {
|
|
102
|
+
skipped.push(file);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
textFiles += 1;
|
|
106
|
+
textBytes += file.size;
|
|
107
|
+
accepted.push(file);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return { accepted, skipped };
|
|
111
|
+
}
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
import { describe, expect, test } from 'bun:test';
|
|
18
18
|
import type { Attachment } from '@/shared/types';
|
|
19
19
|
import {
|
|
20
|
-
applyTextAttachmentBudget,
|
|
21
20
|
attachmentHasPayload,
|
|
22
21
|
attachmentImage,
|
|
23
22
|
attachmentName,
|
|
@@ -183,22 +182,6 @@ describe('text contents', () => {
|
|
|
183
182
|
});
|
|
184
183
|
});
|
|
185
184
|
|
|
186
|
-
describe('inline budget', () => {
|
|
187
|
-
test('counts replayed attachments, so repeated drops stop at the cap', () => {
|
|
188
|
-
const existing = Array.from({ length: 10 }, (_, i) => ({ name: `f${i}.md`, type: 'text/markdown', size: 10, content: 'x' }));
|
|
189
|
-
const { accepted, skipped } = applyTextAttachmentBudget([liveFile('extra.md', 'x', 'text/markdown')], existing);
|
|
190
|
-
expect(accepted).toEqual([]);
|
|
191
|
-
expect(skipped.map((f) => f.name)).toEqual(['extra.md']);
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
test('lets an image through when the text budget is spent', () => {
|
|
195
|
-
const existing = Array.from({ length: 10 }, (_, i) => ({ name: `f${i}.md`, type: 'text/markdown', size: 10, content: 'x' }));
|
|
196
|
-
const { accepted, skipped } = applyTextAttachmentBudget([liveFile('shot.png', 'x', 'image/png')], existing);
|
|
197
|
-
expect(accepted.map((f) => f.name)).toEqual(['shot.png']);
|
|
198
|
-
expect(skipped).toEqual([]);
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
|
|
202
185
|
describe('content sniffing for unclassified files', () => {
|
|
203
186
|
test('a file whose name and MIME say nothing is recognised as text', async () => {
|
|
204
187
|
// A promised-file drag from another app arrives like this: real bytes, a
|
|
@@ -27,9 +27,6 @@ import { TEXT_FILE_EXTENSIONS, isTextMimeType } from '@/shared/lib/chat/text-fil
|
|
|
27
27
|
|
|
28
28
|
export { looksLikeTextFile } from '@/shared/lib/chat/text-file';
|
|
29
29
|
|
|
30
|
-
export const MAX_ATTACHED_TEXT_BYTES = 256 * 1024;
|
|
31
|
-
export const MAX_ATTACHED_TEXT_FILES = 10;
|
|
32
|
-
|
|
33
30
|
export interface AttachedTextFileData {
|
|
34
31
|
name: string;
|
|
35
32
|
mimeType: string;
|
|
@@ -156,56 +153,6 @@ export function toAttachmentList(
|
|
|
156
153
|
}));
|
|
157
154
|
}
|
|
158
155
|
|
|
159
|
-
export interface AttachmentBudget {
|
|
160
|
-
/** Files that fit the inline budget and may be attached. */
|
|
161
|
-
accepted: File[];
|
|
162
|
-
/** Text files refused because the budget was already spent. */
|
|
163
|
-
skipped: File[];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/** User-facing reason for a refusal, shared by every composer attach path. */
|
|
167
|
-
export function describeAttachmentBudget(skipped: File[]): string {
|
|
168
|
-
const limit = `${MAX_ATTACHED_TEXT_FILES} text files / ${Math.round(MAX_ATTACHED_TEXT_BYTES / 1024)} KB total`;
|
|
169
|
-
if (skipped.length === 1) return `"${skipped[0].name}" was not attached — inline limit is ${limit}.`;
|
|
170
|
-
return `${skipped.length} text files were not attached — inline limit is ${limit}.`;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Gate a batch of incoming files against the text-inline budget.
|
|
175
|
-
*
|
|
176
|
-
* Only text files are gated: their contents are inlined into the prompt, so a
|
|
177
|
-
* directory drop can otherwise push megabytes into a single request. Images and
|
|
178
|
-
* other binaries travel as payloads and are capped by the caller's own limit.
|
|
179
|
-
*
|
|
180
|
-
* The budget spans the whole composer, not the batch — `existing` counts too,
|
|
181
|
-
* so three successive drops of four text files stop at ten.
|
|
182
|
-
*/
|
|
183
|
-
export function applyTextAttachmentBudget(
|
|
184
|
-
files: File[],
|
|
185
|
-
existing: { name?: string; type?: string; size?: number; file?: File }[],
|
|
186
|
-
): AttachmentBudget {
|
|
187
|
-
const accepted: File[] = [];
|
|
188
|
-
const skipped: File[] = [];
|
|
189
|
-
let textFiles = existing.filter((a) => isTextAttachment(a)).length;
|
|
190
|
-
let textBytes = existing.reduce((total, a) => (isTextAttachment(a) ? attachmentSize(a) : total), 0);
|
|
191
|
-
|
|
192
|
-
for (const file of files) {
|
|
193
|
-
if (!isTextAttachment({ name: file.name, type: file.type, file })) {
|
|
194
|
-
accepted.push(file);
|
|
195
|
-
continue;
|
|
196
|
-
}
|
|
197
|
-
if (textFiles >= MAX_ATTACHED_TEXT_FILES || textBytes + file.size > MAX_ATTACHED_TEXT_BYTES) {
|
|
198
|
-
skipped.push(file);
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
textFiles += 1;
|
|
202
|
-
textBytes += file.size;
|
|
203
|
-
accepted.push(file);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
return { accepted, skipped };
|
|
207
|
-
}
|
|
208
|
-
|
|
209
156
|
function languageForFile(name: string): string {
|
|
210
157
|
const extension = getFileExtension(name);
|
|
211
158
|
if (extension === 'md' || extension === 'markdown' || extension === 'mdx') return 'markdown';
|