@kabmo-labs/kabmo 0.58.1 → 0.59.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 +513 -495
- package/dist/client/static/js/{Body-ysmhxbvk.js → Body-5yedtmnk.js} +3 -3
- package/dist/client/static/js/{CsvGrid-w90pxyn2.js → CsvGrid-39m8pp1c.js} +2 -2
- package/dist/client/static/js/{DocxView-evxn6kaq.js → DocxView-vd99cv12.js} +3 -3
- package/dist/client/static/js/{DrawioView-tmdevwf4.js → DrawioView-6nq4412n.js} +2 -2
- package/dist/client/static/js/{HtmlPreview-bpsn2z9p.js → HtmlPreview-cs51gszy.js} +1 -1
- package/dist/client/static/js/ImageView-nc2n0w6s.js +1 -0
- package/dist/client/static/js/LayoutWrapper-j7786frq.js +2 -0
- package/dist/client/static/js/MergeDiffView-0rn5zsy5.js +1 -0
- package/dist/client/static/js/Modal-7ag7a9qq.js +60 -0
- package/dist/client/static/js/{PdfView-txxn6qff.js → PdfView-0zab721q.js} +1 -1
- package/dist/client/static/js/SessionsView-t9rhx472.js +1 -0
- package/dist/client/static/js/{SheetView-52b33e6f.js → SheetView-2wdn5hkd.js} +11 -11
- package/dist/client/static/js/{SvgPreview-hrk4pfm1.js → SvgPreview-fmrfxd7z.js} +1 -1
- package/dist/client/static/js/{abnfDiagram-O67JEVCF-at77sybc.js → abnfDiagram-O67JEVCF-41scfh9v.js} +1 -1
- package/dist/client/static/js/architecture-7GRP2DOG-bwn1drdz.js +1 -0
- package/dist/client/static/js/{architectureDiagram-NJMV4G6O-raw33jgg.js → architectureDiagram-NJMV4G6O-fp6etjvt.js} +3 -3
- package/dist/client/static/js/{astro-qha7sceh.js → astro-ryr2ajmg.js} +1 -1
- package/dist/client/static/js/bash-zknkkwkw.js +1 -0
- package/dist/client/static/js/{blockDiagram-BEXU5L5S-b6e90fbk.js → blockDiagram-BEXU5L5S-pespk9mt.js} +4 -4
- package/dist/client/static/js/c-0w02jkxb.js +1 -0
- package/dist/client/static/js/{c4Diagram-YGBWAQC7-msg9y1c6.js → c4Diagram-YGBWAQC7-rt4z91dx.js} +2 -2
- package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-jmrd1h8r.js → classDiagram-v2-NBCMYWYE-6bzaq8sd.js} +4 -4
- package/dist/client/static/js/{cose-bilkent-JH36ORCC-na65ebq3.js → cose-bilkent-JH36ORCC-z3fhgcba.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-9xkkw71m.js → cynefinDiagram-VND7K2PF-8endeh4p.js} +2 -2
- package/dist/client/static/js/{dagre-6A5THRUB-p59f19tv.js → dagre-6A5THRUB-2a2f32dv.js} +2 -2
- package/dist/client/static/js/{diagram-22UHCM2B-2e2rcvn7.js → diagram-22UHCM2B-wgbyr6b7.js} +9 -9
- package/dist/client/static/js/{diagram-3UASUU5V-r9ds8vgr.js → diagram-3UASUU5V-5122b41x.js} +1 -1
- package/dist/client/static/js/{diagram-ATOU4E4O-jgwxv7v8.js → diagram-ATOU4E4O-1gt9fr7e.js} +3 -3
- package/dist/client/static/js/{diagram-CDSNMT55-20m35eqq.js → diagram-CDSNMT55-v6hs59jb.js} +4 -4
- package/dist/client/static/js/{diagram-MLGK6HIB-vt3kxt2m.js → diagram-MLGK6HIB-yey2m5nm.js} +1 -1
- package/dist/client/static/js/{diagram-MPIPVDR6-c47rgxf1.js → diagram-MPIPVDR6-hg4f3q4d.js} +2 -2
- package/dist/client/static/js/{dockerfile-gtcyey0q.js → dockerfile-56tfnp5r.js} +1 -1
- package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-aszw3xy3.js → ebnfDiagram-ZINNZB2B-2mhc9aar.js} +1 -1
- package/dist/client/static/js/{elixir-w92v180e.js → elixir-fyxw6d70.js} +1 -1
- package/dist/client/static/js/{elk-276RUBZZ-gbvr3gry.js → elk-276RUBZZ-wedtvz9y.js} +2 -2
- package/dist/client/static/js/{erDiagram-OPXOYQCR-1hqca8qe.js → erDiagram-OPXOYQCR-1kysnby9.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-vd4z6bvy.js +1 -0
- package/dist/client/static/js/{ganttDiagram-FUAMR5RP-07v22te5.js → ganttDiagram-FUAMR5RP-j4g65rpm.js} +3 -3
- package/dist/client/static/js/gitGraph-4MIJSDKK-mvqq7tcs.js +1 -0
- package/dist/client/static/js/{gitGraphDiagram-X574FWY7-y068jtz9.js → gitGraphDiagram-X574FWY7-vcwmj4b3.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-r8d4bk86.js → index-10vzyga1.js} +2 -2
- package/dist/client/static/js/index-1mkn5fbf.js +481 -0
- package/dist/client/static/js/{index-medk4f18.js → index-2h7xh93h.js} +2 -2
- package/dist/client/static/js/{index-fhtnvqgf.js → index-3j2he86h.js} +2 -2
- package/dist/client/static/js/{index-zhgh7a31.js → index-3kedv94b.js} +2 -2
- package/dist/client/static/js/{index-374xq5a4.js → index-42k78whj.js} +1 -1
- package/dist/client/static/js/{index-c9aqx3ht.js → index-42q5gg7t.js} +1 -1
- 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-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-th61y26d.js → index-69mnn71v.js} +2 -2
- package/dist/client/static/js/index-6vbra7p9.js +1 -0
- package/dist/client/static/js/{index-007sewcn.js → index-7enfdvh0.js} +2 -2
- package/dist/client/static/js/{index-gaa39w5q.js → index-8tzt0dek.js} +2 -2
- package/dist/client/static/js/{index-ewryzs4g.js → index-92h38pwg.js} +2 -2
- package/dist/client/static/js/{index-vw8b29ek.js → index-9mgpbwfr.js} +1 -1
- package/dist/client/static/js/{index-80kx6dm6.js → index-a3bpmw2r.js} +2 -2
- package/dist/client/static/js/{index-fv7nybnf.js → index-a70sk36c.js} +2 -2
- package/dist/client/static/js/index-c5401dqs.js +4 -0
- package/dist/client/static/js/{index-xmg1x6zv.js → index-csxnqgzw.js} +5 -5
- package/dist/client/static/js/{index-qefssj0m.js → index-d201jvs9.js} +1 -1
- package/dist/client/static/js/{index-y0f3wbc3.js → index-d9sfavx1.js} +2 -2
- package/dist/client/static/js/{index-5hvt233n.js → index-db6s66jr.js} +2 -2
- package/dist/client/static/js/index-dbsy29gn.js +2 -0
- package/dist/client/static/js/{index-j830qk07.js → index-dw9epydj.js} +2 -2
- package/dist/client/static/js/{index-s4dpkds5.js → index-e39m185a.js} +2 -2
- package/dist/client/static/js/{index-dxq1tbwm.js → index-fg0ne74z.js} +2 -2
- package/dist/client/static/js/{index-hb7a7m9m.js → index-fnaq8baz.js} +1 -1
- package/dist/client/static/js/{index-tq3t3qm4.js → index-fsa18ns9.js} +2 -2
- package/dist/client/static/js/{index-wxqcnsrq.js → index-fvphmwkf.js} +2 -2
- package/dist/client/static/js/{index-94d416ee.js → index-gajpd90b.js} +2 -2
- package/dist/client/static/js/{index-rxt8sf9a.js → index-h1xbx74w.js} +2 -2
- package/dist/client/static/js/{index-1e0rt7c6.js → index-hgzf4ask.js} +5 -5
- package/dist/client/static/js/{index-wn28m9h7.js → index-hrez92pw.js} +8 -8
- package/dist/client/static/js/{index-zs7kw0be.js → index-jaf968hx.js} +4 -4
- package/dist/client/static/js/{index-sxag9ptg.js → index-jct0jryd.js} +2 -2
- package/dist/client/static/js/{index-5xxbbzqa.js → index-kt77dwsg.js} +7 -7
- package/dist/client/static/js/{index-8d8ce00v.js → index-m62sf9wn.js} +2 -2
- package/dist/client/static/js/{index-6x0kn8pb.js → index-mhrkjbjq.js} +2 -2
- package/dist/client/static/js/index-mttx9327.css +1 -0
- package/dist/client/static/js/{index-1e710snk.js → index-n7bmqeqz.js} +1 -1
- package/dist/client/static/js/{index-3ymw778n.js → index-ndqtff48.js} +2 -2
- package/dist/client/static/js/{index-cmjyet7w.js → index-nf4hq5tg.js} +27 -27
- package/dist/client/static/js/{index-3p732mvs.js → index-np2rfq06.js} +2 -2
- package/dist/client/static/js/{index-2s17netq.js → index-nwbr15b3.js} +2 -2
- package/dist/client/static/js/{index-nptbz7sv.js → index-pn0ja904.js} +1 -1
- package/dist/client/static/js/{index-azz46nwc.js → index-pr8wsq24.js} +2 -2
- package/dist/client/static/js/{index-7sq6cjt1.js → index-q3k8r0ms.js} +11 -11
- package/dist/client/static/js/{index-an7fq7f6.js → index-qc3de995.js} +1 -1
- package/dist/client/static/js/{index-f61c25vn.js → index-r42f3r1p.js} +3 -3
- package/dist/client/static/js/{index-e4nge3f4.js → index-s7p2wdr1.js} +1 -1
- package/dist/client/static/js/{index-vny4ymjf.js → index-sg65xdey.js} +1 -1
- package/dist/client/static/js/index-skp6991n.js +2 -0
- package/dist/client/static/js/index-spnrx2c0.js +2 -0
- package/dist/client/static/js/{index-fe92hqmb.js → index-sqyvj03y.js} +4 -4
- package/dist/client/static/js/{index-cpp43af3.js → index-tz5ewsza.js} +9 -9
- package/dist/client/static/js/{index-v8xhgfeq.js → index-vs2y8gxr.js} +2 -2
- package/dist/client/static/js/{index-e0kahttb.js → index-vs3g6njv.js} +1 -1
- package/dist/client/static/js/index-wkxsypj1.js +2 -0
- package/dist/client/static/js/{index-gqrt766t.js → index-xqz7bqcn.js} +61 -61
- package/dist/client/static/js/{index-jxsha63v.js → index-y4cx8cqf.js} +2 -2
- package/dist/client/static/js/{index-kzzvrqnv.js → index-y5pkqrga.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-1x83h4k4.js → infoDiagram-VRGFBTTK-7craq9x2.js} +2 -2
- package/dist/client/static/js/ini-62r3vxaf.js +1 -0
- package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-et6z3c28.js → ishikawaDiagram-OU5B5YK6-ncjty2re.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-sw669e7a.js → journeyDiagram-ZHPQQLJL-yx222bzt.js} +2 -2
- 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-z14p8jsx.js → julia-agc5kfvg.js} +1 -1
- package/dist/client/static/js/{kanban-definition-PNTS6WVX-aqxg95kx.js → kanban-definition-PNTS6WVX-a2f84qmn.js} +6 -6
- 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-9vfwthw3.js +12 -0
- package/dist/client/static/js/{mindmap-definition-NLK3R4M7-530anpc4.js → mindmap-definition-NLK3R4M7-fsxysg6f.js} +4 -4
- package/dist/client/static/js/one-dark-pro-7v4by00h.js +1 -0
- package/dist/client/static/js/one-light-5rfzh8p4.js +1 -0
- package/dist/client/static/js/packet-AYTQ26CC-dgpge627.js +1 -0
- package/dist/client/static/js/{pegDiagram-GJSIUBJH-5zar6hvy.js → pegDiagram-GJSIUBJH-77wxmp9g.js} +1 -1
- package/dist/client/static/js/{perl-1na2x6yd.js → perl-v5vbtzgf.js} +1 -1
- package/dist/client/static/js/{php-x75tt7w3.js → php-83qwy98t.js} +1 -1
- package/dist/client/static/js/pie-WAS4IAKB-b8pgsqrd.js +1 -0
- package/dist/client/static/js/{pieDiagram-5QR66LMP-3bx8syvw.js → pieDiagram-5QR66LMP-gvgfhez0.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-yaarpr2e.js → quadrantDiagram-O4NWA36T-9zkbt5h8.js} +2 -2
- 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-ag41q4nt.js → railroadDiagram-XR7U4H2S-w55bsyw6.js} +1 -1
- package/dist/client/static/js/{requirementDiagram-PLB6GJNP-g8sr48h4.js → requirementDiagram-PLB6GJNP-828s1e5g.js} +3 -3
- package/dist/client/static/js/{ruby-3h22qahv.js → ruby-994n5j6e.js} +1 -1
- package/dist/client/static/js/{rust-r27demr5.js → rust-csv5f258.js} +1 -1
- package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-t1wbd1hh.js → sankeyDiagram-IPEJSGJF-34f3fyvg.js} +3 -3
- package/dist/client/static/js/{sass-8bq5r2tz.js → sass-p6g7qdv2.js} +1 -1
- package/dist/client/static/js/{scss-c04ezwnn.js → scss-4j4t3r6y.js} +1 -1
- package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-407mjqty.js → sequenceDiagram-PO4LG4MO-nnta2hn0.js} +7 -7
- package/dist/client/static/js/{sizeCapture-INFHLROL-w38zb9ky.js → sizeCapture-INFHLROL-gpcramga.js} +1 -1
- package/dist/client/static/js/sql-kwpd5w07.js +1 -0
- package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-4cvgymkc.js → stateDiagram-v2-GCMORJYK-3f2en220.js} +3 -3
- package/dist/client/static/js/{svelte-egg3x4tw.js → svelte-bek3h1sz.js} +1 -1
- package/dist/client/static/js/{swimlanes-2SLR337P-w7ts2rzw.js → swimlanes-2SLR337P-jgqt12z9.js} +1 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-xx1z57df.js +8 -0
- package/dist/client/static/js/{timeline-definition-EJHVYXUP-nq46nzy9.js → timeline-definition-EJHVYXUP-sgchcs11.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-q144snzb.js → usecaseDiagram-POWQR4AR-znkg9pkq.js} +15 -15
- package/dist/client/static/js/{vennDiagram-UO4OBE2U-2wemak2p.js → vennDiagram-UO4OBE2U-dncg96ej.js} +4 -4
- package/dist/client/static/js/{vue-d7p4wv35.js → vue-y44m889c.js} +1 -1
- package/dist/client/static/js/wardley-WFR3VGLG-cbqtax1x.js +1 -0
- package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-bb2qvvgr.js → wardleyDiagram-VNRHLVJA-77xz2d49.js} +4 -4
- package/dist/client/static/js/xml-xs6qz3ya.js +1 -0
- package/dist/client/static/js/{xychartDiagram-PMCCYNJV-9dr05fdq.js → xychartDiagram-PMCCYNJV-40j1aqyf.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/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 +8 -1
- package/src/client/components/common/session-row/index.tsx +4 -0
- package/src/client/components/common/session-row/session-row.test.tsx +5 -0
- 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/RevealRow.tsx +36 -5
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +45 -28
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +10 -3
- package/src/client/components/layout/session-sidebar/modern/index.tsx +2 -0
- package/src/client/components/layout/session-sidebar/modern/reveal-row.test.tsx +28 -1
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +27 -11
- 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/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/ThinkingSection.test.tsx +17 -0
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +9 -3
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.test.ts +39 -2
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +19 -4
- 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 +44 -21
- 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 +24 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +14 -3
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +24 -1
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +78 -135
- package/src/client/components/workspace/chat-timeline/chat-input/VoiceButton.tsx +58 -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/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/index.tsx +1 -1
- 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/model-dropdown/CloseButton.tsx +2 -2
- package/src/client/components/workspace/model-dropdown/Fullscreen.tsx +2 -2
- package/src/client/components/workspace/model-dropdown/HarnessTabs.tsx +40 -10
- package/src/client/components/workspace/model-dropdown/Header.tsx +33 -18
- package/src/client/components/workspace/model-dropdown/Panel.tsx +19 -1
- 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 +39 -5
- package/src/client/components/workspace/model-dropdown/index.tsx +20 -47
- package/src/client/components/workspace/model-dropdown/picker-close.test.tsx +34 -4
- 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/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/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/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-ssazqckj.js +0 -1
- package/dist/client/static/js/LayoutWrapper-qwpfq4dq.js +0 -2
- package/dist/client/static/js/MergeDiffView-en6aazw8.js +0 -1
- package/dist/client/static/js/Modal-zjnhj9nb.js +0 -60
- package/dist/client/static/js/SessionsView-eryjtmb2.js +0 -1
- package/dist/client/static/js/architecture-7GRP2DOG-v05ap4e3.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-q2k6afe3.js +0 -1
- package/dist/client/static/js/css-sp1cgdbr.js +0 -1
- package/dist/client/static/js/cynefin-OW5HDTMX-sqv0ze38.js +0 -1
- package/dist/client/static/js/eventmodeling-NTZA5JFV-t4dzf5s7.js +0 -1
- package/dist/client/static/js/flowDiagram-KWPJA3E3-c16xmjyv.js +0 -1
- package/dist/client/static/js/gitGraph-4MIJSDKK-0jq8y0qd.js +0 -1
- package/dist/client/static/js/graphql-qx4tt6ze.js +0 -1
- package/dist/client/static/js/html-5e0g8664.js +0 -1
- package/dist/client/static/js/index-4ddgpqm0.css +0 -1
- package/dist/client/static/js/index-5g2j626a.js +0 -1
- package/dist/client/static/js/index-cc7qbfvn.js +0 -477
- package/dist/client/static/js/index-f27wvdky.js +0 -4
- package/dist/client/static/js/index-m5n0zsft.js +0 -2
- package/dist/client/static/js/index-rqt8mem9.js +0 -2
- package/dist/client/static/js/index-s9k82stc.js +0 -2
- package/dist/client/static/js/index-skwem10a.js +0 -2
- package/dist/client/static/js/index-tv9rn2nd.js +0 -2
- package/dist/client/static/js/info-A6RAGUB7-szttx3v5.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-av46zx4c.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-6cgqsgcf.js +0 -12
- package/dist/client/static/js/one-dark-pro-9hnhtkpr.js +0 -1
- package/dist/client/static/js/one-light-2n5y8592.js +0 -1
- package/dist/client/static/js/packet-AYTQ26CC-401149bv.js +0 -1
- package/dist/client/static/js/pie-WAS4IAKB-bgfv8tfz.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-pw720590.js +0 -1
- package/dist/client/static/js/railroad-74A4TZTK-n2a30ngs.js +0 -1
- package/dist/client/static/js/railroad-abnf-HS5TGJTU-rn5rx9qt.js +0 -1
- package/dist/client/static/js/railroad-ebnf-LZEXJU2U-t4yryhtd.js +0 -1
- package/dist/client/static/js/railroad-peg-WCYAUIDC-c4ebgvrr.js +0 -1
- package/dist/client/static/js/sql-sd00wgem.js +0 -1
- package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-v82nym6b.js +0 -8
- package/dist/client/static/js/treeView-Q6P3EWNA-bxgt5yhm.js +0 -1
- package/dist/client/static/js/treemap-WGGIJYW6-hh3595m0.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-6bza7h1b.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.test.tsx +0 -110
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +0 -86
|
@@ -33,6 +33,7 @@ import { resolveDefaultModel, modelProvider } from '@kabmo-labs/kabmo-harness/co
|
|
|
33
33
|
import { harnessProbeModels } from '@kabmo-labs/kabmo-harness/config-store/probe-cache.server';
|
|
34
34
|
import { claimHarness } from '@kabmo-labs/kabmo-harness/registry';
|
|
35
35
|
import { registerAcpSession } from '@/server/lib/harness/register.server';
|
|
36
|
+
import { isActivityEvent, noteAcpActivity } from '@/server/lib/harness/activity.server';
|
|
36
37
|
import { loadHarnessSessionTitle, saveHarnessSession } from '@kabmo-labs/kabmo-harness/session/session-store.server';
|
|
37
38
|
import { noteHarnessLease, removeHarnessLease } from '@kabmo-labs/kabmo-harness/lease/session-lease.server';
|
|
38
39
|
import { emitRealtimeSignal } from '@kabmo-labs/kabmo-realtime-signals';
|
|
@@ -260,6 +261,14 @@ export async function startAcpSession(
|
|
|
260
261
|
await recorder.hydrate();
|
|
261
262
|
session.onEvent((event) => recorder.record(event));
|
|
262
263
|
}
|
|
264
|
+
// The sidebar dates an ACP row by `harness_sessions.updated_at` (its agent
|
|
265
|
+
// writes no session file), and nothing used to advance it mid-run — a chat
|
|
266
|
+
// still streaming stayed where it spawned. Attached for a RESTORED chat too:
|
|
267
|
+
// its replayed frames were emitted during the handshake (before this
|
|
268
|
+
// listener existed), so only the turns that follow count as activity.
|
|
269
|
+
session.onEvent((event) => {
|
|
270
|
+
if (isActivityEvent(event)) void noteAcpActivity(realSessionId);
|
|
271
|
+
});
|
|
263
272
|
// The raw panel reads the original `session/update` payloads, not the fold
|
|
264
273
|
// above. A restore replays the agent's history and must not duplicate it.
|
|
265
274
|
const frameRecorder = request.replay ? null : new AcpFrameRecorder(() => realSessionId);
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
* left beside it (a full copy of the same transcript: leaving it behind
|
|
17
17
|
* would mean the conversation was not actually deleted);
|
|
18
18
|
* - its sibling artifacts directory, which holds the subagent transcripts;
|
|
19
|
-
* - the `archived_sessions`, `
|
|
20
|
-
* `queued_messages` and `chat_sessions` rows for
|
|
19
|
+
* - the `archived_sessions`, `pinned_sessions`, `session_ui_state`,
|
|
20
|
+
* `session_stream_state`, `queued_messages` and `chat_sessions` rows for
|
|
21
|
+
* that id;
|
|
21
22
|
* - the `harness_sessions`, `harness_goal_state` and `harness_usage_state`
|
|
22
23
|
* rows, which are the WHOLE record of a chat that ran on an ACP agent (its
|
|
23
24
|
* transcript is written by nobody Kabmo can read) and its resume id, goal
|
|
@@ -65,6 +66,7 @@ export interface SessionPurgeResult {
|
|
|
65
66
|
*/
|
|
66
67
|
const SESSION_ROW_DELETES: readonly (readonly [string, string])[] = [
|
|
67
68
|
['archived_sessions', 'session_id'],
|
|
69
|
+
['pinned_sessions', 'session_id'],
|
|
68
70
|
['session_ui_state', 'session_id'],
|
|
69
71
|
['session_stream_state', 'session_id'],
|
|
70
72
|
['queued_messages', 'session_id'],
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* test exercises the same read `loadSidebarStatus` does.
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
import { afterAll, afterEach, describe, expect, test } from 'bun:test';
|
|
27
|
+
import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
28
28
|
import fs from 'fs';
|
|
29
29
|
import * as os from 'os';
|
|
30
30
|
import * as path from 'path';
|
|
@@ -33,6 +33,11 @@ import { loadSidebarActivity } from '@kabmo-labs/kabmo-omp/sidebar-data/activity
|
|
|
33
33
|
import { localRuns } from '@kabmo-labs/kabmo-omp/session-runtime/local-runs.server';
|
|
34
34
|
import { clearSessionFileCaches } from '@kabmo-labs/kabmo-omp/session-scan/files';
|
|
35
35
|
import { SESSION_TITLE_SLOT_BYTES } from '@kabmo-labs/kabmo-omp/session-scan/files';
|
|
36
|
+
import { saveHarnessSession, loadHarnessSessionUpdatedAt } from '@kabmo-labs/kabmo-harness/session/session-store.server';
|
|
37
|
+
import { isolateDb, releaseDb } from '@/test-support/isolated-db';
|
|
38
|
+
// The "a run is in flight" read is registered by the registry module as a side
|
|
39
|
+
// effect; importing it keeps this suite runnable on its own.
|
|
40
|
+
import '@/server/lib/omp/rpc/session-registry';
|
|
36
41
|
|
|
37
42
|
const tempDirs: string[] = [];
|
|
38
43
|
const previousAgentDir = process.env.PI_CODING_AGENT_DIR;
|
|
@@ -97,9 +102,16 @@ function writeSession(agentDir: string, fixture: SessionFixture): string {
|
|
|
97
102
|
return file;
|
|
98
103
|
}
|
|
99
104
|
|
|
100
|
-
|
|
105
|
+
beforeEach(async () => {
|
|
106
|
+
// The resolver now reads `harness_sessions` for a live run with no omp file,
|
|
107
|
+
// so this suite must never reach the developer's own database.
|
|
108
|
+
await isolateDb();
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
afterEach(async () => {
|
|
101
112
|
localRuns().clear();
|
|
102
113
|
clearSessionFileCaches();
|
|
114
|
+
await releaseDb();
|
|
103
115
|
});
|
|
104
116
|
|
|
105
117
|
afterAll(() => {
|
|
@@ -149,6 +161,16 @@ describe('loadSidebarActivity', () => {
|
|
|
149
161
|
expect(await loadSidebarActivity()).toEqual({});
|
|
150
162
|
});
|
|
151
163
|
|
|
164
|
+
test('dates a live ACP chat by its persisted stamp, since it writes no file', async () => {
|
|
165
|
+
useAgentDir();
|
|
166
|
+
await saveHarnessSession({ sessionId: 'acp-live', harness: 'claude', agentSessionId: '', cwd: '/tmp/project' });
|
|
167
|
+
localRuns().add('acp-live');
|
|
168
|
+
|
|
169
|
+
const stamp = await loadHarnessSessionUpdatedAt('acp-live');
|
|
170
|
+
const activity = await loadSidebarActivity();
|
|
171
|
+
expect(activity['acp-live']?.updatedAt).toBe(new Date(stamp as number).toISOString());
|
|
172
|
+
});
|
|
173
|
+
|
|
152
174
|
test('reports the subagent flag, which moves mid-run', async () => {
|
|
153
175
|
const agentDir = useAgentDir();
|
|
154
176
|
writeSession(agentDir, {
|
|
@@ -169,6 +169,20 @@ describe('sidebar folders resolve sessions through a canonical path', () => {
|
|
|
169
169
|
expect(folder?.sessions.map((session) => session.id)).toEqual(['canonical-plain']);
|
|
170
170
|
});
|
|
171
171
|
|
|
172
|
+
test('a pinned session leads its folder regardless of activity', async () => {
|
|
173
|
+
await writeSession('pin-old', realProject);
|
|
174
|
+
await writeSession('pin-new', realProject);
|
|
175
|
+
const db = await getDb();
|
|
176
|
+
await db.run('INSERT INTO pinned_sessions (session_id) VALUES (?)', ['pin-old']);
|
|
177
|
+
const folderId = await registerFolder(realProject);
|
|
178
|
+
|
|
179
|
+
const payload = await loadSidebarStructure();
|
|
180
|
+
const folder = payload.folders.find((entry) => Number(entry.id) === folderId);
|
|
181
|
+
|
|
182
|
+
expect(folder?.sessions).toHaveLength(2);
|
|
183
|
+
expect(folder?.sessions[0]).toMatchObject({ id: 'pin-old', isPinned: true });
|
|
184
|
+
});
|
|
185
|
+
|
|
172
186
|
testPosix('a session in an unrelated directory stays out of the folder', async () => {
|
|
173
187
|
const other = join(root, 'other-project');
|
|
174
188
|
await fs.promises.mkdir(other, { recursive: true });
|
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
readLastOpenedSessionId,
|
|
27
27
|
recordLastOpenedSession,
|
|
28
28
|
} from '@/server/lib/sessions/last-opened.server';
|
|
29
|
+
import { workspaceSessionId } from '@/shared/lib/workspace/workspace-session';
|
|
29
30
|
|
|
30
31
|
const SESSION_ID = '42';
|
|
31
32
|
const CLIENT = '11111111-2222-4333-8444-555555555555';
|
|
@@ -119,6 +120,22 @@ describe('lastOpenedSession', () => {
|
|
|
119
120
|
expect(await readLastOpenedSessionId(CLIENT)).toBeNull();
|
|
120
121
|
});
|
|
121
122
|
|
|
123
|
+
test('a workspace session restores while its folder exists', async () => {
|
|
124
|
+
const workspaceId = workspaceSessionId(7);
|
|
125
|
+
expect(await recordLastOpenedSession(CLIENT, workspaceId)).toBe(true);
|
|
126
|
+
expect(await lastOpenedSession(CLIENT, free)).toBe(workspaceId);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
test('a workspace session whose folder is gone is refused and cleared', async () => {
|
|
130
|
+
const workspaceId = workspaceSessionId(7);
|
|
131
|
+
await recordLastOpenedSession(CLIENT, workspaceId);
|
|
132
|
+
await db.run('DELETE FROM sessions WHERE folder_id = 7');
|
|
133
|
+
await db.run('DELETE FROM workspace_folders WHERE id = 7');
|
|
134
|
+
|
|
135
|
+
expect(await lastOpenedSession(CLIENT, free)).toBeNull();
|
|
136
|
+
expect(await readLastOpenedSessionId(CLIENT)).toBeNull();
|
|
137
|
+
});
|
|
138
|
+
|
|
122
139
|
test('clearing leaves the next launch on the empty workspace', async () => {
|
|
123
140
|
await recordLastOpenedSession(CLIENT, SESSION_ID);
|
|
124
141
|
await clearLastOpenedSession(CLIENT);
|
|
@@ -47,6 +47,10 @@ import { isSinglePathSegment } from '@kabmo-labs/kabmo-paths/path-segment';
|
|
|
47
47
|
import { getDb } from '@/server/db.server';
|
|
48
48
|
import { isSessionArchived, sessionExists } from '@/server/lib/sessions/resolve.server';
|
|
49
49
|
import { isSessionOwnedElsewhere } from '@/server/lib/omp/session/ownership.server';
|
|
50
|
+
import {
|
|
51
|
+
isWorkspaceSessionId,
|
|
52
|
+
workspaceFolderIdFromSessionId,
|
|
53
|
+
} from '@/shared/lib/workspace/workspace-session';
|
|
50
54
|
|
|
51
55
|
/** The stored id for one client, or null when there is none. */
|
|
52
56
|
export async function readLastOpenedSessionId(clientId: string): Promise<string | null> {
|
|
@@ -98,6 +102,17 @@ export async function clearLastOpenedSession(clientId: string): Promise<void> {
|
|
|
98
102
|
*/
|
|
99
103
|
async function sessionCanOpen(sessionId: string): Promise<boolean> {
|
|
100
104
|
const db = await getDb();
|
|
105
|
+
// A workspace session is restorable while its folder exists: it has no
|
|
106
|
+
// transcript, no archive row and no owner, but its panel state is worth
|
|
107
|
+
// reopening into.
|
|
108
|
+
const workspaceFolderId = workspaceFolderIdFromSessionId(sessionId);
|
|
109
|
+
if (workspaceFolderId !== null) {
|
|
110
|
+
const folder = await db.get(
|
|
111
|
+
'SELECT 1 AS present FROM workspace_folders WHERE CAST(id AS TEXT) = ?',
|
|
112
|
+
[workspaceFolderId],
|
|
113
|
+
);
|
|
114
|
+
return folder != null;
|
|
115
|
+
}
|
|
101
116
|
const deleted = await db.get(
|
|
102
117
|
'SELECT 1 AS present FROM deleted_sessions WHERE session_id = ?',
|
|
103
118
|
[sessionId],
|
|
@@ -139,6 +154,8 @@ export async function lastOpenedSession(
|
|
|
139
154
|
await clearLastOpenedSession(clientId);
|
|
140
155
|
return null;
|
|
141
156
|
}
|
|
142
|
-
|
|
157
|
+
// No process can own a folder's panel scope, so the ownership probe (which
|
|
158
|
+
// asks the agent registry) must not be consulted for it.
|
|
159
|
+
if (!isWorkspaceSessionId(sessionId) && (await ownedElsewhere(sessionId))) return null;
|
|
143
160
|
return sessionId;
|
|
144
161
|
}
|
|
@@ -5,12 +5,12 @@ import * as sessionsQueue from '@/server/routes/sessions/queue';
|
|
|
5
5
|
import {
|
|
6
6
|
archiveSession,
|
|
7
7
|
getSessionModes,
|
|
8
|
-
getSessionState,
|
|
9
8
|
markSeen,
|
|
10
|
-
putSessionState,
|
|
11
9
|
renameSession,
|
|
12
10
|
renameWithAi,
|
|
11
|
+
pinSession,
|
|
13
12
|
} from '@/server/routes/sessions/session';
|
|
13
|
+
import { getSessionState, putSessionState } from '@/server/routes/sessions/state';
|
|
14
14
|
import { listSubagents, readSubagentTranscript } from '@/server/routes/sessions/subagents';
|
|
15
15
|
import { cancelSubagent, steerSubagent } from '@/server/routes/sessions/subagent-control';
|
|
16
16
|
import { deleteSession } from '@/server/routes/sessions/delete';
|
|
@@ -77,6 +77,7 @@ export const sessionsBindings: HandlerBinding[] = [
|
|
|
77
77
|
// applies after the loader, replacing the workspace listing with it.
|
|
78
78
|
{ method: 'DELETE', path: '/api/sessions/:sessionId', handler: deleteSession },
|
|
79
79
|
...actionBindings(archiveSession, '/api/sessions/:sessionId/archive'),
|
|
80
|
+
...actionBindings(pinSession, '/api/sessions/:sessionId/pin'),
|
|
80
81
|
// Per-item queue routes. `actionBindings` mounts ALL four mutating verbs on
|
|
81
82
|
// one path, and Elysia lets a later registration override an earlier one —
|
|
82
83
|
// mounting reorder on the same `/queue` path that way would clobber the
|
|
@@ -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
|
+
}
|