@kabmo-labs/kabmo 0.8.0 → 0.10.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 (391) hide show
  1. package/README.md +52 -0
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +336 -336
  4. package/dist/client/static/js/index-18xe7655.css +1 -0
  5. package/dist/client/static/js/{index-qwpvd9fv.js → index-nxpe7835.js} +933 -898
  6. package/package.json +11 -1
  7. package/src/client/components/common/code-surface/bracket-guide.test.ts +249 -0
  8. package/src/client/components/common/code-surface/bracket-guide.ts +131 -0
  9. package/src/client/components/common/code-surface/documents.test.ts +122 -0
  10. package/src/client/components/common/code-surface/documents.ts +286 -0
  11. package/src/client/components/common/code-surface/extensions.test.ts +115 -0
  12. package/src/client/components/common/code-surface/extensions.ts +295 -0
  13. package/src/client/components/common/code-surface/fold-stack.test.ts +218 -0
  14. package/src/client/components/common/code-surface/fold.test.ts +148 -0
  15. package/src/client/components/common/code-surface/fold.ts +118 -0
  16. package/src/client/components/common/code-surface/handle.ts +102 -0
  17. package/src/client/components/common/code-surface/indent-guide.ts +104 -0
  18. package/src/client/components/common/code-surface/indent.test.ts +239 -0
  19. package/src/client/components/common/code-surface/indent.ts +124 -0
  20. package/src/client/components/common/code-surface/index.tsx +283 -314
  21. package/src/client/components/common/code-surface/keymap.test.ts +133 -0
  22. package/src/client/components/common/code-surface/keymap.ts +256 -0
  23. package/src/client/components/common/code-surface/line-commands.test.ts +90 -0
  24. package/src/client/components/common/code-surface/line-commands.ts +103 -0
  25. package/src/client/components/common/code-surface/marks.ts +74 -0
  26. package/src/client/components/common/code-surface/props.ts +87 -0
  27. package/src/client/components/common/code-surface/shiki.ts +234 -0
  28. package/src/client/components/common/code-surface/stream-language.test.ts +118 -0
  29. package/src/client/components/common/code-surface/stream-language.ts +123 -0
  30. package/src/client/components/common/code-surface/sync.test.ts +185 -0
  31. package/src/client/components/common/code-surface/sync.ts +58 -0
  32. package/src/client/components/common/code-surface/theme.test.ts +237 -0
  33. package/src/client/components/common/code-surface/theme.ts +224 -0
  34. package/src/client/components/common/code-surface/typing.test.ts +97 -0
  35. package/src/client/components/common/code-surface/typing.ts +111 -0
  36. package/src/client/components/common/editor-view-buttons/index.test.tsx +148 -0
  37. package/src/client/components/common/editor-view-buttons/index.tsx +109 -0
  38. package/src/client/components/common/shell-update-button/Modal.tsx +163 -0
  39. package/src/client/components/common/shell-update-button/index.test.tsx +251 -0
  40. package/src/client/components/common/shell-update-button/index.tsx +125 -0
  41. package/src/client/components/common/toolbar-row/index.test.tsx +215 -0
  42. package/src/client/components/common/toolbar-row/index.tsx +260 -0
  43. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +58 -78
  44. package/src/client/components/layout/desktop-layout/index.tsx +65 -67
  45. package/src/client/components/layout/desktop-layout/resizer/index.tsx +6 -3
  46. package/src/client/components/layout/session-sidebar/Footer.tsx +8 -15
  47. package/src/client/components/mobile/LayoutWrapper.tsx +1 -0
  48. package/src/client/components/mobile/mobile-right-sidebar/FullDiff.tsx +3 -0
  49. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +98 -71
  50. package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +20 -1
  51. package/src/client/components/mobile/mobile-right-sidebar/OutlineButton.test.tsx +137 -0
  52. package/src/client/components/mobile/mobile-right-sidebar/OutlineButton.tsx +14 -3
  53. package/src/client/components/mobile/mobile-right-sidebar/editor-props.ts +25 -0
  54. package/src/client/components/mobile/mobile-session-sidebar/Footer.tsx +9 -21
  55. package/src/client/components/settings/Modal.tsx +8 -0
  56. package/src/client/components/settings/categories/AppearanceSettings.tsx +9 -0
  57. package/src/client/components/settings/categories/appearance-settings/EditorIndentSection.tsx +87 -0
  58. package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.test.tsx +167 -0
  59. package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +184 -0
  60. package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +99 -0
  61. package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +8 -2
  62. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +16 -8
  63. package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +9 -4
  64. package/src/client/components/workspace/chat-timeline/TaskResultContent.tsx +9 -7
  65. package/src/client/components/workspace/chat-timeline/chat-input/expansion.ts +9 -4
  66. package/src/client/components/workspace/chat-timeline/chat-input/index.tsx +15 -11
  67. package/src/client/components/workspace/chat-timeline/chat-input/stretch-send.test.tsx +165 -0
  68. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.test.tsx +132 -0
  69. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +120 -0
  70. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.test.tsx +319 -0
  71. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +285 -0
  72. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.test.ts +2 -0
  73. package/src/client/components/workspace/chat-timeline/tool-renderers/hashline-patch/index.tsx +34 -29
  74. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AstEdit.tsx +11 -9
  75. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +10 -7
  76. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Edit.tsx +25 -8
  77. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Eval.tsx +8 -11
  78. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/FileMatches.test.ts +114 -0
  79. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/FileMatches.tsx +111 -0
  80. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +7 -7
  81. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchTool.tsx +9 -59
  82. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactBody.tsx +2 -7
  83. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.test.ts +43 -30
  84. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/DiffView.tsx +49 -32
  85. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ExcerptCode.tsx +8 -8
  86. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/HighlightedCode.tsx +35 -0
  87. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/JsonCodeBlock.tsx +4 -4
  88. package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +179 -0
  89. package/src/client/components/workspace/diff-panel/ThemedMergeDiffView.tsx +24 -0
  90. package/src/client/components/workspace/diff-panel/Toolbar.tsx +224 -186
  91. package/src/client/components/workspace/diff-panel/ToolbarSegments.tsx +98 -0
  92. package/src/client/components/workspace/diff-panel/index.tsx +76 -145
  93. package/src/client/components/workspace/diff-panel/merge.ts +315 -0
  94. package/src/client/components/workspace/editor/Body.tsx +28 -7
  95. package/src/client/components/workspace/editor/CommandPalette.tsx +6 -6
  96. package/src/client/components/workspace/editor/ConflictStrip.tsx +77 -0
  97. package/src/client/components/workspace/editor/Dialogs.tsx +53 -0
  98. package/src/client/components/workspace/editor/EmptyEditor.tsx +23 -0
  99. package/src/client/components/workspace/editor/ExternalChangeStrip.tsx +61 -0
  100. package/src/client/components/workspace/editor/FileDocument.tsx +146 -63
  101. package/src/client/components/workspace/editor/FilePane.tsx +47 -7
  102. package/src/client/components/workspace/editor/FindWidget.test.ts +9 -5
  103. package/src/client/components/workspace/editor/FindWidget.tsx +36 -2
  104. package/src/client/components/workspace/editor/GoToLineModal.tsx +123 -0
  105. package/src/client/components/workspace/editor/Notices.tsx +71 -0
  106. package/src/client/components/workspace/editor/Pane.tsx +118 -0
  107. package/src/client/components/workspace/editor/PluginColumn.tsx +32 -0
  108. package/src/client/components/workspace/editor/QuickOpenModal.tsx +146 -0
  109. package/src/client/components/workspace/editor/SaveAsModal.tsx +175 -0
  110. package/src/client/components/workspace/editor/SplitColumn.tsx +98 -0
  111. package/src/client/components/workspace/editor/SplitPane.tsx +57 -0
  112. package/src/client/components/workspace/editor/StatusBar.tsx +106 -0
  113. package/src/client/components/workspace/editor/TabContextMenu.tsx +75 -0
  114. package/src/client/components/workspace/editor/Tabs.tsx +195 -18
  115. package/src/client/components/workspace/editor/Toolbar.tsx +110 -140
  116. package/src/client/components/workspace/editor/index.tsx +201 -193
  117. package/src/client/components/workspace/editor/props.ts +64 -0
  118. package/src/client/components/workspace/editor/toolbar-clusters.tsx +300 -0
  119. package/src/client/components/workspace/file-explorer/Modals.tsx +14 -1
  120. package/src/client/components/workspace/file-explorer/OutlineSection.test.tsx +18 -0
  121. package/src/client/components/workspace/file-explorer/OutlineSection.tsx +10 -3
  122. package/src/client/components/workspace/file-explorer/TreeItem.tsx +2 -1
  123. package/src/client/components/workspace/file-explorer/clipboard.test.ts +3 -1
  124. package/src/client/components/workspace/file-explorer/index.test.ts +61 -0
  125. package/src/client/components/workspace/file-explorer/index.tsx +10 -48
  126. package/src/client/components/workspace/file-explorer/local-edit.test.ts +8 -3
  127. package/src/client/components/workspace/search-panel/Body.tsx +7 -2
  128. package/src/client/components/workspace/worktree-modal/index.test.tsx +118 -0
  129. package/src/client/hooks/chat/composer/file-drop.ts +22 -37
  130. package/src/client/hooks/chat/composer/pipeline.test.ts +76 -0
  131. package/src/client/hooks/chat/composer/pipeline.ts +12 -1
  132. package/src/client/hooks/chat/omp/reconnect.test.ts +338 -0
  133. package/src/client/hooks/chat/omp/reconnect.ts +187 -0
  134. package/src/client/hooks/chat/omp/run-liveness.test.ts +71 -0
  135. package/src/client/hooks/chat/omp/run-liveness.ts +65 -0
  136. package/src/client/hooks/chat/omp/session-list.activity.test.ts +114 -0
  137. package/src/client/hooks/chat/omp/session-list.test-util.ts +164 -0
  138. package/src/client/hooks/chat/omp/session-list.test.ts +30 -150
  139. package/src/client/hooks/chat/omp/session-list.tsx +69 -9
  140. package/src/client/hooks/chat/timeline/generating.ts +19 -2
  141. package/src/client/hooks/chat/timeline/index.ts +19 -24
  142. package/src/client/hooks/chat/timeline/lost-run.test.ts +329 -0
  143. package/src/client/hooks/chat/timeline/lost-run.ts +177 -0
  144. package/src/client/hooks/chat/timeline/session-load.test-util.ts +205 -0
  145. package/src/client/hooks/chat/timeline/session-load.test.ts +61 -162
  146. package/src/client/hooks/chat/timeline/session-load.ts +69 -37
  147. package/src/client/hooks/chat/timeline/session-switch.test.ts +65 -0
  148. package/src/client/hooks/chat/timeline/session-switch.ts +63 -0
  149. package/src/client/hooks/code/deferred-highlight.test.ts +182 -0
  150. package/src/client/hooks/code/deferred-highlight.ts +129 -0
  151. package/src/client/hooks/editor/caret-position.test.ts +58 -0
  152. package/src/client/hooks/editor/caret-position.ts +48 -0
  153. package/src/client/hooks/editor/file-editor-types.ts +200 -0
  154. package/src/client/hooks/editor/find-history.test.ts +132 -0
  155. package/src/client/hooks/editor/find-history.ts +46 -0
  156. package/src/client/hooks/editor/find-selection-range.test.ts +100 -0
  157. package/src/client/hooks/editor/find-selection-range.ts +49 -0
  158. package/src/client/hooks/editor/find-state.ts +14 -1
  159. package/src/client/hooks/editor/font.test.ts +0 -93
  160. package/src/client/hooks/editor/indent-settings.test.ts +104 -0
  161. package/src/client/hooks/editor/indent-settings.ts +88 -0
  162. package/src/client/hooks/editor/quick-open.test.ts +141 -0
  163. package/src/client/hooks/editor/quick-open.ts +127 -0
  164. package/src/client/hooks/editor/save-as.test.ts +156 -0
  165. package/src/client/hooks/editor/save-as.ts +122 -0
  166. package/src/client/hooks/editor/save-file.test.ts +179 -0
  167. package/src/client/hooks/editor/save-file.ts +73 -28
  168. package/src/client/hooks/editor/theme.test.ts +206 -0
  169. package/src/client/hooks/editor/theme.ts +82 -0
  170. package/src/client/hooks/editor/typing-settings.test.ts +73 -0
  171. package/src/client/hooks/editor/typing-settings.ts +65 -0
  172. package/src/client/hooks/editor/use-close-guard.ts +98 -0
  173. package/src/client/hooks/editor/use-editor-drop-overlay.test.ts +159 -0
  174. package/src/client/hooks/editor/use-editor-drop.shell.test.ts +224 -0
  175. package/src/client/hooks/editor/use-editor-drop.test.ts +101 -0
  176. package/src/client/hooks/editor/use-editor-drop.ts +120 -77
  177. package/src/client/hooks/editor/use-editor-find.test.ts +2 -2
  178. package/src/client/hooks/editor/use-editor-find.ts +45 -10
  179. package/src/client/hooks/editor/use-editor-panel-keys.ts +152 -0
  180. package/src/client/hooks/editor/use-editor-tab-state.ts +71 -0
  181. package/src/client/hooks/editor/use-external-change-notice.ts +71 -0
  182. package/src/client/hooks/editor/use-external-change.test.ts +88 -0
  183. package/src/client/hooks/editor/use-external-change.ts +146 -0
  184. package/src/client/hooks/editor/use-file-editor.ts +83 -116
  185. package/src/client/hooks/editor/use-file-read.ts +16 -8
  186. package/src/client/hooks/editor/use-file-writes.ts +28 -3
  187. package/src/client/hooks/editor/use-mobile-editor-find.ts +69 -0
  188. package/src/client/hooks/editor/use-mobile-reveal.ts +53 -0
  189. package/src/client/hooks/editor/use-outline-view.test.ts +182 -0
  190. package/src/client/hooks/editor/use-outline-view.ts +94 -7
  191. package/src/client/hooks/editor/use-scroll-restore.test.ts +55 -2
  192. package/src/client/hooks/editor/use-scroll-restore.ts +124 -4
  193. package/src/client/hooks/editor/use-search-reveal-jump.ts +57 -0
  194. package/src/client/hooks/editor/use-search-reveal.ts +1 -1
  195. package/src/client/hooks/editor/use-split-editor.test.tsx +169 -0
  196. package/src/client/hooks/editor/use-split-editor.ts +91 -0
  197. package/src/client/hooks/editor/use-unload-guard.tsx +117 -0
  198. package/src/client/hooks/editor/use-write-conflict.test.ts +164 -0
  199. package/src/client/hooks/editor/use-write-conflict.ts +152 -0
  200. package/src/client/hooks/editor/wheel-zoom.test.ts +141 -0
  201. package/src/client/hooks/editor/wheel-zoom.ts +96 -0
  202. package/src/client/hooks/ui/drag-presence.test.ts +193 -0
  203. package/src/client/hooks/ui/drag-presence.ts +108 -0
  204. package/src/client/hooks/ui/settings-modal.test.ts +115 -0
  205. package/src/client/hooks/ui/settings-modal.ts +56 -0
  206. package/src/client/hooks/ui/updates/shell-download.test.ts +2 -0
  207. package/src/client/hooks/ui/updates/shell-download.ts +55 -14
  208. package/src/client/hooks/ui/updates/shell-offer.test.ts +26 -0
  209. package/src/client/hooks/ui/updates/shell-update.test.ts +140 -0
  210. package/src/client/hooks/ui/updates/shell-update.ts +119 -0
  211. package/src/client/hooks/workspace/diff-file.ts +29 -10
  212. package/src/client/hooks/workspace/diff-git-actions.ts +147 -0
  213. package/src/client/hooks/workspace/editor-view.ts +61 -0
  214. package/src/client/hooks/workspace/file-listing.ts +36 -24
  215. package/src/client/hooks/workspace/file-tabs.test.ts +152 -5
  216. package/src/client/hooks/workspace/file-tabs.ts +70 -11
  217. package/src/client/hooks/workspace/file-tree-edits.ts +103 -0
  218. package/src/client/hooks/workspace/navbar-session-actions.ts +72 -0
  219. package/src/client/hooks/workspace/worktree/index.ts +20 -5
  220. package/src/client/lib/desktop/bridge.ts +45 -0
  221. package/src/client/lib/desktop/dropped-paths.ts +83 -0
  222. package/src/client/lib/editor/tab-menu.test.ts +127 -0
  223. package/src/client/lib/editor/tab-menu.ts +127 -0
  224. package/src/client/lib/editor-dirty-tabs.test.ts +102 -0
  225. package/src/client/lib/editor-dirty-tabs.ts +103 -0
  226. package/src/client/lib/native/resume.test.ts +66 -0
  227. package/src/client/lib/native/resume.ts +42 -0
  228. package/src/client/lib/search-reveal.ts +1 -1
  229. package/src/client/main.tsx +13 -1
  230. package/src/client/tailwind.css +75 -8
  231. package/src/server/lib/auth/guard.test.ts +28 -0
  232. package/src/server/lib/auth/guard.ts +10 -0
  233. package/src/server/lib/bundler/css.test.ts +31 -0
  234. package/src/server/lib/fs/listing.test.ts +81 -16
  235. package/src/server/lib/fs/listing.ts +72 -5
  236. package/src/server/lib/fs/worktree/create.ts +2 -3
  237. package/src/server/lib/fs/worktree/list.ts +13 -0
  238. package/src/server/lib/fs/worktree/remove.ts +3 -3
  239. package/src/server/lib/fs/write-conflict.test.ts +68 -0
  240. package/src/server/lib/fs/write-conflict.ts +84 -0
  241. package/src/server/lib/lifecycle/claim-port.test.ts +156 -0
  242. package/src/server/lib/lifecycle/port-guard.test.ts +20 -164
  243. package/src/server/lib/lifecycle/port-guard.ts +39 -7
  244. package/src/server/lib/lifecycle/probe-health.test.ts +166 -0
  245. package/src/server/lib/lifecycle/probe.test.ts +77 -164
  246. package/src/server/lib/lifecycle/probe.ts +121 -13
  247. package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +112 -0
  248. package/src/server/lib/omp/rpc/frame-fold.ts +10 -5
  249. package/src/server/lib/omp/session/sidebar-activity.server.test.ts +162 -0
  250. package/src/server/lib/omp/session/sidebar-activity.server.ts +70 -0
  251. package/src/server/lib/omp/session/telemetry/compute.ts +13 -1
  252. package/src/server/lib/omp/session/telemetry.test.ts +33 -0
  253. package/src/server/lib/realtime/signals.server.ts +10 -0
  254. package/src/server/lib/realtime/topics/catalog.server.ts +4 -1
  255. package/src/server/lib/realtime/topics.server.ts +16 -0
  256. package/src/server/lib/updates/shell-assets.ts +94 -3
  257. package/src/server/lib/updates/shell-cache.ts +105 -0
  258. package/src/server/lib/updates/shell-pages.test.ts +33 -2
  259. package/src/server/lib/updates/shell-pages.ts +17 -5
  260. package/src/server/lib/updates/shell-release-desktop.test.ts +166 -0
  261. package/src/server/lib/updates/shell-release.test.ts +10 -27
  262. package/src/server/lib/updates/shell-release.ts +107 -111
  263. package/src/server/routes/fs/action-save-as.test.ts +82 -0
  264. package/src/server/routes/fs/action.test.ts +82 -0
  265. package/src/server/routes/fs/action.ts +54 -1
  266. package/src/server/routes/fs/exists.ts +11 -1
  267. package/src/server/routes/fs/git-merge.test.ts +11 -1
  268. package/src/server/routes/fs/read.test.ts +24 -7
  269. package/src/server/routes/fs/read.ts +6 -1
  270. package/src/server/routes/fs/scope.test.ts +15 -10
  271. package/src/server/routes/fs/scope.ts +3 -14
  272. package/src/server/routes/updates/android.ts +6 -1
  273. package/src/server/routes/updates/desktop.ts +29 -7
  274. package/src/server/routes/updates/ios.ts +5 -1
  275. package/src/server/routes/worktrees/list.ts +11 -1
  276. package/src/server/routes/worktrees/routes.test.ts +17 -0
  277. package/src/shared/lib/chat/timeline/omp-callbacks.test.ts +36 -0
  278. package/src/shared/lib/chat/timeline/omp-callbacks.ts +18 -0
  279. package/src/shared/lib/chat/timeline/run-signals.test.ts +2 -0
  280. package/src/shared/lib/code/editor/comment-syntax.test.ts +37 -0
  281. package/src/shared/lib/code/editor/comment-syntax.ts +55 -0
  282. package/src/shared/lib/code/editor/find-replace.test.ts +134 -0
  283. package/src/shared/lib/code/editor/{find.ts → find-replace.ts} +23 -107
  284. package/src/shared/lib/code/editor/{find.test.ts → find-scan.test.ts} +20 -74
  285. package/src/shared/lib/code/editor/find-scan.ts +198 -0
  286. package/src/shared/lib/code/editor/find-selection.test.ts +56 -0
  287. package/src/shared/lib/code/editor/indent-guide-rule.test.ts +65 -0
  288. package/src/shared/lib/code/editor/indent-guide-rule.ts +47 -0
  289. package/src/shared/lib/code/editor/indent-rules.test.ts +219 -0
  290. package/src/shared/lib/code/editor/indent-rules.ts +198 -0
  291. package/src/shared/lib/code/editor/keymap.test.ts +23 -0
  292. package/src/shared/lib/code/editor/keymap.ts +43 -6
  293. package/src/shared/lib/code/editor/lines.test.ts +7 -55
  294. package/src/shared/lib/code/editor/lines.ts +8 -48
  295. package/src/shared/lib/code/editor/marks.test.ts +4 -5
  296. package/src/shared/lib/code/editor/marks.ts +13 -25
  297. package/src/shared/lib/code/editor/palette.test.ts +25 -2
  298. package/src/shared/lib/code/editor/palette.ts +10 -0
  299. package/src/shared/lib/code/editor/stream-modes.ts +225 -0
  300. package/src/shared/lib/code/editor/theme-loader.ts +97 -0
  301. package/src/shared/lib/code/editor/themes.generated.ts +156 -0
  302. package/src/shared/lib/code/editor/themes.test.ts +165 -0
  303. package/src/shared/lib/code/editor/themes.ts +165 -0
  304. package/src/shared/lib/code/highlight-memo.test.ts +103 -0
  305. package/src/shared/lib/code/highlight-memo.ts +149 -0
  306. package/src/shared/lib/code/highlighter-warmup.ts +112 -0
  307. package/src/shared/lib/code/highlighter.ts +3 -1
  308. package/src/shared/lib/code/idle.ts +37 -0
  309. package/src/shared/lib/code/outline/rows.test.ts +96 -0
  310. package/src/shared/lib/code/outline/rows.ts +94 -0
  311. package/src/shared/lib/code/syntax-highlight.test.ts +2 -80
  312. package/src/shared/lib/code/syntax-highlight.ts +2 -3
  313. package/src/shared/lib/fs/file-kind-classify.test.ts +25 -11
  314. package/src/shared/lib/fs/file-kind.ts +47 -13
  315. package/src/shared/lib/fs/file-tree.test.ts +41 -0
  316. package/src/shared/lib/fs/file-tree.ts +126 -34
  317. package/src/shared/lib/fs/file-url.test.ts +52 -0
  318. package/src/shared/lib/fs/file-url.ts +37 -0
  319. package/src/shared/lib/fs/folder-chain.test.ts +87 -0
  320. package/src/shared/lib/fs/folder-chain.ts +91 -0
  321. package/src/shared/lib/fs/fs-helpers.test.ts +4 -50
  322. package/src/shared/lib/fs/patch-sides.test.ts +114 -0
  323. package/src/shared/lib/fs/patch-sides.ts +139 -0
  324. package/src/shared/lib/realtime/connection.test.ts +5 -1
  325. package/src/shared/lib/realtime/connection.ts +25 -119
  326. package/src/shared/lib/realtime/frozen-recovery.test.ts +93 -0
  327. package/src/shared/lib/realtime/protocol.ts +16 -0
  328. package/src/shared/lib/realtime/resume.ts +223 -0
  329. package/src/shared/lib/realtime/state.ts +22 -0
  330. package/src/shared/lib/realtime/watchdog-wiring.test.ts +224 -0
  331. package/src/shared/lib/realtime/watchdog.test.ts +99 -0
  332. package/src/shared/lib/realtime/watchdog.ts +72 -0
  333. package/src/shared/lib/ui/toolbar-overflow.test.ts +83 -0
  334. package/src/shared/lib/ui/toolbar-overflow.ts +86 -0
  335. package/src/shared/lib/updates/shell-arch.ts +54 -0
  336. package/src/shared/lib/updates/shell-ua.ts +4 -4
  337. package/src/shared/lib/workspace/editor-view-mode.test.ts +70 -0
  338. package/src/shared/lib/workspace/editor-view-mode.ts +48 -0
  339. package/src/shared/lib/workspace/panel-widths.test.ts +30 -0
  340. package/src/shared/lib/workspace/panel-widths.ts +25 -5
  341. package/src/shared/lib/workspace/session-state/cache.ts +159 -0
  342. package/src/shared/lib/workspace/session-state/harness.test-util.ts +55 -0
  343. package/src/shared/lib/workspace/session-state/merge.ts +100 -0
  344. package/src/shared/lib/workspace/session-state/store-load.test.ts +206 -0
  345. package/src/shared/lib/workspace/session-state/store.test.ts +17 -139
  346. package/src/shared/lib/workspace/session-state/store.ts +92 -130
  347. package/src/shared/lib/workspace/split-editor.test.ts +104 -0
  348. package/src/shared/lib/workspace/split-editor.ts +129 -0
  349. package/src/shared/lib/workspace/workspace-panel-widths.ts +124 -0
  350. package/src/shared/types/realtime.ts +29 -0
  351. package/src/shared/types/settings/state.ts +10 -0
  352. package/src/test-support/file-explorer-disk.test-util.ts +30 -3
  353. package/src/test-support/loopback.ts +183 -0
  354. package/src/test-support/pristine-globals.ts +7 -0
  355. package/dist/client/static/js/index-gtbpewr7.css +0 -1
  356. package/src/client/components/common/code-editor/handler.test.ts +0 -274
  357. package/src/client/components/common/code-editor/handler.ts +0 -175
  358. package/src/client/components/common/code-editor/index.tsx +0 -314
  359. package/src/client/components/common/code-surface/measure.ts +0 -148
  360. package/src/client/components/workspace/chat-timeline/target-picker/index.test.tsx +0 -227
  361. package/src/client/components/workspace/chat-timeline/target-picker/index.tsx +0 -260
  362. package/src/client/components/workspace/diff-panel/SplitView.tsx +0 -209
  363. package/src/client/components/workspace/diff-panel/UnifiedView.tsx +0 -150
  364. package/src/client/hooks/editor/scroll-container.test.ts +0 -102
  365. package/src/client/hooks/editor/scroll-container.ts +0 -26
  366. package/src/client/hooks/editor/use-code-window.ts +0 -100
  367. package/src/client/hooks/editor/use-editor-history.test.ts +0 -216
  368. package/src/client/hooks/editor/use-editor-history.ts +0 -134
  369. package/src/client/hooks/editor/use-occurrences.test.ts +0 -236
  370. package/src/client/hooks/editor/use-occurrences.ts +0 -98
  371. package/src/shared/lib/code/editor/commands.test.ts +0 -155
  372. package/src/shared/lib/code/editor/commands.ts +0 -260
  373. package/src/shared/lib/code/editor/edits.test.ts +0 -100
  374. package/src/shared/lib/code/editor/edits.ts +0 -122
  375. package/src/shared/lib/code/editor/history.test.ts +0 -118
  376. package/src/shared/lib/code/editor/history.ts +0 -101
  377. package/src/shared/lib/code/editor/layers.test.ts +0 -77
  378. package/src/shared/lib/code/editor/layers.ts +0 -67
  379. package/src/shared/lib/code/editor/line-edits.test.ts +0 -131
  380. package/src/shared/lib/code/editor/line-edits.ts +0 -159
  381. package/src/shared/lib/code/editor/occurrences.test.ts +0 -117
  382. package/src/shared/lib/code/editor/occurrences.ts +0 -111
  383. package/src/shared/lib/code/editor/reset-css.test.ts +0 -35
  384. package/src/shared/lib/code/editor/reset-css.ts +0 -32
  385. package/src/shared/lib/code/editor/text-commands.test.ts +0 -178
  386. package/src/shared/lib/code/editor/text-commands.ts +0 -154
  387. package/src/shared/lib/code/lazy-window.test.ts +0 -161
  388. package/src/shared/lib/code/lazy-window.ts +0 -156
  389. package/src/shared/lib/code/windowed-highlight.ts +0 -114
  390. package/src/shared/lib/fs/diff-parser.test.ts +0 -116
  391. package/src/shared/lib/fs/diff-parser.ts +0 -213
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The watchdog's decision, pinned directly.
8
+ *
9
+ * Every branch here answers a timing question, and a timing case driven through
10
+ * real timers is a test of the clock rather than of the rule. The driver that
11
+ * calls this is `resume.ts`; the interval it owns is covered separately in
12
+ * `connection.test.ts`, through the public client.
13
+ *
14
+ * The reported failure this exists for: an Android WebView that was backgrounded
15
+ * fires no `visibilitychange` on return, and a socket the server's 30s heartbeat
16
+ * reaped while the page was frozen produces no `close` — `readyState` still says
17
+ * OPEN. The channel sat on a corpse until a page reload.
18
+ */
19
+
20
+ import { describe, expect, test } from 'bun:test';
21
+
22
+ import {
23
+ FREEZE_DETECT_MS,
24
+ IDLE_PROBE_AFTER_MS,
25
+ LIVENESS_TICK_MS,
26
+ watchdogAction,
27
+ } from '@/shared/lib/realtime/watchdog';
28
+
29
+ /** A healthy tick: on schedule, traffic just arrived, page visible and open. */
30
+ const HEALTHY = {
31
+ sinceTick: LIVENESS_TICK_MS,
32
+ sinceInbound: LIVENESS_TICK_MS,
33
+ hidden: false,
34
+ open: true,
35
+ wanted: true,
36
+ } as const;
37
+
38
+ describe('watchdogAction', () => {
39
+ test('a healthy connection asks for nothing', () => {
40
+ expect(watchdogAction(HEALTHY)).toBeNull();
41
+ });
42
+
43
+ test('a late tick is a freeze, and waking beats probing', () => {
44
+ // The page was suspended: the clock moved, our interval did not. This is the
45
+ // only resume signal a backgrounded Android WebView leaves behind.
46
+ expect(watchdogAction({ ...HEALTHY, sinceTick: FREEZE_DETECT_MS + 1 })).toBe('wake');
47
+ // Even with the socket silent for longer still, waking is the stronger
48
+ // repair: it re-dials a socket that is gone, while a probe can only question
49
+ // one the browser still believes in.
50
+ expect(
51
+ watchdogAction({ ...HEALTHY, sinceTick: FREEZE_DETECT_MS + 1, sinceInbound: IDLE_PROBE_AFTER_MS * 4 }),
52
+ ).toBe('wake');
53
+ });
54
+
55
+ test('a late tick on a HIDDEN page is throttling, not a freeze', () => {
56
+ // A hidden tab is legitimately throttled to about a tick a minute. Reading
57
+ // that as a freeze would re-dial on every throttled tick for a page nobody is
58
+ // looking at.
59
+ expect(
60
+ watchdogAction({ ...HEALTHY, hidden: true, sinceTick: LIVENESS_TICK_MS * 20 }),
61
+ ).toBeNull();
62
+ });
63
+
64
+ test('silence on a visible open socket is probed', () => {
65
+ expect(watchdogAction({ ...HEALTHY, sinceInbound: IDLE_PROBE_AFTER_MS })).toBe('probe');
66
+ });
67
+
68
+ test('a probe fires below the server heartbeat, not after it', () => {
69
+ // The server reaps an unanswered connection at 30s. Probing later would only
70
+ // ever discover a connection already torn down.
71
+ expect(IDLE_PROBE_AFTER_MS).toBeLessThan(30_000);
72
+ expect(FREEZE_DETECT_MS).toBeGreaterThan(LIVENESS_TICK_MS);
73
+ });
74
+
75
+ test('silence on a hidden page is still probed', () => {
76
+ // Deliberately not gated on visibility: a connection that died while the
77
+ // user was in another app is repaired before they come back, rather than
78
+ // after. `wake` is what needs the page to be visible.
79
+ expect(
80
+ watchdogAction({ ...HEALTHY, hidden: true, sinceInbound: IDLE_PROBE_AFTER_MS + 1 }),
81
+ ).toBe('probe');
82
+ });
83
+
84
+ test('a closed socket is never probed', () => {
85
+ // `wake` owns the re-dial path; a probe has nothing to send on.
86
+ expect(watchdogAction({ ...HEALTHY, open: false, sinceInbound: IDLE_PROBE_AFTER_MS * 3 })).toBeNull();
87
+ });
88
+
89
+ test('nothing happens once every subscription is released', () => {
90
+ expect(
91
+ watchdogAction({ ...HEALTHY, wanted: false, sinceTick: FREEZE_DETECT_MS * 3, sinceInbound: IDLE_PROBE_AFTER_MS * 3 }),
92
+ ).toBeNull();
93
+ });
94
+
95
+ test('a tick one millisecond under either threshold is not enough', () => {
96
+ expect(watchdogAction({ ...HEALTHY, sinceTick: FREEZE_DETECT_MS })).toBeNull();
97
+ expect(watchdogAction({ ...HEALTHY, sinceInbound: IDLE_PROBE_AFTER_MS - 1 })).toBeNull();
98
+ });
99
+ });
@@ -0,0 +1,72 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The watchdog's DECISION, separated from the interval that drives it.
8
+ *
9
+ * A pure function over two clocks, because the cases that matter are timing
10
+ * cases and a timing case tested through real timers is a test of the clock. The
11
+ * driver in `resume.ts` reads `Date.now()` and calls this; every branch below is
12
+ * pinned directly.
13
+ *
14
+ * Two facts it distinguishes, and neither is available from the browser:
15
+ *
16
+ * - **The page was FROZEN.** A tick that arrives far later than its deadline
17
+ * cannot be produced by a running interval, so the page was suspended — a
18
+ * backgrounded phone, a suspended tab. That is a resume, and the failure count
19
+ * from the frozen window is worthless.
20
+ * - **The socket is SILENT.** An OPEN socket with no inbound traffic for longer
21
+ * than the idle window is questioned, which catches a connection that died
22
+ * while the tab stayed visible (a Wi-Fi to cellular handoff).
23
+ *
24
+ * A HIDDEN document is neither: it is legitimately throttled to roughly a tick a
25
+ * minute, so every tick would read as a freeze. Freeze detection is therefore
26
+ * gated on a visible page, while the idle probe is not — that one also repairs a
27
+ * connection that died while the user was in another app, before they return.
28
+ */
29
+
30
+ /** How often the watchdog runs. */
31
+ export const LIVENESS_TICK_MS = 5_000;
32
+ /**
33
+ * A tick this much later than it was scheduled means the page was frozen: a
34
+ * running interval cannot skip its own deadline by this much.
35
+ */
36
+ export const FREEZE_DETECT_MS = LIVENESS_TICK_MS * 2;
37
+ /**
38
+ * Silence on an OPEN socket that justifies a probe. Below the server's 30s
39
+ * protocol heartbeat, so a connection the server is about to reap is checked
40
+ * before the reap rather than after it.
41
+ */
42
+ export const IDLE_PROBE_AFTER_MS = 25_000;
43
+
44
+ export interface WatchdogInput {
45
+ /** Milliseconds since the previous tick fired. */
46
+ sinceTick: number;
47
+ /** Milliseconds since anything last arrived on the open socket. */
48
+ sinceInbound: number;
49
+ /** Whether the document reports itself hidden. */
50
+ hidden: boolean;
51
+ /** Whether a socket is open right now (the probe is only meaningful then). */
52
+ open: boolean;
53
+ /** Whether anyone still wants the channel. */
54
+ wanted: boolean;
55
+ }
56
+
57
+ /**
58
+ * `'wake'` — treat the page as back (reset the budget, probe or re-dial);
59
+ * `'probe'` — question the open socket; `null` — nothing to do.
60
+ */
61
+ export type WatchdogAction = 'wake' | 'probe' | null;
62
+
63
+ export function watchdogAction(input: WatchdogInput): WatchdogAction {
64
+ if (!input.wanted) return null;
65
+ // Ordered: a freeze explains the silence too, and waking is the stronger
66
+ // repair — it re-dials when the socket is already gone, while a probe can only
67
+ // question one the browser still believes in.
68
+ if (input.sinceTick > FREEZE_DETECT_MS && !input.hidden) return 'wake';
69
+ if (!input.open) return null;
70
+ if (input.sinceInbound < IDLE_PROBE_AFTER_MS) return null;
71
+ return 'probe';
72
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The `⋯` rule, asserted as arithmetic.
8
+ *
9
+ * Each case is a failure the toolbars had: a row that wrapped into two rows
10
+ * instead of hiding a control, a control hidden while the width was still
11
+ * unknown (a menu flashing on every mount), and a pinned control buried in the
12
+ * menu because the row happened to be narrow.
13
+ */
14
+
15
+ import { describe, expect, test } from 'bun:test';
16
+
17
+ import {
18
+ TOOLBAR_ITEM_GAP_PX,
19
+ TOOLBAR_OVERFLOW_TRIGGER_PX,
20
+ toolbarHasOverflow,
21
+ toolbarVisibleClusters,
22
+ } from '@/shared/lib/ui/toolbar-overflow';
23
+
24
+ /** Save, find, wrap, zoom, copy, modes, full screen — the editor's real row. */
25
+ const widths = [26, 26, 26, 52, 52, 52, 26];
26
+ const pinned = [true, false, false, false, false, true, true];
27
+
28
+ /** Row width needed to draw `visible` plus the trigger when anything is hidden. */
29
+ function rowWidth(visible: boolean[]): number {
30
+ const shown = widths.filter((_, index) => visible[index]);
31
+ const overflow = toolbarHasOverflow(visible);
32
+ return (
33
+ shown.reduce((sum, width) => sum + width, 0) +
34
+ TOOLBAR_ITEM_GAP_PX * Math.max(0, shown.length - 1) +
35
+ (overflow ? TOOLBAR_OVERFLOW_TRIGGER_PX + TOOLBAR_ITEM_GAP_PX : 0)
36
+ );
37
+ }
38
+
39
+ describe('toolbarVisibleClusters', () => {
40
+ test('an unmeasured row shows every cluster', () => {
41
+ // Not "hide everything": the row is measured a layout effect later, and a
42
+ // menu that flashes on every mount is worse than one frame of a full row.
43
+ expect(toolbarVisibleClusters({ widths, pinned, available: 0 }).every(Boolean)).toBe(true);
44
+ });
45
+
46
+ test('a row wide enough for everything shows everything, with no trigger', () => {
47
+ const total = widths.reduce((sum, width) => sum + width, 0) + TOOLBAR_ITEM_GAP_PX * (widths.length - 1);
48
+ const visible = toolbarVisibleClusters({ widths, pinned, available: total });
49
+ expect(visible.every(Boolean)).toBe(true);
50
+ expect(toolbarHasOverflow(visible)).toBe(false);
51
+ });
52
+
53
+ test('a narrow row hides what does not fit and reserves the trigger', () => {
54
+ // 200px of row: the three pinned clusters (26 + 52 + 26) plus their gaps
55
+ // leave room for one unpinned control and the `⋯` trigger, and no more.
56
+ const visible = toolbarVisibleClusters({ widths, pinned, available: 200 });
57
+ expect(toolbarHasOverflow(visible)).toBe(true);
58
+ // The promise the arithmetic has to keep: what stays plus the trigger fits.
59
+ expect(rowWidth(visible)).toBeLessThanOrEqual(200);
60
+ });
61
+
62
+ test('a pinned cluster stays on the row at any width', () => {
63
+ // A 120px row fits one 26px control plus the trigger, and the pinned width
64
+ // modes (52px) would not fit at all on their own — they stay regardless,
65
+ // because a menu-only mode button is a mode the reader never finds.
66
+ const visible = toolbarVisibleClusters({ widths, pinned, available: 120 });
67
+ expect(visible[0]).toBe(true);
68
+ expect(visible[5]).toBe(true);
69
+ expect(visible[6]).toBe(true);
70
+ // The unpinned controls are what gives way.
71
+ expect(visible[1]).toBe(false);
72
+ });
73
+
74
+ test('order is preserved: what stays is a subsequence, not a re-sort', () => {
75
+ const visible = toolbarVisibleClusters({ widths, pinned, available: 200 });
76
+ const shownIndexes = visible.flatMap((isShown, index) => (isShown ? [index] : []));
77
+ expect([...shownIndexes].sort((a, b) => a - b)).toEqual(shownIndexes);
78
+ });
79
+
80
+ test('no clusters is no row', () => {
81
+ expect(toolbarVisibleClusters({ widths: [], pinned: [], available: 500 })).toEqual([]);
82
+ });
83
+ });
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * Which toolbar clusters fit on ONE row, and which go into the `⋯` menu.
8
+ *
9
+ * The editor and diff toolbars carry ten-plus controls and the editor panel is
10
+ * 320px wide on a 1440px screen. WRAPPING was the previous answer and it is the
11
+ * wrong one: a second row moves the document down by the toolbar's own height
12
+ * and reads as a second toolbar. A horizontal scroll is worse still — a clipped
13
+ * control is invisible and reads as "there is nothing more here".
14
+ *
15
+ * So: the clusters that do not fit move into a `⋯` menu, and a cluster can be
16
+ * PINNED to stay on the row at every width. Pinning is what keeps this from
17
+ * being a priority guess — the toolbar's visual order is not its priority order
18
+ * (Save is drawn first because that is where a reader looks for it, while the
19
+ * width modes sit last and are the reason the panel exists).
20
+ *
21
+ * Pure, and measured widths in: the caller lays the clusters out once and hands
22
+ * their rendered widths here. A table of guessed pixel widths drifts the moment
23
+ * a label, an icon or a font changes.
24
+ */
25
+
26
+ /** Width the `⋯` trigger needs, including the gap before it. */
27
+ export const TOOLBAR_OVERFLOW_TRIGGER_PX = 30;
28
+
29
+ /** Gap between two clusters (`gap-x-1`). */
30
+ export const TOOLBAR_ITEM_GAP_PX = 4;
31
+
32
+ export interface ToolbarOverflowArgs {
33
+ /** Rendered width of each cluster, in row order. */
34
+ widths: number[];
35
+ /** Which clusters never leave the row. Same length as `widths`. */
36
+ pinned: boolean[];
37
+ /** Width the row actually has, or 0 before it is measured. */
38
+ available: number;
39
+ }
40
+
41
+ /**
42
+ * Which clusters to render on the row, in row order.
43
+ *
44
+ * An unmeasured row (available 0) keeps everything: hiding controls before the
45
+ * width is known flashes a menu on every mount, and the row is measured a
46
+ * layout effect later.
47
+ */
48
+ export function toolbarVisibleClusters({ widths, pinned, available }: ToolbarOverflowArgs): boolean[] {
49
+ if (!(available > 0) || widths.length === 0) return widths.map(() => true);
50
+
51
+ const total = widths.reduce((sum, width) => sum + width, 0) + TOOLBAR_ITEM_GAP_PX * (widths.length - 1);
52
+ if (total <= available) return widths.map(() => true);
53
+
54
+ // Pinned clusters are placed FIRST and in full, because whether the row is
55
+ // wide enough for them is not a question — they stay and the row clips if it
56
+ // must. The unpinned ones then take whatever is left, in row order, once the
57
+ // `⋯` trigger's own width is set aside. Filling in one pass over row order
58
+ // instead would let an early unpinned control consume the space a pinned one
59
+ // later needs.
60
+ const shown = widths.map(() => false);
61
+ let used = 0;
62
+ let rendered = 0;
63
+ widths.forEach((width, index) => {
64
+ if (!pinned[index]) return;
65
+ used += width + (rendered > 0 ? TOOLBAR_ITEM_GAP_PX : 0);
66
+ rendered += 1;
67
+ shown[index] = true;
68
+ });
69
+
70
+ let budget = available - used - TOOLBAR_OVERFLOW_TRIGGER_PX - TOOLBAR_ITEM_GAP_PX;
71
+ widths.forEach((width, index) => {
72
+ if (pinned[index]) return;
73
+ const cost = width + (rendered > 0 ? TOOLBAR_ITEM_GAP_PX : 0);
74
+ if (cost > budget) return;
75
+ budget -= cost;
76
+ rendered += 1;
77
+ shown[index] = true;
78
+ });
79
+
80
+ return shown;
81
+ }
82
+
83
+ /** True when at least one cluster is going into the menu. */
84
+ export function toolbarHasOverflow(visible: boolean[]): boolean {
85
+ return visible.some((shown) => !shown);
86
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The architecture a DESKTOP shell runs as, and the artifact it installs itself
8
+ * from.
9
+ *
10
+ * ## Why this exists at all
11
+ *
12
+ * Every desktop artifact is per-architecture (`Kabmo-0.2.0-mac-arm64.zip`,
13
+ * `Kabmo-0.2.0-win-x64-setup.exe`), and the console used to answer a desktop
14
+ * probe with the RELEASE PAGE precisely because it could not know which
15
+ * architecture the window asking was running on. That is correct for a link and
16
+ * useless for a self-update: handing an arm64 reader an x64 installer produces
17
+ * an app that does not launch, and on Windows an installer that refuses with
18
+ * "this installation package could not be opened".
19
+ *
20
+ * So a desktop shell reports its own architecture over the bridge, and the
21
+ * server names the ONE artifact. This module is the vocabulary both ends share,
22
+ * which is what stops the shell, the route and the asset table from spelling
23
+ * `x86_64`, `x64` and `amd64` for the same machine.
24
+ *
25
+ * ## Two spellings, one canonical token
26
+ *
27
+ * A shell reports the CANONICAL token (`arm64` / `x64`) because that is what the
28
+ * client and the route pass around. Each platform's release assets spell its
29
+ * architecture differently — Linux says `x86_64`, macOS and Windows say `x64` —
30
+ * and that mapping lives in ONE table (`SHELL_ASSETS`), on the server, next to
31
+ * the names it has to match. A shell that mapped its own spelling to the asset's
32
+ * would be a second copy of the same fact.
33
+ */
34
+
35
+ /** A desktop architecture, in the vocabulary the console and the shells share. */
36
+ export type ShellArch = 'arm64' | 'x64';
37
+
38
+ /**
39
+ * Read a canonical arch out of a string, or null.
40
+ *
41
+ * Lenient about the spellings a shell might report (a shell that read
42
+ * `std::env::consts::ARCH` says `x86_64`; one that read
43
+ * `RuntimeInformation.ProcessArchitecture` says `X64`), because a refused arch
44
+ * costs the reader the self-update and buys nothing: the value only chooses
45
+ * between two artifacts of the same product, and the artifact is then verified
46
+ * by the shell before it is installed.
47
+ */
48
+ export function parseShellArch(value: string | null | undefined): ShellArch | null {
49
+ if (!value) return null;
50
+ const folded = value.trim().toLowerCase();
51
+ if (folded === 'arm64' || folded === 'aarch64') return 'arm64';
52
+ if (folded === 'x64' || folded === 'x86_64' || folded === 'amd64') return 'x64';
53
+ return null;
54
+ }
@@ -23,10 +23,10 @@ export type MobileShellKind = 'android' | 'ios';
23
23
 
24
24
  /**
25
25
  * The desktop shells. They carry NO User-Agent token — a desktop app is not
26
- * downloaded from the console, so the server has nothing to parse per request.
27
- * They report their version over the shell bridge instead (`__kabmoDesktop`),
28
- * which is why they are a separate family: the version exists, the UA channel
29
- * does not.
26
+ * downloaded from a page, so the server has nothing to parse per request. They
27
+ * report their version and their ARCHITECTURE over the shell bridge instead
28
+ * (`__kabmoDesktop`), which is why they are a separate family: both facts exist,
29
+ * the UA channel does not.
30
30
  */
31
31
  export type DesktopShellKind = 'macos' | 'windows' | 'linux';
32
32
 
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The three width modes' table, asserted as data.
8
+ *
9
+ * Each case is a rule the layout depends on and that no component test would
10
+ * catch: `compact` must NOT hide the sidebar (that is `full`'s job, and the
11
+ * two buttons would be the same button if it did), the right panel is hidden
12
+ * by neither, and clicking an active mode returns to `normal` rather than
13
+ * doing nothing.
14
+ */
15
+
16
+ import { describe, expect, test } from 'bun:test';
17
+
18
+ import {
19
+ DEFAULT_EDITOR_VIEW_MODE,
20
+ isEditorViewMode,
21
+ editorViewHides,
22
+ toggledEditorViewMode,
23
+ } from '@/shared/lib/workspace/editor-view-mode';
24
+
25
+ describe('editorViewHides', () => {
26
+ test('compact hides the chat only', () => {
27
+ expect(editorViewHides('compact', 'chat')).toBe(true);
28
+ expect(editorViewHides('compact', 'sidebar')).toBe(false);
29
+ });
30
+
31
+ test('full hides the chat AND the sidebar', () => {
32
+ expect(editorViewHides('full', 'chat')).toBe(true);
33
+ expect(editorViewHides('full', 'sidebar')).toBe(true);
34
+ });
35
+
36
+ test('normal hides nothing', () => {
37
+ expect(editorViewHides('normal', 'chat')).toBe(false);
38
+ expect(editorViewHides('normal', 'sidebar')).toBe(false);
39
+ });
40
+ });
41
+
42
+ describe('toggledEditorViewMode', () => {
43
+ test('a mode button enters its mode', () => {
44
+ expect(toggledEditorViewMode('normal', 'compact')).toBe('compact');
45
+ expect(toggledEditorViewMode('normal', 'full')).toBe('full');
46
+ });
47
+
48
+ test('the OTHER mode switches rather than toggling off', () => {
49
+ expect(toggledEditorViewMode('compact', 'full')).toBe('full');
50
+ expect(toggledEditorViewMode('full', 'compact')).toBe('compact');
51
+ });
52
+
53
+ test('clicking the active mode returns to normal', () => {
54
+ expect(toggledEditorViewMode('compact', 'compact')).toBe('normal');
55
+ expect(toggledEditorViewMode('full', 'full')).toBe('normal');
56
+ });
57
+ });
58
+
59
+ describe('isEditorViewMode', () => {
60
+ test('accepts the three modes and nothing else', () => {
61
+ expect(['normal', 'compact', 'full'].every(isEditorViewMode)).toBe(true);
62
+ expect(isEditorViewMode('fullscreen')).toBe(false);
63
+ expect(isEditorViewMode(undefined)).toBe(false);
64
+ expect(isEditorViewMode(null)).toBe(false);
65
+ });
66
+
67
+ test('the fallback is the ordinary layout', () => {
68
+ expect(DEFAULT_EDITOR_VIEW_MODE).toBe('normal');
69
+ });
70
+ });
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * How wide the editor column is allowed to be, as ONE of three modes.
8
+ *
9
+ * `compact` and `full` both hide the chat timeline and let the editor take the
10
+ * width the chat had; `full` also hides the session sidebar. Neither touches
11
+ * the right panel: the point of the two modes is a wider DOCUMENT, and the
12
+ * right column is where the outline, search hits and the diff list live while
13
+ * it is being read. The third width — the existing `fixed inset-0` full
14
+ * SCREEN — is a different thing entirely (it covers the right panel too) and
15
+ * stays where it is, on its own button.
16
+ *
17
+ * The rules are pure so the layout, both toolbars and the tests read the same
18
+ * table: which columns a mode hides is data, never a condition at a call site.
19
+ */
20
+
21
+ export type EditorViewMode = 'normal' | 'compact' | 'full';
22
+
23
+ /** The two modes a toolbar button can name. */
24
+ export type EditorViewModeTarget = 'compact' | 'full';
25
+
26
+ /** Session-state slot. Per session, like every other layout choice. */
27
+ export const EDITOR_VIEW_MODE_KEY = 'layout.editorViewMode';
28
+
29
+ export const DEFAULT_EDITOR_VIEW_MODE: EditorViewMode = 'normal';
30
+
31
+ /** A stored value written by another build is not a mode this one can draw. */
32
+ export function isEditorViewMode(value: unknown): value is EditorViewMode {
33
+ return value === 'normal' || value === 'compact' || value === 'full';
34
+ }
35
+
36
+ /**
37
+ * What a mode HIDES. `full` hides everything `compact` does plus the sidebar,
38
+ * so it is strictly wider — the two are ordered, not alternatives.
39
+ */
40
+ export function editorViewHides(mode: EditorViewMode, column: 'chat' | 'sidebar'): boolean {
41
+ if (column === 'chat') return mode === 'compact' || mode === 'full';
42
+ return mode === 'full';
43
+ }
44
+
45
+ /** Clicking the mode a button already names returns to `normal`. */
46
+ export function toggledEditorViewMode(current: EditorViewMode, next: EditorViewModeTarget): EditorViewMode {
47
+ return current === next ? 'normal' : next;
48
+ }
@@ -124,6 +124,27 @@ describe('resolvePanelWidth', () => {
124
124
  // panel keeps its minimum and the row clips, rather than collapsing.
125
125
  expect(resolvePanelWidth({ ...base, available: 400, siblingWidth: 320, handleCount: 2 })).toBe(320);
126
126
  });
127
+
128
+ test('a collapsed chat removes the floor AND the pair caps', () => {
129
+ const available = 2000;
130
+ // The ordinary layout would cap this at 0.6 × 2000 = 1200 (own cap) and at
131
+ // 0.7 × 2000 − 320 = 1080 (pair cap, a sibling reserving its floor), and the
132
+ // chat's 400 floor would bind at 1280. With no chat on screen there is no
133
+ // conversation to leave room for, so only the group's own width limits it.
134
+ const wanted = { fraction: 0.9 };
135
+ expect(resolvePanelWidth({ ...base, available, siblingWidth: 320, handleCount: 1, stored: wanted })).toBe(
136
+ Math.round(PAIR_MAX_FRACTION * available),
137
+ );
138
+ expect(resolvePanelWidth({ ...base, available, siblingWidth: 320, handleCount: 1, stored: wanted, chatHidden: true })).toBe(
139
+ available - 320 - 1 * 3,
140
+ );
141
+ });
142
+
143
+ test('the floor still wins with the chat collapsed', () => {
144
+ // A group narrower than the sibling and this panel's floor: the panel keeps
145
+ // its minimum rather than collapsing into nothing.
146
+ expect(resolvePanelWidth({ ...base, available: 400, siblingWidth: 320, handleCount: 1, chatHidden: true })).toBe(320);
147
+ });
127
148
  });
