@kabmo-labs/kabmo 0.28.0 → 0.30.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 (232) hide show
  1. package/bunfig.toml +6 -0
  2. package/dist/client/index.html +2 -2
  3. package/dist/client/index.js +481 -472
  4. package/dist/client/static/js/{index-xzvyrxya.js → index-5vjbp04s.js} +1193 -1049
  5. package/dist/client/static/js/index-naa91727.css +1 -0
  6. package/dist/client/static/{manifest-q6h8k9e0.webmanifest → manifest-vdvdqpre.webmanifest} +1 -0
  7. package/package.json +3 -2
  8. package/public/manifest.webmanifest +1 -0
  9. package/src/client/components/common/ComposerTextarea.test.tsx +109 -0
  10. package/src/client/components/common/ComposerTextarea.tsx +6 -0
  11. package/src/client/components/common/ReloadPageButton.test.tsx +14 -0
  12. package/src/client/components/common/ReloadPageButton.tsx +11 -2
  13. package/src/client/components/common/diagram-viewer/read-block.test.ts +71 -0
  14. package/src/client/components/common/diagram-viewer/read-block.ts +40 -16
  15. package/src/client/components/common/file-icon/index.tsx +7 -1
  16. package/src/client/components/common/harness-glyph/brands.ts +7 -1
  17. package/src/client/components/common/image-viewer/index.tsx +37 -165
  18. package/src/client/components/common/picker-search/index.tsx +70 -0
  19. package/src/client/components/common/search-select/index.tsx +2 -7
  20. package/src/client/components/common/zoom-pan-stage/index.tsx +258 -0
  21. package/src/client/components/common/zoom-pan-stage/zoom-pan-stage.test.tsx +87 -0
  22. package/src/client/components/layout/session-sidebar/ClassicView.tsx +1 -1
  23. package/src/client/components/layout/session-sidebar/SessionListNotice.tsx +7 -3
  24. package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +4 -1
  25. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +12 -1
  26. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.test.tsx +82 -0
  27. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +23 -3
  28. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +1 -0
  29. package/src/client/components/layout/session-sidebar/modern/index.tsx +1 -1
  30. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +6 -4
  31. package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +8 -0
  32. package/src/client/components/mobile/mobile-right-sidebar/EditorSurface.tsx +25 -0
  33. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +1 -1
  34. package/src/client/components/settings/Sidebar.tsx +6 -8
  35. package/src/client/components/settings/categories/HarnessSettings.tsx +4 -2
  36. package/src/client/components/settings/categories/PanelPluginSettings.tsx +2 -2
  37. package/src/client/components/settings/categories/PluginSettings.tsx +1 -1
  38. package/src/client/components/settings/categories/harness-settings/ConfigForm.tsx +3 -6
  39. package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +36 -0
  40. package/src/client/components/settings/categories/panel-plugins/Section.tsx +1 -3
  41. package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +18 -4
  42. package/src/client/components/settings/categories/plugin-settings/MarketplacePane.tsx +64 -61
  43. package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +15 -4
  44. package/src/client/components/settings/groups.test.tsx +2 -2
  45. package/src/client/components/workspace/chat-timeline/IrcNotice.test.tsx +55 -0
  46. package/src/client/components/workspace/chat-timeline/IrcNotice.tsx +71 -0
  47. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +4 -1
  48. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +19 -0
  49. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +8 -3
  50. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.search.test.tsx +72 -0
  51. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +42 -15
  52. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.test.tsx +28 -0
  53. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +28 -10
  54. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.test.tsx +47 -1
  55. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +55 -5
  56. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +3 -2
  57. package/src/client/components/workspace/editor/FilePane.tsx +32 -0
  58. package/src/client/components/workspace/editor/Toolbar.tsx +4 -0
  59. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +1 -0
  60. package/src/client/components/workspace/editor/toolbar-clusters.tsx +5 -2
  61. package/src/client/components/workspace/editor/viewers/CsvGrid.tsx +52 -5
  62. package/src/client/components/workspace/editor/viewers/DataGrid.tsx +227 -41
  63. package/src/client/components/workspace/editor/viewers/DrawioView.tsx +93 -0
  64. package/src/client/components/workspace/editor/viewers/GridRow.tsx +91 -0
  65. package/src/client/components/workspace/editor/viewers/GridToolbar.tsx +53 -0
  66. package/src/client/components/workspace/editor/viewers/SheetView.tsx +152 -57
  67. package/src/client/components/workspace/editor/viewers/dispatch.tsx +42 -9
  68. package/src/client/components/workspace/editor/viewers/drawio-pages.test.ts +80 -0
  69. package/src/client/components/workspace/editor/viewers/drawio-pages.ts +63 -0
  70. package/src/client/components/workspace/editor/viewers/grid.test.ts +296 -0
  71. package/src/client/components/workspace/editor/viewers/use-cell-edit.ts +64 -0
  72. package/src/client/components/workspace/editor/viewers/use-grid-interaction.ts +216 -0
  73. package/src/client/components/workspace/editor/viewers/viewers.test.ts +47 -2
  74. package/src/client/components/workspace/editor/viewers/workbook.ts +149 -0
  75. package/src/client/components/workspace/file-explorer/ArchiveModals.tsx +262 -0
  76. package/src/client/components/workspace/file-explorer/ContextMenu.tsx +30 -6
  77. package/src/client/components/workspace/file-explorer/Modals.tsx +8 -3
  78. package/src/client/components/workspace/file-explorer/RootOverlays.tsx +60 -0
  79. package/src/client/components/workspace/file-explorer/RowLabel.tsx +6 -2
  80. package/src/client/components/workspace/file-explorer/TreeItem.tsx +39 -49
  81. package/src/client/components/workspace/file-explorer/TreeItemModals.tsx +80 -0
  82. package/src/client/components/workspace/file-explorer/index.tsx +53 -29
  83. package/src/client/components/workspace/file-explorer/selection.test.tsx +109 -0
  84. package/src/client/data/settings/omp-schema.json +169 -22
  85. package/src/client/glass-palette.test.ts +72 -0
  86. package/src/client/glass.css +39 -14
  87. package/src/client/glass.test.ts +28 -67
  88. package/src/client/hooks/chat/composer/history.test.ts +267 -0
  89. package/src/client/hooks/chat/composer/history.ts +146 -0
  90. package/src/client/hooks/chat/timeline/ask-frames.test.ts +54 -0
  91. package/src/client/hooks/chat/timeline/ask-frames.ts +29 -1
  92. package/src/client/hooks/chat/timeline/timeline-rail.test.ts +34 -2
  93. package/src/client/hooks/chat/timeline/user-turns.ts +31 -2
  94. package/src/client/hooks/editor/file-editor-types.ts +15 -0
  95. package/src/client/hooks/editor/save-bytes.ts +79 -0
  96. package/src/client/hooks/editor/use-dirty-tracking.test.ts +73 -0
  97. package/src/client/hooks/editor/use-dirty-tracking.ts +96 -0
  98. package/src/client/hooks/editor/use-file-cache.ts +1 -0
  99. package/src/client/hooks/editor/use-file-editor.test.ts +30 -0
  100. package/src/client/hooks/editor/use-file-editor.ts +20 -17
  101. package/src/client/hooks/editor/use-file-read.ts +21 -2
  102. package/src/client/hooks/editor/use-grid-selection.ts +160 -0
  103. package/src/client/hooks/models/use-harness-update.test.ts +35 -2
  104. package/src/client/hooks/models/use-harness-update.ts +49 -10
  105. package/src/client/hooks/workspace/diff-file.test.ts +72 -0
  106. package/src/client/hooks/workspace/diff-file.ts +12 -6
  107. package/src/client/hooks/workspace/file-archive.ts +220 -0
  108. package/src/client/hooks/workspace/file-clipboard.test.ts +4 -4
  109. package/src/client/hooks/workspace/file-clipboard.ts +37 -26
  110. package/src/client/hooks/workspace/file-selection.test.ts +67 -0
  111. package/src/client/hooks/workspace/file-selection.ts +156 -0
  112. package/src/client/hooks/workspace/file-tree-actions-clipboard.test.ts +5 -5
  113. package/src/client/hooks/workspace/file-tree-actions.ts +36 -8
  114. package/src/client/lib/editor/workbook-drafts.ts +42 -0
  115. package/src/client/lib/launch/file-handlers.ts +2 -2
  116. package/src/client/lib/scrollbar-activity.test.ts +21 -88
  117. package/src/client/lib/scrollbar-activity.ts +71 -73
  118. package/src/client/lib/scrollbar-events.ts +143 -0
  119. package/src/client/lib/scrollbar-input.test.ts +126 -0
  120. package/src/client/lib/scrollbar-probe.test-util.ts +107 -0
  121. package/src/client/tailwind.css +32 -1
  122. package/src/server/db.server.test.ts +50 -1
  123. package/src/server/db.server.ts +36 -3
  124. package/src/server/lib/chat/prompt-history.server.test.ts +92 -0
  125. package/src/server/lib/chat/prompt-history.server.ts +65 -0
  126. package/src/server/lib/chat/schema.server.ts +35 -0
  127. package/src/server/lib/db/schema.ts +3 -0
  128. package/src/server/lib/fs/archive.test.ts +198 -0
  129. package/src/server/lib/fs/archive.ts +278 -0
  130. package/src/server/lib/fs/git-diff.test.ts +26 -1
  131. package/src/server/lib/fs/git-diff.ts +43 -15
  132. package/src/server/lib/harness/launch-table.ts +19 -0
  133. package/src/server/lib/harness/provider-entry.ts +1 -1
  134. package/src/server/lib/harness/provider-file.server.ts +1 -1
  135. package/src/server/lib/harness/provider-sources.server.ts +2 -1
  136. package/src/server/lib/harness/provider-write.server.ts +2 -1
  137. package/src/server/lib/harness/update-job-store.ts +12 -0
  138. package/src/server/lib/harness/update-queue.server.ts +15 -10
  139. package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +5 -1
  140. package/src/server/lib/omp/rpc/frame-fold.test.ts +5 -1
  141. package/src/server/lib/omp/rpc/lifecycle.test.ts +4 -0
  142. package/src/server/lib/omp/session/auto-title.server.test.ts +4 -0
  143. package/src/server/lib/omp/session/delete.server.ts +1 -0
  144. package/src/server/lib/omp/session/goal-driver.test.ts +5 -1
  145. package/src/server/lib/omp/session/goal-settings.test.ts +5 -1
  146. package/src/server/lib/panels/auto-update.server.test.ts +5 -2
  147. package/src/server/lib/panels/git-update.server.test.ts +5 -2
  148. package/src/server/lib/panels/install.server.test.ts +5 -2
  149. package/src/server/lib/panels/remove.server.test.ts +5 -2
  150. package/src/server/routes/agent/command.ts +11 -0
  151. package/src/server/routes/agent/new.ts +5 -0
  152. package/src/server/routes/chat/index.ts +5 -0
  153. package/src/server/routes/chat/prompt-history.test.ts +67 -0
  154. package/src/server/routes/chat/prompt-history.ts +31 -0
  155. package/src/server/routes/chat/stream.test.ts +21 -0
  156. package/src/server/routes/chat/stream.ts +5 -0
  157. package/src/server/routes/fs/action-archive.test.ts +128 -0
  158. package/src/server/routes/fs/action-bulk.ts +106 -0
  159. package/src/server/routes/fs/action-save-bytes.test.ts +59 -0
  160. package/src/server/routes/fs/action-transfer.test.ts +26 -0
  161. package/src/server/routes/fs/action.ts +91 -11
  162. package/src/server/routes/fs/archive.ts +20 -0
  163. package/src/server/routes/fs/grant.test.ts +5 -2
  164. package/src/server/routes/fs/index.ts +2 -0
  165. package/src/server/routes/fs/scope.test.ts +6 -2
  166. package/src/server/routes/harness/import-action.ts +1 -1
  167. package/src/server/routes/harness/root.ts +6 -1
  168. package/src/server/routes/harness/summary.test.ts +50 -0
  169. package/src/server/routes/harness/update-status.ts +41 -2
  170. package/src/server/routes/harness/update.test.ts +56 -2
  171. package/src/server/routes/sessions/delete.test.ts +4 -0
  172. package/src/shared/lib/chat/ask-form/index.ts +39 -31
  173. package/src/shared/lib/chat/ask-form/labels.ts +46 -0
  174. package/src/shared/lib/chat/ask-form/tokens.ts +11 -2
  175. package/src/shared/lib/chat/ask-form.test.ts +57 -0
  176. package/src/shared/lib/chat/ask-questions.ts +31 -0
  177. package/src/shared/lib/chat/composer/history.test.ts +67 -0
  178. package/src/shared/lib/chat/composer/history.ts +61 -0
  179. package/src/shared/lib/chat/irc-notice.ts +42 -0
  180. package/src/shared/lib/chat/timeline/fork-anchor.test.ts +2 -0
  181. package/src/shared/lib/chat/todo/parser.ts +6 -4
  182. package/src/shared/lib/fs/archive.test.ts +101 -0
  183. package/src/shared/lib/fs/archive.ts +191 -0
  184. package/src/shared/lib/fs/clipboard.test.ts +32 -7
  185. package/src/shared/lib/fs/clipboard.ts +59 -14
  186. package/src/shared/lib/fs/csv.test.ts +50 -0
  187. package/src/shared/lib/fs/csv.ts +40 -0
  188. package/src/shared/lib/fs/document-kind.test.ts +13 -6
  189. package/src/shared/lib/fs/document-kind.ts +18 -6
  190. package/src/shared/lib/fs/file-kind-classify.test.ts +4 -0
  191. package/src/shared/lib/fs/file-kind.test.ts +2 -7
  192. package/src/shared/lib/fs/file-kind.ts +4 -2
  193. package/src/shared/lib/fs/grid-edit.test.ts +24 -0
  194. package/src/shared/lib/fs/grid-edit.ts +29 -0
  195. package/src/shared/lib/fs/grid-selection.test.ts +137 -0
  196. package/src/shared/lib/fs/grid-selection.ts +138 -0
  197. package/src/shared/lib/harness/brand-color.ts +5 -0
  198. package/src/shared/lib/harness/catalog.test.ts +22 -0
  199. package/src/shared/lib/harness/catalog.ts +12 -1
  200. package/src/shared/lib/harness/config-fields.test.ts +25 -0
  201. package/src/shared/lib/harness/config-fields.ts +33 -3
  202. package/src/shared/lib/harness/dialects.ts +1 -1
  203. package/src/shared/lib/harness/mcp-facts.ts +4 -0
  204. package/src/shared/lib/harness/provider-contracts.ts +109 -0
  205. package/src/shared/lib/harness/provider-facts.test.ts +2 -1
  206. package/src/shared/lib/harness/provider-facts.ts +24 -115
  207. package/src/shared/lib/harness/provider-lookup.ts +37 -0
  208. package/src/shared/lib/harness/providers.ts +2 -1
  209. package/src/shared/lib/harness/updates.ts +10 -0
  210. package/src/shared/lib/icons/tint-hues.generated.ts +14 -13
  211. package/src/shared/lib/omp/session/mapper.test.ts +31 -0
  212. package/src/shared/lib/omp/session/mapper.ts +17 -0
  213. package/src/shared/lib/omp/session/messages-map-notice.test.ts +68 -0
  214. package/src/shared/lib/omp/session/messages-map.test.ts +1 -35
  215. package/src/shared/lib/omp/session/messages-map.ts +17 -0
  216. package/src/shared/lib/omp/session/wait.ts +10 -1
  217. package/src/shared/lib/settings/sections.ts +8 -4
  218. package/src/shared/lib/ui/picker-filter.test.ts +23 -0
  219. package/src/shared/lib/ui/picker-filter.ts +20 -0
  220. package/src/shared/types/chat.ts +4 -0
  221. package/src/shared/types/harness.ts +5 -1
  222. package/src/shared/types/omp/session.ts +18 -0
  223. package/src/shared/types/settings/state.ts +6 -6
  224. package/src/shared/types/todo.ts +3 -1
  225. package/src/test-support/file-actions.test-util.ts +4 -0
  226. package/src/test-support/file-archive.test-util.ts +41 -0
  227. package/src/test-support/file-clipboard.test-util.ts +9 -6
  228. package/src/test-support/file-editor.test-util.ts +3 -2
  229. package/src/test-support/glass-css.ts +30 -0
  230. package/src/test-support/harness-table.test-util.ts +2 -0
  231. package/src/test-support/preload.ts +46 -0
  232. package/dist/client/static/js/index-81f7berm.css +0 -1
