aicodeman 1.44.0 → 1.46.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 (351) hide show
  1. package/README.md +32 -8
  2. package/dist/agent-codex-identity.d.ts +26 -0
  3. package/dist/agent-codex-identity.d.ts.map +1 -0
  4. package/dist/agent-codex-identity.js +253 -0
  5. package/dist/agent-codex-identity.js.map +1 -0
  6. package/dist/agent-inspection.d.ts +32 -0
  7. package/dist/agent-inspection.d.ts.map +1 -0
  8. package/dist/agent-inspection.js +196 -0
  9. package/dist/agent-inspection.js.map +1 -0
  10. package/dist/agent-staging.d.ts +130 -0
  11. package/dist/agent-staging.d.ts.map +1 -0
  12. package/dist/agent-staging.js +312 -0
  13. package/dist/agent-staging.js.map +1 -0
  14. package/dist/case-rename.d.ts +65 -0
  15. package/dist/case-rename.d.ts.map +1 -0
  16. package/dist/case-rename.js +198 -0
  17. package/dist/case-rename.js.map +1 -0
  18. package/dist/cli-agent.d.ts +91 -3
  19. package/dist/cli-agent.d.ts.map +1 -1
  20. package/dist/cli-agent.js +501 -44
  21. package/dist/cli-agent.js.map +1 -1
  22. package/dist/cli-history.d.ts +20 -0
  23. package/dist/cli-history.d.ts.map +1 -0
  24. package/dist/cli-history.js +61 -0
  25. package/dist/cli-history.js.map +1 -0
  26. package/dist/cli.d.ts.map +1 -1
  27. package/dist/cli.js +6 -1
  28. package/dist/cli.js.map +1 -1
  29. package/dist/codex-rollout-format.d.ts +66 -0
  30. package/dist/codex-rollout-format.d.ts.map +1 -0
  31. package/dist/codex-rollout-format.js +111 -0
  32. package/dist/codex-rollout-format.js.map +1 -0
  33. package/dist/codex-transcript.d.ts +3 -0
  34. package/dist/codex-transcript.d.ts.map +1 -1
  35. package/dist/codex-transcript.js +13 -41
  36. package/dist/codex-transcript.js.map +1 -1
  37. package/dist/config/auth-config.d.ts +16 -1
  38. package/dist/config/auth-config.d.ts.map +1 -1
  39. package/dist/config/auth-config.js +16 -1
  40. package/dist/config/auth-config.js.map +1 -1
  41. package/dist/config/cli-registry/schema.d.ts +12 -7
  42. package/dist/config/cli-registry/schema.d.ts.map +1 -1
  43. package/dist/config/cli-registry/schema.js +26 -0
  44. package/dist/config/cli-registry/schema.js.map +1 -1
  45. package/dist/config/cli-registry/stock.d.ts.map +1 -1
  46. package/dist/config/cli-registry/stock.js +40 -1
  47. package/dist/config/cli-registry/stock.js.map +1 -1
  48. package/dist/config/cli-registry/types.d.ts +57 -0
  49. package/dist/config/cli-registry/types.d.ts.map +1 -1
  50. package/dist/config/server-timing.d.ts +6 -0
  51. package/dist/config/server-timing.d.ts.map +1 -1
  52. package/dist/config/server-timing.js +9 -0
  53. package/dist/config/server-timing.js.map +1 -1
  54. package/dist/daemon-control.d.ts +1 -0
  55. package/dist/daemon-control.d.ts.map +1 -1
  56. package/dist/daemon-control.js +2 -0
  57. package/dist/daemon-control.js.map +1 -1
  58. package/dist/deepseek-transcript.d.ts +9 -7
  59. package/dist/deepseek-transcript.d.ts.map +1 -1
  60. package/dist/deepseek-transcript.js +9 -7
  61. package/dist/deepseek-transcript.js.map +1 -1
  62. package/dist/docker-hosts.d.ts +8 -0
  63. package/dist/docker-hosts.d.ts.map +1 -1
  64. package/dist/docker-hosts.js +29 -0
  65. package/dist/docker-hosts.js.map +1 -1
  66. package/dist/git-fetch-scheduler.d.ts +124 -0
  67. package/dist/git-fetch-scheduler.d.ts.map +1 -0
  68. package/dist/git-fetch-scheduler.js +249 -0
  69. package/dist/git-fetch-scheduler.js.map +1 -0
  70. package/dist/git-fetch.d.ts +241 -0
  71. package/dist/git-fetch.d.ts.map +1 -0
  72. package/dist/git-fetch.js +392 -0
  73. package/dist/git-fetch.js.map +1 -0
  74. package/dist/git-workspace-status.d.ts +36 -1
  75. package/dist/git-workspace-status.d.ts.map +1 -1
  76. package/dist/git-workspace-status.js +42 -5
  77. package/dist/git-workspace-status.js.map +1 -1
  78. package/dist/hooks-config.d.ts +14 -2
  79. package/dist/hooks-config.d.ts.map +1 -1
  80. package/dist/hooks-config.js +39 -3
  81. package/dist/hooks-config.js.map +1 -1
  82. package/dist/host-sensors.d.ts +115 -0
  83. package/dist/host-sensors.d.ts.map +1 -0
  84. package/dist/host-sensors.js +457 -0
  85. package/dist/host-sensors.js.map +1 -0
  86. package/dist/local-history.d.ts +71 -0
  87. package/dist/local-history.d.ts.map +1 -0
  88. package/dist/local-history.js +750 -0
  89. package/dist/local-history.js.map +1 -0
  90. package/dist/mcp-server.d.ts.map +1 -1
  91. package/dist/mcp-server.js +2 -2
  92. package/dist/mcp-server.js.map +1 -1
  93. package/dist/mux-interface.d.ts +5 -2
  94. package/dist/mux-interface.d.ts.map +1 -1
  95. package/dist/prompt-cache-keepwarm.d.ts.map +1 -1
  96. package/dist/prompt-cache-keepwarm.js +5 -3
  97. package/dist/prompt-cache-keepwarm.js.map +1 -1
  98. package/dist/remote-hosts.d.ts +7 -0
  99. package/dist/remote-hosts.d.ts.map +1 -1
  100. package/dist/remote-hosts.js +17 -3
  101. package/dist/remote-hosts.js.map +1 -1
  102. package/dist/remote-pane-history.d.ts.map +1 -1
  103. package/dist/remote-pane-history.js +2 -2
  104. package/dist/remote-pane-history.js.map +1 -1
  105. package/dist/session.d.ts +113 -0
  106. package/dist/session.d.ts.map +1 -1
  107. package/dist/session.js +354 -13
  108. package/dist/session.js.map +1 -1
  109. package/dist/terminal-input-classifier.d.ts +8 -0
  110. package/dist/terminal-input-classifier.d.ts.map +1 -0
  111. package/dist/terminal-input-classifier.js +60 -0
  112. package/dist/terminal-input-classifier.js.map +1 -0
  113. package/dist/tmux-manager.d.ts +30 -4
  114. package/dist/tmux-manager.d.ts.map +1 -1
  115. package/dist/tmux-manager.js +101 -21
  116. package/dist/tmux-manager.js.map +1 -1
  117. package/dist/tmux-prefix-table.d.ts +37 -5
  118. package/dist/tmux-prefix-table.d.ts.map +1 -1
  119. package/dist/tmux-prefix-table.js +40 -5
  120. package/dist/tmux-prefix-table.js.map +1 -1
  121. package/dist/tui/tui-app.d.ts +8 -1
  122. package/dist/tui/tui-app.d.ts.map +1 -1
  123. package/dist/tui/tui-app.js +49 -12
  124. package/dist/tui/tui-app.js.map +1 -1
  125. package/dist/tui/tui-client.d.ts +90 -3
  126. package/dist/tui/tui-client.d.ts.map +1 -1
  127. package/dist/tui/tui-client.js +195 -26
  128. package/dist/tui/tui-client.js.map +1 -1
  129. package/dist/types/session.d.ts +15 -0
  130. package/dist/types/session.d.ts.map +1 -1
  131. package/dist/types/session.js.map +1 -1
  132. package/dist/web/agent-inbox-persistence.d.ts +52 -0
  133. package/dist/web/agent-inbox-persistence.d.ts.map +1 -0
  134. package/dist/web/agent-inbox-persistence.js +139 -0
  135. package/dist/web/agent-inbox-persistence.js.map +1 -0
  136. package/dist/web/agent-inbox.d.ts +140 -0
  137. package/dist/web/agent-inbox.d.ts.map +1 -0
  138. package/dist/web/agent-inbox.js +258 -0
  139. package/dist/web/agent-inbox.js.map +1 -0
  140. package/dist/web/middleware/auth.d.ts +2 -0
  141. package/dist/web/middleware/auth.d.ts.map +1 -1
  142. package/dist/web/middleware/auth.js +145 -52
  143. package/dist/web/middleware/auth.js.map +1 -1
  144. package/dist/web/network-auth-policy.d.ts +13 -3
  145. package/dist/web/network-auth-policy.d.ts.map +1 -1
  146. package/dist/web/network-auth-policy.js +15 -3
  147. package/dist/web/network-auth-policy.js.map +1 -1
  148. package/dist/web/ports/infra-port.d.ts +2 -0
  149. package/dist/web/ports/infra-port.d.ts.map +1 -1
  150. package/dist/web/public/admin-ui.js.gz +0 -0
  151. package/dist/web/public/api-client.c9b1cddc.js.gz +0 -0
  152. package/dist/web/public/app.3093527f.js +43 -0
  153. package/dist/web/public/app.3093527f.js.br +0 -0
  154. package/dist/web/public/app.3093527f.js.gz +0 -0
  155. package/dist/web/public/approvals-ui.js.gz +0 -0
  156. package/dist/web/public/{constants.4866ecc3.js → constants.affcdde6.js} +622 -12
  157. package/dist/web/public/constants.affcdde6.js.br +0 -0
  158. package/dist/web/public/constants.affcdde6.js.gz +0 -0
  159. package/dist/web/public/cron-ui.js.gz +0 -0
  160. package/dist/web/public/entrance-animations.js.gz +0 -0
  161. package/dist/web/public/git-status-ui.js +88 -5
  162. package/dist/web/public/git-status-ui.js.br +0 -0
  163. package/dist/web/public/git-status-ui.js.gz +0 -0
  164. package/dist/web/public/header-divider.eb2d2463.js +1 -0
  165. package/dist/web/public/header-divider.eb2d2463.js.br +0 -0
  166. package/dist/web/public/header-divider.eb2d2463.js.gz +0 -0
  167. package/dist/web/public/home-sessions.js.gz +0 -0
  168. package/dist/web/public/host-wake-ui.js.gz +0 -0
  169. package/dist/web/public/i18n.70265257.js +2 -0
  170. package/dist/web/public/i18n.70265257.js.br +0 -0
  171. package/dist/web/public/i18n.70265257.js.gz +0 -0
  172. package/dist/web/public/image-input.941386e7.js.gz +0 -0
  173. package/dist/web/public/index.html +170 -16
  174. package/dist/web/public/index.html.br +0 -0
  175. package/dist/web/public/index.html.gz +0 -0
  176. package/dist/web/public/input-cjk.8bc46081.js.gz +0 -0
  177. package/dist/web/public/keyboard-accessory.4e8b20ac.js.gz +0 -0
  178. package/dist/web/public/{mobile-handlers.44adaa07.js → mobile-handlers.f7c3f692.js} +26 -2
  179. package/dist/web/public/mobile-handlers.f7c3f692.js.br +0 -0
  180. package/dist/web/public/mobile-handlers.f7c3f692.js.gz +0 -0
  181. package/dist/web/public/mobile-ime-preview.2dbaf262.js.gz +0 -0
  182. package/dist/web/public/mobile-overview.js.gz +0 -0
  183. package/dist/web/public/mobile.1bbd2d67.css +1 -0
  184. package/dist/web/public/mobile.1bbd2d67.css.br +0 -0
  185. package/dist/web/public/mobile.1bbd2d67.css.gz +0 -0
  186. package/dist/web/public/notification-manager.feb82c04.js.gz +0 -0
  187. package/dist/web/public/orchestrator-panel.js.gz +0 -0
  188. package/dist/web/public/{panels-ui.cbb24ba1.js → panels-ui.4a56ee63.js} +76 -70
  189. package/dist/web/public/panels-ui.4a56ee63.js.br +0 -0
  190. package/dist/web/public/panels-ui.4a56ee63.js.gz +0 -0
  191. package/dist/web/public/ralph-panel.b350e2ef.js.gz +0 -0
  192. package/dist/web/public/ralph-wizard.b6c0dd19.js.gz +0 -0
  193. package/dist/web/public/readmymind-ui.js.gz +0 -0
  194. package/dist/web/public/reboot-restore-ui.js.gz +0 -0
  195. package/dist/web/public/respawn-ui.d7adcf6a.js.gz +0 -0
  196. package/dist/web/public/sanitize-html.e7147e76.js.gz +0 -0
  197. package/dist/web/public/session-lineage.js.gz +0 -0
  198. package/dist/web/public/session-ui.186f9419.js +106 -0
  199. package/dist/web/public/session-ui.186f9419.js.br +0 -0
  200. package/dist/web/public/session-ui.186f9419.js.gz +0 -0
  201. package/dist/web/public/settings-ui.a191154e.js +106 -0
  202. package/dist/web/public/settings-ui.a191154e.js.br +0 -0
  203. package/dist/web/public/settings-ui.a191154e.js.gz +0 -0
  204. package/dist/web/public/spreadsheet-preview-worker.js.gz +0 -0
  205. package/dist/web/public/spreadsheet-preview.75c751de.js.gz +0 -0
  206. package/dist/web/public/spreadsheet-xlsx-core.js.gz +0 -0
  207. package/dist/web/public/styles.7238eae8.css +1 -0
  208. package/dist/web/public/styles.7238eae8.css.br +0 -0
  209. package/dist/web/public/styles.7238eae8.css.gz +0 -0
  210. package/dist/web/public/subagent-windows.07277a58.js.gz +0 -0
  211. package/dist/web/public/sw.js +2 -2
  212. package/dist/web/public/sw.js.br +0 -0
  213. package/dist/web/public/sw.js.gz +0 -0
  214. package/dist/web/public/tab-layout-browser.2d6189f7.js.gz +0 -0
  215. package/dist/web/public/{tab-rail-resize.7157e0bd.js → tab-rail-resize.b5cdceaf.js} +1 -1
  216. package/dist/web/public/tab-rail-resize.b5cdceaf.js.br +0 -0
  217. package/dist/web/public/tab-rail-resize.b5cdceaf.js.gz +0 -0
  218. package/dist/web/public/terminal-keycode229-recovery.af09f99a.js.gz +0 -0
  219. package/dist/web/public/terminal-split.js.gz +0 -0
  220. package/dist/web/public/terminal-tile.js +10 -1
  221. package/dist/web/public/terminal-tile.js.br +0 -0
  222. package/dist/web/public/terminal-tile.js.gz +0 -0
  223. package/dist/web/public/terminal-ui.7e787829.js +4 -0
  224. package/dist/web/public/terminal-ui.7e787829.js.br +0 -0
  225. package/dist/web/public/terminal-ui.7e787829.js.gz +0 -0
  226. package/dist/web/public/tile-grid.js.gz +0 -0
  227. package/dist/web/public/ultracode-panel.js.gz +0 -0
  228. package/dist/web/public/ultracode-windows.js.gz +0 -0
  229. package/dist/web/public/vendor/dompurify.min.js.gz +0 -0
  230. package/dist/web/public/vendor/exceljs.min.js.gz +0 -0
  231. package/dist/web/public/vendor/fflate.min.js.gz +0 -0
  232. package/dist/web/public/vendor/marked.min.js.gz +0 -0
  233. package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
  234. package/dist/web/public/vendor/xterm-addon-serialize.min.js.gz +0 -0
  235. package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
  236. package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
  237. package/dist/web/public/vendor/{xterm-predictive-echo.ae5e3d5d.js → xterm-predictive-echo.276b11d9.js} +1 -1
  238. package/dist/web/public/vendor/xterm-predictive-echo.276b11d9.js.br +0 -0
  239. package/dist/web/public/vendor/xterm-predictive-echo.276b11d9.js.gz +0 -0
  240. package/dist/web/public/vendor/xterm-zerolag-input.1be42307.js +5 -0
  241. package/dist/web/public/vendor/xterm-zerolag-input.1be42307.js.br +0 -0
  242. package/dist/web/public/vendor/xterm-zerolag-input.1be42307.js.gz +0 -0
  243. package/dist/web/public/vendor/xterm.css.gz +0 -0
  244. package/dist/web/public/vendor/xterm.min.js.gz +0 -0
  245. package/dist/web/public/voice-input.2342c37b.js.gz +0 -0
  246. package/dist/web/public/voice-pcm-worklet.js.gz +0 -0
  247. package/dist/web/public/webview-tabs.js.gz +0 -0
  248. package/dist/web/public/whats-new.json +9 -9
  249. package/dist/web/route-helpers.d.ts +57 -6
  250. package/dist/web/route-helpers.d.ts.map +1 -1
  251. package/dist/web/route-helpers.js +72 -4
  252. package/dist/web/route-helpers.js.map +1 -1
  253. package/dist/web/routes/agent-session-routes.d.ts +20 -0
  254. package/dist/web/routes/agent-session-routes.d.ts.map +1 -0
  255. package/dist/web/routes/agent-session-routes.js +160 -0
  256. package/dist/web/routes/agent-session-routes.js.map +1 -0
  257. package/dist/web/routes/case-routes.d.ts.map +1 -1
  258. package/dist/web/routes/case-routes.js +203 -16
  259. package/dist/web/routes/case-routes.js.map +1 -1
  260. package/dist/web/routes/config-backup-routes.js +2 -2
  261. package/dist/web/routes/config-backup-routes.js.map +1 -1
  262. package/dist/web/routes/git-status-routes.d.ts +21 -7
  263. package/dist/web/routes/git-status-routes.d.ts.map +1 -1
  264. package/dist/web/routes/git-status-routes.js +78 -12
  265. package/dist/web/routes/git-status-routes.js.map +1 -1
  266. package/dist/web/routes/inbox-routes.d.ts +43 -0
  267. package/dist/web/routes/inbox-routes.d.ts.map +1 -0
  268. package/dist/web/routes/inbox-routes.js +148 -0
  269. package/dist/web/routes/inbox-routes.js.map +1 -0
  270. package/dist/web/routes/index.d.ts +2 -0
  271. package/dist/web/routes/index.d.ts.map +1 -1
  272. package/dist/web/routes/index.js +2 -0
  273. package/dist/web/routes/index.js.map +1 -1
  274. package/dist/web/routes/ralph-routes.d.ts.map +1 -1
  275. package/dist/web/routes/ralph-routes.js +7 -16
  276. package/dist/web/routes/ralph-routes.js.map +1 -1
  277. package/dist/web/routes/session-routes.d.ts.map +1 -1
  278. package/dist/web/routes/session-routes.js +120 -74
  279. package/dist/web/routes/session-routes.js.map +1 -1
  280. package/dist/web/routes/system-routes.d.ts.map +1 -1
  281. package/dist/web/routes/system-routes.js +107 -59
  282. package/dist/web/routes/system-routes.js.map +1 -1
  283. package/dist/web/routes/ws-routes.d.ts +5 -0
  284. package/dist/web/routes/ws-routes.d.ts.map +1 -1
  285. package/dist/web/routes/ws-routes.js +84 -47
  286. package/dist/web/routes/ws-routes.js.map +1 -1
  287. package/dist/web/schemas.d.ts +56 -7
  288. package/dist/web/schemas.d.ts.map +1 -1
  289. package/dist/web/schemas.js +88 -1
  290. package/dist/web/schemas.js.map +1 -1
  291. package/dist/web/sensitive-path.d.ts.map +1 -1
  292. package/dist/web/sensitive-path.js +2 -0
  293. package/dist/web/sensitive-path.js.map +1 -1
  294. package/dist/web/server.d.ts +7 -2
  295. package/dist/web/server.d.ts.map +1 -1
  296. package/dist/web/server.js +144 -16
  297. package/dist/web/server.js.map +1 -1
  298. package/dist/web/session-wait-registry.d.ts +48 -4
  299. package/dist/web/session-wait-registry.d.ts.map +1 -1
  300. package/dist/web/session-wait-registry.js +144 -6
  301. package/dist/web/session-wait-registry.js.map +1 -1
  302. package/dist/web/settings-writer.d.ts +47 -0
  303. package/dist/web/settings-writer.d.ts.map +1 -0
  304. package/dist/web/settings-writer.js +110 -0
  305. package/dist/web/settings-writer.js.map +1 -0
  306. package/dist/web/sse-events.d.ts +4 -1
  307. package/dist/web/sse-events.d.ts.map +1 -1
  308. package/dist/web/sse-events.js +4 -1
  309. package/dist/web/sse-events.js.map +1 -1
  310. package/package.json +1 -1
  311. package/skills/codeman/SKILL.md +30 -8
  312. package/skills/codeman/preamble.sh +3 -3
  313. package/skills/codeman/reference/endpoints.md +24 -3
  314. package/skills/codeman/reference/history.md +84 -0
  315. package/skills/codeman/reference/inspection-and-staging.md +152 -0
  316. package/skills/codeman/reference/messaging.md +1 -1
  317. package/skills/codeman/reference/verbs.md +65 -3
  318. package/dist/web/public/app.9314ee60.js +0 -43
  319. package/dist/web/public/app.9314ee60.js.br +0 -0
  320. package/dist/web/public/app.9314ee60.js.gz +0 -0
  321. package/dist/web/public/constants.4866ecc3.js.br +0 -0
  322. package/dist/web/public/constants.4866ecc3.js.gz +0 -0
  323. package/dist/web/public/i18n.22ca902b.js +0 -2
  324. package/dist/web/public/i18n.22ca902b.js.br +0 -0
  325. package/dist/web/public/i18n.22ca902b.js.gz +0 -0
  326. package/dist/web/public/mobile-handlers.44adaa07.js.br +0 -0
  327. package/dist/web/public/mobile-handlers.44adaa07.js.gz +0 -0
  328. package/dist/web/public/mobile.12fb18de.css +0 -1
  329. package/dist/web/public/mobile.12fb18de.css.br +0 -0
  330. package/dist/web/public/mobile.12fb18de.css.gz +0 -0
  331. package/dist/web/public/panels-ui.cbb24ba1.js.br +0 -0
  332. package/dist/web/public/panels-ui.cbb24ba1.js.gz +0 -0
  333. package/dist/web/public/session-ui.9c1f009b.js +0 -104
  334. package/dist/web/public/session-ui.9c1f009b.js.br +0 -0
  335. package/dist/web/public/session-ui.9c1f009b.js.gz +0 -0
  336. package/dist/web/public/settings-ui.fea9ddae.js +0 -106
  337. package/dist/web/public/settings-ui.fea9ddae.js.br +0 -0
  338. package/dist/web/public/settings-ui.fea9ddae.js.gz +0 -0
  339. package/dist/web/public/styles.e096fcd6.css +0 -1
  340. package/dist/web/public/styles.e096fcd6.css.br +0 -0
  341. package/dist/web/public/styles.e096fcd6.css.gz +0 -0
  342. package/dist/web/public/tab-rail-resize.7157e0bd.js.br +0 -0
  343. package/dist/web/public/tab-rail-resize.7157e0bd.js.gz +0 -0
  344. package/dist/web/public/terminal-ui.68dbd352.js +0 -2
  345. package/dist/web/public/terminal-ui.68dbd352.js.br +0 -0
  346. package/dist/web/public/terminal-ui.68dbd352.js.gz +0 -0
  347. package/dist/web/public/vendor/xterm-predictive-echo.ae5e3d5d.js.br +0 -0
  348. package/dist/web/public/vendor/xterm-predictive-echo.ae5e3d5d.js.gz +0 -0
  349. package/dist/web/public/vendor/xterm-zerolag-input.0b69623c.js +0 -4
  350. package/dist/web/public/vendor/xterm-zerolag-input.0b69623c.js.br +0 -0
  351. package/dist/web/public/vendor/xterm-zerolag-input.0b69623c.js.gz +0 -0
@@ -26,7 +26,7 @@
26
26
  // not the current one, so the old constant key meant that cleanup never deleted
27
27
  // anything — hashed assets from every release ever deployed accumulated in one
28
28
  // bucket until the origin hit its storage quota.
29
- const BUILD_ID = '1256af9349fb';
29
+ const BUILD_ID = '86c261a69d9f';
30
30
  const CACHE_NAME = `codeman-${BUILD_ID}`;
31
31
 
32
32
  // Reverse-proxy base path: the worker is served at `<base>/sw.js`, so its own
@@ -48,7 +48,7 @@ const B = (p) => (p && p[0] === '/' ? SW_BASE + p : p);
48
48
  // handler caches every successful GET at runtime, but the precache warmed
49
49
  // nothing while looking like it did. Deriving it from the same manifest that
50
50
  // renames the files is the only thing that keeps the two from drifting again.
51
- const HASHED_ASSETS = ["styles.e096fcd6.css", "mobile.12fb18de.css", "constants.4866ecc3.js", "i18n.22ca902b.js", "mobile-handlers.44adaa07.js", "voice-input.2342c37b.js", "notification-manager.feb82c04.js", "keyboard-accessory.4e8b20ac.js", "input-cjk.8bc46081.js", "mobile-ime-preview.2dbaf262.js", "terminal-keycode229-recovery.af09f99a.js", "sanitize-html.e7147e76.js", "tab-layout-browser.2d6189f7.js", "app.9314ee60.js", "tab-rail-resize.7157e0bd.js", "terminal-ui.68dbd352.js", "respawn-ui.d7adcf6a.js", "ralph-panel.b350e2ef.js", "settings-ui.fea9ddae.js", "panels-ui.cbb24ba1.js", "session-ui.9c1f009b.js", "ralph-wizard.b6c0dd19.js", "api-client.c9b1cddc.js", "subagent-windows.07277a58.js", "image-input.941386e7.js", "spreadsheet-preview.75c751de.js", "vendor/xterm-zerolag-input.0b69623c.js", "vendor/xterm-predictive-echo.ae5e3d5d.js"];
51
+ const HASHED_ASSETS = ["styles.7238eae8.css", "mobile.1bbd2d67.css", "constants.affcdde6.js", "i18n.70265257.js", "mobile-handlers.f7c3f692.js", "voice-input.2342c37b.js", "notification-manager.feb82c04.js", "keyboard-accessory.4e8b20ac.js", "input-cjk.8bc46081.js", "mobile-ime-preview.2dbaf262.js", "terminal-keycode229-recovery.af09f99a.js", "sanitize-html.e7147e76.js", "tab-layout-browser.2d6189f7.js", "app.3093527f.js", "tab-rail-resize.b5cdceaf.js", "header-divider.eb2d2463.js", "terminal-ui.7e787829.js", "respawn-ui.d7adcf6a.js", "ralph-panel.b350e2ef.js", "settings-ui.a191154e.js", "panels-ui.4a56ee63.js", "session-ui.186f9419.js", "ralph-wizard.b6c0dd19.js", "api-client.c9b1cddc.js", "subagent-windows.07277a58.js", "image-input.941386e7.js", "spreadsheet-preview.75c751de.js", "vendor/xterm-zerolag-input.1be42307.js", "vendor/xterm-predictive-echo.276b11d9.js"];
52
52
 
