@kabmo-labs/kabmo 0.39.0 → 0.40.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 (264) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +363 -363
  3. package/dist/client/static/js/{CsvGrid-kfcp4sd6.js → CsvGrid-j9nvnhq1.js} +2 -2
  4. package/dist/client/static/js/{DocxView-atff5w38.js → DocxView-87gnpm81.js} +5 -5
  5. package/dist/client/static/js/{DrawioView-yfnq4c99.js → DrawioView-a351t8f8.js} +2 -2
  6. package/dist/client/static/js/ImageView-c139r891.js +1 -0
  7. package/dist/client/static/js/LayoutWrapper-08axzr3a.js +2 -0
  8. package/dist/client/static/js/{Modal-2xqd3sss.js → Modal-0weqfqvk.js} +17 -17
  9. package/dist/client/static/js/{PdfView-mk8paxt1.js → PdfView-n6bwcvc8.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-ner25qxn.js → SessionsView-awef8ehj.js} +1 -1
  11. package/dist/client/static/js/{SheetView-s6n3fawm.js → SheetView-k8ymr87w.js} +24 -24
  12. package/dist/client/static/js/{SvgPreview-8bxvz3ez.js → SvgPreview-5pcp444e.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-tvvz9fha.js → abnfDiagram-O67JEVCF-psav75bx.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-6rbq97t9.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-bybv3wg4.js → architectureDiagram-NJMV4G6O-9bk6ykn7.js} +3 -3
  16. package/dist/client/static/js/{astro-4ybhkc9b.js → astro-0rh34hha.js} +1 -1
  17. package/dist/client/static/js/bash-vv2ysp0a.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-h3fs79x6.js → blockDiagram-BEXU5L5S-17xsf182.js} +5 -5
  19. package/dist/client/static/js/c-67jyc7sg.js +1 -0
  20. package/dist/client/static/js/{c4Diagram-YGBWAQC7-h8p3h54v.js → c4Diagram-YGBWAQC7-jn9j4n04.js} +2 -2
  21. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-q645r4q6.js → classDiagram-v2-NBCMYWYE-663z1g1r.js} +5 -5
  22. package/dist/client/static/js/{cose-bilkent-JH36ORCC-p4mm1zcv.js → cose-bilkent-JH36ORCC-vp4yvx8x.js} +1 -1
  23. package/dist/client/static/js/cpp-crfbnwv8.js +1 -0
  24. package/dist/client/static/js/css-983fbv00.js +1 -0
  25. package/dist/client/static/js/css-zj4qzw6r.js +1 -0
  26. package/dist/client/static/js/cynefin-OW5HDTMX-zafxcz2k.js +1 -0
  27. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-v2hbc3aq.js → cynefinDiagram-VND7K2PF-dagkrjbh.js} +1 -1
  28. package/dist/client/static/js/{dagre-6A5THRUB-4edpda33.js → dagre-6A5THRUB-8qgwpb5a.js} +2 -2
  29. package/dist/client/static/js/{diagram-22UHCM2B-b6gp813w.js → diagram-22UHCM2B-671xtp0d.js} +11 -11
  30. package/dist/client/static/js/{diagram-3UASUU5V-s1f3b0ng.js → diagram-3UASUU5V-8nn5fha8.js} +1 -1
  31. package/dist/client/static/js/{diagram-ATOU4E4O-ga06kjp5.js → diagram-ATOU4E4O-dnar0ktg.js} +3 -3
  32. package/dist/client/static/js/{diagram-CDSNMT55-wdbmv4td.js → diagram-CDSNMT55-bt0fhk7n.js} +3 -3
  33. package/dist/client/static/js/{diagram-MLGK6HIB-fkntefcq.js → diagram-MLGK6HIB-tp6dwxdb.js} +1 -1
  34. package/dist/client/static/js/{diagram-MPIPVDR6-k2zh7edp.js → diagram-MPIPVDR6-qgx8c8ee.js} +2 -2
  35. package/dist/client/static/js/{dockerfile-srcym0bs.js → dockerfile-hk0s4qaw.js} +1 -1
  36. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-4vc4vz9c.js → ebnfDiagram-ZINNZB2B-nmf9r33z.js} +1 -1
  37. package/dist/client/static/js/{elixir-v9bbxsgg.js → elixir-gpez1k9m.js} +1 -1
  38. package/dist/client/static/js/{elk-276RUBZZ-g2ppf1by.js → elk-276RUBZZ-dheh5ngz.js} +1 -1
  39. package/dist/client/static/js/{erDiagram-OPXOYQCR-rmnwkb5q.js → erDiagram-OPXOYQCR-8837mk18.js} +5 -5
  40. package/dist/client/static/js/{erlang-55r0skxa.js → erlang-w9gmf866.js} +1 -1
  41. package/dist/client/static/js/eventmodeling-NTZA5JFV-cq3dvz7e.js +1 -0
  42. package/dist/client/static/js/flowDiagram-KWPJA3E3-spzh2jxq.js +1 -0
  43. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-ptfvae64.js → ganttDiagram-FUAMR5RP-g68mvnje.js} +2 -2
  44. package/dist/client/static/js/{ghostty-web-2gt2tp72.js → ghostty-web-22pdvhta.js} +4 -4
  45. package/dist/client/static/js/gitGraph-4MIJSDKK-epgk26pj.js +1 -0
  46. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-ne9n3cyf.js → gitGraphDiagram-X574FWY7-ymk81cdj.js} +2 -2
  47. package/dist/client/static/js/graphql-dewsj5g1.js +1 -0
  48. package/dist/client/static/js/html-1cpe2xc8.js +1 -0
  49. package/dist/client/static/js/{index-dmd26a1y.js → index-018ehs1n.js} +1 -1
  50. package/dist/client/static/js/{index-442mbhwb.js → index-173x4bh0.js} +2 -2
  51. package/dist/client/static/js/{index-c1be3rva.js → index-2kg3r5jw.js} +2 -2
  52. package/dist/client/static/js/{index-gvkc9e32.js → index-4j1g7m8g.js} +1 -1
  53. package/dist/client/static/js/{index-7h5n5rz4.js → index-4j5jwb54.js} +2 -2
  54. package/dist/client/static/js/{index-8egjccbq.js → index-547h1b8j.js} +52 -52
  55. package/dist/client/static/js/{index-4pehdq5h.js → index-69xe17c1.js} +2 -2
  56. package/dist/client/static/js/{index-k5a6r25s.js → index-6wtx7a9x.js} +2 -2
  57. package/dist/client/static/js/{index-m3r0j562.js → index-8888hgj8.js} +5 -5
  58. package/dist/client/static/js/{index-8w2tx2k9.js → index-8ggxxp8c.js} +2 -2
  59. package/dist/client/static/js/{index-b08hx4tw.js → index-9wjnbb3q.js} +2 -2
  60. package/dist/client/static/js/{index-p89z1qmj.js → index-ag78jnva.js} +1 -1
  61. package/dist/client/static/js/{index-xrp2zv8z.js → index-agdbjh5k.js} +2 -2
  62. package/dist/client/static/js/index-aznkfx1z.js +2 -0
  63. package/dist/client/static/js/{index-cfnxda13.js → index-b612vske.js} +2 -2
  64. package/dist/client/static/js/{index-k3c3n69j.js → index-bdz08fe2.js} +12 -12
  65. package/dist/client/static/js/{index-ntx3bbmb.js → index-bgpcf3mr.js} +1 -1
  66. package/dist/client/static/js/index-bj3wn9je.js +1 -0
  67. package/dist/client/static/js/{index-7z63xr1s.js → index-c003wb3r.js} +1 -1
  68. package/dist/client/static/js/{index-5kvvb0zm.js → index-cccrappc.js} +2 -2
  69. package/dist/client/static/js/{index-k7sdsmgv.js → index-ce4vytm6.js} +2 -2
  70. package/dist/client/static/js/{index-2rs03vfy.js → index-d1vearmk.js} +2 -2
  71. package/dist/client/static/js/index-dhrp656p.js +1 -0
  72. package/dist/client/static/js/{index-k61tdd4a.js → index-dj7y2df7.js} +2 -2
  73. package/dist/client/static/js/{index-4wtr5wjp.js → index-ek4gwrm8.js} +2 -2
  74. package/dist/client/static/js/{index-mdxnhndy.js → index-ek7hqfp0.js} +2 -2
  75. package/dist/client/static/js/{index-drjtwfp5.js → index-fg965t62.js} +2 -2
  76. package/dist/client/static/js/{index-me7m3516.js → index-g10nr8m6.js} +5 -5
  77. package/dist/client/static/js/{index-4wvtar0v.js → index-gn92c6hp.js} +2 -2
  78. package/dist/client/static/js/{index-t6gznaxm.js → index-gx2xefdg.js} +2 -2
  79. package/dist/client/static/js/{index-q0bph5x0.js → index-haaz8t7e.js} +2 -2
  80. package/dist/client/static/js/{index-pr7gk5eq.js → index-harsfp4x.js} +10 -10
  81. package/dist/client/static/js/{index-3fw3sd10.js → index-j4ks5s41.js} +179 -179
  82. package/dist/client/static/js/{index-cst843zs.css → index-jqs23cc7.css} +1 -1
  83. package/dist/client/static/js/{index-ymp2wqtc.js → index-js81yrmy.js} +3 -3
  84. package/dist/client/static/js/{index-enmh3w27.js → index-jy91r3ap.js} +2 -2
  85. package/dist/client/static/js/{index-y2prm0xm.js → index-mxpgfj6p.js} +2 -2
  86. package/dist/client/static/js/{index-a7qccdq2.js → index-p2812ygk.js} +1 -1
  87. package/dist/client/static/js/index-pp6mss9b.js +3 -0
  88. package/dist/client/static/js/index-q1bqg4f6.js +1 -0
  89. package/dist/client/static/js/{index-v8vjh5jj.js → index-qnt118mp.js} +1 -1
  90. package/dist/client/static/js/index-qntpsp98.js +2 -0
  91. package/dist/client/static/js/{index-fjnkzk12.js → index-qsw5edtk.js} +5 -5
  92. package/dist/client/static/js/{index-ywpdhntc.js → index-qw5aqk2d.js} +1 -1
  93. package/dist/client/static/js/{index-9gepbvdt.js → index-r1fe56cn.js} +2 -2
  94. package/dist/client/static/js/{index-72289dgx.js → index-rc8wrs2a.js} +2 -2
  95. package/dist/client/static/js/index-rvjc19x7.js +2 -0
  96. package/dist/client/static/js/{index-9d6x1f3t.js → index-s78n0dtv.js} +2 -2
  97. package/dist/client/static/js/{index-c36pag9y.js → index-sj4y8kj2.js} +2 -2
  98. package/dist/client/static/js/{index-qsrw5c67.js → index-vv9ytx0t.js} +2 -2
  99. package/dist/client/static/js/{index-1sgad84m.js → index-vwc8pdy3.js} +2 -2
  100. package/dist/client/static/js/{index-8qgwj6m8.js → index-w130cs7d.js} +1 -1
  101. package/dist/client/static/js/{index-hh05xd1d.js → index-wsqgp9jw.js} +2 -2
  102. package/dist/client/static/js/{index-61qjr1k0.js → index-wv36ddd5.js} +48 -48
  103. package/dist/client/static/js/{index-56w8m083.js → index-wy05jt00.js} +2 -2
  104. package/dist/client/static/js/{index-0j518hqm.js → index-xf36nmbm.js} +2 -2
  105. package/dist/client/static/js/{index-xdqsqhnn.js → index-y5hxhr7q.js} +4 -4
  106. package/dist/client/static/js/{index-pzqsp5jw.js → index-y82bk3hr.js} +3 -3
  107. package/dist/client/static/js/{index-rj81xrvw.js → index-ys4t1am4.js} +2 -2
  108. package/dist/client/static/js/{index-y3qxrs90.js → index-yzg9mbsv.js} +2 -2
  109. package/dist/client/static/js/info-A6RAGUB7-0an46pag.js +1 -0
  110. package/dist/client/static/js/{infoDiagram-VRGFBTTK-ctfwcm3n.js → infoDiagram-VRGFBTTK-11trzn8c.js} +1 -1
  111. package/dist/client/static/js/ini-09e0scxh.js +1 -0
  112. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-b0b0pn4y.js → ishikawaDiagram-OU5B5YK6-8xnnymb5.js} +2 -2
  113. package/dist/client/static/js/java-vnaesxzs.js +1 -0
  114. package/dist/client/static/js/javascript-zegm06a1.js +1 -0
  115. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-kdq12drs.js → journeyDiagram-ZHPQQLJL-wd47j0hy.js} +3 -3
  116. package/dist/client/static/js/json-g5ggnd94.js +1 -0
  117. package/dist/client/static/js/jsx-xz71aed4.js +1 -0
  118. package/dist/client/static/js/{julia-jhe2vd4f.js → julia-c2q0vwpd.js} +1 -1
  119. package/dist/client/static/js/{kanban-definition-PNTS6WVX-65x6xn2q.js → kanban-definition-PNTS6WVX-s5rgcp44.js} +4 -4
  120. package/dist/client/static/js/lua-e4wenyzt.js +1 -0
  121. package/dist/client/static/js/markdown-yv3p1p7m.js +1 -0
  122. package/dist/client/static/js/{mermaid.core-0fq63jpa.js → mermaid.core-9fxp8nt2.js} +7 -7
  123. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-p86myex3.js → mindmap-definition-NLK3R4M7-4fyewtst.js} +3 -3
  124. package/dist/client/static/js/one-dark-pro-ahch85zb.js +1 -0
  125. package/dist/client/static/js/one-light-9706jgqt.js +1 -0
  126. package/dist/client/static/js/packet-AYTQ26CC-5e397pav.js +1 -0
  127. package/dist/client/static/js/{pegDiagram-GJSIUBJH-p2hkk9xb.js → pegDiagram-GJSIUBJH-s2xe2e2k.js} +1 -1
  128. package/dist/client/static/js/{perl-qhj6tk7k.js → perl-6pa0tn3b.js} +1 -1
  129. package/dist/client/static/js/{php-arycc4w7.js → php-1zy994pz.js} +1 -1
  130. package/dist/client/static/js/pie-WAS4IAKB-0zzmzg64.js +1 -0
  131. package/dist/client/static/js/{pieDiagram-5QR66LMP-bza19wkx.js → pieDiagram-5QR66LMP-1szpjbzy.js} +2 -2
  132. package/dist/client/static/js/properties-0ag74bdj.js +1 -0
  133. package/dist/client/static/js/python-zsn5tdbj.js +1 -0
  134. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-bxqec9w1.js → quadrantDiagram-O4NWA36T-mv3ee2qa.js} +3 -3
  135. package/dist/client/static/js/r-mwtqhnw3.js +1 -0
  136. package/dist/client/static/js/radar-RG4KPBEZ-mtar9742.js +1 -0
  137. package/dist/client/static/js/railroad-74A4TZTK-d6a6j9fq.js +1 -0
  138. package/dist/client/static/js/railroad-abnf-HS5TGJTU-1257kd8x.js +1 -0
  139. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-v8b6qmas.js +1 -0
  140. package/dist/client/static/js/railroad-peg-WCYAUIDC-jxpbx410.js +1 -0
  141. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-1g3hx3sm.js → railroadDiagram-XR7U4H2S-hgdqjpm9.js} +1 -1
  142. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-qbjjm48v.js → requirementDiagram-PLB6GJNP-yrfjp9wx.js} +3 -3
  143. package/dist/client/static/js/{ruby-fb6zzevm.js → ruby-arvs7kz4.js} +1 -1
  144. package/dist/client/static/js/{rust-jatm47v6.js → rust-3ahjk339.js} +1 -1
  145. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-t2ythbh7.js → sankeyDiagram-IPEJSGJF-k7k871xa.js} +3 -3
  146. package/dist/client/static/js/{sass-fzs6a0kr.js → sass-cmkf7nwd.js} +1 -1
  147. package/dist/client/static/js/{scss-gdb52d0c.js → scss-x7ddw6gb.js} +1 -1
  148. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-mqsfek2j.js → sequenceDiagram-PO4LG4MO-gd80m0as.js} +7 -7
  149. package/dist/client/static/js/{sizeCapture-INFHLROL-xj67pgds.js → sizeCapture-INFHLROL-jv6p4834.js} +1 -1
  150. package/dist/client/static/js/sql-aczp05f2.js +1 -0
  151. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-gj4fezak.js → stateDiagram-v2-GCMORJYK-tvphxq2h.js} +3 -3
  152. package/dist/client/static/js/{svelte-8s3k6qjd.js → svelte-0hv6pak2.js} +1 -1
  153. package/dist/client/static/js/{swimlanes-2SLR337P-pgtdd1pk.js → swimlanes-2SLR337P-3dt7nxj2.js} +1 -1
  154. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-aqnh1hhp.js +8 -0
  155. package/dist/client/static/js/{timeline-definition-EJHVYXUP-q013vdd1.js → timeline-definition-EJHVYXUP-40vvf856.js} +4 -4
  156. package/dist/client/static/js/treeView-Q6P3EWNA-q3qr7ew7.js +1 -0
  157. package/dist/client/static/js/treemap-WGGIJYW6-zgbdydeq.js +1 -0
  158. package/dist/client/static/js/tsx-s1shkfg9.js +1 -0
  159. package/dist/client/static/js/typescript-htx9v6bf.js +1 -0
  160. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-7swsbqnq.js → usecaseDiagram-POWQR4AR-g1j5x0xh.js} +28 -28
  161. package/dist/client/static/js/{vennDiagram-UO4OBE2U-9dygxdxf.js → vennDiagram-UO4OBE2U-5b8789qk.js} +1 -1
  162. package/dist/client/static/js/{vue-k3f3chre.js → vue-zccj3qa5.js} +1 -1
  163. package/dist/client/static/js/wardley-WFR3VGLG-b230aajh.js +1 -0
  164. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-aaaa9kj3.js → wardleyDiagram-VNRHLVJA-c7x3za3w.js} +3 -3
  165. package/dist/client/static/js/xml-23y6pgvx.js +1 -0
  166. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-tamf39gx.js → xychartDiagram-PMCCYNJV-h0fy45tg.js} +3 -3
  167. package/dist/client/static/js/yaml-vrayja34.js +1 -0
  168. package/marketplace/plugins/command-runner/package.json +2 -2
  169. package/marketplace/plugins/command-runner/src/panel/Custom.test.tsx +1 -0
  170. package/marketplace/plugins/command-runner/src/panel/Groups.test.tsx +10 -0
  171. package/marketplace/plugins/command-runner/src/panel/Groups.tsx +24 -3
  172. package/marketplace/plugins/command-runner/src/panel/index.tsx +1 -0
  173. package/marketplace/plugins/command-runner/src/protocol.ts +10 -0
  174. package/marketplace/plugins/command-runner/src/server/discovery.test.ts +30 -0
  175. package/marketplace/plugins/command-runner/src/server/scan.ts +16 -3
  176. package/package.json +1 -1
  177. package/src/client/components/common/header-controls/MoreMenu.tsx +24 -14
  178. package/src/client/components/common/header-controls/index.test.tsx +22 -0
  179. package/src/client/components/common/header-controls/index.tsx +8 -2
  180. package/src/client/components/mobile/LayoutWrapper.tsx +19 -2
  181. package/src/client/components/mobile/RightSidebar.tsx +49 -1
  182. package/src/client/components/mobile/SessionSidebar.tsx +25 -1
  183. package/src/client/components/mobile/header-titlebar.test.tsx +17 -0
  184. package/src/client/components/mobile/mobile-main-view/Header.test.tsx +43 -0
  185. package/src/client/components/mobile/mobile-main-view/Header.tsx +30 -0
  186. package/src/client/components/mobile/mobile-session-sidebar/Dock.tsx +5 -1
  187. package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +12 -1
  188. package/src/client/components/mobile/panel-chips.test.tsx +13 -0
  189. package/src/client/components/mobile/panel-chips.tsx +9 -2
  190. package/src/client/components/settings/categories/connect-settings/DeviceTable.test.tsx +92 -0
  191. package/src/client/components/settings/categories/connect-settings/DeviceTable.tsx +22 -3
  192. package/src/client/components/workspace/git-panel/commit-modal/Header.test.tsx +21 -0
  193. package/src/client/components/workspace/git-panel/commit-modal/Header.tsx +13 -9
  194. package/src/client/components/workspace/terminal-panel/focus-target.test.ts +121 -0
  195. package/src/client/components/workspace/terminal-panel/focus-target.ts +54 -0
  196. package/src/client/components/workspace/terminal-panel/index.tsx +7 -1
  197. package/src/client/components/workspace/terminal-panel/instance.ts +82 -0
  198. package/src/client/components/workspace/terminal-panel/mount.ts +22 -63
  199. package/src/client/components/workspace/terminal-panel/soft-keyboard.ts +29 -0
  200. package/src/client/hooks/ui/touch-device.ts +8 -3
  201. package/src/client/hooks/ui/visibility-menu-trigger.test.ts +155 -0
  202. package/src/client/hooks/ui/visibility-menu-trigger.ts +85 -0
  203. package/src/client/hooks/workspace/panel-visibility-menu.ts +50 -0
  204. package/src/client/lib/ui/soft-keyboard.test.ts +103 -0
  205. package/src/client/lib/ui/soft-keyboard.ts +90 -0
  206. package/src/server/lib/auth/guard.ts +8 -2
  207. package/src/server/lib/connect/devices.server.test.ts +70 -0
  208. package/src/server/lib/connect/devices.server.ts +43 -1
  209. package/src/server/lib/connect/last-connect.gate.test.ts +52 -0
  210. package/src/server/lib/terminal/attach-replay.test.ts +80 -17
  211. package/src/server/plugins/static.test.ts +23 -1
  212. package/src/server/plugins/static.ts +24 -1
  213. package/src/server/routes/connect/devices.ts +5 -4
  214. package/src/shared/lib/connect/types.ts +1 -0
  215. package/dist/client/static/js/ImageView-nreh25s0.js +0 -1
  216. package/dist/client/static/js/LayoutWrapper-0x1q1q5z.js +0 -2
  217. package/dist/client/static/js/architecture-7GRP2DOG-y0zb4vqa.js +0 -1
  218. package/dist/client/static/js/bash-k6p3y3pr.js +0 -1
  219. package/dist/client/static/js/c-ve09y19q.js +0 -1
  220. package/dist/client/static/js/cpp-vhqp7bcy.js +0 -1
  221. package/dist/client/static/js/css-77mvf0ca.js +0 -1
  222. package/dist/client/static/js/css-tys2rrny.js +0 -1
  223. package/dist/client/static/js/cynefin-OW5HDTMX-nt1ed192.js +0 -1
  224. package/dist/client/static/js/eventmodeling-NTZA5JFV-v4edaxx7.js +0 -1
  225. package/dist/client/static/js/flowDiagram-KWPJA3E3-jvrvhb9d.js +0 -1
  226. package/dist/client/static/js/gitGraph-4MIJSDKK-adzhec96.js +0 -1
  227. package/dist/client/static/js/graphql-g97hycb3.js +0 -1
  228. package/dist/client/static/js/html-2syect3n.js +0 -1
  229. package/dist/client/static/js/index-1jeyjqkh.js +0 -2
  230. package/dist/client/static/js/index-270y5r9k.js +0 -2
  231. package/dist/client/static/js/index-5a4w58r2.js +0 -1
  232. package/dist/client/static/js/index-878d61js.js +0 -1
  233. package/dist/client/static/js/index-dt22v9ns.js +0 -2
  234. package/dist/client/static/js/index-jkph8wqq.js +0 -3
  235. package/dist/client/static/js/index-mmsszqvn.js +0 -1
  236. package/dist/client/static/js/info-A6RAGUB7-2ye26vqn.js +0 -1
  237. package/dist/client/static/js/ini-7ffv28px.js +0 -1
  238. package/dist/client/static/js/java-4x5yky4a.js +0 -1
  239. package/dist/client/static/js/javascript-4kw2j9t3.js +0 -1
  240. package/dist/client/static/js/json-h3kwpty2.js +0 -1
  241. package/dist/client/static/js/jsx-jk20f0dr.js +0 -1
  242. package/dist/client/static/js/lua-k02dpxq8.js +0 -1
  243. package/dist/client/static/js/markdown-fhhg7ms6.js +0 -1
  244. package/dist/client/static/js/one-dark-pro-c4q810z4.js +0 -1
  245. package/dist/client/static/js/one-light-czk9dzya.js +0 -1
  246. package/dist/client/static/js/packet-AYTQ26CC-b0j3te0q.js +0 -1
  247. package/dist/client/static/js/pie-WAS4IAKB-28qq62fn.js +0 -1
  248. package/dist/client/static/js/properties-qhvcxc13.js +0 -1
  249. package/dist/client/static/js/python-3qsrs510.js +0 -1
  250. package/dist/client/static/js/r-z2ng7mza.js +0 -1
  251. package/dist/client/static/js/radar-RG4KPBEZ-fyrcbpyd.js +0 -1
  252. package/dist/client/static/js/railroad-74A4TZTK-9s62qncd.js +0 -1
  253. package/dist/client/static/js/railroad-abnf-HS5TGJTU-f7yjmhrk.js +0 -1
  254. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-sfrw8gkz.js +0 -1
  255. package/dist/client/static/js/railroad-peg-WCYAUIDC-4mm4cern.js +0 -1
  256. package/dist/client/static/js/sql-ypk53ntb.js +0 -1
  257. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-zk37paj9.js +0 -8
  258. package/dist/client/static/js/treeView-Q6P3EWNA-a5vgg4gz.js +0 -1
  259. package/dist/client/static/js/treemap-WGGIJYW6-ctqhajgg.js +0 -1
  260. package/dist/client/static/js/tsx-zy7hb2hw.js +0 -1
  261. package/dist/client/static/js/typescript-2hr53c8j.js +0 -1
  262. package/dist/client/static/js/wardley-WFR3VGLG-ns7e0fqf.js +0 -1
  263. package/dist/client/static/js/xml-p4742r9b.js +0 -1
  264. package/dist/client/static/js/yaml-qbckg671.js +0 -1
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The device split in the terminal's focus target.
8
+ *
9
+ * A phone types into the renderer's textarea (`beforeinput`); a hardware
10
+ * keyboard types into the container (`keydown`). Focusing the container on a
11
+ * phone is what left the keyboard closed and the first characters swallowed, so
12
+ * the two branches are pinned here — including the redirect that survives
13
+ * ghostty's own delayed container focus.
14
+ */
15
+
16
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
17
+ import { Window } from 'happy-dom';
18
+ import type { Terminal } from 'ghostty-web';
19
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
20
+ import {
21
+ focusTerminal,
22
+ focusTerminalTextarea,
23
+ redirectSoftKeyboardFocus,
24
+ } from '@/client/components/workspace/terminal-panel/focus-target';
25
+
26
+ let win: Window;
27
+ let container: HTMLDivElement;
28
+ let textarea: HTMLTextAreaElement;
29
+ let containerFocuses = 0;
30
+
31
+ function setSoftKeyboardDevice(value: boolean): void {
32
+ win.matchMedia = ((query: string) => ({
33
+ matches: value && query === '(pointer: coarse)',
34
+ media: query,
35
+ onchange: null,
36
+ addListener() {},
37
+ removeListener() {},
38
+ addEventListener() {},
39
+ removeEventListener() {},
40
+ dispatchEvent: () => false,
41
+ })) as unknown as typeof win.matchMedia;
42
+ Object.defineProperty(win.navigator, 'maxTouchPoints', { value: 0, configurable: true });
43
+ }
44
+
45
+ function fakeTerminal(): Terminal {
46
+ return {
47
+ textarea,
48
+ focus() {
49
+ containerFocuses += 1;
50
+ container.focus();
51
+ },
52
+ } as unknown as Terminal;
53
+ }
54
+
55
+ beforeAll(() => {
56
+ win = new Window({ url: 'http://localhost' });
57
+ installDomGlobals(win);
58
+ });
59
+
60
+ afterEach(() => {
61
+ document.body.innerHTML = '';
62
+ containerFocuses = 0;
63
+ });
64
+
65
+ afterAll(() => {
66
+ restoreDomGlobals();
67
+ });
68
+
69
+ function mount(): void {
70
+ container = document.createElement('div');
71
+ container.tabIndex = 0;
72
+ textarea = document.createElement('textarea');
73
+ container.appendChild(textarea);
74
+ document.body.appendChild(container);
75
+ }
76
+
77
+ describe('terminal focus target', () => {
78
+ test('a phone focuses the textarea, not the container', () => {
79
+ mount();
80
+ setSoftKeyboardDevice(true);
81
+ focusTerminal(fakeTerminal());
82
+ expect(document.activeElement).toBe(textarea);
83
+ expect(containerFocuses).toBe(0);
84
+ });
85
+
86
+ test('a hardware keyboard focuses the container', () => {
87
+ mount();
88
+ setSoftKeyboardDevice(false);
89
+ focusTerminal(fakeTerminal());
90
+ expect(document.activeElement).toBe(container);
91
+ expect(containerFocuses).toBe(1);
92
+ });
93
+
94
+ test('the textarea helper is a no-op on a desktop', () => {
95
+ mount();
96
+ setSoftKeyboardDevice(false);
97
+ focusTerminalTextarea(fakeTerminal());
98
+ expect(document.activeElement).not.toBe(textarea);
99
+ });
100
+
101
+ test('a phone redirects the container focus ghostty schedules after open', () => {
102
+ mount();
103
+ setSoftKeyboardDevice(true);
104
+ const stop = redirectSoftKeyboardFocus(container, fakeTerminal());
105
+ container.focus();
106
+ expect(document.activeElement).toBe(textarea);
107
+ stop();
108
+ textarea.blur();
109
+ container.focus();
110
+ expect(document.activeElement).toBe(container);
111
+ });
112
+
113
+ test('a desktop keeps the container focus', () => {
114
+ mount();
115
+ setSoftKeyboardDevice(false);
116
+ const stop = redirectSoftKeyboardFocus(container, fakeTerminal());
117
+ container.focus();
118
+ expect(document.activeElement).toBe(container);
119
+ stop();
120
+ });
121
+ });
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Which element takes the terminal's focus, per device.
8
+ *
9
+ * ghostty-web focuses its CONTAINER (`tabindex=0`, `contenteditable`), which is
10
+ * the hardware-keyboard surface: its `keydown` listener is what encodes a
11
+ * physical key. A phone's input arrives as `beforeinput` on the renderer's
12
+ * textarea instead, and only an editable element that is focused can open the
13
+ * soft keyboard — focusing the container there left the keyboard closed and the
14
+ * panel needing a tap before it accepted a character.
15
+ *
16
+ * The second half is a race the vendor creates: `Terminal.open()` ends with
17
+ * `focus()`, and `Terminal.focus()` focuses the container and then focuses it
18
+ * AGAIN on a 0 ms timer. Focusing the textarea after `open()` therefore lost to
19
+ * that timer one tick later — measured on the phone layout: the textarea held
20
+ * focus at mount and the container owned it 12 ms after. A `focusin` redirect is
21
+ * event-driven, so it survives the timer and any later internal `focus()`;
22
+ * keydown still reaches the container because the textarea is its child.
23
+ */
24
+
25
+ import type { Terminal } from 'ghostty-web';
26
+ import { isSoftKeyboardDevice } from '@/client/hooks/ui/touch-device';
27
+
28
+ /** Focus whatever this device types into. */
29
+ export function focusTerminal(term: Terminal): void {
30
+ if (isSoftKeyboardDevice() && term.textarea) term.textarea.focus();
31
+ else term.focus();
32
+ }
33
+
34
+ /**
35
+ * Move the textarea's keyboard focus onto the terminal on a phone.
36
+ *
37
+ * A no-op on a desktop, where the container is the correct target and the
38
+ * padding click's caret behaviour is pinned by `terminal.e2e.ts`.
39
+ */
40
+ export function focusTerminalTextarea(term: Terminal): void {
41
+ if (isSoftKeyboardDevice()) term.textarea?.focus();
42
+ }
43
+
44
+ /**
45
+ * Keep a soft-keyboard device's focus on the textarea. Returns the disposer.
46
+ */
47
+ export function redirectSoftKeyboardFocus(container: HTMLElement, term: Terminal): () => void {
48
+ const redirect = (event: FocusEvent) => {
49
+ if (event.target !== container || !isSoftKeyboardDevice()) return;
50
+ term.textarea?.focus();
51
+ };
52
+ container.addEventListener('focusin', redirect);
53
+ return () => container.removeEventListener('focusin', redirect);
54
+ }
@@ -9,6 +9,7 @@ import { TerminalHeader } from '@/client/components/workspace/terminal-panel/Hea
9
9
  import { TerminalQuickActions } from '@/client/components/workspace/terminal-panel/QuickActions';