@@ -26,6 +26,7 @@ import { runPanelAutoUpdatePass } from '@/server/lib/panels/auto-update.server';
26
26
  import { installPanelPluginFromGit } from '@/server/lib/panels/install.server';
27
27
  import { readGitStatus } from '@/server/lib/panels/git-status.server';
28
28
  import { invalidatePanelScan } from '@/server/lib/panels/registry.server';
29
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
29
30
 
30
31
  const hasGit = Boolean(Bun.which('git'));
31
32
 
@@ -64,7 +65,8 @@ function advance(repo: string, version: string): void {
64
65
  run(['commit', '-q', '-m', `v${version}`]);
65
66
  }
66
67
 
67
- beforeEach(() => {
68
+ beforeEach(async () => {
69
+ await isolateDb();
68
70
  root = fs.mkdtempSync(join(tmpdir(), 'omp-autoupd-'));
69
71
  work = fs.mkdtempSync(join(tmpdir(), 'omp-autoupd-repos-'));
70
72
  process.env.KABMO_MARKETPLACE_DIR = root;
@@ -72,12 +74,13 @@ beforeEach(() => {
72
74
  invalidatePanelScan();
73
75
  });
74
76
 
75
- afterEach(() => {
77
+ afterEach(async () => {
76
78
  delete process.env.KABMO_MARKETPLACE_DIR;
77
79
  globalThis.__kabmoPanelGitStatus = undefined;
78
80
  invalidatePanelScan();
79
81
  fs.rmSync(root, { recursive: true, force: true });
80
82
  fs.rmSync(work, { recursive: true, force: true });
83
+ await releaseDb();
81
84
  });
82
85
 
83
86
  describe('runPanelAutoUpdatePass', () => {
@@ -26,6 +26,7 @@ import { probeGitUpdate, updateGitPlugin } from '@/server/lib/panels/git-update.
26
26
  import { readGitOrigin } from '@/server/lib/panels/git-clone.server';
27
27
  import { discoverPanelPlugins, invalidatePanelScan } from '@/server/lib/panels/registry.server';
28
28
  import { removeDir } from '@/test-support/remove-dir';
29
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
29
30
 
30
31
  const hasGit = Boolean(Bun.which('git'));
31
32
 
@@ -81,18 +82,20 @@ function advance(repo: string, version: string): void {
81
82
  git(repo, ['commit', '-q', '-m', `v${version}`]);
82
83
  }
83
84
 
84
- beforeEach(() => {
85
+ beforeEach(async () => {
86
+ await isolateDb();
85
87
  root = fs.mkdtempSync(join(tmpdir(), 'omp-panels-git-'));
86
88
  work = fs.mkdtempSync(join(tmpdir(), 'omp-panels-repos-'));
87
89
  process.env.KABMO_MARKETPLACE_DIR = root;
88
90
  invalidatePanelScan();
89
91
  });
90
92
 
91
- afterEach(() => {
93
+ afterEach(async () => {
92
94
  delete process.env.KABMO_MARKETPLACE_DIR;
93
95
  invalidatePanelScan();
94
96
  removeDir(root);
95
97
  removeDir(work);
98
+ await releaseDb();
96
99
  });
97
100
 
98
101
  describe('readGitOrigin', () => {
@@ -25,6 +25,7 @@ import { join } from 'node:path';
25
25
  import { discoverPanelPlugins, getMarketplaceCatalogPath, invalidatePanelScan } from '@/server/lib/panels/registry.server';
26
26
  import { installPanelPluginFromGit } from '@/server/lib/panels/install.server';
27
27
  import { seedDefaultMarketplace } from '@/server/lib/panels/seed.server';
28
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
28
29
 
29
30
  let root = '';
30
31
  let work = '';
@@ -85,18 +86,20 @@ function makeBundledStore(manifest: unknown = VALID): string {
85
86
  return bundled;
86
87
  }
87
88
 
88
- beforeEach(() => {
89
+ beforeEach(async () => {
90
+ await isolateDb();
89
91
  root = fs.mkdtempSync(join(tmpdir(), 'kabmo-seed-'));
90
92
  work = fs.mkdtempSync(join(tmpdir(), 'kabmo-repos-'));
91
93
  process.env.KABMO_MARKETPLACE_DIR = root;
92
94
  invalidatePanelScan();
93
95
  });
94
96
 
95
- afterEach(() => {
97
+ afterEach(async () => {
96
98
  delete process.env.KABMO_MARKETPLACE_DIR;
97
99
  invalidatePanelScan();
98
100
  fs.rmSync(root, { recursive: true, force: true });
99
101
  fs.rmSync(work, { recursive: true, force: true });
102
+ await releaseDb();
100
103
  });
101
104
 
102
105
  describe('seedDefaultMarketplace', () => {
@@ -28,6 +28,7 @@ import { join } from 'node:path';
28
28
 
29
29
  import { discoverPanelPlugins, getMarketplaceCatalogPath, invalidatePanelScan } from '@/server/lib/panels/registry.server';
30
30
  import { removePanelPlugin } from '@/server/lib/panels/install.server';
31
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
31
32
 
32
33
  let root = '';
33
34
 
@@ -46,16 +47,18 @@ function writeCatalog(catalog: unknown): void {
46
47
  fs.writeFileSync(getMarketplaceCatalogPath(), JSON.stringify(catalog));
47
48
  }
48
49
 
49
- beforeEach(() => {
50
+ beforeEach(async () => {
51
+ await isolateDb();
50
52
  root = fs.mkdtempSync(join(tmpdir(), 'kabmo-remove-'));
51
53
  process.env.KABMO_MARKETPLACE_DIR = root;
52
54
  invalidatePanelScan();
53
55
  });
54
56
 
55
- afterEach(() => {
57
+ afterEach(async () => {
56
58
  delete process.env.KABMO_MARKETPLACE_DIR;
57
59
  invalidatePanelScan();
58
60
  fs.rmSync(root, { recursive: true, force: true });
61
+ await releaseDb();
59
62
  });
60
63
 
61
64
  describe('removePanelPlugin', () => {
@@ -17,6 +17,8 @@ import { forwardToPeer, isPeerRelayed, peerOriginForSession } from '@/server/lib
17
17
  import { applyHarnessMode, resumeRecordedHarnessSession } from '@/server/routes/agent/harness-command';
18
18
  import { asHarnessSession } from '@/server/lib/harness/registry';
19
19
  import { asOmpSession, getLiveSession } from '@/server/lib/omp/rpc/session-registry';
20
+ import { recordPrompt } from '@/server/lib/chat/prompt-history.server';
21
+ import { RECALLABLE_COMMAND_TYPES } from '@/shared/lib/chat/composer/history';
20
22
 
21
23
  /** How long after an accepted Resume Kabmo nudges the loop. The
22
24
  * extension answers the mode command first; this only coalesces the nudge
@@ -78,6 +80,15 @@ export async function sendCommand({ params, request }: ActionFunctionArgs) {
78
80
  // local extension command inside the child, never an RPC verb.
79
81
  const forwarded = modeRequest ? { type: 'prompt', message: modeCommandPrompt(modeRequest) } : body;
80
82
 
83
+ // The composer's ArrowUp recall. Recorded here, where the operator's own
84
+ // words enter, and never for a mode request: that is Kabmo's control
85
+ // channel, not something anyone typed. A refused send is recorded too —
86
+ // the client queues it and the delivery replays the same text, which the
87
+ // store's consecutive-duplicate guard collapses.
88
+ if (!modeRequest && RECALLABLE_COMMAND_TYPES[body.type]) {
89
+ await recordPrompt(sessionId, typeof body.message === 'string' ? body.message : '');
90
+ }
91
+
81
92
  // Fast path: already-running session — whichever harness runs it. An ACP
82
93
  // session answers the same command vocabulary, so the transport is invisible
83
94
  // to the client.
@@ -12,6 +12,7 @@ import { harnessDescriptor, type HarnessId } from '@/shared/lib/harness/catalog'
12
12
  import { startAcpSession } from '@/server/lib/harness/spawn.server';
13
13
  import { mintAgentEnvironment, rememberAgentToken } from '@/server/lib/sessions/agent-token.server';
14
14
  import { isMockMode } from '@/server/mock.server';
15
+ import { recordPrompt } from '@/server/lib/chat/prompt-history.server';
15
16
 
16
17
  /** The model-dropdown persists its selection here (actionType 'selectModel');
17
18
  * a spawn that arrives without an explicit provider/modelId falls back to it. */
@@ -135,6 +136,9 @@ export async function action({ request }: ActionFunctionArgs) {
135
136
  message: message ?? '',
136
137
  ...(images?.length ? { images } : {}),
137
138
  });
139
+ // A brand-new chat's first prompt belongs in the recall list too, under
140
+ // the id the child just reported.
141
+ await recordPrompt(realSessionId, message ?? '');
138
142
  return json({ success: true, sessionId: realSessionId, data: ack });
139
143
  }
140
144
 
@@ -196,6 +200,7 @@ async function startAcpChat({ harness, cwd, body, model, accessMode }: {
196
200
  message: typeof body.message === 'string' ? body.message : '',
197
201
  ...(Array.isArray(body.images) && body.images.length > 0 ? { images: body.images } : {}),
198
202
  });
203
+ await recordPrompt(realSessionId, typeof body.message === 'string' ? body.message : '');
199
204
  return json({ success: true, sessionId: realSessionId, data: ack, harness });
200
205
  }
201
206
  return json({ error: `Unsupported command: ${type}` }, { status: 400 });
@@ -4,9 +4,14 @@ import * as chatSession from '@/server/routes/chat/session';
4
4
  import * as chatRewind from '@/server/routes/chat/rewind';
5
5
  import * as chatStream from '@/server/routes/chat/stream';
6
6
  import * as chatTurns from '@/server/routes/chat/turns';
7
+ import * as chatPromptHistory from '@/server/routes/chat/prompt-history';
7
8
 
8
9
  export const chatBindings: HandlerBinding[] = [
9
10
  ...bindingsFor(chatRoot, '/api/chat'),
11
+ // Static segment in the same position as `:sessionId`: registered BEFORE the
12
+ // parameter route, explicitly, so the recall list is never answered by the
13
+ // session loader.
14
+ ...bindingsFor(chatPromptHistory, '/api/chat/prompt-history'),
10
15
  ...bindingsFor(chatSession, '/api/chat/:sessionId'),
11
16
  ...bindingsFor(chatRewind, '/api/chat/:sessionId/rewind'),
12
17
  ...bindingsFor(chatStream, '/api/chat/stream'),
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * GET /api/chat/prompt-history — the scope the composer's ArrowUp asks for.
8
+ *
9
+ * The static path shares its position with `:sessionId`, which is why the
10
+ * route is mounted before the session loader in `chat/index.ts`. This file
11
+ * pins both the scope rules and that ordering: a bare request must answer the
12
+ * merged list, never `{ error: 'Session ID is required' }`.
13
+ */
14
+
15
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
16
+ import { listPrompts, recordPrompt } from '@/server/lib/chat/prompt-history.server';
17
+ import { loader } from '@/server/routes/chat/prompt-history';
18
+ import { chatBindings } from '@/server/routes/chat';
19
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
20
+
21
+ beforeEach(async () => {
22
+ await isolateDb();
23
+ });
24
+
25
+ afterEach(async () => {
26
+ await releaseDb();
27
+ });
28
+
29
+ function request(path: string): Request {
30
+ return new Request(`http://localhost${path}`);
31
+ }
32
+
33
+ describe('chat prompt-history loader', () => {
34
+ test('answers the merged list when no session is named', async () => {
35
+ await recordPrompt('s1', 'from one');
36
+ await recordPrompt('s2', 'from two');
37
+ const response = (await loader({ request: request('/api/chat/prompt-history') } as never)) as Response;
38
+ expect(response.status).toBe(200);
39
+ expect(await response.json()).toEqual({ prompts: ['from two', 'from one'] });
40
+ });
41
+
42
+ test('scopes to the named session', async () => {
43
+ await recordPrompt('s1', 'from one');
44
+ await recordPrompt('s2', 'from two');
45
+ const response = (await loader({ request: request('/api/chat/prompt-history?sessionId=s1') } as never)) as Response;
46
+ expect(await response.json()).toEqual({ prompts: ['from one'] });
47
+ });
48
+
49
+ test('clamps an out-of-range limit instead of failing', async () => {
50
+ await recordPrompt('s1', 'one');
51
+ await recordPrompt('s1', 'two');
52
+ const clamped = (await loader({ request: request('/api/chat/prompt-history?limit=0') } as never)) as Response;
53
+ expect(await clamped.json()).toEqual({ prompts: ['two'] });
54
+ const junk = (await loader({ request: request('/api/chat/prompt-history?limit=abc') } as never)) as Response;
55
+ expect((await junk.json()).prompts).toHaveLength(2);
56
+ });
57
+
58
+ test('is mounted ahead of the session route it shares a position with', () => {
59
+ const paths = chatBindings.map((binding) => binding.path);
60
+ expect(paths.indexOf('/api/chat/prompt-history')).toBeLessThan(paths.indexOf('/api/chat/:sessionId'));
61
+ });
62
+
63
+ test('the store it reads is the one a sent prompt writes', async () => {
64
+ await recordPrompt('s9', 'sent once');
65
+ expect(await listPrompts('s9')).toEqual(['sent once']);
66
+ });
67
+ });
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * GET /api/chat/prompt-history — the composer's ArrowUp recall list.
8
+ *
9
+ * `?sessionId=` scopes it to one chat; without it the answer is the merged
10
+ * list across every session, which is what a pending `new-…` chat shows.
11
+ * Newest first, deduplicated, capped (see `PROMPT_HISTORY_LIMIT`).
12
+ */
13
+
14
+ import { json } from '@/server/lib/remix-compat';
15
+ import type { LoaderFunctionArgs } from '@/server/lib/remix-compat';
16
+ import { listPrompts } from '@/server/lib/chat/prompt-history.server';
17
+ import { PROMPT_HISTORY_LIMIT } from '@/server/lib/chat/schema.server';
18
+
19
+ export async function loader({ request }: LoaderFunctionArgs) {
20
+ const url = new URL(request.url);
21
+ const sessionId = url.searchParams.get('sessionId');
22
+ const requested = Number(url.searchParams.get('limit') ?? PROMPT_HISTORY_LIMIT);
23
+ const limit = Number.isFinite(requested)
24
+ ? Math.min(Math.max(Math.trunc(requested), 1), PROMPT_HISTORY_LIMIT)
25
+ : PROMPT_HISTORY_LIMIT;
26
+ try {
27
+ return json({ prompts: await listPrompts(sessionId, limit) });
28
+ } catch (error) {
29
+ return json({ error: error instanceof Error ? error.message : String(error) }, { status: 500 });
30
+ }
31
+ }
@@ -30,6 +30,7 @@ import { localRuns } from '@/server/lib/omp/session/local-runs.server';
30
30
  import { onRealtimeSignal } from '@/server/lib/realtime/signals.server';
31
31
  import { isolateDb, releaseDb } from '@/test-support/isolated-db';
32
32
  import { action } from '@/server/routes/chat/stream';
33
+ import { listPrompts } from '@/server/lib/chat/prompt-history.server';
33
34
 
34
35
  const savedMock = Bun.env.MOCK;
35
36
 
@@ -99,4 +100,24 @@ describe('simulated stream status', () => {
99
100
  const response = await action({ request, params: {} });
100
101
  expect(response.status).toBe(400);
101
102
  });
103
+
104
+ test('a simulated send feeds the composer\'s prompt recall', async () => {
105
+ const abort = new AbortController();
106
+ const request = new Request('http://localhost/api/chat/stream', {
107
+ method: 'POST',
108
+ headers: { 'Content-Type': 'application/json' },
109
+ body: JSON.stringify({ sessionId: 'sim-recall', prompt: 'recall me' }),
110
+ signal: abort.signal,
111
+ });
112
+ const response = await action({ request, params: {} });
113
+ expect(response.status).toBe(200);
114
+ // Recorded before the first frame, so a recall during the run sees it.
115
+ expect(await listPrompts('sim-recall')).toEqual(['recall me']);
116
+ abort.abort();
117
+ const reader = response.body!.getReader();
118
+ for (;;) {
119
+ const { done } = await reader.read();
120
+ if (done) break;
121
+ }
122
+ }, 20_000);
102
123
  });
@@ -4,6 +4,7 @@ import { handleSimulatedStreaming } from '@/shared/lib/chat/stream-service';
4
4
  import { createSseStream } from '@/server/lib/sse';
5
5
  import { markStreamStatus } from '@/shared/lib/omp/session/stream-state.server';
6
6
  import { localRuns } from '@/server/lib/omp/session/local-runs.server';
7
+ import { recordPrompt } from '@/server/lib/chat/prompt-history.server';
7
8
 
8
9
  export async function loader({ request }: LoaderFunctionArgs) {
9
10
  return handleStreamingRequest(request);
@@ -42,6 +43,10 @@ async function handleStreamingRequest(request: Request) {
42
43
  });
43
44
  }
44
45
 
46
+ // The simulated path is a real send from the operator's point of view, so it
47
+ // feeds the composer's ArrowUp recall like the agent routes do.
48
+ await recordPrompt(sessionId, prompt);
49
+
45
50
  const stream = createSseStream({
46
51
  headers: { 'Cache-Control': 'no-cache, no-transform', 'X-Accel-Buffering': 'no' },
47
52
  async onStart(handlers) {
@@ -0,0 +1,128 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The archive and batch-delete actions at the route.
8
+ *
9
+ * The round trips are driven through the real `/api/fs/action` entry point, so
10
+ * the scoped-root resolution, the JSON path list and the external tool all run
11
+ * together. Cases that need a binary the machine lacks are skipped, not failed.
12
+ */
13
+
14
+ import { afterEach, describe, expect, test } from 'bun:test';
15
+ import fs from 'node:fs';
16
+ import path from 'node:path';
17
+ import { action } from '@/server/routes/fs/action';
18
+
19
+ const DIR = path.join(process.cwd(), 'tmp-fs-archive-probe');
20
+
21
+ function reset(files: Record<string, string>): void {
22
+ fs.rmSync(DIR, { recursive: true, force: true });
23
+ for (const [rel, content] of Object.entries(files)) {
24
+ const target = path.join(DIR, rel);
25
+ fs.mkdirSync(path.dirname(target), { recursive: true });
26
+ fs.writeFileSync(target, content);
27
+ }
28
+ }
29
+
30
+ afterEach(() => {
31
+ fs.rmSync(DIR, { recursive: true, force: true });
32
+ });
33
+
34
+ async function post(fields: Record<string, string>) {
35
+ const form = new FormData();
36
+ form.append('root', process.cwd());
37
+ for (const [key, value] of Object.entries(fields)) form.append(key, value);
38
+ const res = await action({ request: new Request('http://localhost/api/fs/action', { method: 'POST', body: form }) } as never);
39
+ return { status: res.status, body: (await res.json()) as Record<string, unknown> };
40
+ }
41
+
42
+ const hasZip = Bun.which('zip') !== null && Bun.which('unzip') !== null;
43
+
44
+ describe('fs batch delete', () => {
45
+ test('removes every path in one request', async () => {
46
+ reset({ 'a.ts': 'A', 'src/b.ts': 'B', 'keep.ts': 'K' });
47
+
48
+ const { status, body } = await post({
49
+ actionType: 'delete',
50
+ paths: JSON.stringify(['tmp-fs-archive-probe/a.ts', 'tmp-fs-archive-probe/src']),
51
+ });
52
+
53
+ expect(status).toBe(200);
54
+ expect(body.removed).toEqual(['tmp-fs-archive-probe/a.ts', 'tmp-fs-archive-probe/src']);
55
+ expect(fs.existsSync(path.join(DIR, 'a.ts'))).toBe(false);
56
+ expect(fs.existsSync(path.join(DIR, 'src'))).toBe(false);
57
+ expect(fs.existsSync(path.join(DIR, 'keep.ts'))).toBe(true);
58
+ });
59
+
60
+ test('refuses a path outside the scoped root', async () => {
61
+ reset({ 'a.ts': 'A' });
62
+ const { status } = await post({ actionType: 'delete', paths: JSON.stringify(['../outside.ts']) });
63
+ expect(status).toBe(403);
64
+ });
65
+ });
66
+
67
+ describe('fs archive actions', () => {
68
+ test.skipIf(!hasZip)('compress then extract round-trips the selection', async () => {
69
+ reset({ 'a.ts': 'A', 'deep/b.ts': 'B' });
70
+
71
+ const compressed = await post({
72
+ actionType: 'compress',
73
+ format: 'zip',
74
+ name: 'bundle.zip',
75
+ destination: 'tmp-fs-archive-probe',
76
+ paths: JSON.stringify(['tmp-fs-archive-probe/a.ts', 'tmp-fs-archive-probe/deep']),
77
+ });
78
+
79
+ expect(compressed.status).toBe(200);
80
+ expect(compressed.body.path).toBe('tmp-fs-archive-probe/bundle.zip');
81
+ expect(fs.existsSync(path.join(DIR, 'bundle.zip'))).toBe(true);
82
+
83
+ const extracted = await post({
84
+ actionType: 'extract',
85
+ path: 'tmp-fs-archive-probe/bundle.zip',
86
+ destination: 'tmp-fs-archive-probe/out',
87
+ });
88
+
89
+ expect(extracted.status).toBe(200);
90
+ expect(fs.readFileSync(path.join(DIR, 'out/a.ts'), 'utf8')).toBe('A');
91
+ expect(fs.readFileSync(path.join(DIR, 'out/deep/b.ts'), 'utf8')).toBe('B');
92
+ });
93
+
94
+ test('refuses an archive name carrying a path separator', async () => {
95
+ reset({ 'a.ts': 'A' });
96
+ const { status } = await post({
97
+ actionType: 'compress',
98
+ format: 'zip',
99
+ name: '../escape.zip',
100
+ destination: 'tmp-fs-archive-probe',
101
+ paths: JSON.stringify(['tmp-fs-archive-probe/a.ts']),
102
+ });
103
+ expect(status).toBe(400);
104
+ });
105
+
106
+ test('refuses to extract a file that is not an archive', async () => {
107
+ reset({ 'notes.txt': 'hello' });
108
+ const { status, body } = await post({
109
+ actionType: 'extract',
110
+ path: 'tmp-fs-archive-probe/notes.txt',
111
+ destination: 'tmp-fs-archive-probe/out',
112
+ });
113
+ expect(status).toBe(400);
114
+ expect(String(body.error)).toContain('recognised archive');
115
+ });
116
+
117
+ test('refuses a destination outside the scoped root', async () => {
118
+ reset({ 'a.ts': 'A' });
119
+ const { status } = await post({
120
+ actionType: 'compress',
121
+ format: 'zip',
122
+ name: 'bundle.zip',
123
+ destination: '../outside',
124
+ paths: JSON.stringify(['tmp-fs-archive-probe/a.ts']),
125
+ });
126
+ expect(status).toBe(403);
127
+ });
128
+ });
@@ -0,0 +1,106 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The Files panel's BULK actions: a multi-selection delete, and the two archive
8
+ * verbs. Split from `action.ts` because that dispatcher is at the repository's
9
+ * line ceiling, and because all three take path LISTS rather than the single
10
+ * `path` the row actions are built around.
11
+ */
12
+
13
+ import fs from 'node:fs';
14
+ import { json } from '@/server/lib/remix-compat';
15
+ import { resolveWithinRoot } from '@/server/lib/fs/root';
16
+ import { toRelPath } from '@/server/lib/fs/transfer';
17
+ import { isSinglePathSegment } from '@/server/lib/fs/path-segment';
18
+ import { compressEntries, extractArchive } from '@/server/lib/fs/archive';
19
+ import { COMPRESS_FORMATS } from '@/shared/lib/fs/archive';
20
+
21
+ /**
22
+ * The Files panel's multi-select delete: one request, one resolved path per
23
+ * entry. `paths` is JSON because a form field cannot repeat into an array with
24
+ * a shape the route can trust; the single-row Delete keeps its own branch.
25
+ */
26
+ export async function runBatchDeleteAction(options: { formData: FormData; scopedRoot: string }) {
27
+ const { formData, scopedRoot } = options;
28
+ let paths: unknown;
29
+ try {
30
+ paths = JSON.parse((formData.get('paths') as string) ?? '[]');
31
+ } catch {
32
+ return json({ error: 'Invalid delete list' }, { status: 400 });
33
+ }
34
+ if (!Array.isArray(paths) || paths.length === 0 || paths.some((entry) => typeof entry !== 'string')) {
35
+ return json({ error: 'Invalid delete list' }, { status: 400 });
36
+ }
37
+ // Resolve EVERY path before removing any: one invalid entry must refuse the
38
+ // batch, not delete the entries that came before it.
39
+ const targets: { rel: string; full: string }[] = [];
40
+ for (const rel of paths as string[]) {
41
+ const target = resolveWithinRoot(scopedRoot, rel);
42
+ if (!target) return json({ error: 'Invalid path' }, { status: 403 });
43
+ targets.push({ rel, full: target });
44
+ }
45
+ const removed: string[] = [];
46
+ for (const target of targets) {
47
+ await fs.promises.rm(target.full, { recursive: true, force: true });
48
+ removed.push(target.rel);
49
+ }
50
+ return json({ success: true, removed });
51
+ }
52
+
53
+ /**
54
+ * `extract` and `compress`: the two archive verbs, one branch because they
55
+ * share every piece of path validation.
56
+ *
57
+ * `compress` takes the whole selection as JSON `paths` plus the target file
58
+ * name and the folder it lands in — the folder IS the working directory, which
59
+ * is what keeps every stored name a plain relative one. `extract` takes one
60
+ * archive and the folder to unpack into (`mkdir -p` is the tool's job).
61
+ */
62
+ export async function runArchiveAction(options: { actionType: string; formData: FormData; scopedRoot: string }) {
63
+ const { actionType, formData, scopedRoot } = options;
64
+ if (actionType === 'extract') {
65
+ const archiveRel = ((formData.get('path') as string) ?? '').trim();
66
+ const archivePath = resolveWithinRoot(scopedRoot, archiveRel);
67
+ if (!archivePath) return json({ error: 'Invalid path' }, { status: 403 });
68
+ const destinationRel = ((formData.get('destination') as string) ?? '').trim() || '.';
69
+ const destinationDir = resolveWithinRoot(scopedRoot, destinationRel);
70
+ if (!destinationDir) return json({ error: 'Invalid destination' }, { status: 403 });
71
+ const outcome = await extractArchive({ archivePath, destinationDir });
72
+ if (!outcome.ok) return json({ error: outcome.error }, { status: outcome.status });
73
+ return json({ success: true, path: toRelPath(scopedRoot, destinationDir) });
74
+ }
75
+
76
+ const formatRaw = (formData.get('format') as string) ?? 'zip';
77
+ const format = COMPRESS_FORMATS.find((entry) => entry.id === formatRaw)?.id;
78
+ if (!format) return json({ error: 'Unknown archive format' }, { status: 400 });
79
+ const name = ((formData.get('name') as string) ?? '').trim();
80
+ if (!isSinglePathSegment(name)) {
81
+ return json({ error: 'Enter an archive name without a path separator' }, { status: 400 });
82
+ }
83
+ const destinationRel = ((formData.get('destination') as string) ?? '').trim() || '.';
84
+ const destinationDir = resolveWithinRoot(scopedRoot, destinationRel);
85
+ if (!destinationDir) return json({ error: 'Invalid destination' }, { status: 403 });
86
+
87
+ let paths: unknown;
88
+ try {
89
+ paths = JSON.parse((formData.get('paths') as string) ?? '[]');
90
+ } catch {
91
+ return json({ error: 'Invalid selection' }, { status: 400 });
92
+ }
93
+ if (!Array.isArray(paths) || paths.length === 0 || paths.some((entry) => typeof entry !== 'string')) {
94
+ return json({ error: 'Select something to compress' }, { status: 400 });
95
+ }
96
+ const sources: string[] = [];
97
+ for (const rel of paths as string[]) {
98
+ const full = resolveWithinRoot(scopedRoot, rel);
99
+ if (!full) return json({ error: 'Invalid path' }, { status: 403 });
100
+ sources.push(full);
101
+ }
102
+ const outcome = await compressEntries({ destinationDir, name, format, sources });
103
+ if (!outcome.ok) return json({ error: outcome.error }, { status: outcome.status });
104
+ return json({ success: true, path: toRelPath(scopedRoot, outcome.path) });
105
+ }
106
+
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The binary save branch: a workbook the grid edited.
8
+ *
9
+ * The bytes must land VERBATIM — a ZIP container cannot survive the text
10
+ * field's UTF-8 and line-ending normalization, which is why this branch exists
11
+ * at all — and the conflict guard must apply to it exactly as it does to a text
12
+ * save.
13
+ */
14
+
15
+ import { afterEach, describe, expect, test } from 'bun:test';
16
+ import fs from 'fs';
17
+ import path from 'path';
18
+ import { action } from '@/server/routes/fs/action';
19
+
20
+ const PROBE = path.join(process.cwd(), 'tmp-bytes-probe.xlsx');
21
+
22
+ afterEach(() => {
23
+ fs.rmSync(PROBE, { force: true });
24
+ });
25
+
26
+ async function saveBytes(bytes: Uint8Array, baseMtime?: number) {
27
+ const form = new FormData();
28
+ form.append('actionType', 'saveBytes');
29
+ form.append('root', process.cwd());
30
+ form.append('path', 'tmp-bytes-probe.xlsx');
31
+ form.append('bytes', new Blob([bytes]));
32
+ if (baseMtime !== undefined) form.append('baseMtime', String(baseMtime));
33
+ return action({ request: new Request('http://localhost/api/fs/action', { method: 'POST', body: form }) } as never);
34
+ }
35
+
36
+ describe('fs saveBytes', () => {
37
+ test('writes the bytes verbatim', async () => {
38
+ const bytes = new Uint8Array([0x50, 0x4b, 0x03, 0x04, 0x00, 0xff, 0x0a, 0x0d]);
39
+ const res = await saveBytes(bytes);
40
+ expect(res.status).toBe(200);
41
+ expect([...new Uint8Array(await Bun.file(PROBE).arrayBuffer())]).toEqual([...bytes]);
42
+ });
43
+
44
+ test('a stale base mtime is a conflict, not a write', async () => {
45
+ fs.writeFileSync(PROBE, 'disk');
46
+ const res = await saveBytes(new Uint8Array([1, 2, 3]), 1);
47
+ expect(res.status).toBe(409);
48
+ expect(await Bun.file(PROBE).text()).toBe('disk');
49
+ });
50
+
51
+ test('a request with no bytes is refused', async () => {
52
+ const form = new FormData();
53
+ form.append('actionType', 'saveBytes');
54
+ form.append('root', process.cwd());
55
+ form.append('path', 'tmp-bytes-probe.xlsx');
56
+ const res = await action({ request: new Request('http://localhost/api/fs/action', { method: 'POST', body: form }) } as never);
57
+ expect(res.status).toBe(400);
58
+ });
59
+ });