53
53
  // Core app shell -- cached on install for instant startup
54
54
  const APP_SHELL = [
Binary file
Binary file
@@ -1 +1 @@
1
- "use strict";Object.assign(CodemanApp.prototype,{_getTabRailMinimumTerminalWidth(){const t=this.terminal?._core?._renderService?.dimensions?.css?.cell?.width;return Number.isFinite(t)&&t>0?Math.ceil(t*40+24):420},_getTabRailBounds(){const t=document.querySelector(".main");return{viewportWidth:window.innerWidth,mainWidth:t?.clientWidth||window.innerWidth,minTerminalWidth:this._getTabRailMinimumTerminalWidth()}},_getCurrentTabRailWidth(){const t=Number.parseFloat(document.documentElement.style.getPropertyValue("--tab-rail-width"));if(Number.isFinite(t))return t;const e=document.getElementById("tabRail")?.getBoundingClientRect?.().width;return Number.isFinite(e)&&e>0?e:window.CodemanTabRail?.DEFAULT_WIDTH||256},readTabRailWidthSetting(){const t=document.getElementById("appSettingsTabRailWidth");return t?t.value==="custom"?Number(t.dataset.currentWidth)||this._getCurrentTabRailWidth():Number(t.value)||window.CodemanTabRail?.DEFAULT_WIDTH||256:this._getCurrentTabRailWidth()},syncTabRailWidthSetting(t){const e=document.getElementById("appSettingsTabRailWidth");if(!e)return;const i=Math.round(t);if(e.dataset.currentWidth=String(i),e.querySelector(`option[value="${i}"]`)){e.value=String(i);return}const n=e.querySelector('option[value="custom"]');n&&(n.textContent=`Custom (${i}px)`),e.value="custom"},_setTabRailWidth(t){const e=window.CodemanTabRail;if(!e)return 256;const i=e.resolveWidth({width:t}),a=this._getTabRailBounds(),n=e.resolveWidth({width:i,...a}),h=e.resolveWidth({width:e.MAX_WIDTH,...a}),o=document.documentElement;o.style.setProperty("--tab-rail-width",`${n}px`);const d=o.classList.contains("tab-rail-compact"),s=n<240;if(o.classList.toggle("tab-rail-compact",s),o.classList.toggle("tab-rail-tight",n<288),d!==s){const r=this._tallTabsEnabled;this.applyTabWrapSettings?.(),r!==void 0&&this._tallTabsEnabled!==r||this._fullRenderSessionTabs?.()}const l=document.getElementById("tabRailResizeHandle");return l&&(l.setAttribute("aria-valuemax",String(h)),l.setAttribute("aria-valuenow",String(n))),this.syncTabRailWidthSetting(i),n},_persistTabRailWidth(t){const e=this.loadAppSettingsFromStorage();e.tabRailWidth!==t&&(e.tabRailWidth=t,this.saveAppSettingsToStorage(e))},_claimTabRailResize(){this._tabRailResizeOwnsObserver=!0,clearTimeout(this._tabRailResizeWatchdog),clearTimeout(this._tabRailReleaseTimer),this._tabRailReleaseRaf&&cancelAnimationFrame(this._tabRailReleaseRaf),this._armTabRailResizeWatchdog(),this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeRaf=null,this._resizeTimeout=null},_armTabRailResizeWatchdog(){this._tabRailResizeWatchdog=setTimeout(()=>{if(this._tabRailResizeWatchdog=null,document.body.classList.contains("tab-rail-resizing")){this._armTabRailResizeWatchdog();return}this._tabRailResizeOwnsObserver=!1},1e3)},_releaseTabRailResize(){clearTimeout(this._tabRailResizeWatchdog),this._tabRailResizeWatchdog=null;const t=()=>{clearTimeout(this._tabRailReleaseTimer),this._tabRailReleaseTimer=null,this._tabRailReleaseRaf=null,this._tabRailResizeOwnsObserver=!1};typeof requestAnimationFrame=="function"?(this._tabRailReleaseRaf=requestAnimationFrame(()=>{this._tabRailReleaseRaf=requestAnimationFrame(t)}),this._tabRailReleaseTimer=setTimeout(t,250)):t()},_scheduleTabRailSettle(t,e=t){clearTimeout(this._tabRailSettleTimer),this._tabRailSettleTimer=setTimeout(async()=>{this._tabRailSettleTimer=null,this._persistTabRailWidth(e);try{this.activeSessionId&&this.sendResize?await this.sendResize(this.activeSessionId):this.syncTerminalGeometry?.(),this._updateConnectionLinesImmediate?.()}catch(i){console.warn("Failed to resize terminal after rail resize:",i)}finally{this._releaseTabRailResize()}},150)},_defaultTabRailWidth(){return document.documentElement.dataset.tabRailDetail!=="simple"?window.CodemanTabRail?.RICH_DEFAULT_WIDTH??320:window.CodemanTabRail?.DEFAULT_WIDTH??256},applyTabRailWidth(t={}){const i=this.loadAppSettingsFromStorage().tabRailWidth??this._defaultTabRailWidth(),a=window.CodemanTabRail?.resolveWidth({width:i})??256;t.settle&&this._claimTabRailResize();const n=this._setTabRailWidth(a);return t.persist!==!1&&i!==a&&this._persistTabRailWidth(a),t.settle&&this._scheduleTabRailSettle(n,a),n},_applyTabRailPointerWidth(t){const e=document.querySelector(".main");if(!e)return this._getCurrentTabRailWidth();const i=this._getCurrentTabRailWidth(),a=this._setTabRailWidth(t-e.getBoundingClientRect().left);let n=null;try{n=this.fitAddon?.proposeDimensions?.()}catch{}return n&&n.cols<40?this._setTabRailWidth(i):a},_queueTabRailPointerWidth(t){this._tabRailPendingClientX=t,!this._tabRailPointerRaf&&(this._tabRailPointerRaf=requestAnimationFrame(()=>{this._tabRailPointerRaf=null,this._tabRailDragWidth=this._applyTabRailPointerWidth(this._tabRailPendingClientX)}))},_finishTabRailDrag(t,e){if(!document.body.classList.contains("tab-rail-resizing"))return;this._tabRailPointerRaf&&(cancelAnimationFrame(this._tabRailPointerRaf),this._tabRailPointerRaf=null,this._tabRailDragWidth=this._applyTabRailPointerWidth(this._tabRailPendingClientX)),document.body.classList.remove("tab-rail-resizing");const i=document.getElementById("tabRailResizeShield");i&&(i.hidden=!0);try{t.hasPointerCapture?.(e)&&t.releasePointerCapture(e)}catch{}const a=window.CodemanTabRail?.resolveWidth({width:this._tabRailDragWidth})??this._tabRailDragWidth;this._scheduleTabRailSettle(this._tabRailDragWidth||this._getCurrentTabRailWidth(),a)},_onTabRailKeyDown(t){const e=window.CodemanTabRail?.resolveKeyboardWidth({key:t.key,shiftKey:t.shiftKey,currentWidth:this._getCurrentTabRailWidth(),defaultWidth:this._defaultTabRailWidth?.(),...this._getTabRailBounds()});if(e==null)return;t.preventDefault(),this._claimTabRailResize();const i=this._setTabRailWidth(e);this._scheduleTabRailSettle(i,window.CodemanTabRail.resolveWidth({width:e}))},initTabRailResize(){const t=document.getElementById("tabRailResizeHandle");if(!t||t.dataset.ready==="1")return;t.dataset.ready="1",this.applyTabRailWidth(),t.addEventListener("pointerdown",i=>{if(i.button!==0)return;i.preventDefault(),this.closeTabRailActionMenu(),this._claimTabRailResize(),this._tabRailDragWidth=this._getCurrentTabRailWidth(),this._tabRailPendingClientX=i.clientX,document.body.classList.add("tab-rail-resizing");const a=document.getElementById("tabRailResizeShield");a&&(a.hidden=!1);try{t.setPointerCapture(i.pointerId)}catch{document.body.classList.remove("tab-rail-resizing"),a&&(a.hidden=!0),this._releaseTabRailResize()}}),t.addEventListener("pointermove",i=>{t.hasPointerCapture?.(i.pointerId)&&this._queueTabRailPointerWidth(i.clientX)}),t.addEventListener("pointerup",i=>this._finishTabRailDrag(t,i.pointerId)),t.addEventListener("pointercancel",i=>this._finishTabRailDrag(t,i.pointerId)),t.addEventListener("lostpointercapture",i=>this._finishTabRailDrag(t,i.pointerId)),t.addEventListener("keydown",i=>this._onTabRailKeyDown(i)),t.addEventListener("dblclick",i=>{i.preventDefault(),this._claimTabRailResize();const a=this._defaultTabRailWidth?.()??(window.CodemanTabRail?.DEFAULT_WIDTH||256),n=this._setTabRailWidth(a);this._scheduleTabRailSettle(n,a)});let e=null;window.addEventListener("resize",()=>{clearTimeout(e),e=setTimeout(()=>{this.applyTabOrientation?.(),this.applyTabRailWidth({persist:!1})},100)})},closeTabRailActionMenu(t={}){const e=document.querySelector(".tab-rail-action-menu:not(.tab-layout-group-action-menu)"),i=this._tabRailActionMenuTrigger;e?.remove(),this._tabRailActionMenuOutside&&(document.removeEventListener("pointerdown",this._tabRailActionMenuOutside,!0),this._tabRailActionMenuOutside=null),this._tabRailActionMenuViewport&&(window.removeEventListener("resize",this._tabRailActionMenuViewport),this._tabRailActionMenuViewport=null),this._tabRailActionMenuTrigger=null,t.restoreFocus&&i?.focus?.()},openTabRailActionMenu(t,e){t.preventDefault(),t.stopPropagation(),this.closeTabRailActionMenu();const i=t.currentTarget,a=document.createElement("div");a.className="tab-rail-action-menu",a.setAttribute("role","menu"),a.setAttribute("aria-label","Session actions");const n=this.loadAppSettingsFromStorage(),h=[{label:"Session options",run:()=>this.openSessionOptions(e)},...this._tabRefFocusActions?.({kind:"session",id:e})||[],...this._tabRefMoveActions?.({kind:"session",id:e})||[],...this._tileGrid?.has?.(e)&&this._tileDetachAllowed?.()?[{label:"Open in a new window",run:()=>this.detachTile(e)}]:(this.tabDetachButtonEnabled?.(n)??n.showTabDetachButton)||this.detachedSessions?.has(e)?[{label:"Open in a new window",run:()=>this.detachSession(e)}]:[],{label:"Close session",className:"danger",run:()=>this.requestCloseSession(e)}];for(const s of h){if(s.note){const r=document.createElement("div");r.className="tab-rail-action-menu-note",r.setAttribute("role","none"),r.id="tabRailActionMenuNote",r.textContent=s.label,a.setAttribute("aria-describedby",r.id),a.appendChild(r);continue}const l=document.createElement("button");l.type="button",l.setAttribute("role","menuitem"),l.textContent=s.label,s.className&&(l.className=s.className),l.addEventListener("click",()=>{this.closeTabRailActionMenu(),s.run()}),a.appendChild(l)}document.body.appendChild(a);const o=i.getBoundingClientRect(),d=a.getBoundingClientRect();a.style.left=`${Math.max(8,Math.min(o.right-d.width,window.innerWidth-d.width-8))}px`,a.style.top=`${Math.max(8,Math.min(o.bottom+4,window.innerHeight-d.height-8))}px`,this._tabRailActionMenuTrigger=i,this._tabRailActionMenuOutside=s=>{!a.contains(s.target)&&s.target!==i&&this.closeTabRailActionMenu()},document.addEventListener("pointerdown",this._tabRailActionMenuOutside,!0),this._tabRailActionMenuViewport=()=>this.closeTabRailActionMenu(),window.addEventListener("resize",this._tabRailActionMenuViewport,{once:!0}),a.addEventListener("keydown",s=>{const l=[...a.querySelectorAll("button")],r=l.indexOf(document.activeElement);if(s.key==="Escape")s.preventDefault(),this.closeTabRailActionMenu({restoreFocus:!0});else if(s.key==="ArrowDown"||s.key==="ArrowUp"){s.preventDefault();const c=s.key==="ArrowDown"?1:-1;l[(r+c+l.length)%l.length]?.focus()}}),a.querySelector("button")?.focus()}});
1
+ "use strict";Object.assign(CodemanApp.prototype,{_getTabRailMinimumTerminalWidth(){const t=this.terminal?._core?._renderService?.dimensions?.css?.cell?.width;return Number.isFinite(t)&&t>0?Math.ceil(t*40+24):420},_getTabRailBounds(){const t=document.querySelector(".main");return{viewportWidth:window.innerWidth,mainWidth:t?.clientWidth||window.innerWidth,minTerminalWidth:this._getTabRailMinimumTerminalWidth()}},_getCurrentTabRailWidth(){const t=Number.parseFloat(document.documentElement.style.getPropertyValue("--tab-rail-width"));if(Number.isFinite(t))return t;const e=document.getElementById("tabRail")?.getBoundingClientRect?.().width;return Number.isFinite(e)&&e>0?e:window.CodemanTabRail?.DEFAULT_WIDTH||256},readTabRailWidthSetting(){const t=document.getElementById("appSettingsTabRailWidth");return t?t.value==="custom"?Number(t.dataset.currentWidth)||this._getCurrentTabRailWidth():Number(t.value)||window.CodemanTabRail?.DEFAULT_WIDTH||256:this._getCurrentTabRailWidth()},syncTabRailWidthSetting(t){const e=document.getElementById("appSettingsTabRailWidth");if(!e)return;const i=Math.round(t);if(e.dataset.currentWidth=String(i),e.querySelector(`option[value="${i}"]`)){e.value=String(i);return}const n=e.querySelector('option[value="custom"]');n&&(n.textContent=`Custom (${i}px)`),e.value="custom"},_setTabRailWidth(t){const e=window.CodemanTabRail;if(!e)return 256;const i=e.resolveWidth({width:t}),a=this._getTabRailBounds(),n=e.resolveWidth({width:i,...a}),h=e.resolveWidth({width:e.MAX_WIDTH,...a}),o=document.documentElement;o.style.setProperty("--tab-rail-width",`${n}px`);const d=o.classList.contains("tab-rail-compact"),s=n<240;if(o.classList.toggle("tab-rail-compact",s),o.classList.toggle("tab-rail-tight",n<288),d!==s){const r=this._tallTabsEnabled;this.applyTabWrapSettings?.(),r!==void 0&&this._tallTabsEnabled!==r||this._fullRenderSessionTabs?.()}const l=document.getElementById("tabRailResizeHandle");return l&&(l.setAttribute("aria-valuemax",String(h)),l.setAttribute("aria-valuenow",String(n))),this.syncTabRailWidthSetting(i),n},_persistTabRailWidth(t){const e=this.loadAppSettingsFromStorage();e.tabRailWidth!==t&&(e.tabRailWidth=t,this.saveAppSettingsToStorage(e))},_claimTabRailResize(){this._tabRailResizeOwnsObserver=!0,clearTimeout(this._tabRailResizeWatchdog),clearTimeout(this._tabRailReleaseTimer),this._tabRailReleaseRaf&&cancelAnimationFrame(this._tabRailReleaseRaf),this._armTabRailResizeWatchdog(),this._resizeRaf&&cancelAnimationFrame(this._resizeRaf),this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeRaf=null,this._resizeTimeout=null},_armTabRailResizeWatchdog(){this._tabRailResizeWatchdog=setTimeout(()=>{if(this._tabRailResizeWatchdog=null,document.body.classList.contains("tab-rail-resizing")){this._armTabRailResizeWatchdog();return}this._tabRailResizeOwnsObserver=!1},1e3)},_releaseTabRailResize(){clearTimeout(this._tabRailResizeWatchdog),this._tabRailResizeWatchdog=null;const t=()=>{clearTimeout(this._tabRailReleaseTimer),this._tabRailReleaseTimer=null,this._tabRailReleaseRaf=null,this._tabRailResizeOwnsObserver=!1};typeof requestAnimationFrame=="function"?(this._tabRailReleaseRaf=requestAnimationFrame(()=>{this._tabRailReleaseRaf=requestAnimationFrame(t)}),this._tabRailReleaseTimer=setTimeout(t,250)):t()},_scheduleTabRailSettle(t,e=t){clearTimeout(this._tabRailSettleTimer),this._tabRailSettleTimer=setTimeout(async()=>{this._tabRailSettleTimer=null,this._persistTabRailWidth(e);try{this.activeSessionId&&this.sendResize?await this.sendResize(this.activeSessionId):this.syncTerminalGeometry?.(),this._updateConnectionLinesImmediate?.()}catch(i){console.warn("Failed to resize terminal after rail resize:",i)}finally{this._releaseTabRailResize()}},150)},_defaultTabRailWidth(){return document.documentElement.dataset.tabRailDetail!=="simple"?window.CodemanTabRail?.RICH_DEFAULT_WIDTH??320:window.CodemanTabRail?.DEFAULT_WIDTH??256},applyTabRailWidth(t={}){const i=this.loadAppSettingsFromStorage().tabRailWidth??this._defaultTabRailWidth(),a=window.CodemanTabRail?.resolveWidth({width:i})??256;t.settle&&this._claimTabRailResize();const n=this._setTabRailWidth(a);return t.persist!==!1&&i!==a&&this._persistTabRailWidth(a),t.settle&&this._scheduleTabRailSettle(n,a),n},_applyTabRailPointerWidth(t){const e=document.querySelector(".main");if(!e)return this._getCurrentTabRailWidth();const i=this._getCurrentTabRailWidth(),a=this._setTabRailWidth(t-e.getBoundingClientRect().left);let n=null;try{n=this.fitAddon?.proposeDimensions?.()}catch{}return n&&n.cols<40?this._setTabRailWidth(i):a},_queueTabRailPointerWidth(t){this._tabRailPendingClientX=t,!this._tabRailPointerRaf&&(this._tabRailPointerRaf=requestAnimationFrame(()=>{this._tabRailPointerRaf=null,this._tabRailDragWidth=this._applyTabRailPointerWidth(this._tabRailPendingClientX)}))},_finishTabRailDrag(t,e){if(!document.body.classList.contains("tab-rail-resizing"))return;this._tabRailPointerRaf&&(cancelAnimationFrame(this._tabRailPointerRaf),this._tabRailPointerRaf=null,this._tabRailDragWidth=this._applyTabRailPointerWidth(this._tabRailPendingClientX)),document.body.classList.remove("tab-rail-resizing");const i=document.getElementById("tabRailResizeShield");i&&(i.hidden=!0);try{t.hasPointerCapture?.(e)&&t.releasePointerCapture(e)}catch{}const a=window.CodemanTabRail?.resolveWidth({width:this._tabRailDragWidth})??this._tabRailDragWidth;this._scheduleTabRailSettle(this._tabRailDragWidth||this._getCurrentTabRailWidth(),a)},_onTabRailKeyDown(t){const e=window.CodemanTabRail?.resolveKeyboardWidth({key:t.key,shiftKey:t.shiftKey,currentWidth:this._getCurrentTabRailWidth(),defaultWidth:this._defaultTabRailWidth?.(),...this._getTabRailBounds()});if(e==null)return;t.preventDefault(),this._claimTabRailResize();const i=this._setTabRailWidth(e);this._scheduleTabRailSettle(i,window.CodemanTabRail.resolveWidth({width:e}))},initTabRailResize(){const t=document.getElementById("tabRailResizeHandle");if(!t||t.dataset.ready==="1")return;t.dataset.ready="1",this.applyTabRailWidth(),t.addEventListener("pointerdown",i=>{if(i.button!==0)return;i.preventDefault(),this.closeTabRailActionMenu(),this._claimTabRailResize(),this._tabRailDragWidth=this._getCurrentTabRailWidth(),this._tabRailPendingClientX=i.clientX,document.body.classList.add("tab-rail-resizing");const a=document.getElementById("tabRailResizeShield");a&&(a.hidden=!1);try{t.setPointerCapture(i.pointerId)}catch{document.body.classList.remove("tab-rail-resizing"),a&&(a.hidden=!0),this._releaseTabRailResize()}}),t.addEventListener("pointermove",i=>{t.hasPointerCapture?.(i.pointerId)&&this._queueTabRailPointerWidth(i.clientX)}),t.addEventListener("pointerup",i=>this._finishTabRailDrag(t,i.pointerId)),t.addEventListener("pointercancel",i=>this._finishTabRailDrag(t,i.pointerId)),t.addEventListener("lostpointercapture",i=>this._finishTabRailDrag(t,i.pointerId)),t.addEventListener("keydown",i=>this._onTabRailKeyDown(i)),t.addEventListener("dblclick",i=>{i.preventDefault(),this._claimTabRailResize();const a=this._defaultTabRailWidth?.()??(window.CodemanTabRail?.DEFAULT_WIDTH||256),n=this._setTabRailWidth(a);this._scheduleTabRailSettle(n,a)});let e=null;window.addEventListener("resize",()=>{clearTimeout(e),e=setTimeout(()=>{this.applyTabOrientation?.(),this.applyTabRailWidth({persist:!1})},100)})},closeTabRailActionMenu(t={}){const e=document.querySelector(".tab-rail-action-menu:not(.tab-layout-group-action-menu)"),i=this._tabRailActionMenuTrigger;e?.remove(),this._tabRailActionMenuOutside&&(document.removeEventListener("pointerdown",this._tabRailActionMenuOutside,!0),this._tabRailActionMenuOutside=null),this._tabRailActionMenuViewport&&(window.removeEventListener("resize",this._tabRailActionMenuViewport),this._tabRailActionMenuViewport=null),this._tabRailActionMenuTrigger=null,t.restoreFocus&&i?.focus?.()},openTabRailActionMenu(t,e){t.preventDefault(),t.stopPropagation(),this.closeTabRailActionMenu(),this.closeTabGroupMenu?.();const i=t.currentTarget,a=document.createElement("div");a.className="tab-rail-action-menu",a.setAttribute("role","menu"),a.setAttribute("aria-label","Session actions");const n=this.loadAppSettingsFromStorage(),h=[{label:"Session options",run:()=>this.openSessionOptions(e)},...document.documentElement.classList.contains("tabs-show-new")&&i.closest(".session-tab")?[{label:"New session here\u2026",run:()=>this.openTabNewSessionMenu({currentTarget:i},e)}]:[],...this._tabRefFocusActions?.({kind:"session",id:e})||[],...this._tabRefMoveActions?.({kind:"session",id:e})||[],...this._tileGrid?.has?.(e)&&this._tileDetachAllowed?.()?[{label:"Open in a new window",run:()=>this.detachTile(e)}]:(this.tabDetachButtonEnabled?.(n)??n.showTabDetachButton)||this.detachedSessions?.has(e)?[{label:"Open in a new window",run:()=>this.detachSession(e)}]:[],{label:"Close session",className:"danger",run:()=>this.requestCloseSession(e)}];for(const s of h){if(s.note){const r=document.createElement("div");r.className="tab-rail-action-menu-note",r.setAttribute("role","none"),r.id="tabRailActionMenuNote",r.textContent=s.label,a.setAttribute("aria-describedby",r.id),a.appendChild(r);continue}const l=document.createElement("button");l.type="button",l.setAttribute("role","menuitem"),l.textContent=s.label,s.className&&(l.className=s.className),l.addEventListener("click",()=>{this.closeTabRailActionMenu(),s.run()}),a.appendChild(l)}document.body.appendChild(a);const o=i.getBoundingClientRect(),d=a.getBoundingClientRect();a.style.left=`${Math.max(8,Math.min(o.right-d.width,window.innerWidth-d.width-8))}px`,a.style.top=`${Math.max(8,Math.min(o.bottom+4,window.innerHeight-d.height-8))}px`,this._tabRailActionMenuTrigger=i,this._tabRailActionMenuOutside=s=>{!a.contains(s.target)&&s.target!==i&&this.closeTabRailActionMenu()},document.addEventListener("pointerdown",this._tabRailActionMenuOutside,!0),this._tabRailActionMenuViewport=()=>this.closeTabRailActionMenu(),window.addEventListener("resize",this._tabRailActionMenuViewport,{once:!0}),a.addEventListener("keydown",s=>{const l=[...a.querySelectorAll("button")],r=l.indexOf(document.activeElement);if(s.key==="Escape")s.preventDefault(),this.closeTabRailActionMenu({restoreFocus:!0});else if(s.key==="ArrowDown"||s.key==="ArrowUp"){s.preventDefault();const c=s.key==="ArrowDown"?1:-1;l[(r+c+l.length)%l.length]?.focus()}}),a.querySelector("button")?.focus()}});
@@ -244,6 +244,8 @@
244
244
  scrollback: this.scrollback ?? DEFAULT_SCROLLBACK,
245
245
  allowTransparency: true,
246
246
  allowProposedApi: true,
247
+ // OSC 8 hyperlinks open through the primary pane's opener (terminal-ui.js).
248
+ linkHandler: global.app?._terminalOsc8LinkHandler?.(),
247
249
  });
248
250
 
249
251
  this.fitAddon = new FitAddon.FitAddon();
@@ -1173,9 +1175,13 @@
1173
1175
  // pages the CLI's own transcript with PageUp/PageDown. Every gate is the
1174
1176
  // primary pane's own, asked for THIS pane (its terminal, its session, never
1175
1177
  // the active one), so the CLI rules stay in terminal-ui.js and this file
1176
- // names no CLI. The gesture rules (first-event page, notch accumulation,
1178
+ // names no CLI. The gesture rules (first-event page, notch debt,
1177
1179
  // pinch and sideways-swipe consume) are the shared pure
1178
1180
  // CodemanTerminalInput.pageKeysForGesture, run on this tile's own state.
1181
+ // The primary pane's unloaded-scrollback fall-through (`paneHistoryLines`
1182
+ // > 0 with baseY 0, after a restart's tail replay) has no twin here: a tile
1183
+ // loads tmux's rendered history (`full=1`), so it does not share that
1184
+ // tail-select failure, and its non-shell wheel has no pull to fall through to.
1179
1185
  // Returns true when the wheel was consumed here.
