@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,300 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * The editor toolbar's controls, as data plus the button markup each one draws.
8
+ *
9
+ * Split out of `Toolbar.tsx` for the repository's per-file ceiling, and it earns
10
+ * the boundary: the toolbar is a row of clusters with a hiding order, and every
11
+ * control is the same shape — a label, an icon, a pressed state, and the same
12
+ * `aria-*` pair. Keeping the cluster table beside the buttons is what stops the two
13
+ * from disagreeing about which control is pinned.
14
+ *
15
+ * ## Two rules the row exists to enforce
16
+ *
17
+ * **Every action is an icon-only `<button>` carrying both a `title` and an
18
+ * `aria-label`** — a bare `<svg onClick>` is unreachable by keyboard and invisible
19
+ * to a screen reader. **Pinning is not the visual order**: `pinned` marks what a
20
+ * narrow panel must not bury, and the row is placed in the order a reader looks.
21
+ *
22
+ * **Revert is deliberately never pinned.** It is the only destructive control in
23
+ * the row, and a `⋯` menu is exactly the friction a destructive action should have.
24
+ */
25
+
26
+ import type { ComponentChildren } from 'preact';
27
+ import {
28
+ Copy,
29
+ Download,
30
+ Eye,
31
+ EyeOff,
32
+ Maximize,
33
+ Minimize,
34
+ RotateCcw,
35
+ Save,
36
+ SaveAll,
37
+ Search,
38
+ WrapText,
39
+ ZoomIn,
40
+ ZoomOut,
41
+ } from 'lucide-preact';
42
+
43
+ import type { ToolbarCluster } from '@/client/components/common/toolbar-row';
44
+
45
+ /** Shared icon-button shell. Every action here is icon-only, so each carries both names. */
46
+ export const ACTION_CLASS =
47
+ 'flex items-center justify-center p-1.5 rounded transition-colors cursor-pointer disabled:cursor-default disabled:opacity-50';
48
+
49
+ /** The state the toolbar draws, already resolved by the caller. */
50
+ export interface ToolbarState {
51
+ byteViewer: boolean;
52
+ hasPreview: boolean;
53
+ isPreview: boolean;
54
+ wordWrap: boolean;
55
+ findOpen: boolean;
56
+ copied: boolean;
57
+ isMaximized: boolean;
58
+ saveDisabled: boolean;
59
+ canRevert: boolean;
60
+ saveButton: ComponentChildren;
61
+ previewLabel: string;
62
+ findLabel: string;
63
+ wordWrapLabel: string;
64
+ copyLabel: string;
65
+ maximizeLabel: string;
66
+ onTogglePreview: () => void;
67
+ onToggleFind: () => void;
68
+ onToggleWordWrap: () => void;
69
+ onZoomIn: () => void;
70
+ onZoomOut: () => void;
71
+ onCopy: () => void;
72
+ onDownload: () => void;
73
+ onRevert: () => void;
74
+ onSaveAs: () => void;
75
+ onToggleMaximize: () => void;
76
+ onSave: () => void;
77
+ viewModeActions: ToolbarCluster['actions'];
78
+ maximizeButton: ComponentChildren;
79
+ viewModeButtons: ComponentChildren;
80
+ }
81
+
82
+ /** One pressed-state toggle. */
83
+ function Toggle({
84
+ label,
85
+ pressed,
86
+ title,
87
+ onClick,
88
+ children,
89
+ }: {
90
+ label: string;
91
+ pressed: boolean;
92
+ title?: string;
93
+ onClick: () => void;
94
+ children: ComponentChildren;
95
+ }) {
96
+ return (
97
+ <button
98
+ type="button"
99
+ onClick={onClick}
100
+ className={`${ACTION_CLASS} hover:bg-ink/5 ${pressed ? 'text-ink' : 'hover:text-ink'}`}
101
+ title={title ?? label}
102
+ aria-label={label}
103
+ aria-pressed={pressed}
104
+ >
105
+ {children}
106
+ </button>
107
+ );
108
+ }
109
+
110
+ /**
111
+ * The clusters, in hiding order.
112
+ *
113
+ * ORDER is the hiding order, most important first: the row keeps the width modes
114
+ * and full screen (the controls this panel is FOR), then copy/download, and the
115
+ * reading aids (find, wrap, zoom, preview) move into the `⋯` menu on a narrow
116
+ * panel. Grouping is the existing one — zoom is a pair, copy/download is a pair,
117
+ * the modes are a pair — because splitting a pair leaves half of it on the row.
118
+ */
119
+ export function buildEditorClusters(state: ToolbarState): ToolbarCluster[] {
120
+ const clusters: ToolbarCluster[] = [];
121
+
122
+ if (!state.byteViewer) {
123
+ clusters.push({
124
+ id: 'save',
125
+ // The primary action of the panel: a menu row must never be the only way to
126
+ // save a file.
127
+ pinned: true,
128
+ actions: [{ label: 'Save file', icon: Save, onSelect: state.onSave, disabled: state.saveDisabled }],
129
+ children: state.saveButton,
130
+ });
131
+ }
132
+
133
+ if (state.hasPreview) {
134
+ clusters.push({
135
+ id: 'preview',
136
+ actions: [
137
+ {
138
+ label: state.previewLabel,
139
+ icon: state.isPreview ? EyeOff : Eye,
140
+ onSelect: state.onTogglePreview,
141
+ active: state.isPreview,
142
+ },
143
+ ],
144
+ children: (
145
+ <Toggle label={state.previewLabel} pressed={state.isPreview} onClick={state.onTogglePreview}>
146
+ {state.isPreview ? <EyeOff size={14} /> : <Eye size={14} />}
147
+ </Toggle>
148
+ ),
149
+ });
150
+ }
151
+
152
+ if (!state.byteViewer) {
153
+ clusters.push({
154
+ id: 'find',
155
+ actions: [{ label: state.findLabel, icon: Search, onSelect: state.onToggleFind, active: state.findOpen }],
156
+ children: (
157
+ <Toggle
158
+ label={state.findLabel}
159
+ pressed={state.findOpen}
160
+ title={`${state.findLabel} (Ctrl+F)`}
161
+ onClick={state.onToggleFind}
162
+ >
163
+ <Search size={14} />
164
+ </Toggle>
165
+ ),
166
+ });
167
+ clusters.push({
168
+ id: 'wrap',
169
+ actions: [
170
+ { label: state.wordWrapLabel, icon: WrapText, onSelect: state.onToggleWordWrap, active: state.wordWrap },
171
+ ],
172
+ children: (
173
+ <Toggle label={state.wordWrapLabel} pressed={state.wordWrap} onClick={state.onToggleWordWrap}>
174
+ <WrapText size={14} />
175
+ </Toggle>
176
+ ),
177
+ });
178
+ clusters.push({
179
+ id: 'zoom',
180
+ actions: [
181
+ { label: 'Decrease font size', icon: ZoomOut, onSelect: state.onZoomOut },
182
+ { label: 'Increase font size', icon: ZoomIn, onSelect: state.onZoomIn },
183
+ ],
184
+ children: (
185
+ <>
186
+ <button
187
+ type="button"
188
+ onClick={state.onZoomOut}
189
+ className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
190
+ title="Decrease font size"
191
+ aria-label="Decrease font size"
192
+ >
193
+ <ZoomOut size={14} />
194
+ </button>
195
+ <button
196
+ type="button"
197
+ onClick={state.onZoomIn}
198
+ className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
199
+ title="Increase font size"
200
+ aria-label="Increase font size"
201
+ >
202
+ <ZoomIn size={14} />
203
+ </button>
204
+ </>
205
+ ),
206
+ });
207
+ clusters.push({
208
+ id: 'save-as',
209
+ // Never pinned: it is a rare operation, and the row's space belongs to Save.
210
+ actions: [{ label: 'Save as…', icon: SaveAll, onSelect: state.onSaveAs }],
211
+ children: (
212
+ <button
213
+ type="button"
214
+ onClick={state.onSaveAs}
215
+ className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
216
+ title="Save the buffer to a new file"
217
+ aria-label="Save as"
218
+ >
219
+ <SaveAll size={14} />
220
+ </button>
221
+ ),
222
+ });
223
+ clusters.push({
224
+ id: 'revert',
225
+ // Never `pinned`: it is the one destructive control in the row, and a menu is
226
+ // exactly the friction it should have.
227
+ actions: [
228
+ { label: 'Revert file', icon: RotateCcw, onSelect: state.onRevert, disabled: !state.canRevert },
229
+ ],
230
+ children: (
231
+ <button
232
+ type="button"
233
+ onClick={state.onRevert}
234
+ disabled={!state.canRevert}
235
+ className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
236
+ title={state.canRevert ? 'Discard my changes and reload from disk' : 'No unsaved changes to discard'}
237
+ aria-label="Revert file"
238
+ >
239
+ <RotateCcw size={14} />
240
+ </button>
241
+ ),
242
+ });
243
+ }
244
+
245
+ clusters.push({
246
+ id: 'copy',
247
+ actions: [
248
+ { label: state.copyLabel, icon: Copy, onSelect: state.onCopy },
249
+ { label: 'Download file', icon: Download, onSelect: state.onDownload },
250
+ ],
251
+ children: (
252
+ <>
253
+ <button
254
+ type="button"
255
+ onClick={state.onCopy}
256
+ className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
257
+ title={state.copyLabel}
258
+ aria-label={state.copyLabel}
259
+ >
260
+ {state.copied ? <Copy size={14} className="text-success" /> : <Copy size={14} />}
261
+ </button>
262
+ <button
263
+ type="button"
264
+ onClick={state.onDownload}
265
+ className={`${ACTION_CLASS} hover:bg-ink/5 hover:text-ink`}
266
+ title="Download file"
267
+ aria-label="Download file"
268
+ >
269
+ <Download size={14} />
270
+ </button>
271
+ </>
272
+ ),
273
+ });
274
+
275
+ // The width modes and full SCREEN are the controls this panel exists for, so they
276
+ // are the LAST clusters — the tail is what the menu takes.
277
+ clusters.push({
278
+ id: 'view-modes',
279
+ // The two width modes are why this toolbar grew these buttons, and a mode
280
+ // reachable only from a menu is a mode half the readers never find.
281
+ pinned: true,
282
+ actions: state.viewModeActions,
283
+ children: state.viewModeButtons,
284
+ });
285
+ clusters.push({
286
+ id: 'maximize',
287
+ pinned: true,
288
+ actions: [
289
+ {
290
+ label: state.maximizeLabel,
291
+ icon: state.isMaximized ? Minimize : Maximize,
292
+ onSelect: state.onToggleMaximize,
293
+ active: state.isMaximized,
294
+ },
295
+ ],
296
+ children: state.maximizeButton,
297
+ });
298
+
299
+ return clusters;
300
+ }
@@ -80,19 +80,32 @@ export function FileCreateModal({ folderPath, kind, value, error, isLoading, onC
80
80
  }
81
81
 
82
82
  interface DeleteModalProps {
83
+ /** The entry's real path — what is deleted, and what the dialog must name. */
83
84
  fileName: string;
85
+ /** The row's label, when it differs from the path (a collapsed chain). */
86
+ displayName?: string;
84
87
  isFolder: boolean;
85
88
  isLoading: boolean;
86
89
  onCancel: () => void;
87
90
  onConfirm: () => void;
88
91
  }
89
92
 
90
- export function FileDeleteModal({ fileName, isFolder, isLoading, onCancel, onConfirm }: DeleteModalProps) {
93
+ export function FileDeleteModal({ fileName, displayName, isFolder, isLoading, onCancel, onConfirm }: DeleteModalProps) {
91
94
  return createPortal(
92
95
  <div className="fixed inset-0 bg-ink/20 z-[100] flex items-center justify-center p-4 backdrop-blur-sm">
93
96
  <div className="bg-paper rounded shadow-xl p-4 w-full max-w-sm border border-ink/10 font-sans">
94
97
  <h3 className="font-semibold text-ink mb-2 text-sm">Delete {isFolder ? 'Folder' : 'File'}</h3>
95
98
  <p className="text-xs text-ink/70 mb-4">Are you sure you want to delete <span className="font-mono bg-canvas px-1 rounded">{fileName}</span>? This action cannot be undone.</p>
99
+ {/* A collapsed chain row is LABELLED `com/java/app/package` but its path
100
+ is the deepest directory, and that is what gets deleted. Naming only
101
+ the label would promise a removal of four directories and perform
102
+ one, so the dialog says which it is. */}
103
+ {displayName && displayName !== fileName && (
104
+ <p className="text-[11px] text-ink/50 mb-4">
105
+ The row is <span className="font-mono">{displayName}</span>; this deletes{' '}
106
+ <span className="font-mono">{fileName}</span> only.
107
+ </p>
108
+ )}
96
109
  <div className="flex justify-end space-x-2">
97
110
  <button
98
111
  onClick={onCancel}
@@ -32,6 +32,7 @@ import { SessionStateProvider } from '@/client/components/common/session-state-p
32
32
  import { forgetSession } from '@/shared/lib/workspace/session-state/store';
33
33
  import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
34
34
  import { publishEditorDocument, resetEditorDocument, type EditorDocument } from '@/client/lib/editor-document';
35
+ import { MAX_OUTLINE_ROWS } from '@/shared/lib/code/outline/rows';
35
36
  import { getLineReveal, setLineReveal } from '@/client/lib/line-reveal';
36
37
 
37
38
  const SESSION = 'new-outline-section';
@@ -215,4 +216,21 @@ describe('OutlineSection', () => {
215
216
  expect(reveal().getAttribute('data-expanded')).toBe('true');
216
217
  expect(toggle().getAttribute('aria-expanded')).toBe('true');
217
218
  });
219
+
220
+ // The cap is what keeps a large file's outline from becoming a DOM: 63 618
221
+ // declarations mounted 446 308 nodes and charged 953 ms to every keystroke
222
+ // (measured), where the editor's own cost is 34 ms.
223
+ test('a large outline renders only the first rows, and says how many it is not showing', async () => {
224
+ owner = {};
225
+ const many = Array.from({ length: MAX_OUTLINE_ROWS + 200 }, (_, i) => `export function fn${i}() {}`).join('\n');
226
+ publishEditorDocument(owner, { ...READY, path: 'src/many.ts', content: many });
227
+ await mount();
228
+ await expand();
229
+
230
+ expect(rowLabels()).toHaveLength(MAX_OUTLINE_ROWS);
231
+ // The count badge shows the window against the total, so the number on the
232
+ // toggle cannot be read as "this file has 500 symbols".
233
+ expect(toggle().textContent).toContain(`${MAX_OUTLINE_ROWS}/700`);
234
+ expect(container.textContent).toContain('Showing the first 500 of 700 symbols.');
235
+ });
218
236
  });
@@ -35,6 +35,7 @@ import { setLineReveal } from '@/client/lib/line-reveal';
35
35
  import { useSessionState } from '@/client/hooks/workspace/session-state';
36
36
  import { useOutlineView } from '@/client/hooks/editor/use-outline-view';
37
37
  import type { OutlineSymbol } from '@/shared/lib/code/outline/types';
38
+ import { outlineTruncatedNotice } from '@/shared/lib/code/outline/rows';
38
39
 
39
40
  export function OutlineSection() {
40
41
  const [expanded, setExpanded] = useSessionState<boolean>('files.outlineExpanded', false);
@@ -44,11 +45,12 @@ export function OutlineSection() {
44
45
  // Recomputed from the LIVE buffer, so an edit moves the rows with it. The
45
46
  // scan is a depth-aware line walk (see `outline/extract.ts`): measured at
46
47
  // 0.1–2.2 ms on this repository's largest sources.
47
- const { symbols, notice } = useOutlineView({
48
+ const { symbols, total, truncated, notice } = useOutlineView({
48
49
  content: current.content,
49
50
  language: current.language,
50
51
  state: current.state,
51
52
  note: current.note,
53
+ path: current.path,
52
54
  });
53
55
 
54
56
  // A diff tab HIDES the section rather than explaining that it has none. The
@@ -91,9 +93,9 @@ export function OutlineSection() {
91
93
  <span className="w-3 text-center font-mono" aria-hidden="true">{expanded ? '▾' : '▸'}</span>
92
94
  <ListTree size={12} />
93
95
  <span>Outline</span>
94
- {symbols.length > 0 && (
96
+ {total > 0 && (
95
97
  <span className="font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[9px] text-ink/50">
96
- {symbols.length}
98
+ {truncated ? `${symbols.length}/${total.toLocaleString()}` : total}
97
99
  </span>
98
100
  )}
99
101
  </button>
@@ -125,6 +127,11 @@ export function OutlineSection() {
125
127
  <span className="flex-shrink-0 font-mono text-[9px] text-ink/35">{symbol.line}</span>
126
128
  </button>
127
129
  ))}
130
+ {truncated && (
131
+ <div className="px-1 py-1 text-[10px] italic text-ink/40">
132
+ {outlineTruncatedNotice(total)}
133
+ </div>
134
+ )}
128
135
  </div>
129
136
  )}
130
137
  </div>
@@ -310,7 +310,8 @@ export function FileTreeItem({
310
310
 
311
311
  {mounted && actions.showDeleteModal && (
312
312
  <FileDeleteModal
313
- fileName={file.name}
313
+ fileName={file.path}
314
+ displayName={file.name}
314
315
  isFolder={isFolder}
315
316
  isLoading={actions.busy}
316
317
  onCancel={actions.closeDelete}
@@ -132,7 +132,9 @@ describe('Files panel clipboard', () => {
132
132
  });
133
133
 
134
134
  test('the row menu hides Paste on a folder inside the copied folder’s own subtree', async () => {
135
- panel.disk = { '.': { src: null }, src: { deep: null }, 'src/deep': {} };
135
+ // `src` holds a folder AND a file, so it is its own row — a folder holding
136
+ // only one folder would be collapsed into one row naming the chain.
137
+ panel.disk = { '.': { src: null }, src: { deep: null, 'a.ts': 'file' }, 'src/deep': {} };
136
138
  await panel.mount();
137
139
 
138
140
  await panel.rightClickRow('src');
@@ -127,4 +127,65 @@ describe('Files panel listing', () => {
127
127
  expect(srcReads()).toBe(2);
128
128
  expect(panel.container.textContent).toContain('a.ts');
129
129
  });
130
+
131
+ test('a package tree is ONE row naming the whole chain, and it expands into the deepest folder', async () => {
132
+ panel.disk = {
133
+ '.': { com: null },
134
+ com: { java: null },
135
+ 'com/java': { app: null },
136
+ 'com/java/app': { package: null },
137
+ 'com/java/app/package': { 'Main.java': 'file' },
138
+ };
139
+ panel.dirReads = [];
140
+ await panel.mount();
141
+
142
+ // One row instead of four: the chain's own levels are not rows at all.
143
+ expect(panel.visibleNames()).toContain('com/java/app/package');
144
+ expect(panel.visibleNames()).not.toContain('com');
145
+ // Reading the row's own path is the read that would have happened on the
146
+ // fourth expand; the three levels above it are never asked about.
147
+ expect(panel.dirReads).toEqual(['.']);
148
+
149
+ await panel.clickRow('com/java/app/package');
150
+
151
+ expect(panel.container.textContent).toContain('Main.java');
152
+ expect(panel.dirReads).toContain('com/java/app/package');
153
+ expect(panel.dirReads).not.toContain('com');
154
+ expect(panel.dirReads).not.toContain('com/java');
155
+ });
156
+
157
+ test('a folder holding a folder and a file is not collapsed', async () => {
158
+ panel.disk = {
159
+ '.': { src: null },
160
+ src: { deep: null, 'a.ts': 'file' },
161
+ 'src/deep': { 'b.ts': 'file' },
162
+ };
163
+ await panel.mount();
164
+
165
+ expect(panel.visibleNames()).toContain('src');
166
+ expect(panel.visibleNames()).not.toContain('src/deep');
167
+ });
168
+
169
+ test('the delete dialog names the path it deletes, not just the chain label', async () => {
170
+ // A chain INSIDE a folder is labelled relative to that folder
171
+ // (`java/app/package`) while its path names the whole thing. Both are on
172
+ // screen, because the delete removes the deepest directory only — a dialog
173
+ // showing just the label would promise more than it performs.
174
+ panel.disk = {
175
+ '.': { com: null },
176
+ com: { java: null, 'README.md': 'file' },
177
+ 'com/java': { app: null },
178
+ 'com/java/app': { package: null },
179
+ 'com/java/app/package': { 'Main.java': 'file' },
180
+ };
181
+ await panel.mount();
182
+ await panel.clickRow('com');
183
+
184
+ await panel.rightClickRow('java/app/package');
185
+ await panel.clickMenuRow('Delete');
186
+
187
+ const text = panel.documentText();
188
+ expect(text).toContain('com/java/app/package');
189
+ expect(text).toContain('this deletes');
190
+ });
130
191
  });
@@ -10,7 +10,7 @@ import { useGitStatus } from '@/client/hooks/workspace/git-status';
10
10
  import { useFileListing } from '@/client/hooks/workspace/file-listing';
11
11
  import { useFileCreate } from '@/client/hooks/workspace/file-create';
12
12
  import { useFileClipboard, type ClipboardTarget } from '@/client/hooks/workspace/file-clipboard';
13
- import { rekeyExpansion } from '@/shared/lib/fs/file-tree';
13
+ import { useFileTreeEdits } from '@/client/hooks/workspace/file-tree-edits';
14
14
  import { filterFileTree } from '@/client/components/workspace/file-explorer/filter';
15
15
  import { useRepoList, useRepoScope } from '@/client/hooks/workspace/repo-scope';
16
16
  import { useRealtimeTopic } from '@/client/hooks/ui/realtime';
@@ -100,53 +100,6 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
100
100
  setActiveRepo(repo);
101
101
  };
102
102
 
103
- /**
104
- * Open every folder that leads to `path`.
105
- *
106
- * A nested create (`lib/parse.ts`) and a rename into a new folder both make
107
- * directories the user has never opened, and a row placed inside a collapsed
108
- * folder is a row nobody can see — the write would look like it failed. EVERY
109
- * ancestor is opened, not only the direct parent: expanding just the last one
110
- * still hides the entry behind a collapsed `lib`.
111
- */
112
- const revealPath = (path: string) => {
113
- const segments = path.split('/').slice(0, -1);
114
- if (segments.length === 0) return;
115
- const chain = segments.map((_, index) => segments.slice(0, index + 1).join('/'));
116
- setExpandedPaths(prev => {
117
- if (chain.every((folder) => prev.has(folder))) return prev;
118
- const next = new Set(prev);
119
- for (const folder of chain) next.add(folder);
120
- setStoredExpandedPaths(Array.from(next));
121
- return next;
122
- });
123
- };
124
-
125
- /** Place a row a create just produced, without re-reading the tree. */
126
- const insertCreated = (entry: { path: string; kind: 'file' | 'folder' }) => {
127
- listing.insertEntry(entry);
128
- revealPath(entry.path);
129
- };
130
-
131
- /**
132
- * Move a row a rename just relocated, without re-reading.
133
- *
134
- * A folder's descendants and every open branch beneath it carry its path as a
135
- * prefix, so the expansion set is rekeyed in the same step — an open `src`
136
- * renamed to `lib` must stay open as `lib`, not collapse.
137
- */
138
- const moveRenamed = (fromPath: string, toPath: string) => {
139
- listing.moveEntry(fromPath, toPath);
140
- setExpandedPaths(prev => {
141
- const next = rekeyExpansion(prev, fromPath, toPath);
142
- setStoredExpandedPaths(Array.from(next));
143
- return next;
144
- });
145
- // A rename INTO a new folder (`a.ts` → `nested/a.ts`) has the same problem a
146
- // nested create does: the destination folder is one nobody has opened.
147
- revealPath(toPath);
148
- };
149
-
150
103
  /**
151
104
  * Re-read everything this panel shows. Defined ABOVE the `!enabled` return so
152
105
  * the create flow below can use it: a hook cannot be called after a branch.
@@ -157,6 +110,15 @@ export function FileExplorer({ className = '', enabled = true, rootPath, onOpenF
157
110
  else void listing.reload();
158
111
  };
159
112
 
113
+ // A create and a rename land locally, and the row they produce is revealed
114
+ // through the rows that are DRAWN — see `useFileTreeEdits`.
115
+ const { insertCreated, moveRenamed } = useFileTreeEdits({
116
+ listing,
117
+ setExpandedPaths,
118
+ setStoredExpandedPaths,
119
+ reload: refresh,
120
+ });
121
+
160
122
  // One clipboard for the whole tree, owned here and passed down: a
161
123
  // subscription per row would be hundreds of listeners for a value that
162
124
  // changes on a right-click.
@@ -90,10 +90,15 @@ describe('Files panel local edits', () => {
90
90
  await panel.submitNewFile('lib/deep/parse.ts');
91
91
 
92
92
  // Every folder on the way is expanded and reads its own directory: the
93
- // entry is not somewhere the user has to go hunting for.
93
+ // entry is not somewhere the user has to go hunting for. `lib` and `deep`
94
+ // are ONE row here — a folder holding only one folder collapses into a row
95
+ // naming the chain — and that row is the one the create expands.
94
96
  expect(panel.visibleNames()).toContain('parse.ts');
95
- expect(panel.visibleNames()).toContain('deep');
96
- expect(panel.visibleNames()).toContain('lib');
97
+ expect(panel.visibleNames()).toContain('lib/deep');
98
+ // The reveal expands the row that is DRAWN, not the path's own segments:
99
+ // `lib` and `deep` are not rows, so nothing asks the server about them.
100
+ expect(panel.dirReads).not.toContain('lib');
101
+ expect(panel.dirReads).not.toContain('lib/deep');
97
102
  });
98
103
 
99
104
  test('a rename moves the row in place without re-reading the root', async () => {
@@ -6,7 +6,7 @@ import { SearchResults } from '@/client/components/workspace/search-panel/Result
6
6
  import { setSearchReveal } from '@/client/lib/search-reveal';
7
7
  import { groupSearchResults, MAX_SEARCH_RESULTS } from '@/shared/lib/fs/search-list';
8
8
  import type { SearchResultItem } from '@/shared/types/fs';
9
- import type { FindOptions } from '@/shared/lib/code/editor/find';
9
+ import type { FindOptions } from '@/shared/lib/code/editor/find-scan';
10
10
 
11
11
  interface SearchPanelBodyProps {
12
12
  className: string;
@@ -107,7 +107,12 @@ export function SearchPanelBody({
107
107
 
108
108
  // The same flags the search ran with, so the editor's own matcher paints the
109
109
  // identical set of occurrences once the file opens.
110
- const options: FindOptions = useMemo(() => ({ matchCase, wholeWord, isRegex: useRegex }), [matchCase, wholeWord, useRegex]);
110
+ const options: FindOptions = useMemo(
111
+ // The workspace search has no selection to restrict to, so `inSelection` is false —
112
+ // the flag exists for the EDITOR's bar, where the range is the user's own selection.
113
+ () => ({ matchCase, wholeWord, isRegex: useRegex, inSelection: false }),
114
+ [matchCase, wholeWord, useRegex],
115
+ );
111
116
 
112
117
  /**
113
118
  * A row click opens the file AND points the editor at the hit.