@kabmo-labs/kabmo 0.34.0 → 0.36.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 (210) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +435 -432
  3. package/dist/client/static/js/{CsvGrid-vze4m5ag.js → CsvGrid-1h3bcak7.js} +2 -2
  4. package/dist/client/static/js/{DocxView-jbf21gmh.js → DocxView-ndca8jch.js} +3 -3
  5. package/dist/client/static/js/{DrawioView-b52qybx5.js → DrawioView-kpzd6y0b.js} +2 -2
  6. package/dist/client/static/js/{ImageView-mdgzj8px.js → ImageView-79prn3dg.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-3c49dvtt.js → LayoutWrapper-v2wn2sb2.js} +2 -2
  8. package/dist/client/static/js/{Modal-sqp864vd.js → Modal-99j0zz3z.js} +16 -16
  9. package/dist/client/static/js/{PdfView-g06rxqb1.js → PdfView-2rjd87ay.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-521adxyr.js → SessionsView-t7f3s71b.js} +1 -1
  11. package/dist/client/static/js/{SheetView-h8xmsz7q.js → SheetView-ehb976st.js} +4 -4
  12. package/dist/client/static/js/{SvgPreview-1j4jvcvz.js → SvgPreview-de2bbba6.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-pasxh4b6.js → abnfDiagram-O67JEVCF-nx9jzn7m.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-aqft2erp.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-ms14g0bm.js → architectureDiagram-NJMV4G6O-170v67rr.js} +2 -2
  16. package/dist/client/static/js/{blockDiagram-BEXU5L5S-ycn78fcq.js → blockDiagram-BEXU5L5S-16q285n1.js} +2 -2
  17. package/dist/client/static/js/{c4Diagram-YGBWAQC7-vn2gpjfm.js → c4Diagram-YGBWAQC7-rn3qt45h.js} +1 -1
  18. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fyrm1pr5.js → classDiagram-v2-NBCMYWYE-r26wg74e.js} +3 -3
  19. package/dist/client/static/js/{cose-bilkent-JH36ORCC-ea5nwvgq.js → cose-bilkent-JH36ORCC-82kwe7ha.js} +1 -1
  20. package/dist/client/static/js/css-r2nhvzff.js +1 -0
  21. package/dist/client/static/js/cynefin-OW5HDTMX-v2sz60t6.js +1 -0
  22. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-j6bsjpre.js → cynefinDiagram-VND7K2PF-tcxdn6pa.js} +1 -1
  23. package/dist/client/static/js/{dagre-6A5THRUB-4smdkwv8.js → dagre-6A5THRUB-g833ata3.js} +2 -2
  24. package/dist/client/static/js/{diagram-22UHCM2B-9sm4kqwc.js → diagram-22UHCM2B-f1fq8xec.js} +4 -4
  25. package/dist/client/static/js/{diagram-3UASUU5V-2h3qxaed.js → diagram-3UASUU5V-6j2w016f.js} +1 -1
  26. package/dist/client/static/js/{diagram-ATOU4E4O-1981bc94.js → diagram-ATOU4E4O-6t2qxsk4.js} +1 -1
  27. package/dist/client/static/js/{diagram-CDSNMT55-3vgsxavc.js → diagram-CDSNMT55-7abar8s7.js} +1 -1
  28. package/dist/client/static/js/{diagram-MLGK6HIB-c9gf2r3f.js → diagram-MLGK6HIB-s68rgy16.js} +1 -1
  29. package/dist/client/static/js/{diagram-MPIPVDR6-gjqeq92d.js → diagram-MPIPVDR6-azgkm6w8.js} +1 -1
  30. package/dist/client/static/js/{dockerfile-8v935dkn.js → dockerfile-47e33kqa.js} +1 -1
  31. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4vbsgh99.js → ebnfDiagram-ZINNZB2B-esrjz750.js} +1 -1
  32. package/dist/client/static/js/{elixir-vcbg60wv.js → elixir-rpa1g4gy.js} +1 -1
  33. package/dist/client/static/js/{elk-276RUBZZ-nca3t891.js → elk-276RUBZZ-fhr4b4jj.js} +1 -1
  34. package/dist/client/static/js/{erDiagram-OPXOYQCR-5kfkev03.js → erDiagram-OPXOYQCR-5r3fmdnz.js} +2 -2
  35. package/dist/client/static/js/{erlang-qt876zrq.js → erlang-bh5cbm8m.js} +1 -1
  36. package/dist/client/static/js/eventmodeling-NTZA5JFV-8qbefe4m.js +1 -0
  37. package/dist/client/static/js/flowDiagram-KWPJA3E3-krsvgcq7.js +1 -0
  38. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-mxc73wmq.js → ganttDiagram-FUAMR5RP-j4pf6rdn.js} +2 -2
  39. package/dist/client/static/js/gitGraph-4MIJSDKK-9bx1a38k.js +1 -0
  40. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-7en3ag0e.js → gitGraphDiagram-X574FWY7-x5epk0gr.js} +1 -1
  41. package/dist/client/static/js/graphql-xnpp5gn9.js +1 -0
  42. package/dist/client/static/js/html-pv88ny12.js +1 -0
  43. package/dist/client/static/js/{index-j51d5a5m.js → index-0b1kwsam.js} +28 -28
  44. package/dist/client/static/js/{index-52rqxgya.js → index-3kgrcaq1.js} +1 -1
  45. package/dist/client/static/js/{index-vhqe0y82.js → index-3vdmwpbh.js} +2 -2
  46. package/dist/client/static/js/{index-g2dyfze9.js → index-40ve7zzv.js} +1 -1
  47. package/dist/client/static/js/{index-eyfcm0cy.js → index-44qrckd2.js} +1 -1
  48. package/dist/client/static/js/{index-qckv9nte.js → index-55pqvh82.js} +2 -2
  49. package/dist/client/static/js/{index-r014brzs.js → index-5kjpacvd.js} +1 -1
  50. package/dist/client/static/js/{index-ev3yt353.js → index-5rzk1226.js} +1 -1
  51. package/dist/client/static/js/{index-p0nz38bm.js → index-60ceydzn.js} +1 -1
  52. package/dist/client/static/js/{index-ybm2x4vh.js → index-63c6t75t.js} +1 -1
  53. package/dist/client/static/js/{index-ahv9y42z.js → index-63jbb4kf.js} +2 -2
  54. package/dist/client/static/js/{index-nccwxv0s.js → index-6xzfta4b.js} +1 -1
  55. package/dist/client/static/js/{index-cgzrpvzj.js → index-75haaj8g.js} +169 -169
  56. package/dist/client/static/js/{index-ag2rmtas.js → index-7r1hw2gd.js} +1 -1
  57. package/dist/client/static/js/{index-hf52f59k.js → index-8cy3x2y8.js} +2 -2
  58. package/dist/client/static/js/{index-vy6termr.js → index-8e15fzax.js} +1 -1
  59. package/dist/client/static/js/{index-rzxcj7cg.js → index-97t3mv1v.js} +1 -1
  60. package/dist/client/static/js/{index-km2zb6wk.js → index-982jyfsb.js} +2 -2
  61. package/dist/client/static/js/{index-jsyekbx9.js → index-9gf8b73w.js} +1 -1
  62. package/dist/client/static/js/{index-s7gkkkyz.js → index-a293pdg7.js} +2 -2
  63. package/dist/client/static/js/{index-dbe6afkf.js → index-af24nes6.js} +2 -2
  64. package/dist/client/static/js/{index-ptcwae2n.js → index-b48p8d1j.js} +2 -2
  65. package/dist/client/static/js/{index-cd65zqba.js → index-be6gevq8.js} +1 -1
  66. package/dist/client/static/js/{index-231241f4.js → index-c09a5s1n.js} +9 -9
  67. package/dist/client/static/js/{index-fvmfge3p.js → index-c1j0xb0w.js} +1 -1
  68. package/dist/client/static/js/{index-fta1y9pc.js → index-ctgefatv.js} +10 -10
  69. package/dist/client/static/js/{index-7a64yjrm.js → index-d2km9egp.js} +4 -4
  70. package/dist/client/static/js/index-dh1vd0d9.js +1 -0
  71. package/dist/client/static/js/{index-j0r5hj0j.js → index-dmgawfhw.js} +2 -2
  72. package/dist/client/static/js/{index-1ksg88qf.js → index-h1e1abpt.js} +2 -2
  73. package/dist/client/static/js/{index-4g46wbdw.js → index-htt8qxm3.js} +1 -1
  74. package/dist/client/static/js/{index-c3ek61zv.js → index-k1xt92h4.js} +1 -1
  75. package/dist/client/static/js/{index-f7jhhqtk.js → index-ktvbsj6w.js} +1 -1
  76. package/dist/client/static/js/{index-a0fmsv1d.js → index-ky0prc71.js} +6 -6
  77. package/dist/client/static/js/{index-2svnq5gg.js → index-mm1rf116.js} +1 -1
  78. package/dist/client/static/js/{index-h5bn97p6.js → index-nws03exw.js} +1 -1
  79. package/dist/client/static/js/{index-xx6mqpxm.js → index-pyx8n25s.js} +2 -2
  80. package/dist/client/static/js/{index-rs80cwsv.js → index-q5t4sy22.js} +3 -3
  81. package/dist/client/static/js/{index-76zb4m0n.js → index-r8pckaqe.js} +2 -2
  82. package/dist/client/static/js/{index-4qwzxj81.js → index-sar2ggde.js} +1 -1
  83. package/dist/client/static/js/{index-1b0t1428.js → index-skm6k5w2.js} +3 -3
  84. package/dist/client/static/js/{index-b29afsjh.js → index-v5t761a1.js} +1 -1
  85. package/dist/client/static/js/{index-7y6rpsrp.js → index-v8qd8ypc.js} +2 -2
  86. package/dist/client/static/js/{index-354mqqra.js → index-w3n97x4b.js} +2 -2
  87. package/dist/client/static/js/{index-0vm41je9.js → index-ydvfc9td.js} +1 -1
  88. package/dist/client/static/js/{index-ptcrwswj.js → index-ye450a7z.js} +1 -1
  89. package/dist/client/static/js/{index-rytaa8ca.js → index-z6g74h7g.js} +2 -2
  90. package/dist/client/static/js/{index-sd66wv26.js → index-zdtsvnpq.js} +2 -2
  91. package/dist/client/static/js/{index-pm6xxwz1.js → index-zp73zexp.js} +2 -2
  92. package/dist/client/static/js/info-A6RAGUB7-j51t7jhh.js +1 -0
  93. package/dist/client/static/js/{infoDiagram-VRGFBTTK-sef80132.js → infoDiagram-VRGFBTTK-ktc8nb8g.js} +1 -1
  94. package/dist/client/static/js/ini-ygfyhprj.js +1 -0
  95. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-yhvepp1q.js → ishikawaDiagram-OU5B5YK6-n3dk6227.js} +2 -2
  96. package/dist/client/static/js/java-gm49vw59.js +1 -0
  97. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-5w77y95w.js → journeyDiagram-ZHPQQLJL-f0p1h8qn.js} +3 -3
  98. package/dist/client/static/js/jsx-ksxw1byz.js +1 -0
  99. package/dist/client/static/js/{julia-d4j6wgvf.js → julia-73zjh2w6.js} +1 -1
  100. package/dist/client/static/js/{kanban-definition-PNTS6WVX-02znqtna.js → kanban-definition-PNTS6WVX-7jdt7dv1.js} +2 -2
  101. package/dist/client/static/js/lua-53gzb9bx.js +1 -0
  102. package/dist/client/static/js/markdown-tk3cd3vs.js +1 -0
  103. package/dist/client/static/js/{mermaid.core-a6e6vck4.js → mermaid.core-e8rzrjt9.js} +6 -6
  104. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-y4n74q9x.js → mindmap-definition-NLK3R4M7-7shv6ge0.js} +2 -2
  105. package/dist/client/static/js/one-dark-pro-39bt34v9.js +1 -0
  106. package/dist/client/static/js/one-light-xec0sehr.js +1 -0
  107. package/dist/client/static/js/packet-AYTQ26CC-n83gfj2g.js +1 -0
  108. package/dist/client/static/js/{pegDiagram-GJSIUBJH-pr7ehgzb.js → pegDiagram-GJSIUBJH-17ak2zx3.js} +1 -1
  109. package/dist/client/static/js/{perl-srptw5vm.js → perl-8z46dmze.js} +1 -1
  110. package/dist/client/static/js/{php-n89g3fk7.js → php-6qvnp2t6.js} +1 -1
  111. package/dist/client/static/js/pie-WAS4IAKB-5c5pctwz.js +1 -0
  112. package/dist/client/static/js/{pieDiagram-5QR66LMP-39wpsk08.js → pieDiagram-5QR66LMP-at4x1g4q.js} +2 -2
  113. package/dist/client/static/js/properties-2tcybqjk.js +1 -0
  114. package/dist/client/static/js/python-qph3dntq.js +1 -0
  115. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-esm913km.js → quadrantDiagram-O4NWA36T-apzhwrn4.js} +1 -1
  116. package/dist/client/static/js/r-gd26x93y.js +1 -0
  117. package/dist/client/static/js/radar-RG4KPBEZ-52e5n99a.js +1 -0
  118. package/dist/client/static/js/railroad-74A4TZTK-44nqxxpy.js +1 -0
  119. package/dist/client/static/js/railroad-abnf-HS5TGJTU-25jxgwg7.js +1 -0
  120. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-64pqpf2y.js +1 -0
  121. package/dist/client/static/js/railroad-peg-WCYAUIDC-0p5sxzpx.js +1 -0
  122. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-wy2mgya6.js → railroadDiagram-XR7U4H2S-rw8cj5f3.js} +1 -1
  123. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-6z9xdgbq.js → requirementDiagram-PLB6GJNP-qyrse7mb.js} +1 -1
  124. package/dist/client/static/js/{ruby-r81ytgcm.js → ruby-qy8mhstq.js} +1 -1
  125. package/dist/client/static/js/{rust-frn3szvc.js → rust-fpshqnk0.js} +1 -1
  126. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-rtmxk3ys.js → sankeyDiagram-IPEJSGJF-254qr59q.js} +1 -1
  127. package/dist/client/static/js/{sass-9bxped7y.js → sass-kbwea482.js} +1 -1
  128. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-awzcrafg.js → sequenceDiagram-PO4LG4MO-y9xjxfc5.js} +3 -3
  129. package/dist/client/static/js/{sizeCapture-INFHLROL-03gy196j.js → sizeCapture-INFHLROL-sc5e60t3.js} +1 -1
  130. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-an8v3q5n.js → stateDiagram-v2-GCMORJYK-r134s4xr.js} +2 -2
  131. package/dist/client/static/js/{swimlanes-2SLR337P-n9yb4wcs.js → swimlanes-2SLR337P-xc7rbawt.js} +1 -1
  132. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-kdcdamkj.js +8 -0
  133. package/dist/client/static/js/{timeline-definition-EJHVYXUP-jceb575g.js → timeline-definition-EJHVYXUP-cgjd8shk.js} +2 -2
  134. package/dist/client/static/js/treeView-Q6P3EWNA-8j14nnd1.js +1 -0
  135. package/dist/client/static/js/treemap-WGGIJYW6-esf993kk.js +1 -0
  136. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-888h3100.js → usecaseDiagram-POWQR4AR-9qsmjhm6.js} +4 -4
  137. package/dist/client/static/js/{vennDiagram-UO4OBE2U-wbfz0rzv.js → vennDiagram-UO4OBE2U-4grw9awx.js} +1 -1
  138. package/dist/client/static/js/{vue-c0rtg1wf.js → vue-j8vb9d7r.js} +1 -1
  139. package/dist/client/static/js/wardley-WFR3VGLG-v4dxm2sb.js +1 -0
  140. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-rn8c5qf9.js → wardleyDiagram-VNRHLVJA-8gxy0wat.js} +1 -1
  141. package/dist/client/static/js/xml-0py2vkw7.js +1 -0
  142. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-8sn1apt6.js → xychartDiagram-PMCCYNJV-5sh7tdrx.js} +2 -2
  143. package/dist/client/static/js/yaml-vghdz0f0.js +1 -0
  144. package/package.json +1 -1
  145. package/src/client/components/settings/categories/ConnectSettings.tsx +8 -1
  146. package/src/client/components/settings/categories/connect-settings/CloudflareConfig.test.tsx +84 -0
  147. package/src/client/components/settings/categories/connect-settings/CloudflareConfig.tsx +68 -0
  148. package/src/client/components/settings/categories/connect-settings/PairDialog.test.tsx +159 -0
  149. package/src/client/components/settings/categories/connect-settings/PairDialog.tsx +40 -7
  150. package/src/client/components/workspace/git-panel/init-state.test.ts +5 -0
  151. package/src/client/hooks/chat/composer/speech-to-text.ts +24 -17
  152. package/src/client/hooks/connect/use-connect-status.ts +44 -19
  153. package/src/client/hooks/connect/use-pairing.ts +5 -0
  154. package/src/client/hooks/editor/file-actions.ts +3 -11
  155. package/src/client/hooks/editor/font.test.ts +2 -1
  156. package/src/client/hooks/editor/use-file-transfer.ts +2 -1
  157. package/src/client/lib/browser/download.ts +22 -0
  158. package/src/client/lib/notifications/watch.ts +4 -1
  159. package/src/server/lib/connect/cloudflared-config.server.ts +236 -0
  160. package/src/server/lib/connect/cloudflared-config.test.ts +245 -0
  161. package/src/server/lib/connect/cloudflared.lifecycle.test.ts +116 -15
  162. package/src/server/lib/connect/cloudflared.server.ts +53 -66
  163. package/src/server/lib/connect/pairing.server.ts +33 -0
  164. package/src/server/lib/connect/qr-png.server.test.ts +93 -0
  165. package/src/server/lib/connect/qr-png.server.ts +119 -0
  166. package/src/server/lib/connect/status.server.ts +10 -4
  167. package/src/server/routes/connect/index.ts +2 -0
  168. package/src/server/routes/connect/pair-qr.test.ts +72 -0
  169. package/src/server/routes/connect/pair-qr.ts +44 -0
  170. package/src/server/routes/connect/pair.ts +8 -2
  171. package/src/server/routes/connect/tunnels.test.ts +141 -0
  172. package/src/server/routes/connect/tunnels.ts +32 -7
  173. package/src/server/routes/notifications/stream.ts +11 -2
  174. package/src/shared/lib/connect/types.ts +7 -0
  175. package/src/shared/lib/dictation/capture-failure.test.ts +46 -0
  176. package/src/shared/lib/dictation/capture-failure.ts +36 -0
  177. package/dist/client/static/js/architecture-7GRP2DOG-fc9kmq1w.js +0 -1
  178. package/dist/client/static/js/css-6vj0d308.js +0 -1
  179. package/dist/client/static/js/cynefin-OW5HDTMX-a4t8992q.js +0 -1
  180. package/dist/client/static/js/eventmodeling-NTZA5JFV-18bdrkv5.js +0 -1
  181. package/dist/client/static/js/flowDiagram-KWPJA3E3-fg0yqx0h.js +0 -1
  182. package/dist/client/static/js/gitGraph-4MIJSDKK-8fa6y40p.js +0 -1
  183. package/dist/client/static/js/graphql-n43pd5fs.js +0 -1
  184. package/dist/client/static/js/html-dbrwss36.js +0 -1
  185. package/dist/client/static/js/index-6sf2vsp2.js +0 -1
  186. package/dist/client/static/js/info-A6RAGUB7-3hk844f7.js +0 -1
  187. package/dist/client/static/js/ini-j5dyq6gm.js +0 -1
  188. package/dist/client/static/js/java-g4dgwbfd.js +0 -1
  189. package/dist/client/static/js/jsx-7t5ecz9s.js +0 -1
  190. package/dist/client/static/js/lua-1g6w30de.js +0 -1
  191. package/dist/client/static/js/markdown-afx21x8c.js +0 -1
  192. package/dist/client/static/js/one-dark-pro-vwhfpzr8.js +0 -1
  193. package/dist/client/static/js/one-light-y5t9x6zh.js +0 -1
  194. package/dist/client/static/js/packet-AYTQ26CC-4nj2yy10.js +0 -1
  195. package/dist/client/static/js/pie-WAS4IAKB-k7rde3f9.js +0 -1
  196. package/dist/client/static/js/properties-thd83wey.js +0 -1
  197. package/dist/client/static/js/python-264ns4xw.js +0 -1
  198. package/dist/client/static/js/r-qw82kkv9.js +0 -1
  199. package/dist/client/static/js/radar-RG4KPBEZ-513dpw4f.js +0 -1
  200. package/dist/client/static/js/railroad-74A4TZTK-9bqnst9c.js +0 -1
  201. package/dist/client/static/js/railroad-abnf-HS5TGJTU-7367d5bv.js +0 -1
  202. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-b806b1mj.js +0 -1
  203. package/dist/client/static/js/railroad-peg-WCYAUIDC-5a67rwf8.js +0 -1
  204. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-nx5nfnf0.js +0 -8
  205. package/dist/client/static/js/treeView-Q6P3EWNA-kcy40evb.js +0 -1
  206. package/dist/client/static/js/treemap-WGGIJYW6-fsrvqxf4.js +0 -1
  207. package/dist/client/static/js/wardley-WFR3VGLG-36dmxww4.js +0 -1
  208. package/dist/client/static/js/xml-dz51p1m3.js +0 -1
  209. package/dist/client/static/js/yaml-2cfkd30t.js +0 -1
  210. package/src/server/lib/connect/cloudflared.server.test.ts +0 -65
