@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
@@ -1,6 +1,11 @@
1
1
  import { useEffect, useRef, useState } from 'preact/hooks';
2
2
  import { FileIcon } from '@/client/components/common/file-icon';
3
3
  import { ChevronDown, GitCompare, X } from 'lucide-preact';
4
+ import { useDirtyTabs } from '@/client/lib/editor-dirty-tabs';
5
+ import { TabContextMenu } from '@/client/components/workspace/editor/TabContextMenu';
6
+ import { buildTabMenuRows, type TabMenuAction } from '@/client/lib/editor/tab-menu';
7
+ import { splitCandidate } from '@/shared/lib/workspace/split-editor';
8
+ import { PanelRight } from 'lucide-preact';
4
9
  import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
5
10
  import { getGitStatusInfo } from '@/shared/lib/fs/git-status';
6
11
  import type { OpenedFile } from '@/shared/types/fs';
@@ -12,13 +17,50 @@ interface EditorTabsProps {
12
17
  onCloseFile: (id: number | string) => void;
13
18
  /** Tab ids whose file no longer exists on disk (see `useMissingFiles`). */
14
19
  missingIds?: ReadonlySet<number | string>;
20
+ /**
21
+ * The tab menu's non-close actions.
22
+ *
23
+ * Kept as callbacks rather than done here: copying a path and revealing a file both
24
+ * need the workspace scope, which the strip does not have.
25
+ */
26
+ onCopyPath?: (tab: OpenedFile) => void;
27
+ onRevealInFiles?: (tab: OpenedFile) => void;
28
+ /** Restore the most recently closed tab; returns false with an empty stack. */
29
+ onReopenClosed?: () => boolean;
30
+ /** How many tabs can still be reopened, so the menu row can be absent when none can. */
31
+ reopenableCount?: () => number;
32
+ /** Split the column to this tab, or change which tab the right pane shows. */
33
+ onSplitTo?: (id: number | string) => void;
34
+ /** Collapse the split. The tabs stay open — a split is a view. */
35
+ onUnsplit?: () => void;
36
+ /** The tab the right pane shows, so `Split right` can be absent for it. */
37
+ splitRightFileId?: number | string | null;
15
38
  }
16
39
 
17
- export function EditorTabs({ openedFiles, activeFileId, onSelectFile, onCloseFile, missingIds }: EditorTabsProps) {
40
+ export function EditorTabs({
41
+ openedFiles,
42
+ activeFileId,
43
+ onSelectFile,
44
+ onCloseFile,
45
+ missingIds,
46
+ onCopyPath,
47
+ onRevealInFiles,
48
+ onReopenClosed,
49
+ reopenableCount,
50
+ onSplitTo,
51
+ onUnsplit,
52
+ splitRightFileId = null,
53
+ }: EditorTabsProps) {
54
+ // Which tabs hold edits that are not on disk. The dot replaces the close `×`
55
+ // while the tab is dirty — the VS Code convention, and the reason it costs no
56
+ // extra column: a second mark beside the × would narrow the name on every tab.
57
+ const dirtyIds = useDirtyTabs();
18
58
  const tabsContainerRef = useRef<HTMLDivElement>(null);
19
59
  const dropdownRef = useRef<HTMLDivElement>(null);
20
60
  const [maxVisibleTabs, setMaxVisibleTabs] = useState(5);
21
61
  const [showDropdown, setShowDropdown] = useState(false);
62
+ /** The tab the context menu was opened on, with its viewport position. */
63
+ const [menu, setMenu] = useState<{ tab: OpenedFile; x: number; y: number } | null>(null);
22
64
 
23
65
  useOnClickOutside(dropdownRef, () => setShowDropdown(false));
24
66
 
@@ -37,6 +79,8 @@ export function EditorTabs({ openedFiles, activeFileId, onSelectFile, onCloseFil
37
79
  return () => observer.disconnect();
38
80
  }, []);
39
81
 
82
+ const candidate = splitCandidate(activeFileId, openedFiles.map((file) => file.id));
83
+
40
84
  let visibleTabs: OpenedFile[] = [];
41
85
  let hiddenTabs: OpenedFile[] = [];
42
86
 
@@ -72,6 +116,10 @@ export function EditorTabs({ openedFiles, activeFileId, onSelectFile, onCloseFil
72
116
  <div
73
117
  key={file.id}
74
118
  onClick={() => onSelectFile(file.id)}
119
+ onContextMenu={(event) => {
120
+ event.preventDefault();
121
+ setMenu({ tab: file, x: event.clientX, y: event.clientY });
122
+ }}
75
123
  className={`flex items-center space-x-1.5 px-3 py-1.5 cursor-pointer border-r border-ink/10 min-w-[120px] max-w-[210px] group ${
76
124
  isActive ? 'bg-paper border-t-2 border-t-ink text-ink' : 'bg-transparent border-t-2 border-t-transparent text-ink/60 hover:bg-paper/50'
77
125
  }`}
@@ -91,22 +139,102 @@ export function EditorTabs({ openedFiles, activeFileId, onSelectFile, onCloseFil
91
139
  {statusInfo.charStatus}
92
140
  </span>
93
141
  )}
94
- <div
95
- className={`p-0.5 rounded hover:bg-ink/10 touch-visible ${isActive ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'}`}
96
- onClick={(e) => {
97
- e.stopPropagation();
98
- onCloseFile(file.id);
99
- }}
100
- >
101
- <X size={12} />
102
- </div>
142
+ <TabCloseButton
143
+ dirty={dirtyIds.has(file.id)}
144
+ active={isActive}
145
+ label={`Close ${file.name}`}
146
+ onClose={() => onCloseFile(file.id)}
147
+ />
103
148
  </div>
104
149
  );
105
150
  })}