1180
1186
  _maybePageCliTranscript(ev) {
1181
1187
  if (this._destroyed || !this.terminal || !ev || ev.shiftKey) return false;
@@ -1209,6 +1215,9 @@
1209
1215
  // session, which is usually not the active one: a page key would move its
1210
1216
  // selector. Consumed, so xterm does not scroll the rows under it either.
1211
1217
  if (app.tabAlerts?.get(this.sessionId) === 'action') return true;
1218
+ // A Codex selection menu is not an alert, but PageUp/PageDown move its selection (see
1219
+ // CodemanTerminalInput.isCodexSelectionMenu), so it consumes the wheel the same way.
1220
+ if (app._codexMenuOpen?.({ terminal: this.terminal, sessionId: this.sessionId })) return true;
1212
1221
  if (ev.ctrlKey || Math.abs(ev.deltaX || 0) > Math.abs(ev.deltaY || 0)) return true;
1213
1222
  if (this._pageKeyGesture?.dir && this._pageKeyGesture.dir !== Math.sign(lines)) this._scrollBytes = '';
1214
1223
  const step = input.pageKeysForGesture(this._pageKeyGesture, ev, lines, this.terminal.rows, performance.now());
Binary file
Binary file
@@ -0,0 +1,4 @@
1
+ "use strict";(function(e){const t=/^\x1b\[[\?>=]?[\d;]*[cnR]$/,i=/^\x1b\][\d;]*[^\x07\x1b]*(?:\x07|\x1b\\)$/,s=/^\x1b\[<\d+;\d+;\d+[Mm]$/,n=/^\x1b\[M[\s\S]{3}$/,o=/^\x1b\[[IO]$/,d=["input","textarea","select","button","a[href]",'[contenteditable=""]','[contenteditable="true"]','[tabindex]:not([tabindex="-1"])','[role="treeitem"]',".keyboard-accessory-bar",".path-picker-overlay"].join(","),y=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b\[[0-9;?<>=!]*[ -/]*[@-~]|\x1b[()#][0-9A-Za-z]|\x1b[=>78M]/g,p="\x1B[5~",u="\x1B[6~",T=.5,r=3,m=150,_=.1,I=2,E=3e3,w=1e3;function k(S,C){const M=S.shiftKey&&Math.abs(S.deltaX)>Math.abs(S.deltaY)?S.deltaX:S.deltaY;return M?S.deltaMode===1?M:S.deltaMode===2?M*(C||24):M/25:0}const R=5;function O(S,C){if(!S||!C)return"";const M=S<0?64:65,N=Math.min(Math.abs(S),R);return`\x1B[<${M};${C.col};${C.row}M`.repeat(N)}function A(S,C,M){if(!Number.isFinite(C)||!C)return{state:S||{},ticks:0};const N=Math.sign(C),K=!S||typeof S.lastAt!="number"||M-S.lastAt>m,W=S?.dir&&S.dir!==N;if(K&&Math.abs(C)>=_){const J=N*Math.max(1,Math.round(Math.abs(C)));return{state:{dir:N,lastAt:M,pending:C-J},ticks:N*Math.min(Math.abs(J),R)}}const z=(K||W?0:S.pending||0)+C,j=Math.trunc(z+Math.sign(z)*1e-9);return{state:{dir:N,lastAt:M,pending:Math.abs(z-j)<1e-9?0:z-j},ticks:j===0?0:Math.sign(j)*Math.min(Math.abs(j),R)}}function H(S,C){const M=j=>j?.match(/\x1b\[<(64|65);|\x1b\[(5|6)~/)?.[0],N=M(S),K=M(C);return((N&&N===K?S+C:C).match(/\x1b\[<(?:64|65);\d+;\d+M|\x1b\[[56]~/g)||[]).join("")}function g(S){return Math.max(2,Math.round((S||24)*T))}function x(S,C,M){const N=g(M),K=(S||0)+C,W=Math.trunc(K/N),z=W?(W<0?p:u).repeat(Math.min(Math.abs(W),r)):"";return{pending:K-W*N,keys:z}}function v(S,C,M,N,K){const W=S||{};if(C?.ctrlKey)return{state:W,keys:""};const z=Math.abs(C?.deltaX||0),j=Math.abs(C?.deltaY||0);if(z&&j&&z>j)return{state:W,keys:""};const J=g(N),q=M<0?-1:1,ne=typeof C?.touchId=="number"?C.touchId:null,fe=typeof W.touchId=="number"?W.touchId:null;let oe=W.pending||0,X=!!W.prepaid;const he=q!==W.dir;let Z;if(typeof W.lastAt!="number"||ne!==fe)Z=!0;else if(ne!==null)Z=!1;else{const ee=K-W.lastAt,re=W.notch?E:w;Z=ee>(X&&!he?re:m)}if((Z||he)&&(X&&(oe=0),X=!1),Z){const ee=Math.abs(M),re=oe*q>0?oe:0;if(ee>=_&&ee<J&&(re+M)*q<J)return{state:{pending:re+M-q*J,lastAt:K,dir:q,prepaid:!0,notch:ee>=I,touchId:ne},keys:q<0?p:u}}const ae=x(oe,M,N);return X&&ae.pending*q>=0&&(X=!1),{state:{pending:ae.pending,lastAt:K,dir:q,prepaid:X,notch:X&&!!W.notch,touchId:ne},keys:ae.keys}}const L=4,b=/^\x1b(?:\[(?:[ABCDHF]|1;[2-8][ABCDHF]|[1-8](?:;[2-8])?~)|O[ABCDHF])$/,B="\x1B[200~";function D(S){return b.test(S)}const G=/^› /;function U(S){const C=Array.from(S);if(C.length===1){const M=C[0].codePointAt(0);return M===127?"backspace":M>=32?"char":"clear"}return S.charCodeAt(0)===27?"clear":S.charCodeAt(0)>=32?"text":"clear"}function V(S){try{const C=S.buffer.active,M=C.getLine(C.baseY+C.cursorY);return!!M&&G.test(M.translateToString(!0))}catch{return!1}}const P=/^ {0,2}› (?:\d+\. |Add notes)/,F=/^ {2}[a-z←|]/,Y=/^ {1,4}(?:Press enter to confirm|enter (?:select|continue)|tab (?:to add|or esc to clear) notes)/;function te(S){try{const C=S.buffer.active,M=[];for(let K=C.baseY+S.rows-1;K>=C.baseY;K--){const W=C.getLine(K)?.translateToString(!0)??"";W.trim()&&M.push(W)}let N=0;for(;N<M.length&&!Y.test(M[N]);){if(!F.test(M[N]))return!1;N++}return N<M.length&&M.slice(N+1).some(K=>P.test(K))}catch{return!1}}function ie(S){try{const C=S.buffer.active,M=C.baseY+(C.cursorY||0)-C.viewportY;return M>=0&&M<S.rows?M:null}catch{return null}}function $(S){return t.test(S)||i.test(S)}function Q(S){return $(S)}function se(S){return o.test(S)||s.test(S)||n.test(S)}const le={og:{background:"#0d0d0d",foreground:"#e0e0e0",cursor:"#e0e0e0",cursorAccent:"#0d0d0d",selectionBackground:"rgba(255,255,255,0.3)",black:"#0d0d0d",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#339af0",magenta:"#cc5de8",cyan:"#22b8cf",white:"#e0e0e0",brightBlack:"#495057",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#5c7cfa",brightMagenta:"#da77f2",brightCyan:"#66d9e8",brightWhite:"#ffffff"},"daylight-green":{background:"#161b23",foreground:"#dfe6ef",cursor:"#2fd3aa",cursorAccent:"#161b23",selectionBackground:"rgba(47,211,170,0.22)",black:"#161b23",red:"#ff8585",green:"#34d8a0",yellow:"#f0c25a",blue:"#5cc6e8",magenta:"#c79af2",cyan:"#2bcbbb",white:"#dfe6ef",brightBlack:"#5b6675",brightRed:"#ffa0a0",brightGreen:"#5fe6b8",brightYellow:"#ffd884",brightBlue:"#82d4ee",brightMagenta:"#d6b3f7",brightCyan:"#5ee0d4",brightWhite:"#f3f6fa"},"daylight-blue":{background:"#161b23",foreground:"#dfe6ef",cursor:"#38b6f0",cursorAccent:"#161b23",selectionBackground:"rgba(56,182,240,0.22)",black:"#161b23",red:"#ff8585",green:"#34d8a0",yellow:"#f0c25a",blue:"#5cc6e8",magenta:"#c79af2",cyan:"#2bcbbb",white:"#dfe6ef",brightBlack:"#5b6675",brightRed:"#ffa0a0",brightGreen:"#5fe6b8",brightYellow:"#ffd884",brightBlue:"#82d4ee",brightMagenta:"#d6b3f7",brightCyan:"#5ee0d4",brightWhite:"#f3f6fa"},"paper-gray":{background:"#f6f8fa",foreground:"#1f2328",cursor:"#0969da",cursorAccent:"#ffffff",selectionBackground:"rgba(9,105,218,0.2)",black:"#24292f",red:"#cf222e",green:"#1a7f37",yellow:"#9a6700",blue:"#0969da",magenta:"#8250df",cyan:"#1b7c83",white:"#59636e",brightBlack:"#6e7781",brightRed:"#a40e26",brightGreen:"#116329",brightYellow:"#7d4e00",brightBlue:"#0550ae",brightMagenta:"#6639ba",brightCyan:"#116b75",brightWhite:"#1f2328"},"solarized-light":{background:"#fdf6e3",foreground:"#586e75",cursor:"#147ba3",cursorAccent:"#fdf6e3",selectionBackground:"rgba(38,139,210,0.2)",black:"#eee8d5",red:"#dc322f",green:"#758600",yellow:"#9b7800",blue:"#147ba3",magenta:"#d33682",cyan:"#2a9189",white:"#073642",brightBlack:"#93a1a1",brightRed:"#cb4b16",brightGreen:"#657b83",brightYellow:"#586e75",brightBlue:"#268bd2",brightMagenta:"#6c71c4",brightCyan:"#2aa198",brightWhite:"#002b36"},"catppuccin-latte":{background:"#eff1f5",foreground:"#4c4f69",cursor:"#1e66f5",cursorAccent:"#ffffff",selectionBackground:"rgba(30,102,245,0.18)",black:"#5c5f77",red:"#d20f39",green:"#3b8f2b",yellow:"#a86605",blue:"#1e66f5",magenta:"#8839ef",cyan:"#177f86",white:"#6c6f85",brightBlack:"#7c7f93",brightRed:"#b50930",brightGreen:"#2f7622",brightYellow:"#8b5604",brightBlue:"#174fbf",brightMagenta:"#6f2bc5",brightCyan:"#116b71",brightWhite:"#4c4f69"},"rose-pine-dawn":{background:"#faf4ed",foreground:"#575279",cursor:"#286983",cursorAccent:"#fffaf3",selectionBackground:"rgba(40,105,131,0.2)",black:"#575279",red:"#b4637a",green:"#286983",yellow:"#96681f",blue:"#477f91",magenta:"#907aa9",cyan:"#3f7f8b",white:"#6e6a86",brightBlack:"#797593",brightRed:"#984d66",brightGreen:"#1f5266",brightYellow:"#7d5417",brightBlue:"#386b7c",brightMagenta:"#765f90",brightCyan:"#326b76",brightWhite:"#575279"}},de=new Set(["paper-gray","solarized-light","catppuccin-latte","rose-pine-dawn"]);function ce(){return typeof document<"u"&&document.documentElement.dataset.skin||"daylight-blue"}function ue(){const S=ce();return le[S]||le["daylight-blue"]}function me(S=ce()){return de.has(S)}e.CodemanTerminalInput={isTerminalQueryResponse:$,shouldSuppressTerminalQueryResponse:Q,isTerminalFocusOrMouseReport:se,isComposerNavKey:D,classifyPredictInput:U,isCodexComposerRow:V,isCodexSelectionMenu:te,cursorViewportRow:ie,CODEX_COMPOSER_ROW_RE:G,BRACKETED_PASTE_START:B,USER_SCROLL_STICKY_SUPPRESS_MS:1500,TOUCH_COMPAT_MOUSE_SUPPRESS_MS:450,REPLAY_ESCAPE_RE:y,KEY_PAGE_UP:p,KEY_PAGE_DOWN:u,PAGE_KEY_SCREEN_FRACTION:T,PAGE_KEY_MAX_PER_BATCH:r,wheelDeltaLines:k,SGR_WHEEL_MAX_TICKS:R,sgrWheelReports:O,wheelTicksForGesture:A,coalesceScrollBytes:H,pageKeysForTravel:x,pageKeysForGesture:v,PAGE_KEY_GESTURE_GAP_MS:m,PAGE_KEY_MIN_START_ROWS:_,PAGE_KEY_IMMEDIATE_MAX_ROWS:I,PAGE_KEY_DEBT_MS:w,PAGE_KEY_NOTCH_DEBT_MS:E,TUI_PROMPT_DEFAULT_ROWS_FROM_BOTTOM:L,MOBILE_KEYBOARD_DISMISS_EXEMPT_SELECTOR:d,MOBILE_KEYBOARD_DISMISS_TAP_SLOP:8,TOUCH_SELECT_LONG_PRESS_MS:350,TOUCH_SELECT_FOCUS_GUARD_MS:800},e.CODEMAN_XTERM_THEMES=le,e.codemanCurrentXtermTheme=ue,e.codemanCurrentSkinIsLight=me})(window),Object.assign(CodemanApp.prototype,{_destroyKeyCode229Recovery(){try{this._keyCode229Recovery?.destroy?.()}catch{}this._keyCode229Recovery=null},_destroyMobileImePreview(){try{this._mobileImePreview?.destroy?.()}catch{}this._mobileImePreview=null,this._mobileImePreviewSessionId=null,this._mobileImeCommitOutputSeq=null;try{this._mobileImePreviewNode?.remove?.()}catch{}try{this._mobileImePreviewHelpers?.classList?.remove("codeman-ime-preview-owned")}catch{}this._mobileImePreviewNode=null,this._mobileImePreviewHelpers=null;try{this._mobileImePreviewOfflineHandler&&window.removeEventListener("offline",this._mobileImePreviewOfflineHandler),this._mobileImePreviewPagehideHandler&&window.removeEventListener("pagehide",this._mobileImePreviewPagehideHandler)}catch{}this._mobileImePreviewOfflineHandler=null,this._mobileImePreviewPagehideHandler=null},_initMobileImePreview(){this._destroyMobileImePreview();let e=null,t=null;try{if(typeof MobileImePreview>"u"||!MobileImePreview?.isIosWebKitTouch?.())return;const i=this.terminal?.textarea;if(t=this.terminal?.element?.querySelector?.(".xterm-helpers"),!i||!t)return;e=document.createElement("span"),this._mobileImePreviewNode=e,this._mobileImePreviewHelpers=t,e.className="codeman-ime-preview",e.setAttribute("aria-hidden","true"),e.hidden=!0,t.appendChild(e);const s=()=>{try{const h=t.querySelector?.(".composition-view")||this.terminal?.element?.querySelector?.(".composition-view");if(!h||!e.style)return;const f=typeof getComputedStyle=="function"?getComputedStyle(h):h.style;for(const u of["fontFamily","fontSize","fontWeight","fontStyle","lineHeight","height"]){const T=f?.[u]||h.style?.[u];T&&(e.style[u]=T)}const d=this.terminal?.options?.theme;let y=d?.foreground,p=d?.background;if(!y||!p)try{const u=window.codemanCurrentXtermTheme?.();y=y||u?.foreground,p=p||u?.background}catch{}e.style.color=y||"#e0e0e0",e.style.backgroundColor=p||"#0d0d0d"}catch{}},n=()=>this._localEchoEnabled&&!this._echoPassthroughSessions?.has(this.activeSessionId)&&this._localEchoOverlay||null,o=()=>{try{this._localEchoOverlay?.composition&&this._localEchoOverlay.setComposition("")}catch{}},l=()=>{try{e.hidden=!0}catch{}try{e.textContent=""}catch{}try{delete e.dataset.phase}catch{}try{t.classList.remove("codeman-ime-preview-owned")}catch{}},a=()=>{o(),l()},c=MobileImePreview.create({textarea:i,keydownTarget:this.terminal.element,render:({text:h,phase:f})=>{try{const d=n();if(d&&typeof d.setComposition=="function"){if(d.setComposition(h),!h||d.state?.visible){l(),t.classList.toggle("codeman-ime-preview-owned",!!h);return}d.setComposition("")}else o();s(),e.textContent=h,e.dataset.phase=f,e.hidden=!h,t.classList.toggle("codeman-ime-preview-owned",!!h)}catch{a()}},clear:a});this._mobileImePreview=c,this._mobileImePreviewSessionId=this.activeSessionId,this._mobileImePreviewOfflineHandler=()=>{try{this._mobileImePreview?.reset?.()}catch{}},this._mobileImePreviewPagehideHandler=this._mobileImePreviewOfflineHandler,window.addEventListener("offline",this._mobileImePreviewOfflineHandler),window.addEventListener("pagehide",this._mobileImePreviewPagehideHandler)}catch{this._destroyMobileImePreview()}},_consumeMobileImeTerminalData(e){let t=!1;try{t=this._mobileImePreview?.consumeTerminalData?.(e)===!0}catch{}return t&&(this._mobileImeCommitOutputSeq=this._terminalOutputSeq||0),t},_noteMobileImeAuthoritativeOutput(e,t){try{const i=this._mobileImeCommitOutputSeq;if(i==null||e===null||t!==this.activeSessionId||!(e>i))return;this._mobileImeCommitOutputSeq=null,this._mobileImePreview?.noteAuthoritativeOutput?.()}catch{}},_transferMobileImeCommitToLocalEcho(){this._mobileImeCommitOutputSeq=null;try{this._mobileImePreview?.completeCommit?.({predicted:!0})}catch{}},initTerminal(){const e=parseInt(localStorage.getItem("codeman-scrollback")),t=Number.isFinite(e)&&e>0?Math.max(e,DEFAULT_SCROLLBACK):DEFAULT_SCROLLBACK;this._destroyKeyCode229Recovery();const i=this.loadAppSettingsFromStorage?.()||{};if(this.terminal=new Terminal({theme:{...window.codemanCurrentXtermTheme()},fontFamily:window.CodemanTerminalFont.resolve(i.terminalFontFamily),...window.CodemanTerminalFont.resolveWeights(i),fontSize:MobileDetection.getDeviceType()==="mobile"?10:14,lineHeight:1.2,cursorBlink:!1,cursorStyle:"block",minimumContrastRatio:window.codemanCurrentSkinIsLight()?4.5:1,scrollback:t,allowTransparency:!0,allowProposedApi:!0,linkHandler:this._terminalOsc8LinkHandler()}),this.fitAddon=new FitAddon.FitAddon,this.terminal.loadAddon(this.fitAddon),this._xtermSnapshots=new Map,typeof SerializeAddon<"u")try{this._serializeAddon=new SerializeAddon.SerializeAddon,this.terminal.loadAddon(this._serializeAddon)}catch{this._serializeAddon=null}if(typeof Unicode11Addon<"u")try{const r=new Unicode11Addon.Unicode11Addon;this.terminal.loadAddon(r),this.terminal.unicode.activeVersion="11"}catch{}this._installOsc52Clipboard(this.terminal);const s=document.getElementById("terminalContainer");this.terminal.open(s),this._initMobileImePreview(),this._installMobileTapMouseGuard(),this._installShiftDragSelection(),this._installTouchSelectionFocusGuard(),this.terminal.textarea?.addEventListener("focus",()=>this._noteFocusedTile(null)),this.terminal.attachCustomKeyEventHandler(r=>{try{this._keyCode229Recovery?.handleKeyEvent?.(r)}catch{}if(r.isComposing||r.key==="Process"||r.keyCode===229)return!0;if(r.altKey&&!r.ctrlKey&&!r.shiftKey&&/^(Digit[1-9]|BracketLeft|BracketRight|KeyK)$/.test(r.code||"")||r.type==="keydown"&&this.isUserBoundShortcutEvent?.(r)||r.type==="keydown"&&this.shouldOpenCommandPaletteFromShortcut?.(r)||this.tileShortcutFor?.(r))return!1;if(this.shouldCopyTerminalSelectionFromShortcut?.(r)){const m=this.terminal?.hasSelection?.()?this.terminal.getSelection():"";return this.cleanedTerminalSelection(m).trim()?(r.preventDefault(),this.copyTerminalSelection(m),!1):(this.terminal?.hasSelection?.()&&(this.terminal.clearSelection?.(),this.showToast("Nothing to copy","warning")),r.shiftKey?(r.preventDefault(),!1):!0)}if(r.type==="keydown"&&this.shouldToggleSessionSidebarFromShortcut?.(r))return!1;if((r.ctrlKey||r.metaKey)&&r.key==="v"&&r.type==="keydown")return this.activeSessionId&&this._handleImagePaste&&this._handleImagePaste(),!1;if(r.type==="keydown"&&r.key.toLowerCase()==="z"&&r.ctrlKey&&!r.altKey&&!r.metaKey&&!r.shiftKey){const m=this.activeSessionId?this.sessions.get(this.activeSessionId):null;if(m&&m.mode!=="shell")return r.preventDefault(),!1}if(r.key==="Enter"&&(r.shiftKey||r.ctrlKey)){if(r.type==="keydown"&&this.activeSessionId)if(this._localEchoEnabled){const m=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),m&&(this._pendingInput+=m,u()),setTimeout(()=>{fetch(`/api/sessions/${this.activeSessionId}/send-key`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:r.ctrlKey?"C-Enter":"S-Enter"})})},m?80:0)}else fetch(`/api/sessions/${this.activeSessionId}/send-key`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:r.ctrlKey?"C-Enter":"S-Enter"})});return!1}return!0}),this._webglAddon=null;const n=new URLSearchParams(location.search),o=(()=>{try{const r=localStorage.getItem("codeman-webgl-disabled");if(!r)return!1;const{at:m}=JSON.parse(r);return Date.now()-m>WEBGL_FALLBACK.STICKY_EXPIRY_MS?(localStorage.removeItem("codeman-webgl-disabled"),!1):!0}catch{return!1}})(),l=this.loadAppSettingsFromStorage(),a=this.getDefaultSettings(),c=l.webglRendererEnabled??a.webglRendererEnabled,{skip:h,clearSticky:f}=shouldSkipWebGL({deviceType:MobileDetection.getDeviceType(),noWebglParam:n.has("nowebgl"),forceParam:n.get("webgl")==="force",stickyDisabled:o,userPrefEnabled:c});if(f)try{localStorage.removeItem("codeman-webgl-disabled")}catch{}if(h&&o&&console.log("[CRASH-DIAG] WebGL sticky-disabled from prior stalls \u2014 DOM renderer in use. Re-enable: ?webgl=force"),!h)if(typeof WebglAddon<"u")this._initWebGL();else{const r=document.createElement("script");r.src="vendor/xterm-addon-webgl.min.js",r.onload=()=>this._initWebGL(),r.onerror=()=>console.warn("[CRASH-DIAG] Failed to load WebGL addon \u2014 using canvas renderer"),document.head.appendChild(r)}this._localEchoOverlay=new LocalEchoOverlay(this.terminal),this._predictiveEcho=typeof PredictiveEchoOverlay<"u"?new PredictiveEchoOverlay(this.terminal):null,this._predictiveEcho?.setPredictWhen(r=>window.CodemanTerminalInput.isCodexComposerRow(r)),MobileDetection.isTouchDevice()&&(this.terminal.onCursorMove(()=>this._syncMobileHelperTextareaToCursor()),this.terminal.onRender(()=>this._syncMobileHelperTextareaToCursor()),this.terminal.onCursorMove(()=>this._applyKeyboardClip()),this.terminal.onRender(()=>this._applyKeyboardClip())),this.terminal.onRender(()=>{this._lastRenderAt=Date.now()}),this._startRenderLivenessWatchdog(),this._cjkInput=null,typeof CjkInput<"u"&&(this._cjkInput=CjkInput.init({send:r=>{this._handleCjkInput(r)}}));const d=this.terminal.focus.bind(this.terminal);this.terminal.focus=()=>{const r=document.getElementById("cjkInput");r?.classList.contains("cjk-input-visible")?r.focus():d()},MobileDetection.getDeviceType()==="mobile"&&document.body.classList.contains("safari-browser")?requestAnimationFrame(()=>{this.syncTerminalGeometry(),requestAnimationFrame(()=>this.syncTerminalGeometry())}):this.syncTerminalGeometry(),this._terminalFontReady=this._awaitTerminalFont(),this.registerFilePathLinkProvider(),this.terminal.onSelectionChange?.(()=>{if(!this.terminal?.hasSelection?.()){this._touchSelecting=!1,this._touchSelectionActive=!1,this._touchSelectionAnchor=null,this._hideTouchSelectionBar(),this._autoCopyPending=!1;return}this._autoCopyPending=!0}),this._autoCopyListenerInstalled||(this._autoCopyListenerInstalled=!0,document.addEventListener("mouseup",()=>this._flushAutoCopySelection())),s.addEventListener("wheel",r=>{const m=this.terminal?.modes?.mouseTrackingMode;if(m&&m!=="none"||this.terminal?.buffer?.active?.type==="alternate")return;if(r.preventDefault(),r.stopPropagation(),this._shouldForwardWheelToApp(r)){if(r.ctrlKey||Math.abs(r.deltaX||0)>Math.abs(r.deltaY||0))return;this._logScrollRouting("forward-sgr"),this._forwardScrollToApp(r.clientX,r.clientY,this._wheelScrollLinesFloat(r));return}const _=this._wheelScrollLinesFloat(r);this._maybePageCliTranscript(r,_)||(this._logScrollRouting("local-scrollback"),this._noteTerminalUserScroll(_),this._smoothScrollBy(_))},{passive:!1,capture:!0});{const r=()=>this.terminal._core?._renderService?.dimensions?.css?.cell?.height||13;let m=0,_=0,I=0,E=0,w=null,k=!1,R=0;const O=P=>{const F=E?(P-E)/16.67:1;if(E=P,!k&&Math.abs(I)>.3){const Y=Math.round(I/r());Y!==0&&(this._shouldForwardTouchToApp()?this._forwardScrollToApp(m,_,Y):this._maybePageCliTranscript({shiftKey:!1,touchId:R},Y)||(this.terminal.scrollLines(Y),this._maybeLoadMoreHistoryOnScroll(Y))),I*=.92,w=requestAnimationFrame(O)}else k?w=requestAnimationFrame(O):(w=null,I=0)};let A=0,H=!1,g=null,x=0,v=0,L=0,b=0,B=null;const D=()=>s.classList.contains("term-overflows-x")&&s.scrollWidth-s.clientWidth>1;let G=!1,U=null;const V=window.CodemanTerminalInput.MOBILE_KEYBOARD_DISMISS_TAP_SLOP;s.addEventListener("touchstart",P=>{if(!P.target?.closest?.(".term-select-bar")&&(P.touches.length!==1&&(clearTimeout(g),g=null),P.touches.length===1)){m=P.touches[0].clientX,_=P.touches[0].clientY,L=_,b=m,B=null,this._terminalGestureAxis=null,I=0,A=0,k=!0,R++,H=!1,G=this._isMobileTerminalInputFocused();const F=this._classifyMobileTerminalTap(m,_);U={x:m,y:_,intent:F},F==="content"&&(P.preventDefault(),this._blurMobileTerminalInput()),x=m,v=_,clearTimeout(g),g=setTimeout(()=>{g=null,this._beginTouchSelection(x,v)},window.CodemanTerminalInput.TOUCH_SELECT_LONG_PRESS_MS),E=0,w&&(cancelAnimationFrame(w),w=null)}},{passive:!1}),s.addEventListener("touchmove",P=>{if(this._touchSelecting){P.preventDefault();const F=P.touches[0];F&&this._extendTouchSelection(F.clientX,F.clientY);return}if(g&&P.touches.length===1){const F=P.touches[0];(Math.abs(F.clientX-x)>V||Math.abs(F.clientY-v)>V)&&(clearTimeout(g),g=null)}if(P.touches.length===1&&k){const F=P.touches[0].clientY,Y=P.touches[0].clientX;if(!H){const Q=Math.abs(F-L),se=Math.abs(Y-b);(Q>=V||se>=V)&&(H=!0,B=se>Q?D()?"x":"swipe":"y",this._terminalGestureAxis=B)}if(!H)return;if(P.preventDefault(),B==="swipe"){const Q=typeof SwipeHandler<"u"?SwipeHandler.maxVerticalDrift:50;if(Math.abs(F-L)<=Q)return;B="y",this._terminalGestureAxis="y",m=Y,_=F;return}if(B==="x"){s.scrollLeft-=Y-m,m=Y,_=F;return}const te=_-F;A+=te,I=te*1.2,m=P.touches[0].clientX,_=F;const ie=r(),$=Math.trunc(A/ie);$!==0&&(this._shouldForwardTouchToApp()?(this._logScrollRouting("forward-sgr"),this._forwardScrollToApp(m,_,$)):this._maybePageCliTranscript({shiftKey:!1,touchId:R},$)||(this._logScrollRouting("local-scrollback"),this._noteTerminalUserScroll($),this.terminal.scrollLines($),this._maybeLoadMoreHistoryOnScroll($)),A-=$*ie)}},{passive:!1}),s.addEventListener("touchend",P=>{if(!P.target?.closest?.(".term-select-bar")){if(clearTimeout(g),g=null,k=!1,this._touchSelecting){P.preventDefault(),I=0,this._endTouchSelectionGesture(),G=!1;return}if(!w&&Math.abs(I)>.3&&(w=requestAnimationFrame(O)),!H&&this.terminal){const F=P.changedTouches&&P.changedTouches[0];if(F){this._suppressTrustedTapMouseEvents();const Y=U&&U.x===F.clientX&&U.y===F.clientY?U.intent:null;this._handleMobileTerminalTap(F,G,Y)}}G=!1}},{passive:!1}),s.addEventListener("contextmenu",P=>{if(g!==null||this._touchSelecting||this._touchSelectionActive){P.preventDefault();return}if(!this.terminal?.hasSelection?.())return;const F=this.terminal.getSelection();F&&(P.preventDefault(),this.copyTerminalSelection(F))}),s.addEventListener("touchcancel",()=>{clearTimeout(g),g=null,k=!1,this._touchSelecting=!1,I=0,A=0,G=!1},{passive:!0})}s.addEventListener("click",r=>this._handleDesktopTerminalClick(r)),this._installMobileKeyboardDismiss(),this.showWelcome(),this.initImageInput(),this._chunkedWriteGen=0,this._bufferLoadSeq=0,this._bufferLoadOwner=null,this._lastUserScrollUpAt=null,this._resizeTimeout=null,this._lastResizeDims=null;const p=()=>{this._tabRailResizeOwnsObserver||(this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(()=>{this._resizeTimeout=null,this.flickerFilterBuffer&&(this.flickerFilterTimeout&&(clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=null),this.flushFlickerBuffer());const r=typeof KeyboardHandler<"u"&&KeyboardHandler.keyboardVisible,m=!this.isSoloWindow&&this.detachedSessions?.has(this.activeSessionId),_=this._tilesOwnTerminal?.(),I=this.activeSessionId&&!r&&!m&&!_?this._geometryForResizeRequest():null;if(I){const{cols:E,rows:w}=I;if(!this._lastResizeDims||E!==this._lastResizeDims.cols||w!==this._lastResizeDims.rows){const k=this.activeSessionId?this.sessions.get(this.activeSessionId):null;k&&k.mode!=="shell"&&!this._paneWidthRefused&&this.terminal&&this.isTerminalAtBottom()&&this.terminal.write("\x1B[3J\x1B[H\x1B[2J"),this._lastResizeDims={cols:E,rows:w};const R=typeof MobileDetection<"u"&&MobileDetection.getDeviceType?MobileDetection.getDeviceType():"desktop";let O=!1;if(this._wsReady&&this._wsSessionId===this.activeSessionId)try{this._ws.send(JSON.stringify({t:"z",c:E,r:w,v:R})),O=!0}catch{}if(!O){const A=this.activeSessionId;fetch(`/api/sessions/${this.activeSessionId}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cols:E,rows:w,viewportType:R})}).then(async H=>{const g=(await H.json())?.data??{};this._onPtyGeometryReport(A,g.cols,g.rows)}).catch(()=>{})}}}this.applyLineageLineSettings?.(),this.updateConnectionLines(),this._localEchoOverlay?.rerender(),this._forEachTile?.(E=>E.fit(),{grid:!1})},300))};window.addEventListener("resize",p),this.terminalResizeObserver&&this.terminalResizeObserver.disconnect(),this.terminalResizeObserver=new ResizeObserver(p),this.terminalResizeObserver.observe(s),this._pendingInput="",this._inputFlushTimeout=null,this._lastKeystrokeTime=0;const u=()=>{if(this._inputFlushTimeout=null,this._pendingInput&&this.activeSessionId){const r=this._pendingInput,m=this.activeSessionId;this._pendingInput="",this._sendInputAsync(m,r)}},T=r=>{const m=this._consumeMobileImeTerminalData(r);if(!/^\x1b\[<\d+;\d+;\d+[Mm]$/.test(r)&&(window.cjkActive||document.activeElement?.id==="cjkInput")){const I=document.getElementById("cjkInput");I?.classList.contains("cjk-input-visible")&&document.activeElement===this.terminal.textarea&&!window.CodemanTerminalInput?.shouldSuppressTerminalQueryResponse(r)&&(_crashDiag.log("CJK regain-focus (onData swallowed input)"),I.focus());return}if(this.activeSessionId){if(window.CodemanTerminalInput?.shouldSuppressTerminalQueryResponse(r))return;typeof KeyboardAccessoryBar<"u"&&KeyboardAccessoryBar.isCtrlArmed?.()&&!window.CodemanTerminalInput?.isTerminalFocusOrMouseReport(r)&&(r=KeyboardAccessoryBar.consumeCtrl(r)),this._lastTerminalData={data:r,time:performance.now()};const I=this._localEchoEnabled&&this._echoPassthroughSessions?.has(this.activeSessionId);if(I&&(r==="\r"||r==="")&&this._echoPassthroughSessions.delete(this.activeSessionId),this._localEchoEnabled&&!I){if(r==="\x7F"){const w=this._localEchoOverlay?.removeChar();if(w==="flushed"){const{count:k,text:R}=this._localEchoOverlay.getFlushed();this._flushedOffsets?.has(this.activeSessionId)&&(k===0?(this._flushedOffsets.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId)):(this._flushedOffsets.set(this.activeSessionId,k),this._flushedTexts?.set(this.activeSessionId,R))),this._pendingInput+=r,u()}else w===!1&&(this._pendingInput+=r,u());return}if(/^[\r\n]+$/.test(r)){const w=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),w&&(this._pendingInput+=w,u()),setTimeout(()=>{this._pendingInput+="\r",u()},80);return}if(r.length>1&&r.charCodeAt(0)>=32){this._localEchoOverlay?.appendText(r),m&&this._localEchoOverlay&&this._transferMobileImeCommitToLocalEcho();return}if(r.charCodeAt(0)<32){if(r.length>1&&r.charCodeAt(0)===27){if(r.startsWith(window.CodemanTerminalInput.BRACKETED_PASTE_START)){const k=!!this._localEchoOverlay?.pendingText;this._flushLocalEchoPending(),k?(u(),setTimeout(()=>{this._pendingInput+=r,u()},80)):(this._pendingInput+=r,u());return}if(window.CodemanTerminalInput.isComposerNavKey(r)){this._flushLocalEchoPending(),this._echoPassthroughSessions||(this._echoPassthroughSessions=new Set),this._echoPassthroughSessions.add(this.activeSessionId),this._pendingInput+=r,u();return}this._pendingInput+=r,u();return}if(this._restoringFlushedState){this._pendingInput+=r,u();return}if(r===" "){const k=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),k&&(this._pendingInput+=k),this._pendingInput+=r,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null);let R="";try{const A=this._localEchoOverlay?.findPrompt?.();if(A){const H=this.terminal.buffer.active,g=H.getLine(H.viewportY+A.row);g&&(R=g.translateToString(!0).slice(A.col+2).trimEnd())}}catch{}this._tabCompletionBaseText=R,u(),this._tabCompletionSessionId=this.activeSessionId,this._tabCompletionRetries=0,this._tabCompletionFallback&&clearTimeout(this._tabCompletionFallback);const O=this;this._tabCompletionFallback=setTimeout(()=>{if(O._tabCompletionFallback=null,!O._tabCompletionSessionId||O._tabCompletionSessionId!==O.activeSessionId)return;const A=O._localEchoOverlay;!A||A.pendingText||O.terminal.write("",()=>{if(!O._tabCompletionSessionId)return;A.resetBufferDetection();const H=A.detectBufferText();H&&H!==O._tabCompletionBaseText&&(O._tabCompletionSessionId=null,O._tabCompletionRetries=0,O._tabCompletionBaseText=null,A.rerender())})},300);return}const w=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),w&&(this._pendingInput+=w),this._pendingInput+=r,this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),u();return}if(r.length===1&&r.charCodeAt(0)>=32){this._localEchoOverlay?.addChar(r),m&&this._localEchoOverlay&&this._transferMobileImeCommitToLocalEcho();return}}if(this._predictHookOnData(r),this._pendingInput+=r,r.charCodeAt(0)<32||r.length>1){this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),u();return}const E=performance.now();E-this._lastKeystrokeTime>50?(this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),this._lastKeystrokeTime=E,u()):(this._lastKeystrokeTime=E,this._inputFlushTimeout||(this._inputFlushTimeout=setTimeout(u,0)))}};try{this._keyCode229Recovery=window.CodemanKeyCode229Recovery?.create?.({textarea:this.terminal.textarea,emitRecovered:r=>T(r),getCompositionHelper:()=>this.terminal?._core?._compositionHelper,isScreenReaderMode:()=>this.terminal?.options?.screenReaderMode===!0})}catch{this._keyCode229Recovery=null}this.terminal.onData(r=>{try{const m=window.CodemanTerminalInput;!m?.shouldSuppressTerminalQueryResponse(r)&&!m?.isTerminalFocusOrMouseReport(r)&&this._keyCode229Recovery?.notifyCanonicalData?.()}catch{}T(r)})},_resolveLinkedFilePath(e,t){return typeof resolveLinkedFilePath!="function"?e:resolveLinkedFilePath(e,this.sessions?.get?.(t)?.workingDir)},registerFilePathLinkProvider(e={}){const t=this,i=e.terminal||this.terminal,s=e.getSessionId||(()=>this.activeSessionId),n=e.setHovered||(c=>{this._linkHovered=c}),o=i===this.terminal;let l=-1;const a={provideLinks(c,h){c!==l&&(l=c,console.debug("[LinkProvider] Checking line:",c));const f=i.buffer.active;if(!f.getLine(c-1)){h(void 0);return}const p=window.CodemanTerminalLines?.terminalLinkLine(f,c-1,i.cols,12);if(!p){h(void 0);return}const u=p.text,T=g=>{const x=p.offsetToCell(g);return{x:x.col+1,y:x.row+1}},r=(window.CodemanTerminalLines?.terminalCellWrappedPaths?.(f,c-1,4)??[]).filter(g=>!/(^|\/)\.\.(\/|$)/.test(g.path));if(!u||!u.includes("/")&&!u.includes(".")&&r.length===0){h(void 0);return}const m=[],_=[],I=(g,x)=>_.some(v=>g<v.end&&v.start<g+x),E=({url:g,startIndex:x})=>{const v=T(x);if(m.some(D=>D.range.start.x===v.x&&D.range.start.y===v.y))return;_.push({start:x,end:x+g.length});const L=x+g.length,b=[];let B=x;for(let D=x+1;D<L;D++)T(D).y!==T(D-1).y&&(b.push([B,D]),B=D);b.push([B,L]);for(let D=0;D<b.length;D++){const[G,U]=b[D];m.push({text:g,range:{start:T(G),end:b.length===1?T(U):T(U-1)},decorations:{pointerCursor:!0,underline:!0},activate(){t._openTerminalUrl(g)},hover(){n(!0)},leave(){n(!1)}})}},w=/\b(tail|cat|head|less|grep|watch|vim|nano)\s+(?:[^\s\/]+\s+){0,4}(\/[^\s"'<>|;&\n\x00-\x1f]+)/g,k=/Bash\([^)]*?(\/(?:home|tmp|var|etc|opt)[^\s"'<>|;&\)\n\x00-\x1f]+)/g,R=(g,x=!1)=>{const v=s(),L=t._resolveLinkedFilePath(g,v);if(x){t.openFolderGrid(L,v);return}if(previewsInFileViewer(L)||rendersAsPage(L)||t._isExternalPreviewPath(L,v)){t.openFilePreview(L,v);return}t.openLogViewerWindow(L,v)},O=(g,x,v=!1)=>{const L=u.indexOf(g,x);if(L===-1)return;const b=T(L),B=T(L+g.length);m.some(D=>D.range.start.x===b.x&&D.range.start.y===b.y)||I(L,g.length)||(_.push({start:L,end:L+g.length}),m.push({text:g,range:{start:b,end:B},decorations:{pointerCursor:!0,underline:!0},activate(D,G){R(G,v)},hover(){n(!0)},leave(){n(!1)}}))};let A;for(const g of window.CodemanTerminalLines?.findTerminalUrls?.(u)??[])E(g);for(w.lastIndex=0;(A=w.exec(u))!==null;)O(A[2],A.index);for(const g of findFilePathLinks(u))O(g.path,g.index,!!g.folder);for(k.lastIndex=0;(A=k.exec(u))!==null;)O(A[1],A.index);const H=r.filter(g=>!m.some(x=>x.text===g.path&&x.range.start.y===g.segments[0].row+1&&x.range.start.x===g.segments[0].startCol+1));if(H.length>0){const g=H.flatMap(v=>v.segments),x=v=>g.some(L=>{const b=L.row+1;if(b<v.range.start.y||b>v.range.end.y)return!1;const B=b===v.range.start.y?v.range.start.x:1,D=b===v.range.end.y?v.range.end.x:Number.MAX_SAFE_INTEGER;return B<=L.endCol&&D>=L.startCol+1});for(let v=m.length-1;v>=0;v--)x(m[v])&&m.splice(v,1);for(const v of H)for(const L of v.segments)m.push({text:v.path,range:{start:{x:L.startCol+1,y:L.row+1},end:{x:L.endCol,y:L.row+1}},decorations:{pointerCursor:!0,underline:!0},activate(){R(v.path)},hover(){n(!0)},leave(){n(!1)}})}m.length>0&&console.debug("[LinkProvider] Found links:",m.map(g=>g.text)),h(m.length>0?m:void 0)}};return o&&(this._terminalLinkProvider=a),i.registerLinkProvider(a),console.log("[LinkProvider] File path link provider registered"),a},_terminalOsc8LinkHandler(){return{activate:(e,t)=>{/^https?:\/\/[^\s\x00-\x1f]+$/i.test(t)&&window.confirm(`Open this link?
2
+
3
+ ${t}`)&&this._openTerminalUrl(t)}}},_openTerminalUrl(e){this.openLinkThroughWebTabIfLoopback?.(e)||window.open(e,"_blank","noopener,noreferrer")},_terminalLinkAtPoint(e,t){const i=this._terminalLinkProvider,s=this.terminal?.buffer?.active;if(!i||!s)return null;const n=this._clientPointToCell(e,t);if(!n)return null;const o=(s.viewportY||0)+n.row;let l=null;try{i.provideLinks(o,h=>{l=h||[]})}catch{return null}if(!l||l.length===0)return null;const a=Math.max(1,this.terminal.cols||1),c=o*a+n.col;return l.find(h=>{const f=h?.range?.start,d=h?.range?.end;return!f||!d?!1:f.y*a+f.x<=c&&c<=d.y*a+d.x})||null},_tapIsOnCaretLine(e,t){const i=this.terminal?.buffer?.active;if(!i?.getLine)return!1;const s=this._clientPointToCell(e,t);if(!s)return!1;const n=i.baseY+(i.cursorY||0),o=i.viewportY+s.row-1;let l=n;for(;l>0&&i.getLine(l)?.isWrapped;)l--;let a=n;for(;a+1<i.length&&i.getLine(a+1)?.isWrapped;)a++;return o>=l&&o<=a},_activateTerminalLinkAtPoint(e,t){const i=this._terminalLinkAtPoint(e,t);if(!i||typeof i.activate!="function")return!1;try{i.activate(null,i.text)}catch(s){return console.warn("[LinkProvider] tap activation failed:",s),!1}return!0},_installTouchSelectionFocusGuard(){const e=this.terminal?.textarea;!e||e._codemanSelectionFocusGuard||(e._codemanSelectionFocusGuard=!0,e.addEventListener("focus",()=>{this._touchSelectionFocusGuarded()&&this._blurMobileTerminalInput()}))},_touchSelectionFocusGuarded(){return this._touchSelecting?!0:performance.now()<(this._touchSelectionFocusGuardUntil||0)},_armTouchSelectionFocusGuard(){this._touchSelectionFocusGuardUntil=performance.now()+(window.CodemanTerminalInput?.TOUCH_SELECT_FOCUS_GUARD_MS||800)},_touchSelectionCellAt(e,t){const i=this._clientPointToCell(e,t),s=this.terminal?.buffer?.active;return!i||!s?null:{col:i.col-1,row:(s.viewportY||0)+i.row-1}},_touchSelectionLogicalLine(e){const t=this.terminal?.buffer?.active,i=Math.max(1,this.terminal?.cols||1);return!t||typeof window.CodemanTerminalLines?.terminalLogicalLine!="function"?null:window.CodemanTerminalLines.terminalLogicalLine(t,e,i)},_touchSelectionWordAt(e){const t=Math.max(1,this.terminal?.cols||1),i=this._touchSelectionLogicalLine(e.row);if(!i)return null;const s=i.cellToOffset(e.row,e.col);if(s<0)return null;const n=i.text[s];if(!n||!n.trim())return null;let o=s;for(;o>0&&i.text[o-1]&&i.text[o-1].trim();)o--;let l=s;for(;l+1<i.text.length&&i.text[l+1]&&i.text[l+1].trim();)l++;const a=i.offsetToCell(o),c=i.offsetToCell(l),h=a.row*t+a.col,f=c.row*t+c.col-h+1;return f>0?{index:h,length:f}:null},_applyTouchSelection(e,t){const i=Math.max(1,this.terminal?.cols||1);t<=0||this.terminal?.select?.(e%i,Math.floor(e/i),t)},_beginTouchSelection(e,t){this._blurMobileTerminalInput(),this._suppressTrustedTapMouseEvents(),this._armTouchSelectionFocusGuard(),this._touchSelecting=!0;const i=this._touchSelectionCellAt(e,t);if(!i)return!1;const s=this._touchSelectionWordAt(i);if(!s)return!1;this._touchSelectionAnchor=s,this._touchSelectionActive=!0,this._applyTouchSelection(s.index,s.length);try{navigator.vibrate?.(15)}catch{}return this._showTouchSelectionBar(),!0},_extendTouchSelection(e,t){const i=this._touchSelectionAnchor,s=this._touchSelectionCellAt(e,t);if(!i||!s)return;const n=Math.max(1,this.terminal?.cols||1),o=s.row*n+s.col,l=Math.min(i.index,o),a=Math.max(i.index+i.length,o+1);this._applyTouchSelection(l,a-l),this._armTouchSelectionFocusGuard(),this._positionTouchSelectionBar()},_endTouchSelectionGesture(){this._touchSelecting=!1,this._suppressTrustedTapMouseEvents(),this._armTouchSelectionFocusGuard(),this._positionTouchSelectionBar(),this._flushAutoCopySelection()},_selectTouchSelectionLine(){const e=this._touchSelectionAnchor,t=Math.max(1,this.terminal?.cols||1);if(!e)return;const i=this._touchSelectionLogicalLine(Math.floor(e.index/t));if(!i)return;const n=(this.terminal?.buffer?.active?.getLine(i.endRow)?.translateToString(!0)||"").length,o=i.startRow*t,l=i.endRow*t+Math.max(0,n-1)-o+1;l<=0||(this._touchSelectionAnchor={index:o,length:l},this._applyTouchSelection(o,l),this._positionTouchSelectionBar(),this._flushAutoCopySelection())},async _copyTouchSelection(){const e=await this.copyTerminalSelection();return this._clearTouchSelection(),typeof MobileDetection<"u"&&MobileDetection.isTouchDevice?.()&&this._blurMobileTerminalInput(),e},_clearTouchSelection(){this._touchSelecting=!1,this._touchSelectionActive=!1,this._touchSelectionAnchor=null,this.terminal?.clearSelection?.(),this._hideTouchSelectionBar()},_ensureTouchSelectionBar(){if(this._touchSelectionBar?.isConnected)return this._touchSelectionBar;const e=document.getElementById("terminalContainer");if(!e)return null;const t=document.createElement("div");return t.className="term-select-bar",t.setAttribute("role","toolbar"),t.innerHTML='<button type="button" class="term-select-btn" data-act="copy">Copy</button><button type="button" class="term-select-btn" data-act="line">Line</button><button type="button" class="term-select-btn term-select-btn--close" data-act="close" aria-label="Clear selection">\u2715</button>',t.addEventListener("click",i=>{const s=i.target?.closest?.("[data-act]")?.dataset?.act;s&&(i.preventDefault(),i.stopPropagation(),s==="copy"?this._copyTouchSelection():s==="line"?this._selectTouchSelectionLine():this._clearTouchSelection())}),e.appendChild(t),this._touchSelectionBar=t,t},_showTouchSelectionBar(){const e=this._ensureTouchSelectionBar();e&&(e.classList.add("visible"),this._positionTouchSelectionBar())},_hideTouchSelectionBar(){this._touchSelectionBar?.classList.remove("visible")},_positionTouchSelectionBar(){const e=this._touchSelectionBar,t=document.getElementById("terminalContainer"),i=this.terminal?.element?.querySelector(".xterm-screen"),s=this.terminal?._core?._renderService?.dimensions?.css?.cell,n=this.terminal?.getSelectionPosition?.(),o=this.terminal?.buffer?.active;if(!e||!t||!i||!s?.height||!n||!o)return;const l=i.getBoundingClientRect(),a=t.getBoundingClientRect(),c=r=>r-(o.viewportY||0),h=l.top-a.top+c(n.start.y)*s.height,f=l.top-a.top+(c(n.end.y)+1)*s.height,d=e.offsetHeight||36,y=6;let p=h-d-y;p<0&&(p=f+y),p=Math.max(0,Math.min(p,a.height-d));const u=l.left-a.left+n.start.x*(s.width||8),T=e.offsetWidth||150;e.style.top=`${Math.round(p)}px`,e.style.left=`${Math.round(Math.max(0,Math.min(u,a.width-T)))}px`},showWelcome(){if(this.shouldUseMobileOverview?.()){const t=document.getElementById("welcomeOverlay");t&&t.classList.remove("visible"),this.hideHomeSessions?.(),this.showMobileOverview(),this._updateCjkInputState?.();return}this.hideMobileOverview?.();const e=document.getElementById("welcomeOverlay");e&&(e.classList.add("visible"),this.loadTunnelStatus(),this.applyWelcomeCliVisibility(),this.loadHistorySessions(),this.initSearchPanel(),this.showHomeSessions?.()),this._updateCjkInputState?.()},hideWelcome(){this.hideMobileOverview?.(),this.hideHomeSessions?.();const e=document.getElementById("welcomeOverlay");e&&e.classList.remove("visible");const t=document.getElementById("welcomeQr");t&&(clearTimeout(this._welcomeQrShrinkTimer),t.classList.remove("expanded")),this._updateCjkInputState?.()},async _fetchHistorySessions(){const i=(await(await fetch("/api/history/sessions")).json()).data?.sessions||[];if(i.length===0)return[];const s=new Map;for(const o of i){const l=o.projectKey||o.workingDir;s.has(l)||s.set(l,[]),s.get(l).push(o)}const n=[];for(const[,o]of s)n.push(...o.slice(0,3));return n.sort((o,l)=>new Date(l.lastModified)-new Date(o.lastModified)),n},async _fetchUnifiedSessions(e=60){const t=await fetch("/api/sessions/unified?limit="+e),i=await t.json().catch(()=>null);if(!t.ok||!i||i.success===!1||!i.data)throw new Error(i?.error||`unified sessions request failed (HTTP ${t.status})`);return i.data.sessions||[]},_worktreeLabel(e){const t=e&&e.worktreeName;if(!t)return"";let i=e.gitBranch||"";return(i===t||i===`worktree-${t}`)&&(i=""),i.length>24&&(i=i.slice(0,23)+"\u2026"),"\u2442 "+[t,i].filter(Boolean).join(" \xB7 ")},_resolveCaseLabel(e,t){if(!e)return"";let i=null;for(const s of t||[])if(!(!s||!s.path)){if(e===s.path)return`#${s.name}`;if(e.startsWith(s.path+"/")){const n=s.path.length;(!i||n>i.len)&&(i={name:s.name,suffix:e.slice(n),len:n})}}return i?`#${i.name}${i.suffix}`:e.split("/").pop()||e},_shortenHomePath(e){return(e||"").replace(/^\/(?:home|Users)\/[^/]+(?=\/|$)/,"~")},_buildHistoryItem(e,t,i){const s=i?.showViewAll!==!1,n=typeof e.sizeBytes=="number",o=n?e.sizeBytes<1024?`${e.sizeBytes}B`:e.sizeBytes<1048576?`${(e.sizeBytes/1024).toFixed(0)}K`:`${(e.sizeBytes/1048576).toFixed(1)}M`:"",l=typeof e.lastActivityAt=="number"?e.lastActivityAt:e.lastModified?Date.parse(e.lastModified):NaN;let a="";if(!Number.isNaN(l)){const b=new Date(l);a=b.toLocaleDateString("en",{month:"short",day:"numeric"})+" "+b.toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit",hour12:!1})}const c=this._shortenHomePath(e.workingDir),h=this._resolveCaseLabel(e.workingDir,t),f=Array.isArray(e.sources)&&e.sources.includes("live"),d=e.pinned===!0,y=document.createElement("div");y.className="history-item"+(d?" is-pinned":""),y.title=e.workingDir||"";const p=document.createElement("div");p.className="history-item-main",p.addEventListener("click",i?.onActivate||(()=>{f&&this.sessions.has(e.sessionId)?this.selectSession(e.sessionId):this.resumeHistorySession(e.claudeSessionId||e.sessionId,e.workingDir||"",e.name,e.mode,e.resumeId)}));const u=document.createElement("div");u.className="history-item-text";const T=document.createElement("span");if(T.className="history-item-title",d){const b=document.createElement("span");b.className="history-item-pin",b.textContent="\u{1F4CC}",b.setAttribute("aria-label","Pinned"),b.title="Pinned",T.appendChild(b)}T.appendChild(document.createTextNode(this._historyRowLabel(e,c)));const r=document.createElement("div");if(r.className="history-item-badges",e.mode){const b=document.createElement("span");b.className="history-item-badge history-item-badge-mode",b.textContent=e.mode,r.appendChild(b)}const m=this._worktreeLabel(e);if(m){const b=document.createElement("span");b.className="history-item-badge history-item-badge-worktree",b.textContent=m,b.title=e.worktreeRepo?`worktree of ${e.worktreeRepo}`:m,r.appendChild(b)}if(f){const b=document.createElement("span");b.className="history-item-badge history-item-badge-live",b.textContent="LIVE",r.appendChild(b)}const _=document.createElement("span");_.className="history-item-subtitle",h.startsWith("#")&&_.classList.add("is-case"),_.textContent=h,u.append(T),r.childElementCount>0&&u.append(r),u.append(_);const I=document.createElement("span");I.className="history-item-meta",I.textContent=a;const E=document.createElement("button");E.className="history-item-expand",E.type="button",E.setAttribute("aria-haspopup","menu"),E.setAttribute("aria-label","Session actions"),E.setAttribute("aria-expanded","false"),E.textContent="\u22EF",p.append(u,I,E);const w=document.createElement("div");w.className="history-item-detail",w.hidden=!0;const k=document.createElement("div");k.className="history-detail-row";const R=document.createElement("span");R.className="history-detail-label",R.textContent="Prompt";const O=document.createElement("span");O.className="history-detail-value history-detail-prompt",O.textContent=e.firstPrompt||"(no prompt captured)",k.append(R,O);let A=null;if(e.lastPrompt&&e.lastPrompt!==e.firstPrompt){A=document.createElement("div"),A.className="history-detail-row";const b=document.createElement("span");b.className="history-detail-label",b.textContent="Last prompt";const B=document.createElement("span");B.className="history-detail-value history-detail-prompt",B.textContent=e.lastPrompt,A.append(b,B)}const H=document.createElement("div");H.className="history-detail-row";const g=document.createElement("span");g.className="history-detail-label",g.textContent="Path";const x=document.createElement("span");x.className="history-detail-value history-detail-path",x.textContent=c,H.append(g,x);const v=document.createElement("div");v.className="history-detail-row history-detail-meta";const L=[];if(a&&L.push(a),n&&L.push(o),L.push(e.sessionId.slice(0,8)),v.textContent=L.join(" \xB7 "),w.append(k),A&&w.append(A),w.append(H,v),s&&e.projectKey){const b=document.createElement("div");b.className="history-detail-row history-detail-actions";const B=document.createElement("button");B.type="button",B.className="history-view-all-btn",B.textContent="View all in this folder",B.addEventListener("click",D=>{D.stopPropagation(),this.openFolderHistoryModal(e.projectKey,e.workingDir,t)}),b.appendChild(B),w.appendChild(b)}return E.addEventListener("click",b=>{b.stopPropagation(),b.preventDefault(),this._openSessionRowMenu(b.currentTarget,e,t,y,w)}),y.append(p,w),y},_openSessionRowMenu(e,t,i,s,n){if(this._openRowMenuClose)try{this._openRowMenuClose()}catch{}const o=Array.isArray(t.sources)&&t.sources.includes("live")&&this.sessions.has(t.sessionId),l=document.createElement("div");l.className="session-row-menu",l.setAttribute("role","menu");let a=null,c=null,h=null;const f=()=>{document.removeEventListener("mousedown",a,!0),document.removeEventListener("keydown",c,!0),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h,!0);try{l.remove()}catch{}this._openRowMenuEl===l&&(this._openRowMenuEl=null,this._openRowMenuClose=null)},d=(_,I,E)=>{const w=document.createElement("button");w.type="button",w.className="session-row-menu-item",w.setAttribute("role","menuitem");const k=document.createElement("span");if(k.className="session-row-menu-label",k.textContent=_,w.appendChild(k),E&&E.sublabel){const R=document.createElement("span");R.className="session-row-menu-sublabel",R.textContent=E.sublabel,w.appendChild(R)}w.addEventListener("click",async R=>{R.stopPropagation(),R.preventDefault(),await I()}),l.appendChild(w)};d(o?"Switch to session":"Resume session",()=>{o?this.selectSession(t.sessionId):this.resumeHistorySession(t.claudeSessionId||t.sessionId,t.workingDir||"",t.name,t.mode,t.resumeId),this.closeSessionManager?.(),f()});const y=t.pinned===!0;d(y?"Unpin session":"Pin to top",async()=>{await this._setSessionPinned(t.sessionId,!y)?(t.pinned=!y,this.showToast(y?"Unpinned":"Pinned to top","success")):this.showToast("Pin failed","error"),f()}),o&&d("Open folder",()=>{this.selectSession(t.sessionId),this.loadFileBrowser?.(t.sessionId),this.closeSessionManager?.(),f()}),t.workingDir&&d("Copy path",async()=>{const _=await this._copyText(t.workingDir);this.showToast(_?"Path copied":"Copy failed",_?"success":"error"),f()}),d("Show details",()=>{const _=s.classList.toggle("expanded");n.hidden=!_,e.setAttribute("aria-expanded",_?"true":"false"),f()}),document.body.appendChild(l);const p=e.getBoundingClientRect(),u=l.getBoundingClientRect(),T=4;let r=p.bottom+T;r+u.height>window.innerHeight&&p.top-T-u.height>=0&&(r=p.top-T-u.height);let m=p.right-u.width;m<T&&(m=T),m+u.width>window.innerWidth-T&&(m=Math.max(T,window.innerWidth-T-u.width)),l.style.top=`${Math.max(T,r)}px`,l.style.left=`${m}px`,a=_=>{l.contains(_.target)||e.contains(_.target)||f()},c=_=>{_.key==="Escape"&&(_.stopPropagation(),f())},h=()=>f(),document.addEventListener("mousedown",a,!0),document.addEventListener("keydown",c,!0),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h,!0),this._openRowMenuEl=l,this._openRowMenuClose=f},async _setSessionPinned(e,t){try{const i=await fetch(`/api/sessions/${encodeURIComponent(e)}/pin`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({pinned:t})});return i.ok?(await i.json())?.success===!0:!1}catch(i){return console.error("[_setSessionPinned]",i),!1}},_HISTORY_INITIAL_COUNT:10,_HISTORY_FETCH_LIMIT:200,_HISTORY_SORT_KEY:"codeman:historySort",async loadHistorySessions(){const e=document.getElementById("historySessions"),t=document.getElementById("historyList");if(!(!e||!t))try{const i=Array.isArray(this.cases)&&this.cases.length>0?Promise.resolve(this.cases):fetch("/api/cases").then(o=>o.ok?o.json():null).then(o=>o?.data||[]).catch(()=>[]),[s,n]=await Promise.all([this._fetchUnifiedSessions(this._HISTORY_FETCH_LIMIT),i]);if(s.length===0){e.style.display="none";return}this._historyAll=s,this._historyCases=n,this._wireHistoryControls(),this._renderHistoryList(),e.style.display=""}catch(i){console.error("[loadHistorySessions]",i),e.style.display="none"}},_wireHistoryControls(){if(this._historyControlsWired)return;const e=document.getElementById("historyFilter"),t=document.getElementById("historySort");if(!(!e&&!t)){if(this._historyControlsWired=!0,t)try{const i=localStorage.getItem(this._HISTORY_SORT_KEY);i&&Array.from(t.options).some(s=>s.value===i)&&(t.value=i)}catch{}e&&(e.addEventListener("input",()=>this._renderHistoryList()),e.addEventListener("keydown",i=>{i.key==="Escape"&&e.value&&(i.stopPropagation(),e.value="",this._renderHistoryList())})),t&&t.addEventListener("change",()=>{try{localStorage.setItem(this._HISTORY_SORT_KEY,t.value)}catch{}this._renderHistoryList()})}},_historyRowMatches(e,t,i){return[e.name,e.workingDir,this._resolveCaseLabel(e.workingDir,i),e.firstPrompt,e.lastPrompt,e.sessionId].some(n=>typeof n=="string"&&n.toLowerCase().includes(t))},_historyRowLabel(e,t){return e.name||e.firstPrompt||t||""},_sortHistoryRows(e,t){const n=t==="name"?a=>this._historyRowLabel(a,this._shortenHomePath(a.workingDir)).toLowerCase():a=>((a.workingDir||"").split("/").pop()||"").toLowerCase(),o=t==="recent"?e.slice():e.slice().sort((a,c)=>n(a).localeCompare(n(c),void 0,{sensitivity:"base",numeric:!0})),l=o.filter(a=>a.pinned);return l.length===0?o:l.concat(o.filter(a=>!a.pinned))},_renderHistoryList(){const e=document.getElementById("historyList");if(!e)return;const t=this._historyAll||[],i=this._historyCases||[],s=document.getElementById("historyCount"),n=(document.getElementById("historyFilter")?.value||"").trim().toLowerCase(),o=document.getElementById("historySort")?.value||"recent",l=n?t.filter(d=>this._historyRowMatches(d,n,i)):t,a=this._sortHistoryRows(l,o),c=!!this._historyExpanded||n.length>0,h=c?a:a.slice(0,this._HISTORY_INITIAL_COUNT);if(e.replaceChildren(),e.classList.toggle("expanded",c),a.length===0){const d=document.createElement("div");d.className="history-empty",d.textContent=`No conversations match "${n}"`,e.appendChild(d)}for(const d of h)e.appendChild(this._buildHistoryItem(d,i));const f=a.length-h.length;if(f>0){const d=document.createElement("button");d.className="history-show-more",d.textContent=`Show ${f} more`,d.addEventListener("click",()=>{this._historyExpanded=!0,this._renderHistoryList()}),e.appendChild(d)}else if(c&&!n&&a.length>this._HISTORY_INITIAL_COUNT){const d=document.createElement("button");d.className="history-show-more",d.textContent="Show less",d.addEventListener("click",()=>{this._historyExpanded=!1,this._renderHistoryList(),e.scrollTop=0}),e.appendChild(d)}s&&(s.textContent=n?`${a.length} of ${t.length}`:a.length>h.length?`${h.length} of ${a.length}`:String(a.length))},_FOLDER_HISTORY_PAGE_SIZE:20,openFolderHistoryModal(e,t,i){this._closeFolderHistoryModal();const s=document.createElement("div");s.className="modal active folder-history-modal",s.id="folderHistoryModal";const n=document.createElement("div");n.className="modal-backdrop",n.addEventListener("click",()=>this._closeFolderHistoryModal());const o=document.createElement("div");o.className="modal-content modal-lg";const l=document.createElement("div");l.className="modal-header";const a=document.createElement("h3");a.textContent="Folder History";const c=document.createElement("div");c.className="folder-history-subtitle",c.textContent=this._shortenHomePath(t);const h=document.createElement("button");h.className="modal-close",h.setAttribute("aria-label","Close"),h.innerHTML="&times;",h.addEventListener("click",()=>this._closeFolderHistoryModal()),l.append(a,h);const f=document.createElement("div");f.className="modal-body";const d=document.createElement("div");d.className="folder-history-list",d.setAttribute("data-loading","true"),d.textContent="Loading...",f.append(c,d),o.append(l,f),s.append(n,o),document.body.appendChild(s),this._folderHistoryState={projectKey:e,workingDir:t,cases:i||[],offset:0,total:null,list:d},this._folderHistoryEscHandler=y=>{y.key==="Escape"&&this._closeFolderHistoryModal()},document.addEventListener("keydown",this._folderHistoryEscHandler),this._loadFolderHistoryPage()},async _loadFolderHistoryPage(){const e=this._folderHistoryState;if(!e)return;const{projectKey:t,cases:i,list:s}=e,n=this._FOLDER_HISTORY_PAGE_SIZE,o=e.offset,l=s.querySelector(".folder-history-more");l&&l.remove(),o===0&&(s.replaceChildren(),s.removeAttribute("data-loading"));try{const a=`/api/history/sessions?projectKey=${encodeURIComponent(t)}&offset=${o}&limit=${n}`,h=await(await fetch(a)).json(),f=h.data?.sessions||[];if(e.total=typeof h.data?.total=="number"?h.data.total:f.length+o,o===0&&f.length===0){const d=document.createElement("div");d.className="folder-history-empty",d.textContent="No conversations found in this folder.",s.appendChild(d);return}for(const d of f)s.appendChild(this._buildHistoryItem(d,i,{showViewAll:!1}));if(e.offset=o+f.length,e.offset<e.total){const d=e.total-e.offset,y=document.createElement("button");y.className="history-show-more folder-history-more",y.textContent=`Show ${Math.min(n,d)} more (${d} remaining)`,y.addEventListener("click",()=>this._loadFolderHistoryPage()),s.appendChild(y)}}catch(a){console.error("[loadFolderHistoryPage]",a);const c=document.createElement("div");c.className="folder-history-empty",c.textContent="Failed to load folder history.",s.appendChild(c)}},_closeFolderHistoryModal(){const e=document.getElementById("folderHistoryModal");e&&e.remove(),this._folderHistoryEscHandler&&(document.removeEventListener("keydown",this._folderHistoryEscHandler),this._folderHistoryEscHandler=null),this._folderHistoryState=null},_resolveResumeName(e,t){if(typeof e=="string"&&e.trim())return e;const i=(t||"").split("/").pop()||"session";let s=1;for(const[,n]of this.sessions){const o=n.name&&n.name.match(/^w(\d+)-/);if(o){const l=parseInt(o[1]);l>=s&&(s=l+1)}}return`w${s}-${i}`},async resumeHistorySession(e,t,i,s,n){document.getElementById("runModeMenu")?.classList.remove("active"),this._closeFolderHistoryModal();try{this.terminal.clear(),this.terminal.writeln(`\x1B[1;32m Resuming conversation ${e.slice(0,8)}...\x1B[0m`);const o=this._resolveResumeName(i,t),a=(this.cases||[]).find(E=>E.path===t)?.name||t.split("/").pop()||"",c=this.loadAppSettingsFromStorage(),h=this.buildEnvOverrides(this.getCaseSettings(a),c),f=this.getEffortSetting(c),d=this.getAdvisorSetting(c),y=s||"claude",p={opencode:"openCodeConfig",pi:"piConfig",grok:"grokConfig",copilot:"copilotConfig",omp:"ompConfig"}[y],u=y==="codex"?n:void 0,T=p?{[p]:{continueSession:!0}}:y==="deepseek"?{deepSeekConfig:{resumeSession:!0}}:u?{codexConfig:{resumeSessionId:u}}:{},r=!!p||y==="deepseek"||!!u,_=await(await fetch("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workingDir:t,name:o,mode:y,...y==="claude"?{resumeSessionId:e}:{},...T,...Object.keys(h).length>0?{envOverrides:h}:{},...f?{effort:f}:{},...d&&y==="claude"?{advisorModel:d}:{}})})).json();if(!_.success)throw new Error(_.error);const I=_.data.session.id;await fetch(`/api/sessions/${I}/interactive`,{method:"POST"}),y!=="claude"&&r&&e!==I&&fetch(`/api/sessions/${e}?killMux=true`,{method:"DELETE"}).catch(()=>{}),this.terminal.writeln(`\x1B[90m Session ${o} ready\x1B[0m`),await this.selectSession(I),this.terminal.focus()}catch(o){this.terminal.writeln(`\x1B[1;31m Error: ${o.message}\x1B[0m`)}},isTerminalAtBottom(){if(!this.terminal)return!0;const e=this.terminal.buffer.active;return e.viewportY>=e.baseY-2},_syncStickyScrollBaseline(){this._wasAtBottomBeforeWrite=this.isTerminalAtBottom()},_noteTerminalUserScroll(e){e<0?this._lastUserScrollUpAt=performance.now():this.isTerminalAtBottom()&&(this._lastUserScrollUpAt=null)},_maybeLoadMoreHistoryOnScroll(e){if(e>0){this.isTerminalAtBottom()&&this._setHistoryNoticeRevealed?.(null);return}if(e===0||this.terminal?.buffer?.active?.viewportY!==0||this._fullHistoryRepullInFlight||this._isLoadingBuffer)return;const t=this.activeSessionId;Promise.resolve(this._maybeRefetchFullHistory?.()).catch(()=>{}).then(()=>{t&&this.activeSessionId===t&&this._setHistoryNoticeRevealed?.(t)})},_estimateReplayRows(e,t){if(typeof e!="string"||!e)return 0;const i=t>0?t:80,s=e.replace(window.CodemanTerminalInput.REPLAY_ESCAPE_RE,"");let n=0;for(const o of s.split(`
4
+ `)){const l=o.endsWith("\r")?o.length-1:o.length;n+=l>i?Math.ceil(l/i):1}return n},_replayWouldShrinkBuffer(e,t){const i=this.terminal,s=i?.buffer?.active?.length||0;if(!s)return!1;const n=i?.rows||24;return(t??this._estimateReplayRows(e,i?.cols))+n<s},_smoothScrollBy(e){if(!e||(this._smoothScrollPending=(this._smoothScrollPending||0)+e,this._smoothScrollSession=this.activeSessionId,this._smoothScrollFrame))return;const t=()=>{this._smoothScrollFrame=null;const i=this._smoothScrollPending||0;if(!i)return;if(this.activeSessionId!==this._smoothScrollSession){this._smoothScrollPending=0;return}if(Math.abs(i)<1)return;const s=i*.22,n=i>0?Math.max(1,Math.floor(s)):Math.min(-1,Math.ceil(s));this._smoothScrollPending=i-n,this.terminal.scrollLines(n),this._maybeLoadMoreHistoryOnScroll(n),Math.abs(this._smoothScrollPending)>=1&&(this._smoothScrollFrame=requestAnimationFrame(t))};this._smoothScrollFrame=requestAnimationFrame(t)},_forwardScrollToApp(e,t,i){this._terminalViewportAtBottom()||this.terminal.scrollToBottom(),this._sendSyntheticSgrWheel(e,t,i)},_hasRecentUserScrollUp(){return typeof this._lastUserScrollUpAt!="number"?!1:performance.now()-this._lastUserScrollUpAt<window.CodemanTerminalInput.USER_SCROLL_STICKY_SUPPRESS_MS},_startRenderLivenessWatchdog(){this._stopRenderLivenessWatchdog(),this._lastRenderAt=Date.now(),this._lastTerminalWriteAt=0,this._renderLivenessTimer=setInterval(()=>{try{if(typeof CodemanRenderLiveness>"u"||!CodemanRenderLiveness.shouldKickRenderer({wroteAt:this._lastTerminalWriteAt||0,renderedAt:this._lastRenderAt||0,now:Date.now(),visible:document.visibilityState==="visible"&&!!this.terminal?.element?.isConnected}))return;const t=this._kickRenderer();_crashDiag.log(`RENDER STALL: kick=${t}`),this._lastRenderAt=Date.now()}catch{}},RENDER_LIVENESS_POLL_MS)},_stopRenderLivenessWatchdog(){this._renderLivenessTimer&&(clearInterval(this._renderLivenessTimer),this._renderLivenessTimer=null)},_kickRenderer(){try{const e=this.terminal?._core?._renderService,t=e?._renderDebouncer;if(!t||typeof e.refreshRows!="function")return!1;const i=t._animationFrame;if(i===void 0)return!1;try{cancelAnimationFrame(i)}catch{}return t._animationFrame=void 0,e.refreshRows(0,Math.max(0,(this.terminal.rows||1)-1)),!0}catch{return!1}},batchTerminalWrite(e){if(this._terminalOutputSeq=(this._terminalOutputSeq||0)+1,this._lastTerminalWriteAt=Date.now(),this._isLoadingBuffer){this._loadBufferQueue&&this._loadBufferQueue.push({at:performance.now(),data:e});return}if(this.writeFrameScheduled||(this._wasAtBottomBeforeWrite=this.isTerminalAtBottom()),(this.activeSessionId?this.sessions.get(this.activeSessionId):null)?.flickerFilterEnabled??!1){if(e.includes("\x1B[2J")||e.includes("\x1B[H\x1B[J")||e.includes("\x1B[H")&&e.includes("\x1B[?25l")){this.flickerFilterActive=!0,this.flickerFilterBuffer+=e,this.flickerFilterTimeout&&clearTimeout(this.flickerFilterTimeout),this.flickerFilterTimeout=setTimeout(()=>{this.flickerFilterTimeout=null,this.flushFlickerBuffer()},SYNC_WAIT_TIMEOUT_MS);return}if(this.flickerFilterActive){this.flickerFilterBuffer+=e;return}}this.pendingWrites.push(e),this._pendingWritesOutputSeq=this._terminalOutputSeq,this._scheduleTerminalWriteFlush()},_scheduleTerminalWriteFlush(){this._terminalWriteInFlight||this.writeFrameScheduled||this.pendingWrites.length===0||(this.writeFrameScheduled=!0,this._safeYield(()=>{this.writeFrameScheduled=!1,this.flushPendingWrites()}))},flushFlickerBuffer(){this.flickerFilterBuffer&&(this.pendingWrites.push(this.flickerFilterBuffer),this._pendingWritesOutputSeq=this._terminalOutputSeq,this.flickerFilterBuffer="",this.flickerFilterActive=!1,this._scheduleTerminalWriteFlush())},_flushLocalEchoPending(){const e=this._localEchoOverlay?.pendingText||"";this._localEchoOverlay?.clear(),this._localEchoOverlay?.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId),e&&(this._pendingInput+=e)},_updateLocalEchoState(){if(this._mobileImePreviewSessionId!==this.activeSessionId){this._mobileImePreviewSessionId=this.activeSessionId,this._mobileImeCommitOutputSeq=null;try{this._mobileImePreview?.reset?.()}catch{}}const e=this.loadAppSettingsFromStorage(),t=this.activeSessionId?this.sessions.get(this.activeSessionId):null,i=e.localEchoEnabled??MobileDetection.isTouchDevice(),s=!!(i&&t);this._localEchoEnabled&&!s&&this._localEchoOverlay?.clear(),this._localEchoEnabled=s,this._localEchoOverlay&&t&&(t.mode==="opencode"?this._localEchoOverlay.setPrompt({type:"custom",offset:3,find:o=>{try{const l=o.buffer.active,a=window.CodemanTerminalInput.cursorViewportRow(o);if(a===null)return null;const c=l.getLine(l.viewportY+a);if(!c)return null;const f=c.translateToString(!0).indexOf("\u2503");return f>=0?{row:a,col:f}:null}catch{return null}}}):t.mode==="shell"||t.mode==="codex"?(this._localEchoOverlay.clear(),this._localEchoEnabled=!1):this._localEchoOverlay.setPrompt({type:"custom",offset:0,find:o=>{try{const l=o.buffer.active,a=window.CodemanTerminalInput.cursorViewportRow(o);if(a===null)return null;const c=Math.max(0,l.baseY-l.viewportY);for(let h=a;h>=c;h--){const f=l.getLine(l.viewportY+h);if(!f)continue;const y=f.translateToString(!0).lastIndexOf("\u276F");if(y>=0)return{row:h,col:y+2}}return{row:a,col:Math.max(0,Math.min(o.cols-1,l.cursorX))}}catch{return null}}}));let n="off";t&&i&&(t.mode==="codex"?n="predict":t.mode!=="shell"&&(n="buffer")),this._localEchoPolicy=n,n!=="predict"&&this._predictiveEcho?.clearPredictions()},_predictHookOnData(e){if(!(this._localEchoPolicy!=="predict"||!this._predictiveEcho))try{const t=window.CodemanTerminalInput.classifyPredictInput(e);t==="char"?this._predictiveEcho.predictChar(e):t==="backspace"?this._predictiveEcho.predictBackspace():this._predictiveEcho.clearPredictions()}catch{}},_handleCjkInput(e){if(!this.activeSessionId){_crashDiag.log(`CJK send DROP no-session len=${e.length}`);return}typeof KeyboardAccessoryBar<"u"&&KeyboardAccessoryBar.isCtrlArmed?.()&&(e=KeyboardAccessoryBar.consumeCtrl(e)),this._localEchoPolicy==="predict"&&this._predictiveEcho?.clearPredictions(),_crashDiag.log(`CJK send\u2192${this.activeSessionId.slice(0,8)} len=${e.length}`),this._sendInputAsync(this.activeSessionId,e)},_restoreTerminalViewport(e,t){e!=null&&(t!==void 0&&t!==this.activeSessionId||this._isLoadingBuffer||typeof this.terminal?.scrollToLine=="function"&&this.terminal.buffer?.active?.viewportY!==e&&this.terminal.scrollToLine(e))},flushPendingWrites(){if(this._terminalWriteInFlight||this.pendingWrites.length===0||!this.terminal)return;const e=performance.now(),t=this.pendingWrites.join("");this.pendingWrites=[];const i=t.length;i>16384&&_crashDiag.log(`FLUSH: ${(i/1024).toFixed(0)}KB`);const n=(this.activeSessionId&&this.sessions?this.sessions.get(this.activeSessionId):null)?.mode==="codex"?32768:65536;let o=!1;const l=this.terminal.buffer?.active&&!this.isTerminalAtBottom()?this.terminal.buffer.active.viewportY:null,a=this.activeSessionId,c=t.slice(0,n);i>n&&(this.pendingWrites.push(t.slice(n)),o=!0);const h=o?null:this._pendingWritesOutputSeq??null;this._terminalWriteInFlight=!0,this._terminalWriteInFlightBytes=c.length;try{this.terminal.write(c,()=>{this._terminalWriteInFlight=!1,this._terminalWriteInFlightBytes=0,this._restoreTerminalViewport(l,a),this._scheduleTerminalWriteFlush(),this._noteMobileImeAuthoritativeOutput(h,a)})}catch(y){throw this._terminalWriteInFlight=!1,this._terminalWriteInFlightBytes=0,y}const f=o?n:i,d=performance.now()-e;if((d>100||o)&&console.warn(`[CRASH-DIAG] flushPendingWrites: ${d.toFixed(0)}ms, ${(f/1024).toFixed(0)}KB written${o?", rest deferred":""} (total ${(i/1024).toFixed(0)}KB)`),l===null&&this._wasAtBottomBeforeWrite&&!this._hasRecentUserScrollUp()&&this.terminal.scrollToBottom(),this._localEchoOverlay?.rerender(),this._tabCompletionSessionId&&this._tabCompletionSessionId===this.activeSessionId&&this._localEchoOverlay&&!this._localEchoOverlay.pendingText){const y=this._localEchoOverlay,p=this;this.terminal.write("",()=>{if(!p._tabCompletionSessionId)return;y.resetBufferDetection();const u=y.detectBufferText();u?u===p._tabCompletionBaseText?(y.undoDetection(),p._tabCompletionRetries=(p._tabCompletionRetries||0)+1,p._tabCompletionRetries>60&&(p._tabCompletionSessionId=null,p._tabCompletionRetries=0)):(p._tabCompletionSessionId=null,p._tabCompletionRetries=0,p._tabCompletionBaseText=null,p._tabCompletionFallback&&(clearTimeout(p._tabCompletionFallback),p._tabCompletionFallback=null),y.rerender()):(p._tabCompletionRetries=(p._tabCompletionRetries||0)+1,p._tabCompletionRetries>60&&(p._tabCompletionSessionId=null,p._tabCompletionRetries=0))})}},_safeYield(e){let t=!1;const i=()=>{t||(t=!0,e())};requestAnimationFrame(i),setTimeout(i,50),this._workerYield(i)},_workerYield(e){try{if(this._yieldWorker===void 0){const t="onmessage=()=>setTimeout(()=>postMessage(0),0);",i=new Blob([t],{type:"application/javascript"}),s=URL.createObjectURL(i);this._yieldWorker=new Worker(s),URL.revokeObjectURL(s),this._yieldQueue=[],this._yieldWorker.onmessage=()=>{const n=this._yieldQueue.shift();n&&n()}}if(!this._yieldWorker)return;this._yieldQueue.push(e),this._yieldWorker.postMessage(0)}catch{this._yieldWorker=null}},scrollToLastNonEmptyLine(){if(!this.terminal?.buffer?.active){this.terminal?.scrollToBottom?.();return}const e=this.terminal.buffer.active,t=e.length;let i=-1;for(let s=t-1;s>=0;s--)if(e.getLine(s)?.translateToString(!0).trim()){i=s;break}if(i>=0&&typeof this.terminal.scrollToLine=="function"){let s=Math.max(0,i-this.terminal.rows+2);const n=Math.max(0,i);for(;s<n&&!e.getLine(s)?.translateToString(!0).trim();)s++;this.terminal.scrollToLine(s)}else this.terminal.scrollToBottom()},chunkedTerminalWrite(e,t=TERMINAL_CHUNK_SIZE,i,s){const n=++this._chunkedWriteGen,o=this._beginBufferLoad(i);return new Promise(l=>{const a=(p=this._chunkedWriteGen===n)=>({parsedAt:performance.now(),bufferLength:this.terminal?.buffer?.active?.length??0,completed:p});if(!e||e.length===0){this._finishBufferLoad(o,s),l(a());return}const c=e.replace(DEC_SYNC_STRIP_RE,"").replace(OSC52_STRIP_RE,"");if(c.length<=t){this.terminal.write(c,()=>l(a())),this._finishBufferLoad(o,s);return}let h=0;const f=performance.now();let d=0;const y=()=>{if(this._chunkedWriteGen!==n){l(a(!1));return}const p=c.slice(h,h+t);if(h+=p.length,d++,this.terminal.write(p),h>=c.length){this.terminal.write("",()=>{const u=a(),T=u.parsedAt-f;console.log(`[CRASH-DIAG] chunkedTerminalWrite complete: ${c.length} bytes in ${d} chunks, ${T.toFixed(0)}ms parsed`),l(u)}),this._finishBufferLoad(o,s);return}this._safeYield(y)};this._safeYield(y)})},_beginBufferLoad(e){this._bufferLoadSeq===void 0&&(this._bufferLoadSeq=0);const t=e===void 0?`buffer-${++this._bufferLoadSeq}`:e,i=this._bufferLoadOwner===t&&Array.isArray(this._loadBufferQueue);return this._bufferLoadOwner=t,this._isLoadingBuffer=!0,i||(this._loadBufferQueue=[]),t},_finishBufferLoad(e,t){if(e!==void 0&&this._bufferLoadOwner!==e)return!1;const i=this._loadBufferQueue;if(this._isLoadingBuffer=!1,this._loadBufferQueue=null,this._bufferLoadOwner=null,t?.flushQueued&&i&&i.length){const s=typeof t.since=="number"?t.since:0;for(const n of i)n.at<s||this.batchTerminalWrite(n.data)}return!0},_focusedPane(){let e=this._focusedTile;return(!e||e._destroyed||!e.terminal)&&this._tilesOwnTerminal?.()&&(e=this._tileFor(this.activeSessionId)),e&&!e._destroyed&&e.terminal?{terminal:e.terminal,sessionId:e.sessionId,isPrimary:!1,tile:e}:{terminal:this.terminal,sessionId:this.activeSessionId,isPrimary:!0,tile:null}},_noteFocusedTile(e){this._focusedTile=e||null},_forEachTile(e,{grid:t=!0}={}){if(this._splitPane?.terminal&&e(this._splitPane),!(!t||!this._tileGrid?.open))for(const{tile:i}of this._tileGrid.tiles.values())i.terminal&&e(i)},clearTerminal(){this._focusedPane().terminal?.clear()},insertTerminalText(e){if(!this.activeSessionId||!e)return;const t=this._focusedPane?.();if(t&&!t.isPrimary){this._sendInputAsync(t.sessionId,e),t.terminal?.focus();return}this._localEchoPolicy==="predict"&&this._predictiveEcho?.clearPredictions(),this._localEchoEnabled&&this._localEchoOverlay&&!this._echoPassthroughSessions?.has(this.activeSessionId)?this._localEchoOverlay.appendText(e):this.sendInput(e).catch(()=>{}),this.terminal?.focus()},clearTerminalInput(){if(!this.activeSessionId)return;typeof CjkInput<"u"&&CjkInput.clear();const e=this._focusedPane?.();if(e&&!e.isPrimary){this._sendInputAsync(e.sessionId,""),this.showToast?.("Input cleared","success"),e.terminal?.focus();return}if(this._inputFlushTimeout&&(clearTimeout(this._inputFlushTimeout),this._inputFlushTimeout=null),this._pendingInput="",this._localEchoPolicy==="predict"&&this._predictiveEcho?.clearPredictions(),this._localEchoEnabled&&this._localEchoOverlay){const t=this._localEchoOverlay.getFlushed?.()||{count:0,text:""};this._localEchoOverlay.clear(),this._localEchoOverlay.suppressBufferDetection(),this._flushedOffsets?.delete(this.activeSessionId),this._flushedTexts?.delete(this.activeSessionId);const i=Array.from(t.text||"").length;i>0&&this.sendInput("\x7F".repeat(i)).catch(()=>{})}else this.sendInput("").catch(()=>{});this.showToast?.("Input cleared","success"),this.terminal?.focus()},async restoreTerminalSize(){const e=this._focusedPane();if(!e.isPrimary){e.tile.fit({force:!0})!==!1?this.showToast(`Terminal restored to ${e.terminal.cols}x${e.terminal.rows}`,"success"):this.detachedSessions?.has(e.sessionId)?this.showToast("This session is sized by its own window","warning"):e.tile._wsReady?this.showToast("Could not determine terminal size","error"):this.showToast("Terminal not connected: its size is sent when it reconnects","warning");return}if(!this.activeSessionId){this.showToast("No active session","warning");return}if(this._tilesOwnTerminal?.())return;if(!this.isSoloWindow&&this.detachedSessions?.has(this.activeSessionId)){this.showToast("This session is sized by its own window","warning");return}const t=this.getTerminalDimensions();if(!t){this.showToast("Could not determine terminal size","error");return}try{await this.sendResize(this.activeSessionId,{force:!0}),this.showToast(`Terminal restored to ${t.cols}x${t.rows}`,"success")}catch(i){console.error("Failed to restore terminal size:",i),this.showToast("Failed to restore terminal size","error")}},sendPendingCtrlL(e){},shouldCopyTerminalSelectionFromShortcut(e){if(!e||e.type!=="keydown"||!e.ctrlKey&&!e.metaKey&&!e.altKey)return!1;const i=typeof this.getShortcutRegistry=="function"&&typeof this.matchesShortcutEvent=="function"?this.getShortcutRegistry().find(s=>s.id==="copy-selection"):null;return i?!i.disabled&&this.matchesShortcutEvent(e,i):!e.altKey&&(e.key||"").toLowerCase()==="c"},cleanedTerminalSelection(e,t={}){const i=t.terminal||this.terminal,s=e??(i?.hasSelection?.()?i.getSelection():"");if(!s)return"";if(i?._core?._selectionService?._activeSelectionMode===3)return s;const n=window.CodemanCopySelection?.clean;if(!n)return s;const o=this._normalisedSelectionRange(i);return n(s,{margin:this._cliGutterColumns(t.sessionId),firstLinePartial:!!o&&o.start.x>0})},_normalisedSelectionRange(e){const t=(e??this.terminal)?.getSelectionPosition?.();if(!t?.start||!t?.end)return null;const{start:i,end:s}=t;return s.y<i.y||s.y===i.y&&s.x<i.x?{start:s,end:i}:{start:i,end:s}},_cliGutterColumns(e){if(!this._copyStripMarginEnabled())return 0;const t=window.__codemanTranscriptGutter;if(!t||typeof t!="object")return 0;const i=this.sessions?.get(e??this.activeSessionId)?.mode,s=i?t[i]:0;return Number.isInteger(s)&&s>0?s:0},_installOsc52Clipboard(e,t=()=>this._isLoadingBuffer){e.parser?.registerOscHandler?.(52,i=>{const s=i.indexOf(";"),n=s>=0?i.slice(s+1):i;if(!n||n==="?"||t())return!0;let o;try{const c=Uint8Array.from(atob(n),h=>h.charCodeAt(0));o=new TextDecoder().decode(c)}catch{return!0}if(!o)return!0;const l=Date.now();if(this._lastOsc52?.text===o&&l-this._lastOsc52.at<OSC52_DEDUPE_MS)return!0;this._lastOsc52={text:o,at:l};const a=document.activeElement;return this._copyText(o).then(c=>{if(a&&a!==document.activeElement&&a.isConnected)try{a.focus()}catch{}c?this.showToast(`Copied to clipboard (${o.length} chars)`,"success"):document.hasFocus?.()&&this._showClipboardFallback?.(o)}),!0})},async copyTerminalSelection(e,t={}){const i=t.terminal||this.terminal,s=this.cleanedTerminalSelection(e,t);if(!s.trim())return i?.clearSelection?.(),this.showToast("Nothing to copy","warning"),!1;const n=await this._copyText(s);return n?(i.clearSelection?.(),this.showToast("Copied to clipboard","success")):this.showToast("Failed to copy","error"),i.focus(),n},_copyStripMarginEnabled(){try{return this.loadAppSettingsFromStorage?.()?.copyStripMargin!==!1}catch{return!0}},_autoCopySelectionEnabled(){try{return this.loadAppSettingsFromStorage?.()?.autoCopySelection===!0}catch{return!1}},async _flushAutoCopySelection(){const e=window.CodemanAutoCopy?.decide;if(!e||!this.terminal)return;const t=this._autoCopySelectionEnabled(),i=t?this.cleanedTerminalSelection():"",s=e({enabled:t,text:i,lastCopied:this._autoCopyLastText,pending:!!this._autoCopyPending});if(this._autoCopyPending=!1,s==="skip")return;if(s==="too-large"){this._autoCopyNotify("Selection too large to copy automatically. Press Ctrl+C.","warning");return}this._autoCopyLastText=i;const n=document.activeElement,o=await this._copyText(i);if(n&&n!==document.activeElement&&n.isConnected&&typeof n.focus=="function")try{n.focus()}catch{}if(!o){this._autoCopyLastText="",this._autoCopyNotify("Auto Copy failed: the browser blocked clipboard access","error");return}this._autoCopyHintShown||(this._autoCopyHintShown=!0,this.showToast("Auto Copy: selection copied","success"))},_autoCopyNotify(e,t){const i=Date.now(),s=this._autoCopyNotifiedAt;s!==void 0&&i-s<1e4||(this._autoCopyNotifiedAt=i,this.showToast(e,t))},_syncMobileHelperTextareaToCursor(){if(!(!MobileDetection.isTouchDevice()||!this.terminal?.element))try{const e=this.terminal.element,t=this.terminal.element.querySelector(".xterm-cursor"),i=this.terminal.element.querySelector(".xterm-screen");if(!(e instanceof HTMLElement)||!(t instanceof HTMLElement)||!(i instanceof HTMLElement))return;const s=t.getBoundingClientRect(),n=i.getBoundingClientRect();if(!s.width&&!s.height)return;const o=Math.max(0,Math.round(s.left-n.left)),l=Math.max(0,Math.round(s.top-n.top));e.style.setProperty("--xterm-helper-left",`${o}px`),e.style.setProperty("--xterm-helper-top",`${l}px`)}catch{}},_isMobileTerminalInputFocused(){const e=document.activeElement;return e===this.terminal?.textarea||e?.classList?.contains("xterm-helper-textarea")||e?.id==="cjkInput"},_classifyMobileTerminalTap(e,t){if(!this._terminalViewportAtBottom())return"history";const i=this._clientPointToCell(e,t);if(!i||!this.terminal)return"input";const s=this.terminal.modes?.mouseTrackingMode;if(!(!!s&&s!=="none")&&!this._shouldReportMouseToCli())return"input";const o=this.terminal.buffer?.active;if(!o?.getLine)return"input";const l=Math.max(1,this.terminal.rows||1),a=[],c=[];let h=!1;for(let _=0;_<l;_++){const I=o.getLine(o.viewportY+_),E=I?.translateToString?.(!0)||"";a.push(E),c.push(!!I?.isWrapped),E.trim()&&(h=!0)}if(!h)return"input";const f=Math.max(0,Math.min(l-1,o.cursorY||0)),d=this.sessions?.get(this.activeSessionId)?.mode||"claude";let y=-1,p=!1;if(d==="opencode")a[f]?.includes("\u2503")&&(y=f);else for(let _=l-1;_>=0;_--){const I=a[_].match(/^\s*[❯›]/);if(!I)continue;const E=a[_].slice(I[0].length).trim(),w=a.some((k,R)=>R!==_&&/^\s+\d+[.)]\s/.test(k));if(/^\d+[.)]\s/.test(E)&&w){p=!0;break}y=_;break}const u=i.row-1;let T=u;for(;T>0&&c[T];)T--;let r=u;for(;r+1<l&&c[r+1];)r++;const m=a.slice(T,r+1).join("");if(d==="claude"&&/\b(?:esc to interrupt|background)\b/i.test(m)||p)return"content";if(y>=0){const _=f>=y?f:y;if(u>=y&&u<=_)return"input"}else if(u===f||u>=Math.max(0,l-window.CodemanTerminalInput.TUI_PROMPT_DEFAULT_ROWS_FROM_BOTTOM))return"input";return"content"},_blurMobileTerminalInput(){const e=document.activeElement;(e===this.terminal?.textarea||e?.classList?.contains("xterm-helper-textarea")||e?.id==="cjkInput")&&e.blur?.()},_installMobileKeyboardDismiss(){if(this._mobileKeyboardDismissHandler)return;let e=0,t=0,i=!1;this._mobileKeyboardDismissStart=s=>{if(s.touches.length!==1){i=!0;return}e=s.touches[0].clientX,t=s.touches[0].clientY,i=!1},this._mobileKeyboardDismissMove=s=>{if(i||!s.touches.length)return;const n=s.touches[0].clientX-e,o=s.touches[0].clientY-t,l=window.CodemanTerminalInput.MOBILE_KEYBOARD_DISMISS_TAP_SLOP;(Math.abs(n)>l||Math.abs(o)>l)&&(i=!0)},this._mobileKeyboardDismissHandler=s=>{if(i||!this._isMobileTerminalInputFocused())return;const n=s.target;!n||typeof n.closest!="function"||n.closest("#terminalContainer")||n.closest(window.CodemanTerminalInput.MOBILE_KEYBOARD_DISMISS_EXEMPT_SELECTOR)||this._blurMobileTerminalInput()},document.addEventListener("touchstart",this._mobileKeyboardDismissStart,{passive:!0}),document.addEventListener("touchmove",this._mobileKeyboardDismissMove,{passive:!0}),document.addEventListener("touchend",this._mobileKeyboardDismissHandler,{passive:!0})},_isActionableMobileTerminalTap(e,t){const i=this._clientPointToCell(e,t),s=this.terminal?.buffer?.active;if(!i||!s?.getLine)return!1;const n=Math.max(1,this.terminal.rows||1),o=[],l=[];for(let r=0;r<n;r++){const m=s.getLine(s.viewportY+r);o.push(m?.translateToString?.(!0)||""),l.push(!!m?.isWrapped)}const a=i.row-1;let c=a;for(;c>0&&l[c];)c--;let h=a;for(;h+1<n&&l[h+1];)h++;const f=o.slice(c,h+1).join(""),d=/\b(?:ctrl\+\w+|shift\+\w+|esc|enter|tab|tap)\s+to\s+(?:expand|collapse|view|open|interrupt|see)\b/i,y=Math.max(0,c-1),p=Math.min(n-1,h+1);for(let r=y;r<=p;r++)if(d.test(o[r]))return!0;const u=o.some(r=>/^\s*[❯›]\s+\d+[.)]\s/.test(r)),T=o.some(r=>/^\s+\d+[.)]\s/.test(r));return u&&T&&/^\s*(?:[❯›]\s*)?\d+[.)]\s/.test(f)},_focusMobileTerminalInput(){this._syncMobileHelperTextareaToCursor();const e=document.getElementById("cjkInput");e?.classList.contains("cjk-input-visible")?e.focus():this.terminal?.focus()},_handleMobileTerminalTap(e,t,i=null){if(!e||!this.terminal)return null;if(this._touchSelectionActive)return this._extendTouchSelection(e.clientX,e.clientY),"select";const s=i??this._classifyMobileTerminalTap(e.clientX,e.clientY),n=this._isActionableMobileTerminalTap(e.clientX,e.clientY);if(!n&&!this._tapIsOnCaretLine(e.clientX,e.clientY)&&this._activateTerminalLinkAtPoint(e.clientX,e.clientY))return"link";if(s==="history")return this._focusMobileTerminalInput(),s;const o=this.terminal.modes?.mouseTrackingMode,l=!!o&&o!=="none",a=s==="content"||t;return a&&l?this._dispatchSyntheticTerminalClick(e.clientX,e.clientY):a&&this._shouldReportMouseToCli()&&this._sendSyntheticSgrTap(e.clientX,e.clientY),s==="content"&&n?this._blurMobileTerminalInput():s==="content"&&t?this._blurMobileTerminalInput():this._focusMobileTerminalInput(),s},_dispatchSyntheticTerminalClick(e,t){const i=this.terminal?.element;if(!i||!Number.isFinite(e)||!Number.isFinite(t))return;const s={bubbles:!0,cancelable:!0,view:window,clientX:e,clientY:t,screenX:e,screenY:t,button:0,detail:1};try{i.dispatchEvent(new MouseEvent("mousedown",{...s,buttons:1})),i.dispatchEvent(new MouseEvent("mouseup",{...s,buttons:0}))}catch{}},_shouldReportMouseToCli(e=this.activeSessionId){return this.sessions?.get(e)?.cliMouseTracking===!0},_terminalViewportAtBottom(e=this.terminal){const t=e?.buffer?.active;return!t||t.viewportY>=t.baseY},_clientPointToCell(e,t,i=this.terminal){if(!i||!Number.isFinite(e)||!Number.isFinite(t))return null;const s=i.element?.querySelector(".xterm-screen"),n=i._core?._renderService?.dimensions?.css?.cell;if(!s||!n?.width||!n?.height)return null;const o=s.getBoundingClientRect(),l=Math.max(1,Math.min(i.cols,Math.floor((e-o.left)/n.width)+1)),a=Math.max(1,Math.min(i.rows,Math.floor((t-o.top)/n.height)+1));return{col:l,row:a}},_sendSyntheticSgrTap(e,t,i={}){const s=i.sessionId||this.activeSessionId,n=i.terminal||this.terminal;if(!s||!this._terminalViewportAtBottom(n))return;const o=this._clientPointToCell(e,t,n);if(!o)return;const l=`\x1B[<0;${o.col};${o.row}M\x1B[<0;${o.col};${o.row}m`;i.ephemeral?this._sendInputEphemeral(s,l):this._sendInputAsync(s,l)},_cliVersionAtLeast(e,t){if(typeof e!="string")return!1;const i=e.trim().replace(/^v/,"").split(".").map(Number);if(i.length!==3||i.some(n=>!Number.isFinite(n)))return!1;const s=t.split(".").map(Number);for(let n=0;n<3;n++)if(i[n]!==s[n])return i[n]>s[n];return!0},_wheelScrollLinesFloat(e){return window.CodemanTerminalInput.wheelDeltaLines(e,this.terminal?.rows)},_shouldForwardTouchToApp(){if(this.loadAppSettingsFromStorage?.()?.terminalWheelLocalScrollback)return!1;const e=this.terminal?.modes?.mouseTrackingMode,t=this.terminal?._core?.coreMouseService?.activeEncoding==="SGR";return!!(e&&e!=="none"&&e!=="x10"&&t)||this._shouldForwardWheelToApp({shiftKey:!1})},_shouldForwardWheelToApp(e,t={}){if(e.shiftKey||this.loadAppSettingsFromStorage?.()?.terminalWheelLocalScrollback)return!1;const i=(t.terminal||this.terminal)?.modes?.mouseTrackingMode;if(i&&i!=="none")return!1;const s=this.sessions?.get(t.sessionId||this.activeSessionId),n=s?.mode||"claude";return n==="copilot"?s?.cliMouseTracking===!0:!(n!=="claude"&&n!=="codex"||n==="claude"&&!this._cliVersionAtLeast(s?.cliVersion,"2.1.187")||s?.cliMouseTracking!==!0)},_sendSyntheticSgrWheel(e,t,i){if(!this.activeSessionId||!i)return;const s=this._clientPointToCell(e,t);if(!s)return;const n=window.CodemanTerminalInput,o=this._wheelTickSession===this.activeSessionId?this._wheelTickGesture:null;o?.dir&&o.dir!==Math.sign(i)&&(this._wheelSgrQueue="");const l=n.wheelTicksForGesture(o,i,performance.now());this._wheelTickSession=this.activeSessionId,this._wheelTickGesture=l.state,this._queueScrollBytes(n.sgrWheelReports(l.ticks,s))},_queueScrollBytes(e){if(!e||!this.activeSessionId)return;const t=e.startsWith("\x1B[<")&&(this._wheelNativeStartSession!==this.activeSessionId||this._wheelNativeStartGeneration!==this._selectGeneration),i=!t&&this._wheelQueueSession===this.activeSessionId&&this._wheelSgrQueue||"";if(this._wheelQueueSession=this.activeSessionId,this._wheelSgrQueue=window.CodemanTerminalInput.coalesceScrollBytes(i,e),t){this._wheelNativeStartSession=this.activeSessionId,this._wheelNativeStartGeneration=this._selectGeneration,this._wheelSgrFlushTimer&&clearTimeout(this._wheelSgrFlushTimer),this._flushWheelSgrQueue();return}this._wheelSgrFlushTimer||(this._wheelSgrFlushTimer=setTimeout(()=>this._flushWheelSgrQueue(),40))},_localScrollbackIsHollow(e={}){const t=this.sessions?.get(e.sessionId||this.activeSessionId)?.mode||"claude",i=window.__codemanTranscriptPageKeys;if(!Array.isArray(i)||!i.includes(t))return!1;const s=(e.terminal||this.terminal)?.buffer?.active;return!s||s.type==="alternate"?!1:((Number.isFinite(e.localRows)?e.localRows:s.baseY)||0)===0},_maybePageCliTranscript(e,t){if(!t||e?.shiftKey||!this.activeSessionId)return!1;if(e?.ctrlKey||Math.abs(e?.deltaX||0)>Math.abs(e?.deltaY||0))return this._localScrollbackIsHollow();if(!this._localScrollbackIsHollow())return!1;if(this.tabAlerts?.get(this.activeSessionId)==="action")return this._logScrollRouting("page-keys-dialog-open"),!0;if(this._codexMenuOpen())return this._logScrollRouting("page-keys-menu-open"),!0;if((this._paneHistoryLines?.get(this.activeSessionId)??0)>0)return this._pageKeyGesture=null,this._wheelSgrQueue="",!1;this._pageKeySession!==this.activeSessionId&&(this._pageKeySession=this.activeSessionId,this._pageKeyGesture=null),this._pageKeyGesture?.dir&&this._pageKeyGesture.dir!==Math.sign(t)&&(this._wheelSgrQueue="");const i=window.CodemanTerminalInput.pageKeysForGesture(this._pageKeyGesture,e,t,this.terminal?.rows,performance.now());return this._pageKeyGesture=i.state,i.keys&&this._queueScrollBytes(i.keys),this._logScrollRouting("page-keys"),!0},_codexMenuOpen(e={}){return this.sessions?.get(e.sessionId||this.activeSessionId)?.mode!=="codex"?!1:window.CodemanTerminalInput.isCodexSelectionMenu(e.terminal||this.terminal)},_logScrollRouting(e){const t=this.activeSessionId||"(none)",i=this.sessions?.get(t),s=!!this.loadAppSettingsFromStorage?.()?.terminalWheelLocalScrollback,n=this.terminal?.modes?.mouseTrackingMode||"none",o=this.terminal?._core?.coreMouseService?.activeEncoding||"unknown",l=i?.cliMouseTracking===!0,a=this.terminal?.buffer?.active?.baseY??-1,c=this._paneHistoryLines?.get(t),h=`${e}|${i?.mode}|${i?.cliVersion}|${s}|${n}|${o}|${l}|${a>0}|${(c??0)>0}`;this._scrollRoutingLogged||(this._scrollRoutingLogged=new Map),this._scrollRoutingLogged.get(t)!==h&&(this._scrollRoutingLogged.set(t,h),console.log(`[scroll] ${t} \u2192 ${e} (mode=${i?.mode||"?"}, cliVersion=${i?.cliVersion||"unknown"}, localScrollbackOptOut=${s}, mouseTracking=${n}, mouseEncoding=${o}, cliMouseTracking=${l}, localScrollbackRows=${a}, paneHistoryLines=${c??"unknown"})`))},_flushWheelSgrQueue(){this._wheelSgrFlushTimer=null;const e=this._wheelSgrQueue;this._wheelSgrQueue="",e&&this.activeSessionId&&this._wheelQueueSession===this.activeSessionId&&this._sendInputEphemeral(this.activeSessionId,e)},_handleDesktopTerminalClick(e,t={}){const i=t.terminal||this.terminal;if(!i||!e?.isTrusted||e.button!==0||e.detail!==1||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey)return;const s=i.modes?.mouseTrackingMode;s&&s!=="none"||this._shouldReportMouseToCli(t.sessionId)&&(i.hasSelection?.()||(t.linkHovered??this._linkHovered)||performance.now()<=(this._trustedTapMouseSuppressUntil||0)||e.target?.closest?.(".xterm-screen")&&this._sendSyntheticSgrTap(e.clientX,e.clientY,t))},_installShiftDragSelection(){const e=this.terminal?.element;!e||e._codemanShiftDragInstalled||(e._codemanShiftDragInstalled=!0,e.addEventListener("mousedown",t=>{if(!t.isTrusted||t.button!==0||!t.shiftKey||t.altKey||t.ctrlKey||t.metaKey||this.terminal?.hasSelection?.())return;const i=this._clientPointToCell(t.clientX,t.clientY);if(!i)return;const s=this.terminal.buffer?.active?.viewportY??0;this.terminal.select(i.col-1,i.row-1+s,0)},!0))},_installMobileTapMouseGuard(){const e=this.terminal?.element;if(!e||e._codemanTapMouseGuardInstalled||typeof MobileDetection<"u"&&MobileDetection.isTouchDevice&&!MobileDetection.isTouchDevice())return;e._codemanTapMouseGuardInstalled=!0;const t=i=>{const s=this._trustedTapMouseSuppressUntil||0;!i.isTrusted||performance.now()>s||(i.preventDefault(),i.stopImmediatePropagation())};e.addEventListener("mousedown",t,!0),e.addEventListener("mouseup",t,!0)},_suppressTrustedTapMouseEvents(){const e=window.CodemanTerminalInput?.TOUCH_COMPAT_MOUSE_SUPPRESS_MS||450;this._trustedTapMouseSuppressUntil=performance.now()+e},increaseFontSize(){if(this._tilesOwnTerminal?.()){this.setTileFontSize(Math.min(this._tileGridFontSize()+2,24));return}const e=this.terminal.options.fontSize||14;this.setFontSize(Math.min(e+2,24))},decreaseFontSize(){if(this._tilesOwnTerminal?.()){this.setTileFontSize(Math.max(this._tileGridFontSize()-2,10));return}const e=this.terminal.options.fontSize||14;this.setFontSize(Math.max(e-2,10))},setFontSize(e){this.terminal.options.fontSize=e,document.getElementById("fontSizeDisplay").textContent=e,this._refitAfterCellSizeChange(),localStorage.setItem("codeman-font-size",e),this._localEchoOverlay?.refreshFont(),this._predictiveEcho?.refreshFont(),this._forEachTile?.(t=>{t.terminal.options.fontSize=e,t.fit()},{grid:!1})},applyTerminalFontFamily(e){const t=window.CodemanTerminalFont.resolve(e);!this.terminal||this.terminal.options.fontFamily===t||(this.terminal.options.fontFamily=t,this._terminalFontReady=this._awaitTerminalFont().then(()=>{this.terminal?.options?.fontFamily===t&&this._refitAfterCellSizeChange()}),this._refitAfterCellSizeChange(),this._localEchoOverlay?.refreshFont(),this._predictiveEcho?.refreshFont(),this._forEachTile?.(i=>{i.terminal.options.fontFamily=t,i.fit()}))},applyTerminalFontWeights(e){const{fontWeight:t,fontWeightBold:i}=window.CodemanTerminalFont.resolveWeights(e);if(this.terminal&&!(this.terminal.options.fontWeight===t&&this.terminal.options.fontWeightBold===i)){this.terminal.options.fontWeight=t,this.terminal.options.fontWeightBold=i,this._terminalFontReady=this._awaitTerminalFont().then(()=>{this.terminal?.options?.fontWeight===t&&this._refitAfterCellSizeChange()}),this._refitAfterCellSizeChange(),this._localEchoOverlay?.refreshFont(),this._predictiveEcho?.refreshFont();for(const[,s]of this.teammateTerminals||[])if(s?.terminal){s.terminal.options.fontWeight=t,s.terminal.options.fontWeightBold=i;try{s.fitAddon?.fit()}catch{}}this._forEachTile?.(s=>{s.terminal.options.fontWeight=t,s.terminal.options.fontWeightBold=i,s.fit()})}},loadFontSize(){const e=localStorage.getItem("codeman-font-size");if(e){const t=parseInt(e,10);t>=10&&t<=24&&(this.terminal.options.fontSize=t,document.getElementById("fontSizeDisplay").textContent=t)}},async _awaitTerminalFont(){try{if(typeof document>"u"||!document.fonts?.load)return;const e=this.terminal?.options?.fontSize||14,t=String(this.terminal?.options?.fontFamily||"").split(",").map(s=>s.trim().replace(/^["']|["']$/g,"")).filter(Boolean).filter(s=>!TERMINAL_FONT_UNMEASURED.has(s.toLowerCase())),i=Promise.all(t.map(s=>document.fonts.load(`${e}px "${s}"`).catch(()=>{}))).then(()=>document.fonts.ready);await Promise.race([i,new Promise(s=>setTimeout(s,TERMINAL_FONT_WAIT_MS))])}catch{}try{this.terminal?._core?._charSizeService?.measure()}catch{}},getTerminalDimensions(){try{const e=window.CodemanTerminalGeometry.clampTerminalDimensions(this.fitAddon?.proposeDimensions()),t=this._keyboardHeldRowsActive?.();return e&&t&&(e.rows=Math.max(e.rows,t)),e}catch{return null}},_keyboardHeldRowsActive(){return this._keyboardHeldRows>0&&typeof KeyboardHandler<"u"&&KeyboardHandler.keyboardVisible?this._keyboardHeldRows:0},_keyboardHoldEligible(e=this.activeSessionId){if(this.loadAppSettingsFromStorage?.()?.keyboardHoldsRows===!1)return!1;const t=e?this.sessions?.get(e):null;if(!t||t.remote||t.docker||t.cliMouseTracking)return!1;const i=window.__codemanKeyboardHoldModes;return Array.isArray(i)&&i.includes(t.mode||"claude")},_reconcileKeyboardHold({resize:e=!0}={}){!this._keyboardHeldRows||this._keyboardHoldEligible()||(this._releaseKeyboardHold(),e&&this.activeSessionId&&this.sendResize(this.activeSessionId)?.catch?.(()=>{}))},_releaseKeyboardHold(){return this._keyboardHeldRows?(this._keyboardHeldRows=0,this._applyKeyboardClip(),!0):!1},_applyKeyboardClip(){const e=this.terminal?.element?.parentElement;if(!e)return;const t=this._keyboardHeldRowsActive()?this.terminal.rows:0,i=t?this.terminal._core?._renderService?.dimensions?.css?.cell?.height:0,s=t?e.clientHeight:0;let n=0;if(i&&s){const o=this.terminal.buffer.active,l=o.viewportY>=o.baseY;let a=-1;if(l){for(let c=t-1;c>=0;c--)if(o.getLine(o.baseY+c)?.translateToString(!0).trim()){a=c;break}}n=window.CodemanTerminalGeometry.keyboardClipPx({rows:t,cellHeight:i,viewHeight:s,cursorRow:o.cursorY,lastContentRow:a,following:l,viewportY:o.viewportY,baseY:o.baseY})}n!==(this._keyboardClipPx||0)&&(this._keyboardClipPx=n,n?e.style.setProperty("--kb-clip",`${n}px`):e.style.removeProperty("--kb-clip")),this._localEchoOverlay?.setRowLimit?.(i&&s?window.CodemanTerminalGeometry.keyboardVisibleRowLimit(n,s,i):null)},syncTerminalGeometry(){if(!this.fitAddon||!this.terminal)return null;try{this._keyboardHeldRowsActive?.()||this.fitAddon.fit()}catch{}const e=this.getTerminalDimensions();return!e||!this._resizeTerminalTo(e)?null:(this._scheduleOverflowAffordanceSync(),e)},_geometryForResizeRequest(){if(!this._paneWidthRefused)return this.syncTerminalGeometry();const e=this.getTerminalDimensions();return!e||!this.terminal||!this._resizeTerminalTo({cols:this.terminal.cols,rows:e.rows})?null:(this._scheduleOverflowAffordanceSync(),e)},_refitAfterCellSizeChange(){if(this.activeSessionId){this.sendResize(this.activeSessionId)?.catch?.(()=>{});return}this.syncTerminalGeometry()},_resizeTerminalTo(e){if(!this.terminal||!e)return null;if(this.terminal.cols===e.cols&&this.terminal.rows===e.rows)return e;try{return this.terminal.resize(e.cols,e.rows),e}catch{return null}},async sendResize(e,t={}){if(!this.isSoloWindow&&this.detachedSessions?.has(e)||this._tilesOwnTerminal?.())return!1;const i=this._geometryForResizeRequest();if(!i)return!1;const s=this._lastResizeDims,n=!s||s.cols!==i.cols||s.rows!==i.rows;this._lastResizeDims={cols:i.cols,rows:i.rows};const o=typeof MobileDetection<"u"&&MobileDetection.getDeviceType?MobileDetection.getDeviceType():window.innerWidth<600?"mobile":window.innerWidth<768?"tablet":"desktop";if(!t.forceHttp&&this._wsReady&&this._wsSessionId===e)try{const c={t:"z",c:i.cols,r:i.rows,v:o};return t.force&&(c.f=!0),this._ws.send(JSON.stringify(c)),n}catch{}const l={...i,viewportType:o};t.force&&(l.force=!0);const a=await fetch(`/api/sessions/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});try{const c=(await a.json())?.data??{};this._onPtyGeometryReport(e,c.cols,c.rows)}catch{}return n},_onPtyGeometryReport(e,t,i){if(!this.terminal||e!==this.activeSessionId)return;const s={cols:this.terminal.cols,rows:this.terminal.rows},{adopt:n}=window.CodemanTerminalGeometry.reconcilePtyGeometry(s,{cols:t,rows:i});n&&this._resizeTerminalTo({cols:t,rows:s.rows})&&(this._lastResizeDims={cols:t,rows:s.rows});const o=this.getTerminalDimensions();this._paneWidthRefused=!!o&&Number.isFinite(t)&&t!==o.cols,this._scheduleOverflowAffordanceSync()},_scheduleOverflowAffordanceSync(){if(typeof requestAnimationFrame!="function"){this._syncTerminalOverflowAffordance();return}this._overflowAffordanceFrame||(this._overflowAffordanceFrame=requestAnimationFrame(()=>{this._overflowAffordanceFrame=null,this._syncTerminalOverflowAffordance()}))},_syncTerminalOverflowAffordance(){let e=null,t=!1;try{e=document.getElementById("terminalContainer");const i=e?.querySelector(".xterm-screen");e&&i&&(t=i.getBoundingClientRect().width-e.clientWidth>1)}catch{}if(e?.classList.toggle("term-overflows-x",t),!t||!this._paneWidthRefused){this._paneOwnedElsewhere=!1;return}this._notePaneOwnedElsewhere()},_notePaneOwnedElsewhere(){this._paneOwnedElsewhere||(this._paneOwnedElsewhere=!0,this.showToast("Another device is setting the width \u2014 scroll sideways","info"))},async sendInput(e){!this.activeSessionId||!e||this._sendInputAsync(this.activeSessionId,e,{useMux:!0})},toggleDirInput(){const e=document.querySelector("#dirDisplay").parentElement,t=document.getElementById("dirInput");t.classList.contains("hidden")&&(t.classList.remove("hidden"),e.style.display="none",t.focus())},hideDirInput(){const e=document.querySelector("#dirDisplay").parentElement,t=document.getElementById("dirInput");setTimeout(()=>{t.classList.add("hidden"),e.style.display="";const i=t.value.trim();document.getElementById("dirDisplay").textContent=i||"No directory"},100)},applyTerminalSkin(e){const t={...window.CODEMAN_XTERM_THEMES[e]||window.CODEMAN_XTERM_THEMES["daylight-blue"]},i=window.codemanCurrentSkinIsLight(e)?4.5:1;if(this.terminal){this.terminal.options.minimumContrastRatio=i,this.terminal.options.theme=t,this._localEchoOverlay?.refreshFont(),this._predictiveEcho?.refreshFont();try{this.terminal.refresh(0,this.terminal.rows-1)}catch{}}if(this.teammateTerminals){for(const[,s]of this.teammateTerminals)if(s&&s.terminal){s.terminal.options.minimumContrastRatio=i,s.terminal.options.theme={...t};try{s.terminal.refresh(0,s.terminal.rows-1)}catch{}}}this._forEachTile?.(s=>{s.terminal.options.minimumContrastRatio=i,s.terminal.options.theme={...t};try{s.terminal.refresh(0,s.terminal.rows-1)}catch{}})}}),(function(e){const s={session:"Sessions",event:"Events",file:"Files"};function n(o){if(!Number.isFinite(o))return"";const l=new Date(o);return l.toLocaleDateString("en",{month:"short",day:"numeric"})+" "+l.toLocaleTimeString("en",{hour:"2-digit",minute:"2-digit",hour12:!1})}e.CodemanSearch={SEARCH_DEBOUNCE_MS:250,SEARCH_LIMIT:60,SOURCE_LABELS:s,formatSearchTime:n}})(window),Object.assign(CodemanApp.prototype,{initSearchPanel(){const e=document.getElementById("searchInput");if(!e||this._searchPanelWired){this._searchPanelWired&&this._populateSearchCaseFilter();return}this._searchPanelWired=!0,this._searchTypes=new Set(["session","event","file"]),this._searchSecondary={caseLabel:"",status:"",days:""},this._searchDebounceTimer=null,this._searchSeq=0,this._searchLastData=null;const t=document.getElementById("searchClearBtn"),i=document.getElementById("searchResults");e.addEventListener("input",()=>{t&&(t.hidden=e.value.length===0),this._scheduleSearch()}),e.addEventListener("keydown",l=>{l.key==="Escape"&&e.value&&(l.stopPropagation(),this._clearSearch())}),t&&t.addEventListener("click",()=>this._clearSearch()),document.querySelectorAll("#searchFilters .search-filter-chip").forEach(l=>{l.addEventListener("click",()=>{const a=l.dataset.typeFilter;this._searchTypes.has(a)&&this._searchTypes.size===1||(this._searchTypes.has(a)?(this._searchTypes.delete(a),l.classList.remove("active")):(this._searchTypes.add(a),l.classList.add("active")),this._runSearch())})});const s=document.getElementById("searchCaseFilter"),n=document.getElementById("searchStatusFilter"),o=document.getElementById("searchDateFilter");s&&s.addEventListener("change",()=>{this._searchSecondary.caseLabel=s.value,this._renderSearch(this._searchLastData)}),n&&n.addEventListener("change",()=>{this._searchSecondary.status=n.value,this._renderSearch(this._searchLastData)}),o&&o.addEventListener("change",()=>{this._searchSecondary.days=o.value,this._renderSearch(this._searchLastData)}),this._populateSearchCaseFilter(),i&&(i.hidden=!0)},_populateSearchCaseFilter(){const e=document.getElementById("searchCaseFilter");if(!e)return;const t=Array.isArray(this.cases)?this.cases:[],i=Array.from(new Set(t.map(o=>o&&o.name).filter(Boolean))).sort(),s=e.value;e.innerHTML="";const n=document.createElement("option");n.value="",n.textContent="All cases",e.appendChild(n);for(const o of i){const l=document.createElement("option");l.value=o,l.textContent="#"+o,e.appendChild(l)}s&&i.includes(s)&&(e.value=s)},_scheduleSearch(){clearTimeout(this._searchDebounceTimer),this._searchDebounceTimer=setTimeout(()=>this._runSearch(),window.CodemanSearch.SEARCH_DEBOUNCE_MS)},_clearSearch(){const e=document.getElementById("searchInput"),t=document.getElementById("searchClearBtn");e&&(e.value=""),t&&(t.hidden=!0),this._searchLastData=null,this._renderSearch(null)},async _runSearch(){const e=document.getElementById("searchInput");if(!e)return;const t=e.value.trim();if(t.length===0){this._searchLastData=null,this._renderSearch(null);return}const i=Array.from(this._searchTypes),s=new URLSearchParams;s.set("q",t.slice(0,200)),i.length>0&&i.length<3&&s.set("types",i.join(",")),s.set("limit",String(window.CodemanSearch.SEARCH_LIMIT));const n=++this._searchSeq,o=await this._apiJson("/api/search?"+s.toString());n===this._searchSeq&&(o?this._searchLastData=o:this._searchLastData={query:t,groups:[],totalResults:0,truncated:!1,_error:!0},this._renderSearch(this._searchLastData))},_applySecondaryFilters(e){const{caseLabel:t,status:i,days:s}=this._searchSecondary;let n=e;if(t){const o="#"+t;n=n.filter(l=>(l.sessionName||"").includes(o)||l.sessionName===t)}if(i){const o=new Set((this.sessionOrder||[]).concat(Object.keys(this.sessions||{})));n=n.filter(l=>{const a=o.has(l.sessionId);return i==="active"?a:!a})}if(s){const o=Date.now()-Number(s)*24*60*60*1e3;n=n.filter(l=>Number.isFinite(l.timestamp)&&l.timestamp>=o)}return n},_renderSearch(e){const t=document.getElementById("searchResults"),i=document.getElementById("historyHeader")||document.getElementById("historyTitle"),s=document.getElementById("historyList");if(!t)return;const n=!!e;if(i&&(i.style.display=n?"none":""),s&&(s.style.display=n?"none":""),t.innerHTML="",!e){t.hidden=!0;return}if(t.hidden=!1,e._error){const a=document.createElement("div");a.className="search-empty",a.textContent="Search unavailable \u2014 check the query and try again.",t.appendChild(a);return}const o=(e.groups||[]).map(a=>({type:a.type,results:this._applySecondaryFilters(a.results||[])})).filter(a=>a.results.length>0);if(o.reduce((a,c)=>a+c.results.length,0)===0){const a=document.createElement("div");a.className="search-empty",a.textContent='No results for "'+(e.query||"")+'"',t.appendChild(a);return}for(const a of o){const c=document.createElement("div");c.className="search-group-header";const h=document.createElement("span");h.className="search-group-label",h.textContent=window.CodemanSearch.SOURCE_LABELS[a.type]||a.type;const f=document.createElement("span");f.className="search-group-count",f.textContent=String(a.results.length),c.append(h,f),t.appendChild(c);for(const d of a.results)t.appendChild(this._buildSearchResultCard(d))}if(e.truncated){const a=document.createElement("div");a.className="search-truncated",a.textContent="Showing the top matches \u2014 refine your search to narrow results.",t.appendChild(a)}},_buildSearchResultCard(e){const t=document.createElement("div");t.className="search-result-card",t.dataset.type=e.type,t.tabIndex=0,t.setAttribute("role","button");const i=document.createElement("div");i.className="search-result-top";const s=e.jumpTo&&e.jumpTo.kind==="resume-session",n=document.createElement("span");n.className="search-result-badge search-badge-"+e.type+(s?" search-badge-past":""),n.textContent=s?"Resume":(window.CodemanSearch.SOURCE_LABELS[e.type]||e.type).replace(/s$/,"");const o=document.createElement("span");o.className="search-result-name",o.textContent=e.sessionName||e.sessionId||"(session)";const l=document.createElement("span");l.className="search-result-time",l.textContent=window.CodemanSearch.formatSearchTime(e.timestamp),i.append(n,o,l);const a=document.createElement("div");a.className="search-result-snippet",a.textContent=e.snippet||"",t.append(i,a);const c=()=>this._jumpToSearchResult(e);return t.addEventListener("click",c),t.addEventListener("keydown",h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),c())}),t},_jumpToSearchResult(e){const t=e&&e.jumpTo;if(t){if(t.kind==="resume-session"){this.resumeHistorySession(t.claudeSessionId||t.sessionId,t.workingDir||"",e.sessionName);return}typeof this.hideWelcome=="function"&&this.hideWelcome();try{t.kind==="run-summary"?this.openRunSummary(t.sessionId):t.kind==="file-preview"?this.openFilePreview(t.relativePath||"",t.sessionId,t.targetId||null):this.selectSession(t.sessionId)}catch(i){console.error("[search] jump failed",i)}}}});
Binary file
@@ -1,4 +1,4 @@
1
- "use strict";var XtermPredictiveEcho=(()=>{var p=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var P=(o,t)=>{for(var e in t)p(o,e,{get:t[e],enumerable:!0})},M=(o,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of S(t))!w.call(o,i)&&i!==e&&p(o,i,{get:()=>t[i],enumerable:!(n=T(t,i))||n.enumerable});return o};var R=o=>M(p({},"__esModule",{value:!0}),o);var k={};P(k,{PredictiveEchoAddon:()=>m});function _(o){let t=o,e=typeof devicePixelRatio=="number"&&devicePixelRatio>0?devicePixelRatio:1;if(t.dimensions?.css?.cell){let n=t.dimensions.css.cell.height;return{width:t.dimensions.css.cell.width,height:n,charTop:(t.dimensions?.device?.char?.top??0)/e,charHeight:(t.dimensions?.device?.char?.height??n*e)/e}}try{let n=t._core?._renderService?.dimensions;if(n?.css?.cell){let i=n.css.cell.height;return{width:n.css.cell.width,height:i,charTop:(n.device?.char?.top??0)/e,charHeight:(n.device?.char?.height??i*e)/e}}}catch{}return null}function b(o,t){if(o?.unicode?.getStringCellWidth)return o.unicode.getStringCellWidth(t);let e=t.codePointAt(0);return e!==void 0&&e>=4352&&(e<=4447||e>=11904&&e<=12350||e>=12352&&e<=13247||e>=13312&&e<=19903||e>=19968&&e<=42191||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65135||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=126976&&e<=130047||e>=131072&&e<=196607||e>=196608&&e<=262143)?2:1}function x(o,t,e){let n=document.createElement("span");n.style.cssText=`position:absolute;left:${e.col*e.dims.width}px;top:${e.row*e.dims.height}px;width:${e.width*e.dims.width}px;height:${e.dims.height+1}px;line-height:${e.dims.height}px;text-align:center;pointer-events:none;font-family:${e.font.fontFamily};font-size:${e.font.fontSize};font-weight:${e.font.fontWeight};`+(e.font.letterSpacing?`letter-spacing:${e.font.letterSpacing};`:"")+`color:${e.font.color};background-color:${e.font.backgroundColor};font-feature-settings:'liga' 0,'calt' 0;`+(e.underline?"text-decoration:underline;":""),n.textContent=e.char,t.set(e.seq,n),o.appendChild(n)}function h(o,t){let e=o.get(t);e&&(e.remove(),o.delete(t))}function y(o){for(let t of o.values())t.remove();o.clear()}var a={zIndex:7,underlinePredictions:!1,ttlMs:1e3,maxPending:32,cursorGraceMs:150,edgeMarginCells:4},v="#000000",C="#ffffff",m=class{_terminal=null;_container=null;_spans=new Map;_outstanding=[];_anchor=null;_cursorOffRowSince=null;_seq=0;_confirmedTotal=0;_droppedTotal=0;_ttlTimer=null;_anchorHold=!1;_reconcileScheduled=!1;_disposables=[];_predictWhen;_options;_font={fontFamily:"monospace",fontSize:"14px",fontWeight:"normal",color:C,backgroundColor:v,letterSpacing:""};constructor(t){this._options={zIndex:t?.zIndex??a.zIndex,underlinePredictions:t?.underlinePredictions??a.underlinePredictions,ttlMs:t?.ttlMs??a.ttlMs,maxPending:t?.maxPending??a.maxPending,cursorGraceMs:t?.cursorGraceMs??a.cursorGraceMs,edgeMarginCells:t?.edgeMarginCells??a.edgeMarginCells,foregroundColor:t?.foregroundColor,backgroundColor:t?.backgroundColor},this._predictWhen=t?.predictWhen??null}activate(t){this._terminal=t,this._container=document.createElement("div"),this._container.setAttribute("data-predictive-echo",""),this._container.style.cssText=`position:absolute;left:0;top:0;z-index:${this._options.zIndex};pointer-events:none`;let e=t.element?.querySelector(".xterm-screen");if(e&&e.appendChild(this._container),this._readFontStyle(),typeof t.onWriteParsed=="function")try{this._disposables.push(t.onWriteParsed(()=>{this._reconcileScheduled||(this._reconcileScheduled=!0,queueMicrotask(()=>{this._reconcileScheduled=!1,this._anchorHold=!1,this._safeReconcile()}))}))}catch{}if(typeof t.onResize=="function")try{this._disposables.push(t.onResize(()=>this.clearPredictions()))}catch{}}dispose(){this.clearPredictions();for(let t of this._disposables)try{t.dispose()}catch{}this._disposables=[],this._container?.remove(),this._container=null,this._terminal=null}predictChar(t){try{if(this._reconcile(),this._anchorHold)return!1;let e=this._terminal;if(!e||!this._container)return!1;let n=_(e);if(!n)return!1;let i=e.buffer.active;if(typeof i.cursorX!="number"||typeof i.cursorY!="number"||i.viewportY!==i.baseY||this._predictWhen&&this._predictWhen(e)===!1)return!1;let l=Array.from(t);if(l.length!==1)return!1;let r=l[0].codePointAt(0);if(r<32||r===127)return!1;let s=b(e,l[0]);if(s!==1&&s!==2||s===2&&!this._hasGetCell()||this._outstanding.length>=this._options.maxPending)return!1;this._outstanding.length===0&&(this._anchor={row:i.cursorY,col:i.cursorX},this._cursorOffRowSince=null);let c=this._anchor,d=this._outstanding[this._outstanding.length-1],g=d?d.offsetCells+d.width:0,f=c.col+g;if(f+s>e.cols-this._options.edgeMarginCells)return!1;let u={seq:this._seq++,char:l[0],width:s,offsetCells:g,snapshot:this._readCell(c.row,f),sentAt:performance.now(),mismatches:0};return this._outstanding.push(u),x(this._container,this._spans,{seq:u.seq,row:c.row,col:f,char:u.char,width:s,dims:n,font:this._font,underline:this._options.underlinePredictions}),this._armTtl(),!0}catch{return!1}}predictBackspace(){try{let t=this._outstanding.pop();return t?(h(this._spans,t.seq),this._outstanding.length===0&&this._resetRun(),!0):(this._anchorHold=!0,!1)}catch{return!1}}clearPredictions(){try{this._anchorHold=!0,this._droppedTotal+=this._outstanding.length,this._outstanding=[],y(this._spans),this._resetRun()}catch{}}reconcile(){this._anchorHold=!1,this._safeReconcile()}setPredictWhen(t){this._predictWhen=t}refreshFont(){this._readFontStyle()}get hasPredictions(){return this._outstanding.length>0}get state(){return{outstanding:this._outstanding.length,confirmedTotal:this._confirmedTotal,droppedTotal:this._droppedTotal,anchor:this._anchor?{...this._anchor}:null}}_safeReconcile(){try{this._reconcile()}catch{}}_reconcile(){let t=this._terminal;if(!t||this._outstanding.length===0)return;let e=t.buffer.active;if(e.viewportY!==e.baseY){this.clearPredictions();return}if(typeof e.cursorX!="number"||typeof e.cursorY!="number")return;let n=this._anchor,i=performance.now();if(e.cursorY!==n.row){if(this._cursorOffRowSince??=i,i-this._cursorOffRowSince>this._options.cursorGraceMs){this.clearPredictions();return}}else this._cursorOffRowSince=null;for(;this._outstanding.length>0;){let r=this._outstanding[0];if(this._readCell(n.row,n.col+r.offsetCells)===r.char&&e.cursorY===n.row&&e.cursorX>=n.col+r.offsetCells+r.width)this._outstanding.shift(),h(this._spans,r.seq),this._confirmedTotal++;else break}let l=-1;for(let r=0;r<this._outstanding.length;r++){let s=this._outstanding[r],c=this._readCell(n.row,n.col+s.offsetCells);if(c!==s.snapshot&&c!==s.char&&c!==" "){if(s.mismatches++,s.mismatches>=2){l=r;break}}else s.mismatches=0}l!==-1&&this._dropFrom(l);for(let r=0;r<this._outstanding.length;r++)if(i-this._outstanding[r].sentAt>this._options.ttlMs){this._dropFrom(r);break}this._outstanding.length===0?this._resetRun():this._armTtl()}_dropFrom(t){let e=this._outstanding.splice(t);for(let n of e)h(this._spans,n.seq);this._droppedTotal+=e.length}_resetRun(){this._anchor=null,this._cursorOffRowSince=null,this._ttlTimer!==null&&(clearTimeout(this._ttlTimer),this._ttlTimer=null)}_armTtl(){if(this._ttlTimer!==null)return;let t=this._outstanding[0];if(!t)return;let e=Math.max(0,t.sentAt+this._options.ttlMs-performance.now())+1;this._ttlTimer=setTimeout(()=>{this._ttlTimer=null,this._safeReconcile(),this._armTtl()},e)}_hasGetCell(){let t=this._terminal?.buffer.active;return t?typeof t.getLine(t.baseY+(t.cursorY??0))?.getCell=="function":!1}_readCell(t,e){let n=this._terminal.buffer.active,i=n.getLine(n.baseY+t);if(!i)return" ";if(typeof i.getCell=="function"){let r=i.getCell(e)?.getChars()??"";return r===""?" ":r}return i.translateToString(!0)[e]??" "}_readFontStyle(){let t=this._terminal;if(!t)return;this._font.fontFamily=t.options.fontFamily||"monospace",this._font.fontSize=(t.options.fontSize||14)+"px",this._font.fontWeight=String(t.options.fontWeight||"normal"),this._font.backgroundColor=this._options.backgroundColor??t.options.theme?.background??v,this._font.color=this._options.foregroundColor??t.options.theme?.foreground??C,this._font.letterSpacing="";let e=t.element?.querySelector(".xterm-rows");if(e){let n=getComputedStyle(e);this._font.letterSpacing=n.letterSpacing,!this._options.foregroundColor&&n.color&&(this._font.color=n.color)}}};return R(k);})();
1
+ "use strict";var XtermPredictiveEcho=(()=>{var m=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var P=(r,t)=>{for(var e in t)m(r,e,{get:t[e],enumerable:!0})},M=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of S(t))!w.call(r,i)&&i!==e&&m(r,i,{get:()=>t[i],enumerable:!(n=T(t,i))||n.enumerable});return r};var R=r=>M(m({},"__esModule",{value:!0}),r);var L={};P(L,{PredictiveEchoAddon:()=>p});function _(r){let t=r,e=typeof devicePixelRatio=="number"&&devicePixelRatio>0?devicePixelRatio:1;if(t.dimensions?.css?.cell){let n=t.dimensions.css.cell.height;return{width:t.dimensions.css.cell.width,height:n,charTop:(t.dimensions?.device?.char?.top??0)/e,charHeight:(t.dimensions?.device?.char?.height??n*e)/e}}try{let n=t._core?._renderService?.dimensions;if(n?.css?.cell){let i=n.css.cell.height;return{width:n.css.cell.width,height:i,charTop:(n.device?.char?.top??0)/e,charHeight:(n.device?.char?.height??i*e)/e}}}catch{}return null}function b(r,t){if(r?.unicode?.getStringCellWidth)return r.unicode.getStringCellWidth(t);let e=t.codePointAt(0);return e!==void 0&&e>=4352&&(e<=4447||e>=11904&&e<=12350||e>=12352&&e<=13247||e>=13312&&e<=19903||e>=19968&&e<=42191||e>=43360&&e<=43388||e>=44032&&e<=55203||e>=63744&&e<=64255||e>=65072&&e<=65135||e>=65281&&e<=65376||e>=65504&&e<=65510||e>=126976&&e<=130047||e>=131072&&e<=196607||e>=196608&&e<=262143)?2:1}function x(r,t,e){let n=document.createElement("span");n.style.cssText=`position:absolute;left:${e.col*e.dims.width}px;top:${e.row*e.dims.height}px;width:${e.width*e.dims.width}px;height:${e.dims.height+1}px;line-height:${e.dims.height}px;text-align:center;pointer-events:none;font-family:${e.font.fontFamily};font-size:${e.font.fontSize};font-weight:${e.font.fontWeight};`+(e.font.letterSpacing?`letter-spacing:${e.font.letterSpacing};`:"")+`color:${e.font.color};background-color:${e.font.backgroundColor};font-feature-settings:'liga' 0,'calt' 0;`+(e.underline?"text-decoration:underline;":""),n.textContent=e.char,t.set(e.seq,n),r.appendChild(n)}function h(r,t){let e=r.get(t);e&&(e.remove(),r.delete(t))}function y(r){for(let t of r.values())t.remove();r.clear()}var a={zIndex:7,underlinePredictions:!1,ttlMs:1e3,maxPending:32,cursorGraceMs:150,edgeMarginCells:4},v="#000000",C="#ffffff",p=class{_terminal=null;_container=null;_spans=new Map;_outstanding=[];_anchor=null;_cursorOffRowSince=null;_seq=0;_confirmedTotal=0;_droppedTotal=0;_ttlTimer=null;_anchorHold=!1;_reconcileScheduled=!1;_disposables=[];_predictWhen;_options;_font={fontFamily:"monospace",fontSize:"14px",fontWeight:"normal",color:C,backgroundColor:v,letterSpacing:""};constructor(t){this._options={zIndex:t?.zIndex??a.zIndex,underlinePredictions:t?.underlinePredictions??a.underlinePredictions,ttlMs:t?.ttlMs??a.ttlMs,maxPending:t?.maxPending??a.maxPending,cursorGraceMs:t?.cursorGraceMs??a.cursorGraceMs,edgeMarginCells:t?.edgeMarginCells??a.edgeMarginCells,foregroundColor:t?.foregroundColor,backgroundColor:t?.backgroundColor},this._predictWhen=t?.predictWhen??null}activate(t){this._terminal=t,this._container=document.createElement("div"),this._container.setAttribute("data-predictive-echo",""),this._container.style.cssText=`position:absolute;left:0;top:0;z-index:${this._options.zIndex};pointer-events:none`;let e=t.element?.querySelector(".xterm-screen");if(e&&e.appendChild(this._container),this._readFontStyle(),typeof t.onWriteParsed=="function")try{this._disposables.push(t.onWriteParsed(()=>{this._reconcileScheduled||(this._reconcileScheduled=!0,queueMicrotask(()=>{this._reconcileScheduled=!1,this._anchorHold=!1,this._safeReconcile()}))}))}catch{}if(typeof t.onResize=="function")try{this._disposables.push(t.onResize(()=>this.clearPredictions()))}catch{}}dispose(){this.clearPredictions();for(let t of this._disposables)try{t.dispose()}catch{}this._disposables=[],this._container?.remove(),this._container=null,this._terminal=null}predictChar(t){try{if(this._reconcile(),this._anchorHold)return!1;let e=this._terminal;if(!e||!this._container)return!1;let n=_(e);if(!n)return!1;let i=e.buffer.active;if(typeof i.cursorX!="number"||typeof i.cursorY!="number"||i.viewportY!==i.baseY||this._predictWhen&&this._predictWhen(e)===!1)return!1;let l=Array.from(t);if(l.length!==1)return!1;let o=l[0].codePointAt(0);if(o<32||o===127)return!1;let s=b(e,l[0]);if(s!==1&&s!==2||s===2&&!this._hasGetCell()||this._outstanding.length>=this._options.maxPending)return!1;this._outstanding.length===0&&(this._anchor={row:i.cursorY,col:i.cursorX},this._cursorOffRowSince=null);let c=this._anchor,d=this._outstanding[this._outstanding.length-1],g=d?d.offsetCells+d.width:0,f=c.col+g;if(f+s>e.cols-this._options.edgeMarginCells)return!1;let u={seq:this._seq++,char:l[0],width:s,offsetCells:g,snapshot:this._readCell(c.row,f),sentAt:performance.now(),mismatches:0};return this._outstanding.push(u),x(this._container,this._spans,{seq:u.seq,row:c.row,col:f,char:u.char,width:s,dims:n,font:this._font,underline:this._options.underlinePredictions}),this._armTtl(),!0}catch{return!1}}predictBackspace(){try{let t=this._outstanding.pop();return t?(h(this._spans,t.seq),this._outstanding.length===0&&this._resetRun(),!0):(this._anchorHold=!0,!1)}catch{return!1}}clearPredictions(){try{this._anchorHold=!0,this._droppedTotal+=this._outstanding.length,this._outstanding=[],y(this._spans),this._resetRun()}catch{}}reconcile(){this._anchorHold=!1,this._safeReconcile()}setPredictWhen(t){this._predictWhen=t}refreshFont(){this._readFontStyle()}get hasPredictions(){return this._outstanding.length>0}get state(){return{outstanding:this._outstanding.length,confirmedTotal:this._confirmedTotal,droppedTotal:this._droppedTotal,anchor:this._anchor?{...this._anchor}:null}}_safeReconcile(){try{this._reconcile()}catch{}}_reconcile(){let t=this._terminal;if(!t||this._outstanding.length===0)return;let e=t.buffer.active;if(e.viewportY!==e.baseY){this.clearPredictions();return}if(typeof e.cursorX!="number"||typeof e.cursorY!="number")return;let n=this._anchor,i=performance.now();if(e.cursorY!==n.row){if(this._cursorOffRowSince??=i,i-this._cursorOffRowSince>this._options.cursorGraceMs){this.clearPredictions();return}}else this._cursorOffRowSince=null;for(;this._outstanding.length>0;){let o=this._outstanding[0];if(this._readCell(n.row,n.col+o.offsetCells)===o.char&&e.cursorY===n.row&&e.cursorX>=n.col+o.offsetCells+o.width)this._outstanding.shift(),h(this._spans,o.seq),this._confirmedTotal++;else break}let l=-1;for(let o=0;o<this._outstanding.length;o++){let s=this._outstanding[o],c=this._readCell(n.row,n.col+s.offsetCells);if(c!==s.snapshot&&c!==s.char&&c!==" "){if(s.mismatches++,s.mismatches>=2){l=o;break}}else s.mismatches=0}l!==-1&&this._dropFrom(l);for(let o=0;o<this._outstanding.length;o++)if(i-this._outstanding[o].sentAt>this._options.ttlMs){this._dropFrom(o);break}this._outstanding.length===0?this._resetRun():this._armTtl()}_dropFrom(t){let e=this._outstanding.splice(t);for(let n of e)h(this._spans,n.seq);this._droppedTotal+=e.length}_resetRun(){this._anchor=null,this._cursorOffRowSince=null,this._ttlTimer!==null&&(clearTimeout(this._ttlTimer),this._ttlTimer=null)}_armTtl(){if(this._ttlTimer!==null)return;let t=this._outstanding[0];if(!t)return;let e=Math.max(0,t.sentAt+this._options.ttlMs-performance.now())+1;this._ttlTimer=setTimeout(()=>{this._ttlTimer=null,this._safeReconcile(),this._armTtl()},e)}_hasGetCell(){let t=this._terminal?.buffer.active;return t?typeof t.getLine(t.baseY+(t.cursorY??0))?.getCell=="function":!1}_readCell(t,e){let n=this._terminal.buffer.active,i=n.getLine(n.baseY+t);if(!i)return" ";if(typeof i.getCell=="function"){let o=i.getCell(e)?.getChars()??"";return o===""?" ":o}return i.translateToString(!0)[e]??" "}_readFontStyle(){let t=this._terminal;if(!t)return;this._font.fontFamily=t.options.fontFamily||"monospace",this._font.fontSize=(t.options.fontSize||14)+"px",this._font.fontWeight=String(t.options.fontWeight||"normal"),this._font.backgroundColor=this._options.backgroundColor??t.options.theme?.background??v,this._font.color=this._options.foregroundColor??t.options.theme?.foreground??C,this._font.letterSpacing="";let e=t.element?.querySelector(".xterm-rows");if(e){let n=getComputedStyle(e);this._font.letterSpacing=n.letterSpacing,!this._options.foregroundColor&&n.color&&(this._font.color=n.color)}}};return R(L);})();
2
2
 
