@kabmo-labs/kabmo 0.33.0 → 0.35.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.
Files changed (272) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +785 -624
  3. package/dist/client/static/js/{CsvGrid-fncjbg6j.js → CsvGrid-0amzgtd7.js} +2 -2
  4. package/dist/client/static/js/{DocxView-c9v2vr3r.js → DocxView-bxjhzxe9.js} +5 -5
  5. package/dist/client/static/js/{DrawioView-vxjksm12.js → DrawioView-7s1yqsf4.js} +2 -2
  6. package/dist/client/static/js/{ImageView-a3g5k226.js → ImageView-ycfbn66h.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-hnjfwsjh.js → LayoutWrapper-tw1q1x0g.js} +2 -2
  8. package/dist/client/static/js/Modal-wqjactyd.js +38 -0
  9. package/dist/client/static/js/{PdfView-ksaes53y.js → PdfView-x6dmtwvr.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-30vcr95v.js → SessionsView-t85wq0me.js} +1 -1
  11. package/dist/client/static/js/{SheetView-vc484scg.js → SheetView-n52nvz8s.js} +25 -25
  12. package/dist/client/static/js/{SvgPreview-tph89jet.js → SvgPreview-59z7syme.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-xbar278c.js → abnfDiagram-O67JEVCF-91gnt049.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-bajpnvy7.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-s171n2z6.js → architectureDiagram-NJMV4G6O-5b9qtff2.js} +4 -4
  16. package/dist/client/static/js/{astro-80bs6hvg.js → astro-31cbyw7b.js} +1 -1
  17. package/dist/client/static/js/bash-0h36tk0k.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-gzx6rv9n.js → blockDiagram-BEXU5L5S-6f23fjkn.js} +3 -3
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-7f00skch.js → c4Diagram-YGBWAQC7-76t6d3am.js} +5 -5
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-j79v95nc.js → classDiagram-v2-NBCMYWYE-f9tb19xm.js} +3 -3
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-5fkn7ee5.js → cose-bilkent-JH36ORCC-t6nwrbwj.js} +1 -1
  22. package/dist/client/static/js/cpp-4wp9sy20.js +1 -0
  23. package/dist/client/static/js/css-c9nsbkh6.js +1 -0
  24. package/dist/client/static/js/cynefin-OW5HDTMX-8q9e90m8.js +1 -0
  25. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-cfs1yvrd.js → cynefinDiagram-VND7K2PF-69gc244j.js} +1 -1
  26. package/dist/client/static/js/{dagre-6A5THRUB-44bgc48p.js → dagre-6A5THRUB-54bry3ey.js} +2 -2
  27. package/dist/client/static/js/{diagram-22UHCM2B-a4g4x83k.js → diagram-22UHCM2B-gfkebye6.js} +11 -11
  28. package/dist/client/static/js/{diagram-3UASUU5V-gm4rg5na.js → diagram-3UASUU5V-a1mr319f.js} +1 -1
  29. package/dist/client/static/js/{diagram-ATOU4E4O-a95y41vk.js → diagram-ATOU4E4O-tkyk0qbe.js} +3 -3
  30. package/dist/client/static/js/{diagram-CDSNMT55-t3j93mmc.js → diagram-CDSNMT55-np0hc9m2.js} +4 -4
  31. package/dist/client/static/js/{diagram-MLGK6HIB-c2wdez02.js → diagram-MLGK6HIB-nh06fshp.js} +2 -2
  32. package/dist/client/static/js/{diagram-MPIPVDR6-gya9jhs5.js → diagram-MPIPVDR6-27q2veks.js} +2 -2
  33. package/dist/client/static/js/{dockerfile-a7q6174s.js → dockerfile-4rtt6c0f.js} +1 -1
  34. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-jjhkza6t.js → ebnfDiagram-ZINNZB2B-x9p9jqe8.js} +1 -1
  35. package/dist/client/static/js/{elk-276RUBZZ-f7re45mw.js → elk-276RUBZZ-fw7waks3.js} +1 -1
  36. package/dist/client/static/js/{erDiagram-OPXOYQCR-tpm9g5te.js → erDiagram-OPXOYQCR-fdfgzr5d.js} +5 -5
  37. package/dist/client/static/js/{erlang-qt876zrq.js → erlang-trjm07as.js} +1 -1
  38. package/dist/client/static/js/eventmodeling-NTZA5JFV-kn4hsm3p.js +1 -0
  39. package/dist/client/static/js/flowDiagram-KWPJA3E3-ah8cvps1.js +1 -0
  40. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-fz43n12d.js → ganttDiagram-FUAMR5RP-2avbqgdr.js} +3 -3
  41. package/dist/client/static/js/gitGraph-4MIJSDKK-hvavh16n.js +1 -0
  42. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-f61hgbn6.js → gitGraphDiagram-X574FWY7-9jmc0a3g.js} +12 -12
  43. package/dist/client/static/js/graphql-hbkmxsty.js +1 -0
  44. package/dist/client/static/js/{index-8239j2v1.js → index-0v34a7wf.js} +1 -1
  45. package/dist/client/static/js/{index-vtbbfwx0.js → index-1wjp16f0.js} +2 -2
  46. package/dist/client/static/js/index-2mx9ej4k.css +1 -0
  47. package/dist/client/static/js/{index-q2w6s8n7.js → index-2v1nmxwr.js} +6 -6
  48. package/dist/client/static/js/{index-apvkd37e.js → index-3ecsp1rx.js} +3 -3
  49. package/dist/client/static/js/{index-1y9r4frb.js → index-43qpbxjv.js} +2 -2
  50. package/dist/client/static/js/{index-w0fwb80e.js → index-4vybd9e7.js} +1 -1
  51. package/dist/client/static/js/{index-ahv9y42z.js → index-6f6cmcbq.js} +2 -2
  52. package/dist/client/static/js/{index-9fjt5anh.js → index-7ct7qrsp.js} +2 -2
  53. package/dist/client/static/js/{index-ajs3jj6j.js → index-7q02xnvq.js} +1 -1
  54. package/dist/client/static/js/{index-rytaa8ca.js → index-7smwzkvq.js} +2 -2
  55. package/dist/client/static/js/{index-rg8jpbsw.js → index-8acv5b77.js} +2 -2
  56. package/dist/client/static/js/{index-gs6f0qwa.js → index-8f9x7ev8.js} +2 -2
  57. package/dist/client/static/js/{index-7y6rpsrp.js → index-8mwragbj.js} +2 -2
  58. package/dist/client/static/js/{index-gcs49f3p.js → index-8x9ecxb0.js} +1 -1
  59. package/dist/client/static/js/{index-3rcjx70v.js → index-9ketbkh6.js} +1 -1
  60. package/dist/client/static/js/{index-ypx3qmhq.js → index-a628fg4m.js} +2 -2
  61. package/dist/client/static/js/{index-e4p4cd3r.js → index-a8ffattk.js} +2 -2
  62. package/dist/client/static/js/{index-js7t1vb1.js → index-b8s3xraa.js} +6 -6
  63. package/dist/client/static/js/index-btr2w8cq.js +12 -0
  64. package/dist/client/static/js/index-dfzrpy54.js +2 -0
  65. package/dist/client/static/js/{index-pxv2nw9w.js → index-ee2p07eg.js} +1 -1
  66. package/dist/client/static/js/{index-03h3bkcf.js → index-ek2e773p.js} +1 -1
  67. package/dist/client/static/js/{index-1xqs14fr.js → index-fvc0x6nx.js} +3 -3
  68. package/dist/client/static/js/{index-3zc1b0dv.js → index-jc1yagmk.js} +2 -2
  69. package/dist/client/static/js/{index-d495kfm0.js → index-jmxqefe3.js} +1 -1
  70. package/dist/client/static/js/{index-2x5f66t6.js → index-k7q01ye4.js} +2 -2
  71. package/dist/client/static/js/{index-5tgq7aqx.js → index-kdkfyrja.js} +2 -2
  72. package/dist/client/static/js/{index-m73za75e.js → index-mc4nefs7.js} +3 -3
  73. package/dist/client/static/js/{index-trm9x02n.js → index-nb8tp4mj.js} +30 -30
  74. package/dist/client/static/js/{index-zt75xpq0.js → index-ncrenheb.js} +206 -206
  75. package/dist/client/static/js/{index-qsm2z36d.js → index-p16scjt7.js} +2 -2
  76. package/dist/client/static/js/{index-sdtye3jy.js → index-pc6eg8h2.js} +2 -2
  77. package/dist/client/static/js/{index-zvfvqvn9.js → index-pnt0vc59.js} +2 -2
  78. package/dist/client/static/js/{index-pbe4yed4.js → index-py2k8std.js} +2 -2
  79. package/dist/client/static/js/{index-dbe6afkf.js → index-pzbssnsc.js} +2 -2
  80. package/dist/client/static/js/{index-qckv9nte.js → index-qqz6bcdd.js} +2 -2
  81. package/dist/client/static/js/{index-xj9649ac.js → index-ray2czf6.js} +7 -7
  82. package/dist/client/static/js/{index-0tf0arsp.js → index-rbgemjsp.js} +3 -3
  83. package/dist/client/static/js/{index-vw4brsdx.js → index-rkn0bxxt.js} +1 -1
  84. package/dist/client/static/js/{index-76zb4m0n.js → index-rv89xpaf.js} +2 -2
  85. package/dist/client/static/js/index-sbd5e816.js +1 -0
  86. package/dist/client/static/js/{index-eyzeya95.js → index-sdby39w4.js} +5 -5
  87. package/dist/client/static/js/{index-0n5wwe60.js → index-t6c0pd43.js} +2 -2
  88. package/dist/client/static/js/{index-km2zb6wk.js → index-tp7yb3bv.js} +2 -2
  89. package/dist/client/static/js/{index-vw5k8csz.js → index-vnw3hbeg.js} +56 -56
  90. package/dist/client/static/js/{index-354mqqra.js → index-vq6wts05.js} +2 -2
  91. package/dist/client/static/js/{index-14vndmcr.js → index-w5373tg1.js} +2 -2
  92. package/dist/client/static/js/{index-0e40xskg.js → index-w7tpgt46.js} +1 -1
  93. package/dist/client/static/js/{index-djmg1d7h.js → index-whbtxmwh.js} +2 -2
  94. package/dist/client/static/js/{index-2svnq5gg.js → index-xs1m0bpt.js} +1 -1
  95. package/dist/client/static/js/{index-9y3gjdj7.js → index-xxtsm2rb.js} +2 -2
  96. package/dist/client/static/js/{index-hf52f59k.js → index-y3ms153k.js} +2 -2
  97. package/dist/client/static/js/{index-1a0zkj8h.js → index-yq39qbs1.js} +2 -2
  98. package/dist/client/static/js/{index-j0r5hj0j.js → index-zh2jj56s.js} +2 -2
  99. package/dist/client/static/js/info-A6RAGUB7-fmjz8qwg.js +1 -0
  100. package/dist/client/static/js/{infoDiagram-VRGFBTTK-1qj804sn.js → infoDiagram-VRGFBTTK-g2dky5xg.js} +2 -2
  101. package/dist/client/static/js/ini-72yrpvd4.js +1 -0
  102. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-4j4qsnzw.js → ishikawaDiagram-OU5B5YK6-exrcjwp1.js} +6 -6
  103. package/dist/client/static/js/java-ab5tb2ra.js +1 -0
  104. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-j0brnfft.js → journeyDiagram-ZHPQQLJL-pn752qa5.js} +4 -4
  105. package/dist/client/static/js/jsx-25zj9j3k.js +1 -0
  106. package/dist/client/static/js/{julia-4ghmfy3e.js → julia-evn99h2m.js} +1 -1
  107. package/dist/client/static/js/{kanban-definition-PNTS6WVX-qqc22br0.js → kanban-definition-PNTS6WVX-v8nvr373.js} +5 -5
  108. package/dist/client/static/js/lua-j5w0c9wm.js +1 -0
  109. package/dist/client/static/js/markdown-j6hn4377.js +1 -0
  110. package/dist/client/static/js/{mermaid.core-vv3wbe65.js → mermaid.core-egzv89zv.js} +6 -6
  111. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-y5b2z8zp.js → mindmap-definition-NLK3R4M7-t9njmv2w.js} +8 -8
  112. package/dist/client/static/js/one-dark-pro-bm3r4js7.js +1 -0
  113. package/dist/client/static/js/one-light-e07dt7sy.js +1 -0
  114. package/dist/client/static/js/packet-AYTQ26CC-cwr6n1cm.js +1 -0
  115. package/dist/client/static/js/{pegDiagram-GJSIUBJH-0be07mqs.js → pegDiagram-GJSIUBJH-zhycy2b7.js} +1 -1
  116. package/dist/client/static/js/{perl-sd00t4b4.js → perl-506fy8m8.js} +1 -1
  117. package/dist/client/static/js/{php-2zfyqa61.js → php-axtsvxck.js} +1 -1
  118. package/dist/client/static/js/pie-WAS4IAKB-h1ebfzgt.js +1 -0
  119. package/dist/client/static/js/{pieDiagram-5QR66LMP-544w86jk.js → pieDiagram-5QR66LMP-sgctvma2.js} +2 -2
  120. package/dist/client/static/js/properties-q8njes42.js +1 -0
  121. package/dist/client/static/js/python-vqxc7181.js +1 -0
  122. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-p09e7z5s.js → quadrantDiagram-O4NWA36T-kzzhdcph.js} +5 -5
  123. package/dist/client/static/js/r-0k5eej8m.js +1 -0
  124. package/dist/client/static/js/radar-RG4KPBEZ-k7p1m364.js +1 -0
  125. package/dist/client/static/js/railroad-74A4TZTK-d08dw3t0.js +1 -0
  126. package/dist/client/static/js/railroad-abnf-HS5TGJTU-txnjycgk.js +1 -0
  127. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-p0r3cv6w.js +1 -0
  128. package/dist/client/static/js/railroad-peg-WCYAUIDC-sryk900a.js +1 -0
  129. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-de830ed2.js → railroadDiagram-XR7U4H2S-nzjffwxm.js} +1 -1
  130. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-b47d74p1.js → requirementDiagram-PLB6GJNP-tz4xxn4d.js} +2 -2
  131. package/dist/client/static/js/{ruby-v9qaqhby.js → ruby-qp7zfk2m.js} +1 -1
  132. package/dist/client/static/js/{rust-fkt0qyrs.js → rust-fz913fvw.js} +1 -1
  133. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-6ezc2fpj.js → sankeyDiagram-IPEJSGJF-2wcb0xr6.js} +4 -4
  134. package/dist/client/static/js/{sass-9bxped7y.js → sass-gnk9vsyp.js} +1 -1
  135. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-by5zqj6w.js → sequenceDiagram-PO4LG4MO-vqgebfns.js} +18 -18
  136. package/dist/client/static/js/{sizeCapture-INFHLROL-q85r06j6.js → sizeCapture-INFHLROL-xc314tes.js} +1 -1
  137. package/dist/client/static/js/sql-0e9mnrda.js +1 -0
  138. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-ep5pyexs.js → stateDiagram-v2-GCMORJYK-8bd9b1h8.js} +3 -3
  139. package/dist/client/static/js/{svelte-mwtx07d9.js → svelte-brpgzrtv.js} +1 -1
  140. package/dist/client/static/js/{swimlanes-2SLR337P-95fcqkh8.js → swimlanes-2SLR337P-t6hbdzcw.js} +1 -1
  141. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-c1czc7kv.js +8 -0
  142. package/dist/client/static/js/{timeline-definition-EJHVYXUP-461e615g.js → timeline-definition-EJHVYXUP-2txxasx5.js} +4 -4
  143. package/dist/client/static/js/treeView-Q6P3EWNA-77kj68p1.js +1 -0
  144. package/dist/client/static/js/treemap-WGGIJYW6-rw94xc82.js +1 -0
  145. package/dist/client/static/js/tsx-yd5wt250.js +1 -0
  146. package/dist/client/static/js/typescript-v7z7crfe.js +1 -0
  147. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-ftqfnvhg.js → usecaseDiagram-POWQR4AR-3x353hn4.js} +17 -17
  148. package/dist/client/static/js/{vennDiagram-UO4OBE2U-7t96h6ez.js → vennDiagram-UO4OBE2U-cerpss8e.js} +7 -7
  149. package/dist/client/static/js/{vue-j8vb9d7r.js → vue-apnkw9qy.js} +1 -1
  150. package/dist/client/static/js/wardley-WFR3VGLG-18xe4fhz.js +1 -0
  151. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-0de8w8c6.js → wardleyDiagram-VNRHLVJA-cx6jfsbf.js} +4 -4
  152. package/dist/client/static/js/xml-94fhzrfs.js +1 -0
  153. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-dez9phkf.js → xychartDiagram-PMCCYNJV-tgn23xj1.js} +5 -5
  154. package/dist/client/static/js/yaml-s8af9rnw.js +1 -0
  155. package/package.json +4 -1
  156. package/src/client/components/auth/login-screen/index.tsx +1 -0
  157. package/src/client/components/common/MarkdownRenderer.tsx +9 -12
  158. package/src/client/components/settings/Modal.tsx +14 -84
  159. package/src/client/components/settings/Sidebar.tsx +3 -1
  160. package/src/client/components/settings/categories/ConnectSettings.tsx +105 -0
  161. package/src/client/components/settings/categories/connect-settings/DeviceTable.tsx +145 -0
  162. package/src/client/components/settings/categories/connect-settings/PairDialog.test.tsx +159 -0
  163. package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +189 -0
  164. package/src/client/components/settings/categories/connect-settings/QrCode.tsx +56 -0
  165. package/src/client/components/settings/categories/connect-settings/ServerCard.tsx +94 -0
  166. package/src/client/components/settings/categories/connect-settings/TunnelRow.tsx +127 -0
  167. package/src/client/components/settings/categories/connect-settings/qr-image.ts +76 -0
  168. package/src/client/components/settings/category-content.tsx +116 -0
  169. package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.test.tsx +120 -0
  170. package/src/client/components/workspace/chat-timeline/ChangedFilesSummary.tsx +56 -20
  171. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +1 -0
  172. package/src/client/components/workspace/git-panel/init-state.test.ts +5 -0
  173. package/src/client/hooks/chat/composer/speech-to-text.ts +24 -17
  174. package/src/client/hooks/chat/timeline/change-stats.ts +57 -0
  175. package/src/client/hooks/connect/use-connect-status.ts +116 -0
  176. package/src/client/hooks/connect/use-pairing.ts +100 -0
  177. package/src/client/hooks/editor/file-actions.ts +3 -11
  178. package/src/client/hooks/editor/font.test.ts +2 -1
  179. package/src/client/hooks/editor/use-file-transfer.ts +2 -1
  180. package/src/client/hooks/ui/clipboard.ts +26 -0
  181. package/src/client/lib/browser/download.ts +22 -0
  182. package/src/client/tailwind.css +5 -0
  183. package/src/server/index.ts +2 -0
  184. package/src/server/lib/assets/font-css.server.test.ts +19 -0
  185. package/src/server/lib/auth/client-address.test.ts +58 -0
  186. package/src/server/lib/auth/client-address.ts +37 -3
  187. package/src/server/lib/auth/guard.ts +31 -4
  188. package/src/server/lib/auth/rate-limit.test.ts +25 -8
  189. package/src/server/lib/auth/rate-limit.ts +8 -5
  190. package/src/server/lib/connect/cloudflared.lifecycle.test.ts +88 -0
  191. package/src/server/lib/connect/cloudflared.server.test.ts +65 -0
  192. package/src/server/lib/connect/cloudflared.server.ts +206 -0
  193. package/src/server/lib/connect/devices.server.ts +192 -0
  194. package/src/server/lib/connect/identity.server.ts +81 -0
  195. package/src/server/lib/connect/pairing.server.test.ts +56 -0
  196. package/src/server/lib/connect/pairing.server.ts +113 -0
  197. package/src/server/lib/connect/qr.roundtrip.test.ts +106 -0
  198. package/src/server/lib/connect/qr.server.ts +36 -0
  199. package/src/server/lib/connect/run.server.ts +101 -0
  200. package/src/server/lib/connect/status.server.ts +177 -0
  201. package/src/server/lib/connect/tailscale.server.test.ts +117 -0
  202. package/src/server/lib/connect/tailscale.server.ts +172 -0
  203. package/src/server/lib/db/schema.ts +4 -0
  204. package/src/server/lib/omp/session/changes.test.ts +64 -1
  205. package/src/server/lib/omp/session/changes.ts +94 -1
  206. package/src/server/routes/connect/devices.ts +56 -0
  207. package/src/server/routes/connect/index.ts +15 -0
  208. package/src/server/routes/connect/pair-page.ts +177 -0
  209. package/src/server/routes/connect/pair.ts +158 -0
  210. package/src/server/routes/connect/status.ts +19 -0
  211. package/src/server/routes/connect/tunnels.ts +76 -0
  212. package/src/server/routes/health/probe.ts +5 -0
  213. package/src/server/routes/index.ts +2 -0
  214. package/src/server/routes/sessions/changes.test.ts +12 -3
  215. package/src/server/routes/sessions/changes.ts +27 -3
  216. package/src/server/routes/sessions/index.ts +2 -1
  217. package/src/shared/lib/connect/payload.test.ts +144 -0
  218. package/src/shared/lib/connect/payload.ts +229 -0
  219. package/src/shared/lib/connect/tier.test.ts +73 -0
  220. package/src/shared/lib/connect/tier.ts +105 -0
  221. package/src/shared/lib/connect/types.ts +99 -0
  222. package/src/shared/lib/dictation/capture-failure.test.ts +46 -0
  223. package/src/shared/lib/dictation/capture-failure.ts +36 -0
  224. package/src/shared/lib/markdown/fira-code-fonts.css +65 -6
  225. package/src/shared/lib/markdown/marked.ts +7 -4
  226. package/src/shared/lib/markdown/mermaid-actions.test.ts +78 -0
  227. package/src/shared/lib/markdown/mermaid-actions.ts +45 -0
  228. package/src/shared/lib/markdown/mermaid.ts +41 -7
  229. package/src/shared/lib/settings/sections.ts +6 -1
  230. package/src/shared/types/session-changes.ts +6 -0
  231. package/src/shared/types/settings/state.ts +2 -0
  232. package/dist/client/static/js/Modal-qtftcp2t.js +0 -38
  233. package/dist/client/static/js/architecture-7GRP2DOG-tavtgb8a.js +0 -1
  234. package/dist/client/static/js/bash-b3rwyg5p.js +0 -1
  235. package/dist/client/static/js/cpp-y0t6mynx.js +0 -1
  236. package/dist/client/static/js/css-6vj0d308.js +0 -1
  237. package/dist/client/static/js/cynefin-OW5HDTMX-cdh3n2z2.js +0 -1
  238. package/dist/client/static/js/eventmodeling-NTZA5JFV-as97tpyp.js +0 -1
  239. package/dist/client/static/js/flowDiagram-KWPJA3E3-ggm06d12.js +0 -1
  240. package/dist/client/static/js/gitGraph-4MIJSDKK-eqz7p9ng.js +0 -1
  241. package/dist/client/static/js/graphql-n43pd5fs.js +0 -1
  242. package/dist/client/static/js/index-at6bhjyf.js +0 -1
  243. package/dist/client/static/js/index-bkye8mz4.js +0 -2
  244. package/dist/client/static/js/index-e94a1en0.css +0 -1
  245. package/dist/client/static/js/index-sffjtm5w.js +0 -12
  246. package/dist/client/static/js/info-A6RAGUB7-4pkzh1qx.js +0 -1
  247. package/dist/client/static/js/ini-j5dyq6gm.js +0 -1
  248. package/dist/client/static/js/java-g4dgwbfd.js +0 -1
  249. package/dist/client/static/js/jsx-7t5ecz9s.js +0 -1
  250. package/dist/client/static/js/lua-1g6w30de.js +0 -1
  251. package/dist/client/static/js/markdown-afx21x8c.js +0 -1
  252. package/dist/client/static/js/one-dark-pro-hm3f56n1.js +0 -1
  253. package/dist/client/static/js/one-light-xrz49rct.js +0 -1
  254. package/dist/client/static/js/packet-AYTQ26CC-yg71sp88.js +0 -1
  255. package/dist/client/static/js/pie-WAS4IAKB-89wd6np0.js +0 -1
  256. package/dist/client/static/js/properties-thd83wey.js +0 -1
  257. package/dist/client/static/js/python-264ns4xw.js +0 -1
  258. package/dist/client/static/js/r-qw82kkv9.js +0 -1
  259. package/dist/client/static/js/radar-RG4KPBEZ-avn0b8r9.js +0 -1
  260. package/dist/client/static/js/railroad-74A4TZTK-de27xv5w.js +0 -1
  261. package/dist/client/static/js/railroad-abnf-HS5TGJTU-rg4zzj7x.js +0 -1
  262. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-d84fhj8v.js +0 -1
  263. package/dist/client/static/js/railroad-peg-WCYAUIDC-dvf8xrmc.js +0 -1
  264. package/dist/client/static/js/sql-g8wcshpc.js +0 -1
  265. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-xs2en5dv.js +0 -8
  266. package/dist/client/static/js/treeView-Q6P3EWNA-mham0bh6.js +0 -1
  267. package/dist/client/static/js/treemap-WGGIJYW6-mxrxax86.js +0 -1
  268. package/dist/client/static/js/tsx-nm94hed6.js +0 -1
  269. package/dist/client/static/js/typescript-0s2t05jj.js +0 -1
  270. package/dist/client/static/js/wardley-WFR3VGLG-8vrvh9p3.js +0 -1
  271. package/dist/client/static/js/xml-dz51p1m3.js +0 -1
  272. package/dist/client/static/js/yaml-2cfkd30t.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import type { LucideIcon } from 'lucide-preact';