106
151
  </div>
107
152
 
153
+ {menu ? (
154
+ <TabContextMenu
155
+ x={menu.x}
156
+ y={menu.y}
157
+ rows={buildTabMenuRows({
158
+ tab: menu.tab,
159
+ openedFiles,
160
+ dirtyIds,
161
+ reopenable: reopenableCount?.() ?? 0,
162
+ activeFileId,
163
+ splitRightFileId,
164
+ })}
165
+ onAction={(action: TabMenuAction) => {
166
+ const tab = menu.tab;
167
+ switch (action) {
168
+ case 'close':
169
+ onCloseFile(tab.id);
170
+ return;
171
+ case 'close-others':
172
+ // Newest-first so the ACTIVE tab survives as the last one standing:
173
+ // closing others one by one leaves whichever id is not closed, and
174
+ // `onCloseFile` re-targets the active tab on every call.
175
+ for (const file of [...openedFiles].reverse()) {
176
+ if (file.id !== tab.id) onCloseFile(file.id);
177
+ }
178
+ onSelectFile(tab.id);
179
+ return;
180
+ case 'close-all':
181
+ for (const file of [...openedFiles].reverse()) onCloseFile(file.id);
182
+ return;
183
+ case 'close-saved':
184
+ // The dirty ones stay — the only reading that cannot lose an edit.
185
+ for (const file of [...openedFiles].reverse()) {
186
+ if (!dirtyIds.has(file.id)) onCloseFile(file.id);
187
+ }
188
+ return;
189
+ case 'copy-path':
190
+ onCopyPath?.(tab);
191
+ return;
192
+ case 'reveal-in-files':
193
+ onRevealInFiles?.(tab);
194
+ return;
195
+ case 'reopen-closed':
196
+ onReopenClosed?.();
197
+ return;
198
+ case 'split-right':
199
+ onSplitTo?.(tab.id);
200
+ return;
201
+ case 'unsplit':
202
+ onUnsplit?.();
203
+ return;
204
+ }
205
+ }}
206
+ onClose={() => setMenu(null)}
207
+ />
208
+ ) : null}
209
+
210
+ {/* The split control. It is NOT inside the overflow conditional: the strip folds every
211
+ non-active tab at panel width, so a split reachable only by right-clicking ANOTHER
212
+ tab would be unreachable exactly when the panel is narrow. It splits to the newest
213
+ other tab, which is the one the user just opened. */}
214
+ <div className="ml-auto flex items-center">
215
+ <button
216
+ type="button"
217
+ onClick={() => (splitRightFileId !== null ? onUnsplit?.() : onSplitTo?.(candidate as number | string))}
218
+ disabled={splitRightFileId === null && candidate === null}
219
+ aria-pressed={splitRightFileId !== null}
220
+ aria-label="Split editor"
221
+ title={
222
+ splitRightFileId !== null
223
+ ? 'Close the split pane (the tab stays open)'
224
+ : candidate === null
225
+ ? 'Open another file to split the editor'
226
+ : 'Split the editor and show the newest other file'
227
+ }
228
+ className={`p-1.5 mx-1 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-default ${
229
+ splitRightFileId !== null ? 'bg-ink/10 text-ink' : 'text-ink/60 hover:bg-ink/10'
230
+ }`}
231
+ >
232
+ <PanelRight size={14} />
233
+ </button>
234
+ </div>
235
+
108
236
  {hiddenTabs.length > 0 && (
109
- <div className="relative flex items-center ml-auto bg-ink/10" ref={dropdownRef}>
237
+ <div className="relative flex items-center bg-ink/10" ref={dropdownRef}>
110
238
  <button
111
239
  className={`p-1.5 mx-1 rounded hover:bg-ink/10 text-ink/60 ${showDropdown ? 'bg-ink/10 text-ink' : ''}`}
112
240
  onClick={() => setShowDropdown(!showDropdown)}
@@ -137,16 +265,15 @@ export function EditorTabs({ openedFiles, activeFileId, onSelectFile, onCloseFil
137
265
  <FileIcon name={file.name} size={14} className={isMissing ? 'text-error' : 'opacity-60'} />
138
266
  )}
139
267
  <span className={`text-xs font-mono truncate flex-1 ${isMissing ? 'text-error line-through' : 'text-ink/80'}`}>{file.name}</span>
140
- <div
141
- className="touch-visible p-0.5 rounded hover:bg-ink/10 opacity-0 group-hover:opacity-100"
142
- onClick={(e) => {
143
- e.stopPropagation();
268
+ <TabCloseButton
269
+ dirty={dirtyIds.has(file.id)}
270
+ active={false}
271
+ label={`Close ${file.name}`}
272
+ onClose={() => {
144
273
  onCloseFile(file.id);
145
274
  if (hiddenTabs.length === 1) setShowDropdown(false);
146
275
  }}
147
- >
148
- <X size={12} className="text-ink/60" />
149
- </div>
276
+ />
150
277
  </div>
151
278
  );
152
279
  })}