3
3
  // Global aliases for browser usage
4
4
  if(typeof window!=="undefined"){window.PredictiveEchoAddon=XtermPredictiveEcho.PredictiveEchoAddon;window.PredictiveEchoOverlay=class extends XtermPredictiveEcho.PredictiveEchoAddon{constructor(terminal){super({});this.activate(terminal);}};}
@@ -0,0 +1,5 @@
1
+ "use strict";var XtermZerolagInput=(()=>{var F=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var G=Object.prototype.hasOwnProperty;var J=(i,e)=>{for(var t in e)F(i,t,{get:e[t],enumerable:!0})},Q=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of N(e))!G.call(i,n)&&n!==t&&F(i,n,{get:()=>e[n],enumerable:!(s=q(e,n))||s.enumerable});return i};var ee=i=>Q(F({},"__esModule",{value:!0}),i);var he={};J(he,{ZerolagInputAddon:()=>K});function z(i){let e=i,t=typeof devicePixelRatio=="number"&&devicePixelRatio>0?devicePixelRatio:1;if(e.dimensions?.css?.cell){let s=e.dimensions.css.cell.height;return{width:e.dimensions.css.cell.width,height:s,charTop:(e.dimensions?.device?.char?.top??0)/t,charHeight:(e.dimensions?.device?.char?.height??s*t)/t}}try{let s=e._core?._renderService?.dimensions;if(s?.css?.cell){let n=s.css.cell.height;return{width:s.css.cell.width,height:n,charTop:(s.device?.char?.top??0)/t,charHeight:(s.device?.char?.height??n*t)/t}}}catch{}return null}function B(i,e){try{let t=i.buffer.active,s=t.viewportY;switch(e.type){case"character":{for(let n=i.rows-1;n>=0;n--){let a=t.getLine(s+n);if(!a)continue;let u=a.translateToString(!0).lastIndexOf(e.char);if(u>=0)return{row:n,col:u}}return null}case"regex":{let n=e.pattern,a=n.global?new RegExp(n.source,n.flags.replace("g","")):n;for(let f=i.rows-1;f>=0;f--){let u=t.getLine(s+f);if(!u)continue;let g=u.translateToString(!0).match(a);if(g){let b=g.index??0;return{row:f,col:b}}}return null}case"custom":return e.find(i);default:return null}}catch{return null}}function H(i,e,t){try{let s=i.buffer.active,n=s.viewportY+e.row,a=s.getLine(n);return a?a.translateToString(!0).slice(e.col+t).trimEnd():""}catch{return""}}function M(i){try{let e=i.buffer.active;if(e.viewportY===e.baseY)return!0;if(typeof e.cursorY!="number")return!1;let t=e.baseY+e.cursorY;return t>=e.viewportY&&t<e.viewportY+i.rows}catch{return!1}}function O(i,e){if(i?.unicode?.getStringCellWidth)return i.unicode.getStringCellWidth(e);let t=e.codePointAt(0);return t!==void 0&&t>=4352&&(t<=4447||t>=11904&&t<=12350||t>=12352&&t<=13247||t>=13312&&t<=19903||t>=19968&&t<=42191||t>=43360&&t<=43388||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65072&&t<=65135||t>=65281&&t<=65376||t>=65504&&t<=65510||t>=126976&&t<=130047||t>=131072&&t<=196607||t>=196608&&t<=262143)?2:1}function te(i,e){let t=0;for(let s of e)t+=O(i,s);return t}var Y=4;function se(i,e){return Math.round(i*e*Y)/Y}var V=new WeakMap;function ie(i,e){let t=i.children;if(t.length!==e.lines.length+(e.cursor?1:0))return!1;for(let s=0;s<e.lines.length;s++)if(t[s]!==e.lines[s])return!1;return!e.cursor||t[e.lines.length]===e.cursor}function U(i,e){let{lines:t,compositionStart:s,startCol:n,totalCols:a,cellW:f,cellH:u,charTop:m,charHeight:g,promptRow:b,totalRows:r,font:c,showCursor:C,cursorColor:L,terminal:v}=e,x=r&&r>0?r:v?.rows,p=[],_=[];{let l=0;for(let D of t){let w=[...D].length;p.push(l),_.push(w),l+=w}}let o=t,S=0,y=!0,d=b;x&&x>0&&(t.length>x?(S=t.length-x,o=t.slice(S),y=!1,d=0):b+t.length>x&&(d=x-t.length)),d=Math.max(0,d),i.style.left="0px",i.style.top=d*u+"px";let P=[f,u,c.fontFamily,c.fontSize,c.fontWeight,c.color,c.backgroundColor,c.letterSpacing,v?.unicode?.activeVersion??""].join(`
2
+ `),h=V.get(i);(!h||h.styleKey!==P||!ie(i,h))&&(i.innerHTML="",h={styleKey:P,lines:[],lineKeys:[],cursor:null},V.set(i,h)),h.cursor?.remove(),h.cursor=null;let X=a*f;for(let l=0;l<o.length;l++){let D=l===0&&y,w=D?n*f:0,T=D?X-w:X,W=l*u,R;if(s!==void 0){let I=s-p[S+l];I<_[S+l]&&(R=Math.max(0,I))}let $=`${w}|${W}|${T}|${R??""}|${o[l]}`;if(h.lineKeys[l]===$)continue;let E=ne(o[l],w,W,T,u,f,m,g,c,v,R),A=h.lines[l];A?i.replaceChild(E,A):i.appendChild(E),h.lines[l]=E,h.lineKeys[l]=$}for(let l=h.lines.length-1;l>=o.length;l--)h.lines[l].remove();if(h.lines.length=o.length,h.lineKeys.length=o.length,C){let l=o[o.length-1],w=(o.length===1&&y?n:0)+te(v,l);if(w<a){let T=document.createElement("span");T.style.cssText="position:absolute;display:inline-block",T.style.left=w*f+"px",T.style.top=(o.length-1)*u+"px",T.style.width=f+"px",T.style.height=u+"px",T.style.backgroundColor=L,i.appendChild(T),h.cursor=T}}i.style.display=""}function ne(i,e,t,s,n,a,f,u,m,g,b){let r=document.createElement("div");r.style.cssText="position:absolute;display:flex;pointer-events:none;text-align:center;font-feature-settings:'liga' 0,'calt' 0",r.style.backgroundColor=m.backgroundColor,r.style.left=e+"px",r.style.top=t+"px",r.style.width=s+"px",r.style.height=n+1+"px",r.style.lineHeight=n+"px",r.style.fontFamily=m.fontFamily,r.style.fontSize=m.fontSize,r.style.fontWeight=m.fontWeight,r.style.color=m.color,m.letterSpacing&&(r.style.letterSpacing=m.letterSpacing);let c=";height:"+n+"px",C=0,L=0,v=0;for(let x of i){C+=O(g,x);let p=se(C,a),_=document.createElement("span");_.style.cssText="flex:none;width:"+(p-L)+"px"+c,b!==void 0&&v>=b&&(_.style.textDecoration="underline",_.setAttribute("data-zerolag-composition",""),_.setAttribute("aria-hidden","true")),_.textContent=x,r.appendChild(_),L=p,v++}return r}var k={type:"character",char:">",offset:2},re=7,oe=50,Z="#0d0d0d",j="#eeeeee",le="#e0e0e0",K=class{_terminal=null;_overlay=null;_options;_pendingText="";_flushedOffset=0;_flushedText="";_bufferDetectDone=!1;_composition="";_rowLimit=null;_lastRenderKey="";_lastPromptPos=null;_font={fontFamily:"monospace",fontSize:"14px",fontWeight:"normal",color:j,backgroundColor:Z,letterSpacing:""};_scrollTimer=null;_scrollHandler=null;_scrollViewport=null;constructor(e){this._options={prompt:e?.prompt??k,zIndex:e?.zIndex??re,showCursor:e?.showCursor??!0,scrollDebounceMs:e?.scrollDebounceMs??oe,backgroundColor:e?.backgroundColor,foregroundColor:e?.foregroundColor,cursorColor:e?.cursorColor}}activate(e){this._terminal=e,this._overlay=document.createElement("div"),this._overlay.style.cssText=`position:absolute;z-index:${this._options.zIndex};pointer-events:none;display:none`;let t=e.element?.querySelector(".xterm-screen");t&&t.appendChild(this._overlay),this._cacheFont(),this._scrollHandler=()=>{try{M(this._terminal)?this._hasContent()&&(this._scrollTimer&&clearTimeout(this._scrollTimer),this._scrollTimer=setTimeout(()=>{this._scrollTimer=null,this._lastRenderKey="",this._render()},this._options.scrollDebounceMs)):(this._overlay.style.display="none",this._scrollTimer&&(clearTimeout(this._scrollTimer),this._scrollTimer=null))}catch{}};let s=e.element?.querySelector(".xterm-viewport");s&&(s.addEventListener("scroll",this._scrollHandler,{passive:!0}),this._scrollViewport=s)}dispose(){this.clear(),this._scrollTimer&&(clearTimeout(this._scrollTimer),this._scrollTimer=null),this._scrollViewport&&this._scrollHandler&&this._scrollViewport.removeEventListener("scroll",this._scrollHandler),this._overlay?.remove(),this._overlay=null,this._scrollViewport=null,this._scrollHandler=null,this._terminal=null}addChar(e){!this._pendingText&&!this._flushedOffset&&this._detectBufferText(),this._pendingText+=e,this._render()}appendText(e){e&&(!this._pendingText&&!this._flushedOffset&&this._detectBufferText(),this._pendingText+=e,this._render())}removeChar(){let e=this._composition.length>0;return this._composition="",this._pendingText.length>0?(this._pendingText=this._pendingText.slice(0,-1),this._pendingText.length>0||this._flushedOffset>0?this._render():this._hide(),"pending"):this._flushedOffset>0?(this._flushedOffset--,this._flushedText=this._flushedText.slice(0,-1),this._flushedOffset>0?this._render():this._hide(),"flushed"):(this._detectBufferText(),this._flushedOffset>0?(this._flushedOffset--,this._flushedText=this._flushedText.slice(0,-1),this._flushedOffset>0?this._render():this._hide(),"flushed"):(e&&this._hide(),!1))}clear(){this._pendingText="",this._composition="",this._flushedOffset=0,this._flushedText="",this._bufferDetectDone=!1,this._lastRenderKey="",this._lastPromptPos=null,this._hide()}setFlushed(e,t,s=!0){this._flushedOffset=e,this._flushedText=t,s&&this._render()}getFlushed(){return{count:this._flushedOffset,text:this._flushedText}}clearFlushed(){this._flushedOffset=0,this._flushedText="",this._pendingText||this._composition?this._render():this._hide()}rerender(){this._hasContent()&&(this._lastRenderKey="",this._render())}setRowLimit(e){let t=e!==null&&Number.isFinite(e)&&e>0?Math.trunc(e):null;t!==this._rowLimit&&(this._rowLimit=t,this.rerender())}_layoutRows(){let e=this._terminal.rows;return this._rowLimit!==null?Math.min(this._rowLimit,e):e}refreshFont(){this._cacheFont(),this._lastRenderKey="",this._hasContent()&&this._render()}detectBufferText(){return this._detectBufferText()}resetBufferDetection(){this._bufferDetectDone=!1}undoDetection(){this._flushedOffset=0,this._flushedText="",this._bufferDetectDone=!1}suppressBufferDetection(){this._bufferDetectDone=!0}setPrompt(e){this._options.prompt=e,this._lastPromptPos=null,this._lastRenderKey="",this._hasContent()&&this._render()}setComposition(e){let t=typeof e=="string"?e.replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g,""):"";t!==this._composition&&(this._composition=t,this._hasContent()?this._render():this._hide())}get composition(){return this._composition}findPrompt(){return this._terminal?B(this._terminal,this._options.prompt??k):null}readPromptText(){if(!this._terminal)return null;let e=this.findPrompt();if(!e)return null;let t=this._getPromptOffset();return H(this._terminal,e,t)||null}get pendingText(){return this._pendingText}get hasPending(){return this._pendingText.length>0||this._flushedOffset>0}get state(){return{pendingText:this._pendingText,flushedLength:this._flushedOffset,flushedText:this._flushedText,visible:this._overlay!==null&&this._overlay.style.display!=="none",promptPosition:this._lastPromptPos?{...this._lastPromptPos}:null}}_hasContent(){return this._pendingText.length>0||this._flushedOffset>0||this._composition.length>0}_getPromptOffset(){return(this._options.prompt??k).offset??2}_detectBufferText(){if(this._bufferDetectDone||!this._terminal)return null;try{let e=this.findPrompt();if(!e)return null;let t=this._getPromptOffset(),s=H(this._terminal,e,t);if(s.length>0)return this._flushedOffset=s.length,this._flushedText=s,this._lastPromptPos=e,this._bufferDetectDone=!0,s}catch{}return null}_cacheFont(){if(!this._terminal)return;let e=this._terminal;this._font.fontFamily=e.options.fontFamily||"monospace",this._font.fontSize=(e.options.fontSize||14)+"px",this._font.fontWeight=String(e.options.fontWeight||"normal"),this._font.backgroundColor=this._options.backgroundColor??e.options.theme?.background??Z,this._font.color=this._options.foregroundColor??e.options.theme?.foreground??j,this._font.letterSpacing="";let t=e.element?.querySelector(".xterm-rows");if(t){let s=getComputedStyle(t);this._font.letterSpacing=s.letterSpacing,!this._options.foregroundColor&&s.color&&(this._font.color=s.color)}}_hide(){this._overlay&&(this._lastRenderKey="",this._lastPromptPos=null,this._overlay.innerHTML="",this._overlay.style.display="none")}_render(){if(!(!this._terminal||!this._overlay)){if(!this._hasContent()){this._overlay.style.display="none";return}try{let e=this._terminal.buffer.active;if(!M(this._terminal)){this._overlay.style.display="none";return}let t=this.findPrompt();if(t)this._lastPromptPos&&this._flushedOffset>0?this._lastPromptPos={row:t.row,col:this._lastPromptPos.col}:this._lastPromptPos=t;else if(!this._lastPromptPos){this._overlay.style.display="none";return}let s=this._lastPromptPos,n=z(this._terminal);if(!n){this._overlay.style.display="none";return}let{width:a,height:f,charTop:u,charHeight:m}=n,g=this._terminal.cols,b=this._getPromptOffset(),r=s.col+b,c=this._pendingText;if(this._flushedOffset>0)if(this._flushedText&&this._flushedText.length===this._flushedOffset)c=this._flushedText+this._pendingText;else{let y=e.viewportY+s.row,d=e.getLine(y);d&&(c=d.translateToString(!0).slice(r,r+this._flushedOffset)+this._pendingText)}let C=[...c].length;c+=this._composition;let L=this._layoutRows(),v=`${c}:${C}:${r}:${s.row}:${s.col}:${g}:${L}:${this._flushedOffset}`;if(v===this._lastRenderKey&&this._overlay.style.display!=="none")return;this._lastRenderKey=v;let x=Math.max(1,g-r),p=[...c],_=[],o=0;{let y="",d=0;for(;o<p.length;){let P=O(this._terminal,p[o]);if(d+P>x)break;y+=p[o],d+=P,o++}_.push(y)}for(;o<p.length;){let y="",d=0;for(;o<p.length;){let P=O(this._terminal,p[o]);if(d+P>g)break;y+=p[o],d+=P,o++}_.push(y)}let S=this._options.cursorColor??this._terminal.options.theme?.cursor??le;U(this._overlay,{lines:_,compositionStart:this._composition?C:void 0,startCol:r,totalCols:g,cellW:a,cellH:f,charTop:u,charHeight:m,promptRow:s.row,totalRows:L,font:this._font,showCursor:this._options.showCursor,cursorColor:S,terminal:this._terminal})}catch{this._overlay&&(this._overlay.innerHTML="",this._overlay.style.display="none")}}}};return ee(he);})();
3
+
4
+ // Global aliases for browser usage
5
+ if(typeof window!=="undefined"){window.ZerolagInputAddon=XtermZerolagInput.ZerolagInputAddon;window.LocalEchoOverlay=class extends XtermZerolagInput.ZerolagInputAddon{constructor(terminal){super({prompt:{type:"character",char:"\u276f",offset:2}});this.activate(terminal);}};}
Binary file
Binary file
@@ -1,13 +1,13 @@
1
1
  {
2
- "version": "1.44.0",
2
+ "version": "1.46.0",
3
3
  "highlights": [
4
- "Config backups (#661)",
5
- "Keep an idle Claude session's prompt cache warm (#666, opt-in)",
6
- "A default tab group per case (#676)",
7
- "A File Viewer you can resize, with Back and Forward (#659)",
8
- "Copilot's premium-request quota in the plan-usage chip (#662)",
9
- "More (or fewer) sessions with `CODEMAN_MAX_SESSIONS` (#668)",
10
- "Multi-line prompts keep their line breaks (#670)",
11
- "A warning for llama.cpp slots that split the context too thin (#658)"
4
+ "Fetch from the Git status window (#714)",
5
+ "Start a session beside any tab (#712, opt-in)",
6
+ "The phone keyboard no longer costs Claude its transcript (#711)",
7
+ "Typing stays smooth in a long prompt (#713)",
8
+ "Links survive wrapping and spaces (#686, #687)",
9
+ "`codeman agent spawn` in a project directory (#708)",
10
+ "Read saved Codex conversations offline (#707)",
11
+ "Experimental: bounded inspection and guarded submission for agents (#694, opt-in)"
12
12
  ]
13
13
  }