128
149
 
129
150
  describe('the editor/right-panel pair', () => {
@@ -273,4 +294,13 @@ describe('pairMaxSize (the drag cap)', () => {
273
294
  test('no measured area means no cap', () => {
274
295
  expect(pairMaxSize({ available: null, siblingMin: editorMin, siblingOpen: true })).toBeUndefined();
275
296
  });
297
+
298
+ test('a collapsed chat lets a drag reach the whole row', () => {
299
+ // Two panels and nothing else: the editor may be dragged up to the group's
300
+ // width minus the right panel's floor. The 0.6 own-cap would have frozen the
301
+ // separator at 2400 of 4000 with 1600px of empty row behind it.
302
+ expect(pairMaxSize({ available, siblingMin: rightMin, siblingOpen: true, chatHidden: true })).toBe(available - rightMin);
303
+ // The sibling closed means nothing to reserve at all.
304
+ expect(pairMaxSize({ available, siblingMin: 0, siblingOpen: false, chatHidden: true })).toBe(available);
305
+ });
276
306
  });
@@ -149,6 +149,13 @@ export interface ResolveWidthArgs {
149
149
  siblingWidth: number;
150
150
  /** Separators in the group, which also consume width. */
151
151
  handleCount: number;
152
+ /**
153
+ * The CHAT column is collapsed (`compact`/`full` editor views), so it holds no
154
+ * floor and the pair caps do not apply — both exist to leave the conversation
155
+ * a share of the group, and neither has anything to reserve once it is off
156
+ * screen. Keeping them would cap a two-panel layout at 70% of its width.
157
+ */
158
+ chatHidden?: boolean;
152
159
  }
153
160
 
154
161
  /**
@@ -172,7 +179,7 @@ export interface ResolveWidthArgs {
172
179
  * default pixel width is used unchanged.
173
180
  */
174
181
  export function resolvePanelWidth(args: ResolveWidthArgs): number {
175
- const { stored, defaultFraction, defaultPx, available, min, pairReservePx = 0, siblingWidth, handleCount } = args;
182
+ const { stored, defaultFraction, defaultPx, available, min, pairReservePx = 0, siblingWidth, handleCount, chatHidden = false } = args;
176
183
 
177
184
  if (available === null || available <= 0) return Math.max(min, Math.round(stored?.px ?? defaultPx));
178
185
 
@@ -182,14 +189,20 @@ export function resolvePanelWidth(args: ResolveWidthArgs): number {
182
189
  // `total × available − the sibling's reserved px` — and ROUNDED, because
183
190
  // `0.7 × 4000` is `2799.9999…` in binary floating point and flooring it lands
184
191
  // a pixel short of the intended share.
185
- const ownCap = Math.round(PAIR_MAX_FRACTION * available);
186
- const pairCap = Math.round(PAIR_MAX_TOTAL_FRACTION * available) - pairReservePx;
192
+ //
193
+ // With the chat COLLAPSED neither cap means anything: the pair's 70% share
194
+ // and the chat floor are both about leaving the conversation room, and there
195
+ // is no conversation on screen. Only the group's own width remains a limit,
196
+ // which is what lets the editor take the width the chat had.
197
+ const ownCap = chatHidden ? Number.MAX_SAFE_INTEGER : Math.round(PAIR_MAX_FRACTION * available);
198
+ const pairCap = chatHidden ? Number.MAX_SAFE_INTEGER : Math.round(PAIR_MAX_TOTAL_FRACTION * available) - pairReservePx;
199
+ const chatFloor = chatHidden ? 0 : MIN_CHAT_PANEL_WIDTH;
187
200
  const ceiling = Math.max(
188
201
  min,
189
202
  Math.min(
190
203
  ownCap,
191
204
  pairCap,
192
- Math.floor(available - MIN_CHAT_PANEL_WIDTH - siblingWidth - handleCount * HANDLE_WIDTH),
205
+ Math.floor(available - chatFloor - siblingWidth - handleCount * HANDLE_WIDTH),
193
206
  ),
194
207
  );
195
208
 
@@ -263,9 +276,16 @@ export function pairMaxSize(args: {
263
276
  siblingMin: number;
264
277
  /** The sibling is open and therefore reserves its floor from the pair total. */
265
278
  siblingOpen: boolean;
279
+ /** The chat column is collapsed, so the pair's shared share is the whole group. */
280
+ chatHidden?: boolean;
266
281
  }): number | undefined {
267
- const { available, siblingMin, siblingOpen } = args;
282
+ const { available, siblingMin, siblingOpen, chatHidden = false } = args;
268
283
  if (available === null || available <= 0) return undefined;
284
+ // No chat on screen means nothing to reserve a share FOR: the pair is the
285
+ // whole row, so each side may be dragged up to the group's width minus the
286
+ // sibling's floor. The 60% own-cap would freeze a separator halfway across a
287
+ // layout whose only two panels are the ones being dragged.
288
+ if (chatHidden) return Math.max(0, Math.floor(available - (siblingOpen ? siblingMin : 0)));
269
289
  const ownCap = Math.round(PAIR_MAX_FRACTION * available);
270
290
  if (!siblingOpen) return ownCap;
271
291
  const pairCap = Math.round(PAIR_MAX_TOTAL_FRACTION * available) - siblingMin;