10
10
  import { TerminalKeyBar } from '@/client/components/workspace/terminal-panel/KeyBar';
11
11
  import { RealtimeTerminalView, type RealtimeTerminalHandle } from '@/client/components/workspace/terminal-panel/RealtimeTerminalView';
12
+ import { releaseSoftKeyboard } from '@/client/lib/ui/soft-keyboard';
12
13
  import {
13
14
  NO_MODIFIERS,
14
15
  applyModifiers,
@@ -62,7 +63,12 @@ export function TerminalPanel({ className = '', enabled = true, rootPath, showHe
62
63
  * renderer's async mount (`focus.ts`).
63
64
  */
64
65
  useEffect(() => {
65
- if (!active || !enabled) return;
66
+ if (!active || !enabled) {
67
+ // The drawer armed the keyboard for a terminal that will not take focus
68
+ // (no workspace, a hidden view); do not leave it up over the placeholder.
69
+ releaseSoftKeyboard();
70
+ return;
71
+ }
66
72
  terminalRef.current?.focus();
67
73
  }, [active, enabled]);
68
74
 
@@ -0,0 +1,82 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * One ghostty-web terminal and the addons bound to it.
8
+ *
9
+ * Split from `mount.ts` so the mount lifecycle (import, observers, replay,
10
+ * focus) stays readable and this file owns only "make a terminal, wire it, tear
11
+ * it down". The caller supplies `wire` because the event handlers it installs
12
+ * close over the mount's own state (the replay gate, the grid announcer).
13
+ */
14
+
15
+ import type { FitAddon, Ghostty, Terminal } from 'ghostty-web';
16
+ import { installCellMetrics } from '@/client/components/workspace/terminal-panel/fonts';
17
+ import { installFullWidthFit } from '@/client/components/workspace/terminal-panel/fit';
18
+ import { focusTerminalTextarea } from '@/client/components/workspace/terminal-panel/focus-target';
19
+ import {
20
+ getTerminalTheme,
21
+ TERMINAL_FONT_FAMILY,
22
+ TERMINAL_FONT_SIZE,
23
+ TERMINAL_SCROLLBACK_BYTES,
24
+ } from '@/client/data/theme/terminal';
25
+
26
+ export interface TerminalInstance {
27
+ term: Terminal;
28
+ fitAddon: FitAddon;
29
+ disposables: { dispose(): void }[];
30
+ }
31
+
32
+ export function createTerminalInstance(
33
+ module: { Terminal: typeof Terminal; FitAddon: typeof FitAddon },
34
+ ghostty: Ghostty,
35
+ container: HTMLElement,
36
+ themeId: string,
37
+ wire: (instance: TerminalInstance) => void,
38
+ ): TerminalInstance {
39
+ const term = new module.Terminal({
40
+ cursorBlink: true,
41
+ cursorStyle: 'block',
42
+ fontSize: TERMINAL_FONT_SIZE,
43
+ fontFamily: TERMINAL_FONT_FAMILY,
44
+ theme: getTerminalTheme(themeId),
45
+ // A byte budget, not xterm's line count. See `theme/terminal.ts`.
46
+ scrollback: TERMINAL_SCROLLBACK_BYTES,
47
+ // No `convertEol`: the PTY already emits CRLF, and converting a lone LF
48
+ // would re-introduce the line-feed doubling a real terminal avoids.
49
+ smoothScrollDuration: 0,
50
+ ghostty,
51
+ });
52
+ term.open(container);
53
+ installCellMetrics(term);
54
+ // The WASM allocator reuses pages: a fresh terminal can inherit the previous
55
+ // screen's cells until something overwrites them. Clear before the first byte
56
+ // is shown.
57
+ term.clear();
58
+ // Only when the container is really on screen: the desktop mounts every view
59
+ // hidden, and a hidden terminal must not take focus (or a keyboard).
60
+ if (container.clientWidth > 0) focusTerminalTextarea(term);
61
+ const fitAddon = new module.FitAddon();
62
+ term.loadAddon(fitAddon);
63
+ installFullWidthFit(fitAddon, term);
64
+ const instance: TerminalInstance = { term, fitAddon, disposables: [] };
65
+ wire(instance);
66
+ return instance;
67
+ }
68
+
69
+ export function disposeTerminalInstance(instance: TerminalInstance | null): void {
70
+ if (!instance) return;
71
+ for (const disposable of instance.disposables) {
72
+ try {
73
+ disposable.dispose();
74
+ } catch {}
75
+ }
76
+ try {
77
+ instance.fitAddon.dispose();
78
+ } catch {}
79
+ try {
80
+ instance.term.dispose();
81
+ } catch {}
82
+ }
@@ -37,24 +37,28 @@
37
37
  * pages and can hand a fresh terminal the previous screen's cells.
38
38
  */
39
39
 
40
- import type { FitAddon, Ghostty, Terminal } from 'ghostty-web';
40
+ import type { Ghostty } from 'ghostty-web';
41
41
  import { terminalInputFrame } from '@/shared/lib/workspace/terminal/input';
42
42
  import {
43
- installCellMetrics,
44
43
  remeasureTerminal,
45
44
  waitForTerminalFonts,
46
45
  watchTerminalFonts,
47
46
  } from '@/client/components/workspace/terminal-panel/fonts';
48
- import { installFullWidthFit } from '@/client/components/workspace/terminal-panel/fit';
49
47
  import { createGridAnnouncer } from '@/client/components/workspace/terminal-panel/grid';
50
- import { attachTouchScroll, handleKeyNavigation } from '@/client/components/workspace/terminal-panel/navigation';
48
+ import {
49
+ attachTouchScroll,
50
+ handleKeyNavigation,
51
+ } from '@/client/components/workspace/terminal-panel/navigation';
51
52
  import { holdAcrossWrite, watchPointerPress } from '@/client/components/workspace/terminal-panel/scroll-hold';
52
53
  import {
53
- getTerminalTheme,
54
- TERMINAL_FONT_FAMILY,
55
- TERMINAL_FONT_SIZE,
56
- TERMINAL_SCROLLBACK_BYTES,
57
- } from '@/client/data/theme/terminal';
54
+ focusTerminal,
55
+ redirectSoftKeyboardFocus,
56
+ } from '@/client/components/workspace/terminal-panel/focus-target';
57
+ import {
58
+ createTerminalInstance,
59
+ disposeTerminalInstance,
60
+ type TerminalInstance,
61
+ } from '@/client/components/workspace/terminal-panel/instance';
58
62
 
59
63
  export interface TerminalMountCallbacks {
60
64
  /** Keystrokes, paste, mouse reports — straight to the PTY. */
@@ -95,12 +99,6 @@ export interface TerminalMount {
95
99
  dispose: () => void;
96
100
  }
97
101
 
98
- interface TerminalInstance {
99
- term: Terminal;
100
- fitAddon: FitAddon;
101
- disposables: { dispose(): void }[];
102
- }
103
-
104
102
  /**
105
103
  * Mount the terminal inside `container`. Resolves to null when the module could
106
104
  * not be loaded or the component unmounted while importing.
@@ -134,6 +132,9 @@ export async function mountTerminal(
134
132
  // one.
135
133
  term.attachCustomKeyEventHandler((event: globalThis.KeyboardEvent) => handleKeyNavigation(term, event));
136
134
  instance.disposables.push(
135
+ // ghostty's own `open()` re-focuses the container on a timer; see
136
+ // `focus-target.ts` for why a phone's textarea needs this redirect.
137
+ { dispose: redirectSoftKeyboardFocus(container, term) },
137
138
  term.onScroll((viewportY: number) => callbacks.onScrolledUpChange(viewportY > 0)),
138
139
  term.onData((data: string) => {
139
140
  const frame = terminalInputFrame(data);
@@ -153,49 +154,6 @@ export async function mountTerminal(
153
154
  );
154
155
  };
155
156
 
156
- const create = (nextThemeId: string): TerminalInstance => {
157
- const term = new module.Terminal({
158
- cursorBlink: true,
159
- cursorStyle: 'block',
160
- fontSize: TERMINAL_FONT_SIZE,
161
- fontFamily: TERMINAL_FONT_FAMILY,
162
- theme: getTerminalTheme(nextThemeId),
163
- // A byte budget, not xterm's line count. See `theme/terminal.ts`.
164
- scrollback: TERMINAL_SCROLLBACK_BYTES,
165
- // No `convertEol`: the PTY already emits CRLF, and converting a lone LF
166
- // would re-introduce the line-feed doubling a real terminal avoids.
167
- smoothScrollDuration: 0,
168
- ghostty: ghostty as Ghostty,
169
- });
170
- term.open(container);
171
- installCellMetrics(term);
172
- // The WASM allocator reuses pages: a fresh terminal can inherit the previous
173
- // screen's cells until something overwrites them. Clear before the first
174
- // byte is shown.
175
- term.clear();
176
- const fitAddon = new module.FitAddon();
177
- term.loadAddon(fitAddon);
178
- installFullWidthFit(fitAddon, term);
179
- const instance: TerminalInstance = { term, fitAddon, disposables: [] };
180
- wire(instance);
181
- return instance;
182
- };
183
-
184
- const disposeInstance = (instance: TerminalInstance | null): void => {
185
- if (!instance) return;
186
- for (const disposable of instance.disposables) {
187
- try {
188
- disposable.dispose();
189
- } catch {}
190
- }
191
- try {
192
- instance.fitAddon.dispose();
193
- } catch {}
194
- try {
195
- instance.term.dispose();
196
- } catch {}
197
- };
198
-
199
157
  /**
200
158
  * Fit to the container. Returns false when no fit was possible — the panel is
201
159
  * hidden, or the cell has not been measured yet — which is what keeps the
@@ -259,7 +217,7 @@ export async function mountTerminal(
259
217
 
260
218
  const pointer = watchPointerPress(container);
261
219
 
262
- current = create(currentThemeId);
220
+ current = createTerminalInstance(module, ghostty as Ghostty, container, currentThemeId, wire);
263
221
  safeFit();
264
222
  grid.schedule();
265
223
 
@@ -309,7 +267,8 @@ export async function mountTerminal(
309
267
  safeFit();
310
268
  },
311
269
  focus() {
312
- current?.term.focus();
270
+ const term = current?.term;
271
+ if (term) focusTerminal(term);
313
272
  },
314
273
  applicationCursorKeys() {
315
274
  return current?.term.wasmTerm?.getMode(1, false) ?? false;
@@ -326,8 +285,8 @@ export async function mountTerminal(
326
285
  setTheme(nextThemeId: string) {
327
286
  if (disposed || nextThemeId === currentThemeId) return;
328
287
  currentThemeId = nextThemeId;
329
- disposeInstance(current);
330
- current = create(nextThemeId);
288
+ disposeTerminalInstance(current);
289
+ current = createTerminalInstance(module, ghostty as Ghostty, container, nextThemeId, wire);
331
290
  safeFit();
332
291
  },
333
292
  dispose() {
@@ -339,7 +298,7 @@ export async function mountTerminal(
339
298
  touch();
340
299
  pointer.stop();
341
300
  resizeObserver.disconnect();
342
- disposeInstance(current);
301
+ disposeTerminalInstance(current);
343
302
  current = null;
344
303
  },
345
304
  };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The terminal is the one built-in panel that is typed into, so it is the one
8
+ * that needs the soft keyboard open before its view mounts.
9
+ *
10
+ * The phone shell arms it at the moment of the tap, before the view exists; the
11
+ * drawer releases the bridge (`lib/ui/soft-keyboard.ts`) when the panel it
12
+ * actually resolved is not the terminal — a stored tab the user has since
13
+ * disabled or moved, or a session with no workspace, must not leave the keyboard
14
+ * up over another view.
15
+ */
16
+
17
+ import { openSoftKeyboard } from '@/client/lib/ui/soft-keyboard';
18
+
19
+ /** The built-in id of this panel (`RIGHT_PANEL_TYPES`), spelled once here. */
20
+ const TERMINAL_PANEL_ID = 'terminal';
21
+
22
+ export function panelWantsSoftKeyboard(panelKey: string | null | undefined): boolean {
23
+ return panelKey === TERMINAL_PANEL_ID;
24
+ }
25
+
26
+ /** Arm the keyboard for the panel about to open; a no-op for every other view. */
27
+ export function armTerminalSoftKeyboard(panelKey: string | null | undefined): void {
28
+ if (panelWantsSoftKeyboard(panelKey)) openSoftKeyboard();
29
+ }
@@ -24,18 +24,23 @@ import { useEffect, useState } from 'preact/hooks';
24
24
  const COARSE_POINTER_QUERY = '(pointer: coarse)';
25
25
  const NO_HOVER_QUERY = '(hover: none)';
26
26
 
27
- function detectSoftKeyboardDevice(): boolean {
27
+ /**
28
+ * The same verdict the hook reports, for code that runs outside a render — the
29
+ * terminal's focus target and the soft-keyboard bridge both need it at the
30
+ * moment of a tap, not at the moment of a render.
31
+ */
32
+ export function isSoftKeyboardDevice(): boolean {
28
33
  if (typeof window === 'undefined') return false;
29
34
  if (window.matchMedia(COARSE_POINTER_QUERY).matches) return true;
30
35
  return navigator.maxTouchPoints > 0 && window.matchMedia(NO_HOVER_QUERY).matches;
31
36
  }
32
37
 
33
38
  export function useTouchDevice(): boolean {
34
- const [isTouch, setIsTouch] = useState(detectSoftKeyboardDevice);
39
+ const [isTouch, setIsTouch] = useState(isSoftKeyboardDevice);
35
40
 
36
41
  useEffect(() => {
37
42
  const queries = [COARSE_POINTER_QUERY, NO_HOVER_QUERY].map((q) => window.matchMedia(q));
38
- const update = () => setIsTouch(detectSoftKeyboardDevice());
43
+ const update = () => setIsTouch(isSoftKeyboardDevice());
39
44
  for (const query of queries) query.addEventListener('change', update);
40
45
  return () => {
41
46
  for (const query of queries) query.removeEventListener('change', update);
@@ -0,0 +1,155 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The phone's right-click: a long press opens the same visibility menu the
8
+ * desktop rails and navbar open on `contextmenu`.
9
+ *
10
+ * Four rules, each a way the gesture would otherwise misbehave:
11
+ *
12
+ * 1. **A right-click still works.** A desktop showing the phone layout keeps
13
+ * the menu it had, anchored to the surface rather than to the pixel.
14
+ * 2. **A hold opens at the press point.** There is no cursor to anchor to.
15
+ * 3. **The click the same gesture produces is swallowed.** Lifting the finger
16
+ * after the menu opened must not also press the control underneath.
17
+ * 4. **A press that moves is a scroll.** The surface is a scroller on a phone;
18
+ * a flick that starts on it must not open a menu.
19
+ */
20
+
21
+ import { afterEach, beforeEach, describe, expect, test, vi } from 'bun:test';
22
+ import { Window } from 'happy-dom';
23
+ import { h, render } from 'preact';
24
+ import { act } from 'preact/test-utils';
25
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
26
+ import {
27
+ useVisibilityMenuTrigger,
28
+ type VisibilityMenuTrigger,
29
+ } from '@/client/hooks/ui/visibility-menu-trigger';
30
+
31
+ let win: Window;
32
+ let container: HTMLElement;
33
+ let trigger: VisibilityMenuTrigger | null = null;
34
+ let clicks = 0;
35
+
36
+ beforeEach(() => {
37
+ vi.useFakeTimers();
38
+ win = new Window({ url: 'http://localhost' });
39
+ installDomGlobals(win);
40
+ container = document.createElement('div');
41
+ document.body.appendChild(container);
42
+ trigger = null;
43
+ clicks = 0;
44
+ });
45
+
46
+ afterEach(() => {
47
+ render(null, container);
48
+ container.remove();
49
+ restoreDomGlobals();
50
+ vi.useRealTimers();
51
+ });
52
+
53
+ /** Mount the hook on a surface with one child control. */
54
+ async function mount(coarse: boolean): Promise<void> {
55
+ win.matchMedia = ((query: string) => ({
56
+ matches: coarse && query === '(pointer: coarse)',
57
+ media: query,
58
+ onchange: null,
59
+ addEventListener: () => {},
60
+ removeEventListener: () => {},
61
+ addListener: () => {},
62
+ removeListener: () => {},
63
+ dispatchEvent: () => false,
64
+ })) as unknown as typeof win.matchMedia;
65
+
66
+ const Probe = () => {
67
+ trigger = useVisibilityMenuTrigger();
68
+ return h(
69
+ 'div',
70
+ { 'data-testid': 'surface', ...trigger.surfaceProps },
71
+ h('button', { 'data-testid': 'child', onClick: () => { clicks += 1; } }, 'child'),
72
+ );
73
+ };
74
+ await act(async () => {
75
+ render(h(Probe, {}), container);
76
+ });
77
+ }
78
+
79
+ /** A touch event carrying one finger at `(x, y)`. */
80
+ function touch(type: string, x: number, y: number): globalThis.TouchEvent {
81
+ const event = new win.Event(type, { bubbles: true, cancelable: true }) as unknown as globalThis.TouchEvent;
82
+ Object.defineProperty(event, 'touches', {
83
+ value: type === 'touchend' || type === 'touchcancel' ? [] : [{ clientX: x, clientY: y }],
84
+ });
85
+ return event;
86
+ }
87
+
88
+ describe('useVisibilityMenuTrigger', () => {
89
+ test('a right-click anchors the menu to the surface', async () => {
90
+ await mount(false);
91
+ (container.querySelector('[data-testid="surface"]') as HTMLElement).getBoundingClientRect = () => ({
92
+ top: 10, bottom: 50, left: 20, right: 120, width: 100, height: 40, x: 20, y: 10,
93
+ toJSON: () => ({}),
94
+ });
95
+
96
+ act(() => {
97
+ (container.querySelector('[data-testid="surface"]') as HTMLElement).dispatchEvent(new win.MouseEvent('contextmenu', { bubbles: true, cancelable: true }) as unknown as Event);
98
+ });
99
+
100
+ expect(trigger!.anchor).toEqual({ top: 10, bottom: 50, left: 20, right: 120 });
101
+ });
102
+
103
+ test('a hold opens the menu at the press point and swallows the click', async () => {
104
+ await mount(true);
105
+
106
+ act(() => {
107
+ (container.querySelector('[data-testid="surface"]') as HTMLElement).dispatchEvent(touch('touchstart', 30, 40));
108
+ });
109
+ await act(async () => {
110
+ vi.advanceTimersByTime(450);
111
+ });
112
+
113
+ expect(trigger!.anchor).toEqual({ top: 40, bottom: 40, left: 30, right: 30 });
114
+
115
+ act(() => {
116
+ (container.querySelector('[data-testid="child"]') as HTMLElement).dispatchEvent(new win.MouseEvent('click', { bubbles: true, cancelable: true }) as unknown as Event);
117
+ });
118
+ expect(clicks).toBe(0);
119
+
120
+ // The suppression is one-shot: the next tap is the user's own.
121
+ act(() => {
122
+ (container.querySelector('[data-testid="child"]') as HTMLElement).dispatchEvent(new win.MouseEvent('click', { bubbles: true, cancelable: true }) as unknown as Event);
123
+ });
124
+ expect(clicks).toBe(1);
125
+ });
126
+
127
+ test('a press that moves is a scroll, not a menu', async () => {
128
+ await mount(true);
129
+
130
+ act(() => {
131
+ (container.querySelector('[data-testid="surface"]') as HTMLElement).dispatchEvent(touch('touchstart', 30, 40));
132
+ });
133
+ act(() => {
134
+ (container.querySelector('[data-testid="surface"]') as HTMLElement).dispatchEvent(touch('touchmove', 60, 40));
135
+ });
136
+ await act(async () => {
137
+ vi.advanceTimersByTime(450);
138
+ });
139
+
140
+ expect(trigger!.anchor).toBeNull();
141
+ });
142
+
143
+ test('a mouse hold does not open the menu', async () => {
144
+ await mount(false);
145
+
146
+ act(() => {
147
+ (container.querySelector('[data-testid="surface"]') as HTMLElement).dispatchEvent(touch('touchstart', 30, 40));
148
+ });
149
+ await act(async () => {
150
+ vi.advanceTimersByTime(450);
151
+ });
152
+
153
+ expect(trigger!.anchor).toBeNull();
154
+ });
155
+ });