@@ -0,0 +1,84 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The config-path field's one contract: the server is not asked to save a path
8
+ * the user has not changed, and what it is asked to save is the trimmed text.
9
+ *
10
+ * The save is the failure point that matters — a button that fires on every
11
+ * keystroke would rewrite `app_settings` while the user is still typing.
12
+ */
13
+
14
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
15
+ import { Window } from 'happy-dom';
16
+ import { h, render } from 'preact';
17
+ import { act } from 'preact/test-utils';
18
+ import { CloudflareConfig } from '@/client/components/settings/categories/connect-settings/CloudflareConfig';
19
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
20
+
21
+ let win: Window;
22
+ let container: HTMLElement | null = null;
23
+
24
+ beforeAll(() => {
25
+ win = new Window({ url: 'http://localhost:3000' });
26
+ installDomGlobals(win);
27
+ });
28
+
29
+ afterEach(() => {
30
+ if (container) {
31
+ render(null, container);
32
+ container.remove();
33
+ }
34
+ container = null;
35
+ document.body.replaceChildren();
36
+ });
37
+
38
+ afterAll(() => {
39
+ restoreDomGlobals();
40
+ });
41
+
42
+ function mount(path: string, onSave: (next: string) => void): HTMLButtonElement {
43
+ const host = document.createElement('div');
44
+ document.body.appendChild(host);
45
+ container = host;
46
+ act(() => {
47
+ render(h(CloudflareConfig, { path, busy: false, onSave }), host);
48
+ });
49
+ const button = [...document.querySelectorAll('button')].find((node) => node.textContent === 'Save');
50
+ if (!button) throw new Error('Save button not found');
51
+ return button as HTMLButtonElement;
52
+ }
53
+
54
+ function input(): HTMLInputElement {
55
+ const field = document.querySelector('input');
56
+ if (!field) throw new Error('input not found');
57
+ return field as HTMLInputElement;
58
+ }
59
+
60
+ describe('CloudflareConfig', () => {
61
+ test('shows the effective path and saves nothing while it is unchanged', () => {
62
+ const saved: string[] = [];
63
+ const button = mount('/home/me/.cloudflared/config.yml', (next) => saved.push(next));
64
+
65
+ expect(input().value).toBe('/home/me/.cloudflared/config.yml');
66
+ expect(button.disabled).toBe(true);
67
+ act(() => button.click());
68
+ expect(saved).toEqual([]);
69
+ });
70
+
71
+ test('saves the trimmed path once the field changes', async () => {
72
+ const saved: string[] = [];
73
+ const button = mount('/home/me/.cloudflared/config.yml', (next) => saved.push(next));
74
+
75
+ await act(async () => {
76
+ input().value = ' /srv/tunnels/kabmo.yml ';
77
+ input().dispatchEvent(new Event('input', { bubbles: true }));
78
+ });
79
+
80
+ expect(button.disabled).toBe(false);
81
+ act(() => button.click());
82
+ expect(saved).toEqual(['/srv/tunnels/kabmo.yml']);
83
+ });
84
+ });
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Which cloudflared config the Cloudflare row reads.
8
+ *
9
+ * Shown because a machine can hold more than one config (a work profile, a
10
+ * secret store) and the tunnel's own state cannot answer "which file am I
11
+ * using?". Saving is a server action: the path is refused unless cloudflared
12
+ * could actually run from it, and the refusal is the server's sentence.
13
+ */
14
+
15
+ import { useEffect, useState } from 'preact/hooks';
16
+
17
+ const INPUT_CLASS =
18
+ 'w-full rounded-md border border-ink/20 bg-paper px-2 py-1.5 font-mono text-[11px] text-ink outline-none transition-colors placeholder:text-ink/30 focus:border-ink/50';
19
+
20
+ export interface CloudflareConfigProps {
21
+ path: string;
22
+ busy: boolean;
23
+ onSave: (path: string) => void;
24
+ }
25
+
26
+ export function CloudflareConfig({ path, busy, onSave }: CloudflareConfigProps) {
27
+ const [draft, setDraft] = useState(path);
28
+ // A save, or a reset from another tab, rewrites the effective path; the field
29
+ // follows it rather than keeping a value the server is not using.
30
+ useEffect(() => setDraft(path), [path]);
31
+
32
+ const dirty = draft.trim() !== path;
33
+
34
+ return (
35
+ <section className="rounded-xl border border-ink/10 bg-paper">
36
+ <header className="border-b border-ink/10 px-4 py-3">
37
+ <h4 className="text-sm font-semibold text-ink">Cloudflare config</h4>
38
+ </header>
39
+ <div className="space-y-2 px-4 py-3">
40
+ <label className="flex flex-col gap-1">
41
+ <span className="text-[10px] text-ink/50">Config file</span>
42
+ <input
43
+ type="text"
44
+ value={draft}
45
+ spellcheck={false}
46
+ placeholder="~/.cloudflared/config.yml"
47
+ onInput={(event) => setDraft(event.currentTarget.value)}
48
+ className={INPUT_CLASS}
49
+ />
50
+ </label>
51
+ <p className="text-[11px] leading-relaxed text-ink/60">
52
+ The tunnel runs a copy of this file with its ingress <code className="font-mono">service:</code> pointed at
53
+ this server's port, so the file's own service line is left alone. Empty uses the default path.
54
+ </p>
55
+ <div className="flex justify-end">
56
+ <button
57
+ type="button"
58
+ disabled={busy || !dirty}
59
+ onClick={() => onSave(draft.trim())}
60
+ className="rounded-md bg-ink px-2.5 py-1 text-[11px] font-medium text-paper transition-opacity disabled:cursor-not-allowed disabled:opacity-40"
61
+ >
62
+ {busy ? 'Saving…' : 'Save'}
63
+ </button>
64
+ </div>
65
+ </div>
66
+ </section>
67
+ );
68
+ }
@@ -0,0 +1,159 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The pairing dialog's two outbound controls.
8
+ *
9
+ * The Copy link cases pin the bug where the button called
10
+ * `navigator.clipboard?.writeText(...)`. Kabmo is routinely opened over plain
11
+ * HTTP on a LAN or Tailscale address — the exact setup the dialog exists for —
12
+ * and `navigator.clipboard` is undefined outside a secure context, so the
13
+ * optional chain swallowed the click with no copy and no feedback. The button now
14
+ * goes through `copyToClipboard` (which falls back to `execCommand`) and reports
15
+ * the outcome as a toast.
16
+ *
17
+ * The Download case pins the SECOND bug: the control used to build a Blob and
18
+ * click an anchor the page created itself. A native shell cannot download a
19
+ * `blob:` URL — Android's download listener ignores it, and the desktop shells
20
+ * never see a navigation — so the button did nothing there while the file it
21
+ * produced in a browser was an SVG most viewers refuse to open. It is now a real
22
+ * link to the server's PNG, which is the one shape every host can download.
23
+ */
24
+
25
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
26
+ import { Window } from 'happy-dom';
27
+ import { h, render } from 'preact';
28
+ import { act } from 'preact/test-utils';
29
+ import { PairDialog } from '@/client/components/settings/categories/connect-settings/PairDialog';
30
+ import { getToastsSnapshot, resetToasts } from '@/client/hooks/ui/toasts';
31
+ import type { PairingCode } from '@/client/hooks/connect/use-pairing';
32
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
33
+
34
+ let win: Window;
35
+ let container: HTMLElement | null = null;
36
+
37
+ const CODE: PairingCode = {
38
+ pairingId: 'pair-1',
39
+ expiresAt: new Date(Date.now() + 120_000).toISOString(),
40
+ link: 'kabmo://pair#abc',
41
+ webLink: 'https://kabmo.example/pair#abc',
42
+ qrUrl: '/api/connect/pair/qr.png?pairingId=pair-1',
43
+ candidates: [{ kind: 'lan', url: 'http://192.168.1.5:3000' }],
44
+ qr: { size: 1, rows: ['1'] },
45
+ };
46
+
47
+ beforeAll(() => {
48
+ win = new Window({ url: 'http://192.168.1.5:3000' });
49
+ installDomGlobals(win);
50
+ });
51
+
52
+ afterEach(() => {
53
+ if (container) {
54
+ render(null, container);
55
+ container.remove();
56
+ }
57
+ container = null;
58
+ document.body.replaceChildren();
59
+ resetToasts();
60
+ // The dialog portals to `<body>`; unmounting the host does not remove it.
61
+ for (const node of document.querySelectorAll('[role="dialog"]')) node.remove();
62
+ });
63
+
64
+ afterAll(() => {
65
+ restoreDomGlobals();
66
+ });
67
+
68
+ /** Mount the dialog. */
69
+ async function mountDialog(secondsLeft = 90): Promise<void> {
70
+ const host = document.createElement('div');
71
+ document.body.appendChild(host);
72
+ container = host;
73
+ await act(async () => {
74
+ render(
75
+ h(PairDialog, {
76
+ code: CODE,
77
+ error: null,
78
+ busy: false,
79
+ secondsLeft,
80
+ onClose: () => {},
81
+ onRetry: () => {},
82
+ }),
83
+ host,
84
+ );
85
+ });
86
+ }
87
+
88
+ /** The control whose visible label is `label`. */
89
+ function control(label: string): HTMLElement {
90
+ const node = [...document.querySelectorAll<HTMLElement>('button, a')].find(
91
+ (candidate) => candidate.textContent === label,
92
+ );
93
+ if (!node) throw new Error(`${label} control not found`);
94
+ return node;
95
+ }
96
+
97
+ /** Make the page look like an insecure LAN origin: no async clipboard API. */
98
+ function removeClipboardApi(): void {
99
+ Object.defineProperty(win, 'isSecureContext', { value: false, configurable: true });
100
+ Object.defineProperty(win.navigator, 'clipboard', { value: undefined, configurable: true });
101
+ }
102
+
103
+ describe('PairDialog copy link', () => {
104
+ test('copies through the execCommand fallback when the clipboard API is unavailable', async () => {
105
+ removeClipboardApi();
106
+ let copied = '';
107
+ document.execCommand = ((command: string) => {
108
+ if (command !== 'copy') return false;
109
+ copied = document.querySelector('textarea')?.value ?? '';
110
+ return true;
111
+ }) as typeof document.execCommand;
112
+
113
+ await mountDialog();
114
+ await act(async () => {
115
+ control('Copy link').click();
116
+ });
117
+
118
+ expect(copied).toBe(CODE.webLink);
119
+ expect(getToastsSnapshot().map((toast) => [toast.message, toast.type])).toEqual([
120
+ ['Pairing link copied', 'success'],
121
+ ]);
122
+ });
123
+
124
+ test('reports a failure instead of silently doing nothing', async () => {
125
+ removeClipboardApi();
126
+ document.execCommand = (() => false) as typeof document.execCommand;
127
+
128
+ await mountDialog();
129
+ await act(async () => {
130
+ control('Copy link').click();
131
+ });
132
+
133
+ const toasts = getToastsSnapshot();
134
+ expect(toasts).toHaveLength(1);
135
+ expect(toasts[0]?.type).toBe('error');
136
+ expect(toasts[0]?.message).toContain('Could not copy the pairing link');
137
+ });
138
+ });
139
+
140
+ describe('PairDialog download QR', () => {
141
+ test('is a link to the server PNG, not a Blob the page builds', async () => {
142
+ await mountDialog();
143
+ const link = control('Download QR');
144
+ expect(link.tagName).toBe('A');
145
+ const anchor = link as HTMLAnchorElement;
146
+ expect(anchor.getAttribute('href')).toBe(CODE.qrUrl);
147
+ expect(anchor.getAttribute('download')).toBe('kabmo-pairing-qr.png');
148
+ // An SVG was the first attempt, and viewers rejected it.
149
+ expect(anchor.getAttribute('href')).not.toContain('.svg');
150
+ });
151
+
152
+ test('an expired code offers no download, because the server would save its refusal', async () => {
153
+ await mountDialog(0);
154
+ const labels = [...document.querySelectorAll<HTMLElement>('button, a')].map((node) => node.textContent);
155
+ expect(labels).not.toContain('Download QR');
156
+ // The link stays available for a different reason: it is a copy, not a file.
157
+ expect(labels).toContain('Copy link');
158
+ });
159
+ });
@@ -22,6 +22,8 @@ import { useEffect } from 'preact/hooks';
22
22
  import { createPortal } from 'preact/compat';