@@ -157,3 +284,53 @@ export function EditorTabs({ openedFiles, activeFileId, onSelectFile, onCloseFil
157
284
  </div>
158
285
  );
159
286
  }
287
+
288
+ /**
289
+ * A tab's trailing control: a dot while the tab is dirty, the `×` otherwise.
290
+ *
291
+ * One control, two meanings, because a dirty tab's primary action is still
292
+ * "close" — the dot says what closing would cost, and the pointer reveals the
293
+ * affordance. Two controls side by side would narrow the file name on every tab
294
+ * for a mark most tabs never show.
295
+ *
296
+ * The dot is a `<span>`, not an icon: it is drawn with `rounded-full bg-current`
297
+ * so it inherits the tab's own ink (active vs inactive) with no second colour.
298
+ */
299
+ function TabCloseButton({
300
+ dirty,
301
+ active,
302
+ label,
303
+ onClose,
304
+ }: {
305
+ dirty: boolean;
306
+ active: boolean;
307
+ label: string;
308
+ onClose: () => void;
309
+ }) {
310
+ return (
311
+ <div
312
+ role="button"
313
+ tabIndex={-1}
314
+ aria-label={label}
315
+ title={dirty ? `${label} — unsaved changes` : label}
316
+ className={`p-0.5 rounded hover:bg-ink/10 touch-visible ${active || dirty ? 'opacity-100' : 'opacity-0 group-hover:opacity-100'}`}
317
+ onClick={(event) => {
318
+ // The row itself selects the tab; a close must not also open it.
319
+ event.stopPropagation();
320
+ onClose();
321
+ }}
322
+ >
323
+ {dirty ? (
324
+ <span
325
+ className="block w-2 h-2 rounded-full bg-current mx-0.5"
326
+ data-tab-dirty=""
327
+ // The dot is decoration over a control that already names the state in
328
+ // its title and aria-label.
329
+ aria-hidden="true"
330
+ />
331
+ ) : (
332
+ <X size={12} />
333
+ )}
334
+ </div>
335
+ );
336
+ }
@@ -1,4 +1,13 @@
1
- import { AlertCircle, Check, Copy, Download, Eye, EyeOff, Maximize, Minimize, Save, Search, WrapText, ZoomIn, ZoomOut } from 'lucide-preact';
1
+ import {
2
+ AlertCircle,
3
+ Check,
4
+ Maximize,
5
+ Minimize,
6
+ Save,
7
+ } from 'lucide-preact';
8
+ import { EditorViewButtons, useEditorViewActions } from '@/client/components/common/editor-view-buttons';
9
+ import { ToolbarRow } from '@/client/components/common/toolbar-row';
10
+ import { ACTION_CLASS, buildEditorClusters } from '@/client/components/workspace/editor/toolbar-clusters';
2
11
 