2
- import { BarChart3, Bell, BookOpen, Bot, Boxes, Cloud, Coins, Cpu, FolderGit, Keyboard, Library, MessageSquare, Palette, Plug, Power, Puzzle, RefreshCw, Search, Sliders, Terminal, Waypoints, X } from 'lucide-preact';
2
+ import { BarChart3, Bell, BookOpen, Bot, Boxes, Cloud, Coins, Cpu, FolderGit, Keyboard, Library, MessageSquare, Palette, Plug, Power, Puzzle, Radio, RefreshCw, Search, Sliders, Terminal, Waypoints, X } from 'lucide-preact';
3
3
  import { HarnessGlyph } from '@/client/components/common/harness-glyph';
4
4
  import type { SettingsCategoryId } from '@/shared/types';
5
5
  import { SETTINGS_SECTIONS, type SettingsSection } from '@/shared/lib/settings/sections';
@@ -28,6 +28,8 @@ export const SETTINGS_CATEGORIES: CategoryDef[] = [
28
28
  { id: 'usage', label: 'Usage', icon: BarChart3, section: 'KABMO', description: 'Build minutes quota, storage, and general usage.' },
29
29
  { id: 'token-usage', label: 'Token Usage', icon: Coins, section: 'KABMO', description: 'Token telemetry, cache, and cost breakdown.' },
30
30
  { id: 'panel-plugins', label: 'Plugins Kabmo', icon: Puzzle, section: 'KABMO', description: 'Plugins installed into Kabmo: panels, background services, and the MCP servers they register.' },
31
+ // CONNECT
32
+ { id: 'connect', label: 'Connect', icon: Radio, section: 'CONNECT', description: 'Tunnels, addresses, and the devices paired to this server.' },
31
33
  // WORKSPACE
32
34
  { id: 'projects', label: 'Projects', icon: FolderGit, section: 'WORKSPACE', description: 'Workspace directories, roots, and ignored paths.' },
33
35
  // OMP
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Settings → Connect.
8
+ *
9
+ * Three blocks, one page: this server's identity and addresses, the two tunnel
10
+ * providers, and the devices that have been paired. No master-detail, because
11
+ * there is nothing to drill into — the only list is the device table, and it is
12
+ * short by construction (a person pairs a handful of devices, not hundreds).
13
+ *
14
+ * The page's job is to make the route order visible. Tailscale is the preferred
15
+ * route even on the same network: it is a direct WireGuard peer connection, so
16
+ * it costs a fraction of a millisecond over the LAN address, and it is the only
17
+ * one of the two that gives the page a secure origin — which is what keeps
18
+ * dictation, clipboard read and the service worker working. The LAN row is the
19
+ * fallback for a device with no tailnet, and it says so when it cannot answer.
20
+ */
21
+
22
+ import { useCallback, useState } from 'preact/hooks';
23
+ import { useConnectStatus } from '@/client/hooks/connect/use-connect-status';
24
+ import { usePairing } from '@/client/hooks/connect/use-pairing';
25
+ import { ServerCard } from '@/client/components/settings/categories/connect-settings/ServerCard';
26
+ import { TunnelRow } from '@/client/components/settings/categories/connect-settings/TunnelRow';
27
+ import { DeviceTable } from '@/client/components/settings/categories/connect-settings/DeviceTable';
28
+ import { PairDialog } from '@/client/components/settings/categories/connect-settings/PairDialog';
29
+
30
+ export function ConnectSettings() {
31
+ const { status, error, busy, refresh, setTunnel, revoke } = useConnectStatus();
32
+ const pairing = usePairing();
33
+ const [dialogOpen, setDialogOpen] = useState(false);
34
+
35
+ const openDialog = useCallback(() => {
36
+ setDialogOpen(true);
37
+ void pairing.create();
38
+ }, [pairing]);
39
+
40
+ const closeDialog = useCallback(() => {
41
+ setDialogOpen(false);
42
+ pairing.reset();
43
+ // A device that paired while the dialog was open appears on the next read;
44
+ // the dialog has no way to know, so the page asks once it closes.
45
+ void refresh();
46
+ }, [pairing, refresh]);
47
+
48
+ if (!status) {
49
+ return (
50
+ <div className="mx-auto w-full max-w-3xl">
51
+ <p className="text-[11px] text-ink/60">{error ?? 'Reading the connection state…'}</p>
52
+ </div>
53
+ );
54
+ }
55
+
56
+ return (
57
+ <div className="mx-auto w-full max-w-3xl space-y-4">
58
+ <p className="text-[11px] leading-relaxed text-ink/60">
59
+ Reach this server from your phone or another desktop without typing an address or a password.
60
+ </p>
61
+
62
+ {error && (
63
+ <p className="rounded-lg border border-ink/10 bg-ink/[0.03] px-3 py-2 text-[11px] leading-relaxed text-ink/70">
64
+ {error}
65
+ </p>
66
+ )}
67
+
68
+ <ServerCard status={status} />
69
+
70
+ <section className="rounded-xl border border-ink/10 bg-paper">
71
+ <header className="border-b border-ink/10 px-4 py-3">
72
+ <h4 className="text-sm font-semibold text-ink">Tunnels</h4>
73
+ </header>
74
+ <div className="divide-y divide-ink/10">
75
+ {status.tunnels.map((tunnel) => (
76
+ <TunnelRow
77
+ key={tunnel.provider}
78
+ tunnel={tunnel}
79
+ busy={busy === `${tunnel.provider}:start` || busy === `${tunnel.provider}:stop`}
80
+ onToggle={(next) => void setTunnel(tunnel.provider, next)}
81
+ />
82
+ ))}
83
+ </div>
84
+ </section>
85
+
86
+ <DeviceTable
87
+ devices={status.devices}
88
+ busy={busy}
89
+ onRevoke={(id) => void revoke(id)}
90
+ onAdd={openDialog}
91
+ />
92
+
93
+ {dialogOpen && (
94
+ <PairDialog
95
+ code={pairing.code}
96
+ error={pairing.error}
97
+ busy={pairing.busy}
98
+ secondsLeft={pairing.secondsLeft}
99
+ onClose={closeDialog}
100
+ onRetry={() => void pairing.create()}
101
+ />
102
+ )}
103
+ </div>
104
+ );
105
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The paired devices, and the one action that matters on each row.
8
+ *
9
+ * The route and round trip are what the DEVICE reported, not something the
10
+ * server measured — it cannot measure a phone's latency. Showing them is what
11
+ * makes the fallback order visible: a phone on Tailscale at home and the same
12
+ * phone on Cloudflare at a café are two different rows of the same device, and
13
+ * the user can see which one it is using right now.
14
+ *
15
+ * A table on a desktop, stacked rows on a phone. The columns are the same facts
16
+ * in both; only the arrangement changes, because a horizontally scrolling table
17
+ * on a phone hides the revoke button off-screen.
18
+ */
19
+
20
+ import { Trash2 } from 'lucide-preact';
21
+ import type { PairedDevice } from '@/shared/lib/connect/types';
22
+
23
+ const ROUTE_LABEL: Record<NonNullable<PairedDevice['route']>, string> = {
24
+ tailscale: 'Tailscale',
25
+ lan: 'LAN',
26
+ cloudflare: 'Cloudflare',
27
+ };
28
+
29
+ function relative(iso: string | null): string {
30
+ if (!iso) return 'never';
31
+ const then = Date.parse(iso);
32
+ if (!Number.isFinite(then)) return 'never';
33
+ const seconds = Math.max(0, Math.round((Date.now() - then) / 1000));
34
+ if (seconds < 60) return 'just now';
35
+ const minutes = Math.round(seconds / 60);
36
+ if (minutes < 60) return `${minutes} min ago`;
37
+ const hours = Math.round(minutes / 60);
38
+ if (hours < 24) return `${hours} h ago`;
39
+ return `${Math.round(hours / 24)} d ago`;
40
+ }
41
+
42
+ export interface DeviceTableProps {
43
+ devices: PairedDevice[];
44
+ busy: string | null;
45
+ onRevoke: (id: string) => void;
46
+ onAdd: () => void;
47
+ }
48
+
49
+ export function DeviceTable({ devices, busy, onRevoke, onAdd }: DeviceTableProps) {
50
+ return (
51
+ <section className="rounded-xl border border-ink/10 bg-paper">
52
+ <header className="flex items-center justify-between gap-2 border-b border-ink/10 px-4 py-3">
53
+ <h4 className="text-sm font-semibold text-ink">Paired devices</h4>
54
+ <button
55
+ type="button"
56
+ onClick={onAdd}
57
+ className="rounded-lg border border-ink/15 px-2.5 py-1 text-[11px] font-semibold text-ink transition-colors hover:bg-ink/5"
58
+ >
59
+ Add a device
60
+ </button>
61
+ </header>
62
+
63
+ {devices.length === 0 ? (
64
+ <div className="px-4 py-6">
65
+ <p className="text-[11px] leading-relaxed text-ink/60">
66
+ No device has been paired yet. Add one to reach this server from your phone without typing an
67
+ address or a password.
68
+ </p>
69
+ </div>
70
+ ) : (
71
+ <>
72
+ {/* Desktop: one row per device. */}
73
+ <table className="hidden w-full md:table">
74
+ <thead>
75
+ <tr className="text-left text-[10px] font-bold uppercase tracking-wider text-ink/40">
76
+ <th className="px-4 py-2 font-bold">Device</th>
77
+ <th className="px-2 py-2 font-bold">Platform</th>
78
+ <th className="px-2 py-2 font-bold">Route</th>
79
+ <th className="px-2 py-2 font-bold">RTT</th>
80
+ <th className="px-2 py-2 font-bold">Last seen</th>
81
+ <th className="px-4 py-2" />
82
+ </tr>
83
+ </thead>
84
+ <tbody>
85
+ {devices.map((device) => (
86
+ <tr key={device.id} className="border-t border-ink/5">
87
+ <td className="px-4 py-2 text-[12px] font-medium text-ink">{device.name}</td>
88
+ <td className="px-2 py-2 text-[11px] text-ink/70">{device.platform}</td>
89
+ <td className="px-2 py-2 text-[11px] text-ink/70">
90
+ {device.route ? ROUTE_LABEL[device.route] : '—'}
91
+ </td>
92
+ <td className="px-2 py-2 font-mono text-[11px] tabular-nums text-ink/70">
93
+ {device.rttMs === null ? '—' : `${device.rttMs} ms`}
94
+ </td>
95
+ <td className="px-2 py-2 text-[11px] text-ink/60">{relative(device.lastSeenAt)}</td>
96
+ <td className="px-4 py-2 text-right">
97
+ <button
98
+ type="button"
99
+ onClick={() => onRevoke(device.id)}
100
+ disabled={busy === `device:${device.id}`}
101
+ aria-label={`Revoke ${device.name}`}
102
+ className="rounded-md p-1 text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink disabled:opacity-50"
103
+ >
104
+ <Trash2 size={13} />
105
+ </button>
106
+ </td>
107
+ </tr>
108
+ ))}
109
+ </tbody>
110
+ </table>
111
+
112
+ {/* Phone: the same facts, stacked. */}
113
+ <ul className="divide-y divide-ink/5 md:hidden">
114
+ {devices.map((device) => (
115
+ <li key={device.id} className="flex items-start justify-between gap-3 px-4 py-3">
116
+ <div className="min-w-0">
117
+ <div className="text-[12px] font-medium text-ink">{device.name}</div>
118
+ <div className="mt-0.5 text-[11px] text-ink/60">
119
+ {device.platform}
120
+ {device.route ? ` · ${ROUTE_LABEL[device.route]}` : ''}
121
+ {device.rttMs === null ? '' : ` · ${device.rttMs} ms`}
122
+ {` · ${relative(device.lastSeenAt)}`}
123
+ </div>
124
+ </div>
125
+ <button
126
+ type="button"
127
+ onClick={() => onRevoke(device.id)}
128
+ disabled={busy === `device:${device.id}`}
129
+ aria-label={`Revoke ${device.name}`}
130
+ className="flex-shrink-0 rounded-md p-1.5 text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink disabled:opacity-50"
131
+ >
132
+ <Trash2 size={14} />
133
+ </button>
134
+ </li>
135
+ ))}
136
+ </ul>
137
+ </>
138
+ )}
139
+
140
+ <p className="border-t border-ink/10 px-4 py-2.5 text-[11px] leading-relaxed text-ink/55">
141
+ Each device holds its own token. Revoking cuts it off immediately; pair it again with a new code.
142
+ </p>
143
+ </section>
144
+ );
145
+ }
@@ -0,0 +1,159 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The pairing dialog's Copy link button.
8
+ *
9
+ * The bug this pins: the button called `navigator.clipboard?.writeText(...)`.
10
+ * Kabmo is routinely opened over plain HTTP on a LAN or Tailscale address — the
11
+ * exact setup the dialog exists for — and `navigator.clipboard` is undefined
12
+ * outside a secure context, so the optional chain swallowed the click with no
13
+ * copy and no feedback. The button now goes through `copyToClipboard` (which
14
+ * falls back to `execCommand`) and reports the outcome as a toast.
15
+ */
16
+
17
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
18
+ import { Window } from 'happy-dom';
19
+ import { h, render } from 'preact';
20
+ import { act } from 'preact/test-utils';
21
+ import { PairDialog } from '@/client/components/settings/categories/connect-settings/PairDialog';
22
+ import { getToastsSnapshot, resetToasts } from '@/client/hooks/ui/toasts';
23
+ import type { PairingCode } from '@/client/hooks/connect/use-pairing';
24
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
25
+
26
+ let win: Window;
27
+ let container: HTMLElement | null = null;
28
+
29
+ const CODE: PairingCode = {
30
+ pairingId: 'pair-1',
31
+ expiresAt: new Date(Date.now() + 120_000).toISOString(),
32
+ link: 'kabmo://pair#abc',
33
+ webLink: 'https://kabmo.example/pair#abc',
34
+ candidates: [{ kind: 'lan', url: 'http://192.168.1.5:3000' }],
35
+ qr: { size: 1, rows: ['1'] },
36
+ };
37
+
38
+ beforeAll(() => {
39
+ win = new Window({ url: 'http://192.168.1.5:3000' });
40
+ installDomGlobals(win);
41
+ });
42
+
43
+ afterEach(() => {
44
+ if (container) {
45
+ render(null, container);
46
+ container.remove();
47
+ }
48
+ container = null;
49
+ document.body.replaceChildren();
50
+ resetToasts();
51
+ // The dialog portals to `<body>`; unmounting the host does not remove it.
52
+ for (const node of document.querySelectorAll('[role="dialog"]')) node.remove();
53
+ });
54
+
55
+ afterAll(() => {
56
+ restoreDomGlobals();
57
+ });
58
+
59
+ /** Mount the dialog and return the button whose label is `label`. */
60
+ async function mountButton(label: string): Promise<HTMLButtonElement> {
61
+ const host = document.createElement('div');
62
+ document.body.appendChild(host);
63
+ container = host;
64
+ await act(async () => {
65
+ render(
66
+ h(PairDialog, {
67
+ code: CODE,
68
+ error: null,
69
+ busy: false,
70
+ secondsLeft: 90,
71
+ onClose: () => {},
72
+ onRetry: () => {},
73
+ }),
74
+ host,
75
+ );
76
+ });
77
+ const button = [...document.querySelectorAll('button')].find((node) => node.textContent === label);
78
+ if (!button) throw new Error(`${label} button not found`);
79
+ return button;
80
+ }
81
+
82
+ /** Make the page look like an insecure LAN origin: no async clipboard API. */
83
+ function removeClipboardApi(): void {
84
+ Object.defineProperty(win, 'isSecureContext', { value: false, configurable: true });
85
+ Object.defineProperty(win.navigator, 'clipboard', { value: undefined, configurable: true });
86
+ }
87
+
88
+ describe('PairDialog copy link', () => {
89
+ test('copies through the execCommand fallback when the clipboard API is unavailable', async () => {
90
+ removeClipboardApi();
91
+ let copied = '';
92
+ document.execCommand = ((command: string) => {
93
+ if (command !== 'copy') return false;
94
+ copied = document.querySelector('textarea')?.value ?? '';
95
+ return true;
96
+ }) as typeof document.execCommand;
97
+
98
+ const button = await mountButton('Copy link');
99
+ await act(async () => {
100
+ button.click();
101
+ });
102
+
103
+ expect(copied).toBe(CODE.webLink);
104
+ expect(getToastsSnapshot().map((toast) => [toast.message, toast.type])).toEqual([
105
+ ['Pairing link copied', 'success'],
106
+ ]);
107
+ });
108
+
109
+ test('reports a failure instead of silently doing nothing', async () => {
110
+ removeClipboardApi();
111
+ document.execCommand = (() => false) as typeof document.execCommand;
112
+
113
+ const button = await mountButton('Copy link');
114
+ await act(async () => {
115
+ button.click();
116
+ });
117
+
118
+ const toasts = getToastsSnapshot();
119
+ expect(toasts).toHaveLength(1);
120
+ expect(toasts[0]?.type).toBe('error');
121
+ expect(toasts[0]?.message).toContain('Could not copy the pairing link');
122
+ });
123
+ });
124
+
125
+ describe('PairDialog download QR', () => {
126
+ test('saves the code as an SVG file with the quiet zone included', async () => {
127
+ const blobs: Blob[] = [];
128
+ const clicked: { href: string; download: string }[] = [];
129
+ const nativeCreate = URL.createObjectURL;
130
+ const nativeRevoke = URL.revokeObjectURL;
131
+ const nativeClick = win.HTMLAnchorElement.prototype.click;
132
+ URL.createObjectURL = (blob: Blob | MediaSource) => {
133
+ blobs.push(blob as Blob);
134
+ return 'blob:qr';
135
+ };
136
+ URL.revokeObjectURL = () => {};
137
+ win.HTMLAnchorElement.prototype.click = function click(this: HTMLAnchorElement) {
138
+ clicked.push({ href: this.href, download: this.download });
139
+ };
140
+
141
+ try {
142
+ const button = await mountButton('Download QR');
143
+ await act(async () => {
144
+ button.click();
145
+ });
146
+
147
+ expect(clicked).toEqual([{ href: 'blob:qr', download: 'kabmo-pairing-qr.svg' }]);
148
+ expect(blobs[0]?.type).toBe('image/svg+xml');
149
+ const markup = await blobs[0]!.text();
150
+ // size 1 + four modules of quiet zone on each side.
151
+ expect(markup).toContain('viewBox="0 0 9 9"');
152
+ expect(markup).toContain('<rect x="4" y="4" width="1" height="1"/>');
153
+ } finally {
154
+ URL.createObjectURL = nativeCreate;
155
+ URL.revokeObjectURL = nativeRevoke;
156
+ win.HTMLAnchorElement.prototype.click = nativeClick;
157
+ }
158
+ });
159
+ });
@@ -0,0 +1,189 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The pairing dialog: one QR, its clock, and the routes it carries.
8
+ *
9
+ * PORTALED TO `<body>`, not positioned inside the settings panel. The panel is
10
+ * `overflow-hidden` and the composer card can become a containing block for
11
+ * `position: fixed` through `backdrop-filter`, a `transform` or `contain:
12
+ * layout` — either one clips or mis-sizes a nested overlay, and the dialog then
13
+ * opens in front of the wrong thing. `createPortal` is the rule the Goal dialog
14
+ * already follows for the same reason.
15
+ *
16
+ * The routes are listed because the code carries all of them: a phone that
17
+ * cannot reach the LAN address still pairs over Tailscale, and the user should
18
+ * be able to see that before scanning.
19
+ */
20
+
21
+ import { useEffect } from 'preact/hooks';
22
+ import { createPortal } from 'preact/compat';
23
+ import { X } from 'lucide-preact';
24
+ import { QrCode } from '@/client/components/settings/categories/connect-settings/QrCode';
25
+ import { downloadQrSvg } from '@/client/components/settings/categories/connect-settings/qr-image';
26
+ import { copyToClipboard } from '@/client/hooks/ui/clipboard';
27
+ import { pushToast } from '@/client/hooks/ui/toasts';
28
+ import type { PairingCode } from '@/client/hooks/connect/use-pairing';
29
+
30
+ const ROUTE_LABEL: Record<string, string> = {
31
+ tailscale: 'Tailscale',
32
+ lan: 'LAN',
33
+ cloudflare: 'Cloudflare',
34
+ };
35
+
36
+ export interface PairDialogProps {
37
+ code: PairingCode | null;
38
+ error: string | null;
39
+ busy: boolean;
40
+ secondsLeft: number;
41
+ onClose: () => void;
42
+ onRetry: () => void;
43
+ }
44
+
45
+ function clock(seconds: number): string {
46
+ const minutes = Math.floor(seconds / 60);
47
+ const rest = seconds % 60;
48
+ return `${minutes}:${String(rest).padStart(2, '0')}`;
49
+ }
50
+
51
+ /**
52
+ * Copy the pairing link and say what happened.
53
+ *
54
+ * `navigator.clipboard` is undefined outside a secure context, and Kabmo is
55
+ * routinely opened over plain HTTP on a LAN or Tailscale address — the exact
56
+ * setup this dialog exists for. The old `navigator.clipboard?.writeText(...)`
57
+ * therefore did nothing at all there, with no feedback. `copyToClipboard` falls
58
+ * back to `execCommand`, and the toast reports the outcome either way.
59
+ */
60
+ async function copyPairingLink(link: string): Promise<void> {
61
+ const ok = await copyToClipboard(link);
62
+ pushToast(
63
+ ok ? 'Pairing link copied' : 'Could not copy the pairing link — select it from the routes list instead.',
64
+ ok ? 'success' : 'error',
65
+ );
66
+ }
67
+
68
+ export function PairDialog({ code, error, busy, secondsLeft, onClose, onRetry }: PairDialogProps) {
69
+ useEffect(() => {
70
+ const onKey = (event: KeyboardEvent) => {
71
+ if (event.key === 'Escape') onClose();
72
+ };
73
+ window.addEventListener('keydown', onKey);
74
+ return () => window.removeEventListener('keydown', onKey);
75
+ }, [onClose]);
76
+
77
+ const expired = code !== null && secondsLeft === 0;
78
+
79
+ return createPortal(
80
+ <div
81
+ className="fixed inset-0 z-[60] flex items-center justify-center bg-ink/40 p-4 backdrop-blur-[2px]"
82
+ onClick={onClose}
83
+ >
84
+ <div
85
+ role="dialog"
86
+ aria-modal="true"
87
+ aria-label="Add a device"
88
+ className="w-full max-w-md rounded-2xl border border-ink/15 bg-paper p-5 shadow-2xl"
89
+ onClick={(event) => event.stopPropagation()}
90
+ >
91
+ <div className="mb-3 flex items-start justify-between gap-3">
92
+ <div>
93
+ <h3 className="text-sm font-semibold text-ink">Add a device</h3>
94
+ <p className="mt-0.5 text-[11px] text-ink/60">Scan with Kabmo on your phone.</p>
95
+ </div>
96
+ <button
97
+ type="button"
98
+ onClick={onClose}
99
+ aria-label="Close"
100
+ className="rounded-lg p-1 text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink"
101
+ >
102
+ <X size={16} />
103
+ </button>
104
+ </div>
105
+
106
+ {error && (
107
+ <p className="mb-3 rounded-lg border border-ink/10 bg-ink/[0.03] px-3 py-2 text-[11px] leading-relaxed text-ink/70">
108
+ {error}
109
+ </p>
110
+ )}
111
+
112
+ {busy && !code && <p className="py-10 text-center text-[11px] text-ink/60">Creating a code…</p>}
113
+
114
+ {code && (
115
+ <>
116
+ <div className={`flex justify-center ${expired ? 'opacity-30' : ''}`}>
117
+ <QrCode matrix={code.qr} label="Pairing QR code" />
118
+ </div>
119
+
120
+ <p className="mt-3 text-center text-[11px] text-ink/60">
121
+ {expired ? (
122
+ 'This code has expired.'
123
+ ) : (
124
+ <>
125
+ Expires in <span className="font-mono tabular-nums text-ink">{clock(secondsLeft)}</span> · works once
126
+ </>
127
+ )}
128
+ </p>
129
+
130
+ <div className="mt-4">
131
+ <div className="mb-1.5 text-[10px] font-bold uppercase tracking-wider text-ink/40">
132
+ Routes in this code
133
+ </div>
134
+ <ul className="space-y-1">
135
+ {code.candidates.map((candidate) => (
136
+ <li key={`${candidate.kind}:${candidate.url}`} className="flex items-baseline gap-2">
137
+ <span aria-hidden="true" className="mt-1.5 h-1.5 w-1.5 flex-shrink-0 rounded-full bg-ink" />
138
+ <span className="w-[74px] flex-shrink-0 text-[11px] font-semibold text-ink">
139
+ {ROUTE_LABEL[candidate.kind] ?? candidate.kind}
140
+ </span>
141
+ <span className="truncate font-mono text-[11px] text-ink/70">{candidate.url}</span>
142
+ </li>
143
+ ))}
144
+ </ul>
145
+ </div>
146
+
147
+ <div className="mt-4 flex items-center justify-between gap-2">
148
+ <div className="flex items-center gap-2">
149
+ <button
150
+ type="button"
151
+ onClick={() => void copyPairingLink(code.webLink)}
152
+ className="rounded-lg border border-ink/15 px-2.5 py-1.5 text-[11px] font-semibold text-ink transition-colors hover:bg-ink/5"
153
+ >
154
+ Copy link
155
+ </button>
156
+ <button
157
+ type="button"
158
+ onClick={() => downloadQrSvg(code.qr, 'kabmo-pairing-qr.svg', 'Pairing QR code')}
159
+ className="rounded-lg border border-ink/15 px-2.5 py-1.5 text-[11px] font-semibold text-ink transition-colors hover:bg-ink/5"
160
+ >
161
+ Download QR
162
+ </button>
163
+ </div>
164
+ <div className="flex items-center gap-2">
165
+ {expired && (
166
+ <button
167
+ type="button"
168
+ onClick={onRetry}
169
+ className="rounded-lg border border-ink/15 px-2.5 py-1.5 text-[11px] font-semibold text-ink transition-colors hover:bg-ink/5"
170
+ >
171
+ New code
172
+ </button>
173
+ )}
174
+ <button
175
+ type="button"
176
+ onClick={onClose}
177
+ className="rounded-lg bg-ink px-3 py-1.5 text-[11px] font-semibold text-paper transition-opacity hover:opacity-90"
178
+ >
179
+ Done
180
+ </button>
181
+ </div>
182
+ </div>
183
+ </>
184
+ )}
185
+ </div>
186
+ </div>,
187
+ document.body,
188
+ );
189
+ }
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The pairing QR, drawn from the server's module matrix.
8
+ *
9
+ * A matrix rather than an SVG string from the server: the payload is a deep link
10
+ * carrying a one-time secret, and injecting server-built markup to render it is
11
+ * the shortcut that turns a QR renderer into an injection point. Here the only
12
+ * thing that reaches the DOM is a `<rect>` per dark module.
13
+ *
14
+ * The quiet zone is part of the drawing, not padding on the container: a scanner
15
+ * needs four modules of margin, and a CSS padding that a theme or a layout rule
16
+ * can shrink is a code that scans on one screen and not another.
17
+ */
18
+
19
+ import type { JSX } from 'preact';
20
+ import { QUIET_ZONE, qrGeometry } from '@/client/components/settings/categories/connect-settings/qr-image';
21
+ import type { QrMatrix } from '@/shared/lib/connect/types';
22
+
23
+ export function QrCode({ matrix, label }: { matrix: QrMatrix; label: string }) {
24
+ const { span, edge } = qrGeometry(matrix);
25
+ const rects: JSX.Element[] = [];
26
+ for (let row = 0; row < matrix.size; row += 1) {
27
+ const line = matrix.rows[row] ?? '';
28
+ for (let column = 0; column < matrix.size; column += 1) {
29
+ if (line[column] !== '1') continue;
30
+ rects.push(
31
+ <rect
32
+ key={`${row}:${column}`}
33
+ x={column + QUIET_ZONE}
34
+ y={row + QUIET_ZONE}
35
+ width={1}
36
+ height={1}
37
+ />,
38
+ );
39
+ }
40
+ }
41
+
42
+ return (
43
+ <svg
44
+ role="img"
45
+ aria-label={label}
46
+ viewBox={`0 0 ${span} ${span}`}
47
+ width={edge}
48
+ height={edge}
49
+ className="block h-auto max-w-full rounded-lg bg-white"
50
+ shape-rendering="crispEdges"
51
+ >
52
+ <rect x={0} y={0} width={span} height={span} fill="#ffffff" />
53
+ <g fill="#141310">{rects}</g>
54
+ </svg>
55
+ );
56
+ }