23
23
  import { X } from 'lucide-preact';
24
24
  import { QrCode } from '@/client/components/settings/categories/connect-settings/QrCode';
25
+ import { copyToClipboard } from '@/client/hooks/ui/clipboard';
26
+ import { pushToast } from '@/client/hooks/ui/toasts';
25
27
  import type { PairingCode } from '@/client/hooks/connect/use-pairing';
26
28
 
27
29
  const ROUTE_LABEL: Record<string, string> = {
@@ -45,6 +47,23 @@ function clock(seconds: number): string {
45
47
  return `${minutes}:${String(rest).padStart(2, '0')}`;
46
48
  }
47
49
 
50
+ /**
51
+ * Copy the pairing link and say what happened.
52
+ *
53
+ * `navigator.clipboard` is undefined outside a secure context, and Kabmo is
54
+ * routinely opened over plain HTTP on a LAN or Tailscale address — the exact
55
+ * setup this dialog exists for. The old `navigator.clipboard?.writeText(...)`
56
+ * therefore did nothing at all there, with no feedback. `copyToClipboard` falls
57
+ * back to `execCommand`, and the toast reports the outcome either way.
58
+ */
59
+ async function copyPairingLink(link: string): Promise<void> {
60
+ const ok = await copyToClipboard(link);
61
+ pushToast(
62
+ ok ? 'Pairing link copied' : 'Could not copy the pairing link — select it from the routes list instead.',
63
+ ok ? 'success' : 'error',
64
+ );
65
+ }
66
+
48
67
  export function PairDialog({ code, error, busy, secondsLeft, onClose, onRetry }: PairDialogProps) {
49
68
  useEffect(() => {
50
69
  const onKey = (event: KeyboardEvent) => {
@@ -125,13 +144,27 @@ export function PairDialog({ code, error, busy, secondsLeft, onClose, onRetry }:
125
144
  </div>
126
145
 
127
146
  <div className="mt-4 flex items-center justify-between gap-2">
128
- <button
129
- type="button"
130
- onClick={() => void navigator.clipboard?.writeText(code.webLink).catch(() => {})}
131
- 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"
132
- >
133
- Copy link
134
- </button>
147
+ <div className="flex items-center gap-2">
148
+ <button
149
+ type="button"
150
+ onClick={() => void copyPairingLink(code.webLink)}
151
+ 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"
152
+ >
153
+ Copy link
154
+ </button>
155
+ {/* A download of an expired code would save the server's refusal
156
+ text under a .png name, so the control is only offered while
157
+ the code still exists. */}
158
+ {!expired && code.qrUrl !== '' && (
159
+ <a
160
+ href={code.qrUrl}
161
+ download="kabmo-pairing-qr.png"
162
+ 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"
163
+ >
164
+ Download QR
165
+ </a>
166
+ )}
167
+ </div>
135
168
  <div className="flex items-center gap-2">
136
169
  {expired && (
137
170
  <button
@@ -23,6 +23,7 @@ import { h, render } from 'preact';
23
23
  import { act } from 'preact/test-utils';
24
24
  import { GitPanel } from '@/client/components/workspace/git-panel';
25
25
  import { SessionStateProvider } from '@/client/components/common/session-state-provider/index';
26
+ import { resetToasts } from '@/client/hooks/ui/toasts';
26
27
  import { resetRealtimeClient } from '@/shared/lib/realtime/client';
27
28
  import { gitTopic, reposTopic } from '@/shared/lib/realtime/protocol';
28
29
  import { startRealtimeTestServer, type RealtimeTestServer } from '@/test-support/realtime-server';
@@ -65,6 +66,10 @@ afterEach(() => {
65
66
  container.remove();
66
67
  }
67
68
  resetRealtimeClient();
69
+ // The Initialize click pushes a real toast into the module-level queue, which
70
+ // outlives this file: without this, the next file that asserts the queue sees
71
+ // "Initialized the repository" (measured: PairDialog.test.tsx failed on Windows).
72
+ resetToasts();
68
73
  server?.stop();
69
74
  });
70
75
 
@@ -21,6 +21,7 @@
21
21
 
22
22
  import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
23
23
  import { concatSamples, float32ToPcm16 } from '@/shared/lib/dictation/audio';
24
+ import { describeCaptureFailure } from '@/shared/lib/dictation/capture-failure';
24
25
  import { DICTATION_SAMPLE_RATE } from '@/shared/lib/dictation/protocol';
25
26
  import type { DictationServerFrame } from '@/shared/lib/dictation/protocol';
26
27
 
@@ -117,26 +118,32 @@ export function useSpeechToText({ onResult, modelKey, language }: UseSpeechToTex
117
118
  .getUserMedia({ audio: true })
118
119
  .then((stream) => {
119
120
  streamRef.current = stream;
120
- const context = new AudioContext({ sampleRate: DICTATION_SAMPLE_RATE });
121
- contextRef.current = context;
122
- inputRateRef.current = context.sampleRate;
123
-
124
- const source = context.createMediaStreamSource(stream);
125
- sourceRef.current = source;
126
- const processor = context.createScriptProcessor(4096, 1, 1);
127
- processorRef.current = processor;
128
- processor.onaudioprocess = (event) => {
129
- chunksRef.current.push(new Float32Array(event.inputBuffer.getChannelData(0)));
130
- };
131
- source.connect(processor);
132
- processor.connect(context.destination);
133
- setIsListening(true);
121
+ try {
122
+ const context = new AudioContext({ sampleRate: DICTATION_SAMPLE_RATE });
123
+ contextRef.current = context;
124
+ inputRateRef.current = context.sampleRate;
125
+
126
+ const source = context.createMediaStreamSource(stream);
127
+ sourceRef.current = source;
128
+ const processor = context.createScriptProcessor(4096, 1, 1);
129
+ processorRef.current = processor;
130
+ processor.onaudioprocess = (event) => {
131
+ chunksRef.current.push(new Float32Array(event.inputBuffer.getChannelData(0)));
132
+ };
133
+ source.connect(processor);
134
+ processor.connect(context.destination);
135
+ setIsListening(true);
136
+ } catch {
137
+ // The microphone IS open at this point, so the failure is the audio
138
+ // graph, not the permission — and the stream has to be released or
139
+ // the OS keeps showing the microphone in use.
140
+ fail('Could not start audio capture.');
141
+ }
134
142
  })
135
143
  .catch((cause: unknown) => {
136
- const name = cause instanceof DOMException ? cause.name : '';
137
- setError(name === 'NotAllowedError' ? 'Microphone permission denied.' : 'Could not open the microphone.');
144
+ setError(describeCaptureFailure(cause));
138
145
  });
139
- }, [isSupported]);
146
+ }, [fail, isSupported]);
140
147
 
141
148
  const stopListening = useCallback(() => {
142
149
  setIsListening(false);
@@ -30,6 +30,7 @@ export interface UseConnectStatusResult {
30
30
  busy: string | null;
31
31
  refresh: () => Promise<void>;
32
32
  setTunnel: (provider: TunnelProvider, verb: TunnelVerb) => Promise<string | null>;
33
+ setCloudflareConfig: (path: string) => Promise<string | null>;
33
34
  revoke: (id: string) => Promise<string | null>;
34
35
  }
35
36
 
@@ -38,6 +39,34 @@ interface StatusEnvelope {
38
39
  error?: string;
39
40
  }
40
41
 
42
+ interface PostOutcome {
43
+ payload: StatusEnvelope | null;
44
+ message: string | null;
45
+ }
46
+
47
+ async function postTunnel(body: Record<string, unknown>): Promise<PostOutcome> {
48
+ try {
49
+ const response = await fetch('/api/connect/tunnels', {
50
+ method: 'POST',
51
+ headers: { 'content-type': 'application/json' },
52
+ body: JSON.stringify(body),
53
+ });
54
+ const payload = (await response.json().catch(() => null)) as StatusEnvelope | null;
55
+ if (!response.ok) {
56
+ return {
57
+ payload,
58
+ message: payload?.error ?? `The tunnel did not change (HTTP ${response.status}).`,
59
+ };
60
+ }
61
+ return { payload, message: null };
62
+ } catch (cause) {
63
+ return {
64
+ payload: null,
65
+ message: cause instanceof Error ? cause.message : 'The tunnel did not change.',
66
+ };
67
+ }
68
+ }
69
+
41
70
  export function useConnectStatus(): UseConnectStatusResult {
42
71
  const [status, setStatus] = useState<ConnectStatus | null>(null);
43
72
  const [error, setError] = useState<string | null>(null);
@@ -61,26 +90,12 @@ export function useConnectStatus(): UseConnectStatusResult {
61
90
  void refresh();
62
91
  }, [refresh]);
63
92
 
64
- const setTunnel = useCallback(
65
- async (provider: TunnelProvider, verb: TunnelVerb): Promise<string | null> => {
66
- setBusy(`${provider}:${verb}`);
93
+ const applyTunnel = useCallback(
94
+ async (busyKey: string, body: Record<string, unknown>): Promise<string | null> => {
95
+ setBusy(busyKey);
67
96
  try {
68
- const response = await fetch('/api/connect/tunnels', {
69
- method: 'POST',
70
- headers: { 'content-type': 'application/json' },
71
- body: JSON.stringify({ provider, action: verb }),
72
- });
73
- const payload = (await response.json().catch(() => null)) as StatusEnvelope | null;
97
+ const { payload, message } = await postTunnel(body);
74
98
  if (payload?.status) setStatus(payload.status);
75
- if (!response.ok) {
76
- const message = payload?.error ?? `The tunnel did not change (HTTP ${response.status}).`;
77
- setError(message);
78
- return message;
79
- }
80
- setError(null);
81
- return null;
82
- } catch (cause) {
83
- const message = cause instanceof Error ? cause.message : 'The tunnel did not change.';
84
99
  setError(message);
85
100
  return message;
86
101
  } finally {
@@ -90,6 +105,16 @@ export function useConnectStatus(): UseConnectStatusResult {
90
105
  [],
91
106
  );
92
107
 
108
+ const setTunnel = useCallback(
109
+ (provider: TunnelProvider, verb: TunnelVerb) => applyTunnel(`${provider}:${verb}`, { provider, action: verb }),
110
+ [applyTunnel],
111
+ );
112
+
113
+ const setCloudflareConfig = useCallback(
114
+ (path: string) => applyTunnel('cloudflare:config', { provider: 'cloudflare', action: 'config', path }),
115
+ [applyTunnel],
116
+ );
117
+
93
118
  const revoke = useCallback(async (id: string): Promise<string | null> => {
94
119
  setBusy(`device:${id}`);
95
120
  try {
@@ -112,5 +137,5 @@ export function useConnectStatus(): UseConnectStatusResult {
112
137
  }
113
138
  }, []);
114
139
 
115
- return { status, error, busy, refresh, setTunnel, revoke };
140
+ return { status, error, busy, refresh, setTunnel, setCloudflareConfig, revoke };
116
141
  }
@@ -22,6 +22,8 @@ export interface PairingCode {
22
22
  link: string;
23
23
  /** The `https://…/pair#…` link a browser can open. This is what the QR holds. */
24
24
  webLink: string;
25
+ /** The same code as a downloadable PNG, served by this origin. */
26
+ qrUrl: string;
25
27
  candidates: ConnectCandidate[];
26
28
  qr: { size: number; rows: string[] };
27
29
  }
@@ -66,6 +68,9 @@ export function usePairing(): UsePairingResult {
66
68
  expiresAt: payload.expiresAt ?? '',
67
69
  link: payload.link,
68
70
  webLink: payload.webLink ?? payload.link,
71
+ // A server too old to serve the PNG still mints a scannable code; the
72
+ // dialog then leaves the download out rather than pointing it at nothing.
73
+ qrUrl: payload.qrUrl ?? '',
69
74
  candidates: payload.candidates ?? [],
70
75
  qr: payload.qr,
71
76
  });
@@ -4,22 +4,14 @@
4
4
  */
5
5
 
6
6
  /**
7
- * Browser file actions shared by the editor surfaces. `saveBlob` is the one
8
- * place that builds and clicks the download anchor, so the text path (a Blob
7
+ * Browser file actions shared by the editor surfaces. The download anchor
8
+ * itself lives in `@/client/lib/browser/download`, so the text path (a Blob
9
9
  * over the buffer) and the image path (a Blob over the fetched bytes) cannot
10
10
  * drift apart — the image case has no text buffer at all, which is why it
11
11
  * needs the URL variant.
12
12
  */
13
13
 
14
- /** Hand `blob` to the browser as a download named `name`. */
15
- export function saveBlob(blob: Blob, name: string): void {
16
- const url = URL.createObjectURL(blob);
17
- const anchor = document.createElement('a');
18
- anchor.href = url;
19
- anchor.download = name;
20
- anchor.click();
21
- URL.revokeObjectURL(url);
22
- }
14
+ import { saveBlob } from '@/client/lib/browser/download';
23
15
 
24
16
  /**
25
17
  * Download a URL's bytes under `name`. Used for images, whose content never
@@ -31,7 +31,8 @@ import {
31
31
  currentEditorFont,
32
32
  useEditorFontStack,
33
33
  } from '@/client/hooks/editor/font';
34
- import { copyImageToClipboard, downloadUrl, saveBlob } from '@/client/hooks/editor/file-actions';
34
+ import { copyImageToClipboard, downloadUrl } from '@/client/hooks/editor/file-actions';
35
+ import { saveBlob } from '@/client/lib/browser/download';
35
36
  import { EDITOR_DEFAULT_FONT_FAMILY, EDITOR_FONT_FAMILY } from '@/shared/lib/code/editor/typography';
36
37
  import { primeKabmoSettings } from '@/shared/lib/settings/client';
37
38
 
@@ -18,7 +18,8 @@
18
18
  */
19
19
 
20
20
  import { useCallback, useState } from 'preact/hooks';
21
- import { copyImageToClipboard, downloadUrl, saveBlob } from '@/client/hooks/editor/file-actions';
21
+ import { copyImageToClipboard, downloadUrl } from '@/client/hooks/editor/file-actions';
22
+ import { saveBlob } from '@/client/lib/browser/download';
22
23
  import type { ByteSource } from '@/client/components/workspace/editor/viewers/bytes';
23
24
 
24
25
  interface FileTransferTarget {
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The one place that builds and clicks a download anchor.
8
+ *
9
+ * Every surface that hands the browser a file — the editor's text and image
10
+ * paths, the pairing QR — goes through here, so the object URL is always
11
+ * released and no caller invents a second anchor.
12
+ */
13
+
14
+ /** Hand `blob` to the browser as a download named `name`. */
15
+ export function saveBlob(blob: Blob, name: string): void {
16
+ const url = URL.createObjectURL(blob);
17
+ const anchor = document.createElement('a');
18
+ anchor.href = url;
19
+ anchor.download = name;
20
+ anchor.click();
21
+ URL.revokeObjectURL(url);
22
+ }
@@ -9,7 +9,10 @@
9
9
  * The event switches live in the server's settings, and the shell has no page
10
10
  * to ask once the app is backgrounded — so the answer is pushed to it here, on
11
11
  * boot and whenever a switch changes. The shell persists it and starts its
12
- * watcher from `onStop` only when it is armed.
12
+ * watcher from that command, while the console is still visible (Android 12+
13
+ * refuses a foreground-service start from the background); it also refuses to
14
+ * start when the OS notification permission is missing, and `MainActivity`
15
+ * re-arms on the next resume once the grant exists.
13
16
  *
14
17
  * A no-op outside a phone shell: the desktop shells and a browser have no
15
18
  * background watcher, and their notifications are posted by the page itself.