3
12
  export type EditorSaveStatus = 'idle' | 'saving' | 'saved' | 'error' | 'needs-permission';
4
13
 
@@ -44,18 +53,30 @@ interface EditorToolbarProps {
44
53
  onZoomOut: () => void;
45
54
  onCopy: () => void;
46
55
  onDownload: () => void;
56
+ /**
57
+ * Throw the buffer away and take the file from disk.
58
+ *
59
+ * Destructive, so it is never pinned and never in the row: a mis-click on a
60
+ * toolbar of icon-only buttons must not be able to lose an edit.
61
+ */
62
+ onRevert: () => void;
63
+ /** Enabled only for a buffer with edits — reverting a clean one does nothing. */
64
+ canRevert: boolean;
65
+ /** Write the buffer to a NEW path; the original tab stays open. */
66
+ onSaveAs: () => void;
47
67
  onToggleMaximize: () => void;
48
68
  }
49
69
 
50
70
  /**
51
- * Shared icon-button shell. Every action here is icon-only, so each one carries
52
- * a `title` (the tooltip) and an `aria-label` (the accessible name) — a bare
53
- * `<svg onClick>` is unreachable by keyboard and unlabeled to a screen reader.
54
- * `p-1.5` also gives the 14px glyph a ~26px hit target.
71
+ * The editor's toolbar: one row of clusters, with the overflow rule in
72
+ * `toolbar-clusters.tsx`.
73
+ *
74
+ * This component owns the STATUS each control draws (the save icon's four faces,
75
+ * the copy confirmation) and the labels they carry; the cluster table owns what
76
+ * exists, in which order, and what a narrow panel must not bury. Splitting it
77
+ * there is what keeps this file under the repository's line ceiling as controls
78
+ * are added.
55
79
  */
56
- const ACTION_CLASS =
57
- 'flex items-center justify-center p-1.5 rounded transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50';
58
-
59
80
  export function EditorToolbar({
60
81
  path,
61
82
  saveStatus,
@@ -77,6 +98,9 @@ export function EditorToolbar({
77
98
  onZoomOut,
78
99
  onCopy,
79
100
  onDownload,
101
+ onRevert,
102
+ canRevert,
103
+ onSaveAs,
80
104
  onToggleMaximize,
81
105
  }: EditorToolbarProps) {
82
106
  const saveTitle =
@@ -94,146 +118,92 @@ export function EditorToolbar({
94
118
  ? 'Save failed — the file on disk was not changed'
95
119
  : 'Save file (Ctrl+S)';
96
120
 
121
+ const saveButton = (
122
+ <button
123
+ type="button"
124
+ onClick={onSave}
125
+ disabled={saveDisabled || saveStatus === 'saving'}
126
+ className={`${ACTION_CLASS} hover:bg-ink/5`}
127
+ title={saveTitle}
128
+ aria-label={saveTitle}
129
+ >
130
+ {saveStatus === 'saving' ? (
131
+ <Save size={14} className="text-amber-500 animate-pulse" />
132
+ ) : saveStatus === 'saved' ? (
133
+ <Check size={14} className="text-success" />
134
+ ) : saveStatus === 'error' ? (
135
+ <AlertCircle size={14} className="text-error" />
136
+ ) : saveStatus === 'needs-permission' ? (
137
+ // Not an error: the buffer is fine and one click grants access.
138
+ <Save size={14} className="text-warning" />
139
+ ) : (
140
+ <Save size={14} className="hover:text-ink" />
141
+ )}
142
+ </button>
143
+ );
144
+
145
+ const maximizeLabel = isMaximized ? 'Exit full screen' : 'Full screen';
146
+ const maximizeButton = (
147
+ <button
148
+ type="button"
149
+ onClick={onToggleMaximize}
150
+ className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink ${isMaximized ? 'text-ink' : ''}`}
151
+ title={maximizeLabel}
152
+ aria-label={maximizeLabel}
153
+ aria-pressed={isMaximized}
154
+ >
155
+ {isMaximized ? <Minimize size={14} /> : <Maximize size={14} />}
156
+ </button>
157
+ );
158
+
159
+ const viewModeActions = useEditorViewActions();
160
+ const clusters = buildEditorClusters({
161
+ byteViewer,
162
+ hasPreview,
163
+ isPreview,
164
+ wordWrap,
165
+ findOpen,
166
+ copied,
167
+ isMaximized,
168
+ saveDisabled,
169
+ canRevert,
170
+ saveButton,
171
+ maximizeButton,
172
+ viewModeButtons: <EditorViewButtons size={14} />,
173
+ viewModeActions,
174
+ previewLabel: isPreview ? 'Show source' : 'Show preview',
175
+ findLabel: 'Find and replace',
176
+ wordWrapLabel: wordWrap ? 'Word wrap on' : 'Word wrap off',
177
+ copyLabel: copied ? 'Copied' : byteViewer ? 'Copy image' : 'Copy content',
178
+ maximizeLabel,
179
+ onTogglePreview,
180
+ onToggleFind,
181
+ onToggleWordWrap,
182
+ onZoomIn,
183
+ onZoomOut,
184
+ onCopy,
185
+ onDownload,
186
+ onRevert,
187
+ onSaveAs,
188
+ onToggleMaximize,
189
+ onSave,
190
+ });
191
+
97
192
  return (
98
193
  // `@container`: the path below hides on a NARROW PANEL, not a narrow
99
- // viewport. At the editor panel's 320px floor the action strip is 273px of
100
- // `flex-shrink-0`, which left the path a measured 23px — a truncated
101
- // fragment of a filename is not information, and the tab above already
194
+ // viewport. At the editor panel's 320px floor the path would be a truncated
195
+ // fragment of a filename — not information, and the tab above already
102
196
  // carries it.
103
- <div className="@container flex items-center justify-between px-3 py-2 border-b border-ink/10 bg-paper flex-shrink-0">
197
+ <div className="@container flex items-center justify-between gap-2 px-3 py-2 border-b border-ink/10 bg-paper flex-shrink-0">
104
198
  {/* Left status */}
105
199
  <div className="hidden @[420px]:flex items-center space-x-2 text-xs font-mono text-ink/40 min-w-0">
106
200
  <span className="truncate max-w-[300px]" title={path}>{path}</span>
107
201
  </div>
108
202
 
109
- {/* Right actions. `ml-auto` keeps them right-aligned once the path block
110
- above is hidden, which `justify-between` alone would not do (a single
111
- child sits at the start). */}
112
- <div className="flex items-center space-x-1 text-ink/40 flex-shrink-0 ml-auto">
113
- {!byteViewer && (
114
- <div className="flex items-center pr-2 mr-1 border-r border-ink/10">
115
- <button
116
- type="button"
117
- onClick={onSave}
118
- disabled={saveDisabled || saveStatus === 'saving'}
119
- className={`${ACTION_CLASS} hover:bg-ink/5`}
120
- title={saveTitle}
121
- aria-label={saveTitle}
122
- >
123
- {saveStatus === 'saving' ? (
124
- <Save size={14} className="text-amber-500 animate-pulse" />
125
- ) : saveStatus === 'saved' ? (
126
- <Check size={14} className="text-success" />
127
- ) : saveStatus === 'error' ? (
128
- <AlertCircle size={14} className="text-error" />
129
- ) : saveStatus === 'needs-permission' ? (
130
- // Not an error: the buffer is fine and one click grants access.
131
- <Save size={14} className="text-warning" />
132
- ) : (
133
- <Save size={14} className="hover:text-ink" />
134
- )}
135
- </button>
136
- </div>
137
- )}
138
-
139
- {hasPreview && (
140
- <div className="flex items-center pr-2 mr-1 border-r border-ink/10">
141
- <button
142
- type="button"
143
- onClick={onTogglePreview}
144
- className={`${ACTION_CLASS} hover:bg-ink/5 ${isPreview ? 'text-ink' : 'hover:text-ink'}`}
145
- title={isPreview ? 'Show source' : 'Show preview'}
146
- aria-label={isPreview ? 'Show source' : 'Show preview'}
147
- aria-pressed={isPreview}
148
- >
149
- {isPreview ? <EyeOff size={14} /> : <Eye size={14} />}
150
- </button>
151
- </div>
152
- )}
153
-
154
- {!byteViewer && (
155
- <>
156
- <div className="flex items-center pr-2 mr-1 border-r border-ink/10">
157
- <button
158
- type="button"
159
- onClick={onToggleFind}
160
- className={`${ACTION_CLASS} hover:bg-ink/5 ${findOpen ? 'text-ink' : 'hover:text-ink'}`}
161
- title="Find and replace (Ctrl+F)"
162
- aria-label="Find and replace"
163
- aria-pressed={findOpen}
164
- >
165
- <Search size={14} />
166
- </button>
167
- </div>
168
-
169
- <div className="flex items-center pr-2 mr-1 border-r border-ink/10">
170
- <button
171
- type="button"
172
- onClick={onToggleWordWrap}
173
- className={`${ACTION_CLASS} hover:bg-ink/5 ${wordWrap ? 'text-ink' : 'hover:text-ink'}`}
174
- title={wordWrap ? 'Word wrap on' : 'Word wrap off'}
175
- aria-label={wordWrap ? 'Word wrap on' : 'Word wrap off'}
176
- aria-pressed={wordWrap}
177
- >
178
- <WrapText size={14} />
179
- </button>
180
- </div>
181
-
182
- <div className="flex items-center pr-2 mr-1 border-r border-ink/10">
183
- <button
184
- type="button"
185
- onClick={onZoomOut}
186
- className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
187
- title="Decrease font size"
188
- aria-label="Decrease font size"
189
- >
190
- <ZoomOut size={14} />
191
- </button>
192
- <button
193
- type="button"
194
- onClick={onZoomIn}
195
- className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
196
- title="Increase font size"
197
- aria-label="Increase font size"
198
- >
199
- <ZoomIn size={14} />
200
- </button>
201
- </div>
202
- </>
203
- )}
204
-
205
- <div className="flex items-center pr-2 mr-1 border-r border-ink/10">
206
- <button
207
- type="button"
208
- onClick={onCopy}
209
- className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
210
- title={copied ? 'Copied' : byteViewer ? 'Copy image' : 'Copy content'}
211
- aria-label={copied ? 'Copied' : byteViewer ? 'Copy image' : 'Copy content'}
212
- >
213
- {copied ? <Check size={14} className="text-success" /> : <Copy size={14} />}
214
- </button>
215
- <button
216
- type="button"
217
- onClick={onDownload}
218
- className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
219
- title="Download file"
220
- aria-label="Download file"
221
- >
222
- <Download size={14} />
223
- </button>
224
- </div>
225
-
226
- <button
227
- type="button"
228
- onClick={onToggleMaximize}
229
- className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink ${isMaximized ? 'text-ink' : ''}`}
230
- title={isMaximized ? 'Exit full screen' : 'Full screen'}
231
- aria-label={isMaximized ? 'Exit full screen' : 'Full screen'}
232
- aria-pressed={isMaximized}
233
- >
234
- {isMaximized ? <Minimize size={14} /> : <Maximize size={14} />}
235
- </button>
236
- </div>
203
+ {/* One row, never two: what does not fit moves into `⋯` (see
204
+ `ToolbarRow`). A wrapped toolbar pushed the document down by its own
205
+ height and read as a second toolbar. */}
206
+ <ToolbarRow clusters={clusters} className="text-ink/40 ml-auto" />
237
207
  </div>
238
208
  );
239
209
  }