@kabmo-labs/kabmo 0.28.0 → 0.29.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 (225) 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-43z47ngg.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.css +39 -14
  86. package/src/client/glass.test.ts +37 -0
  87. package/src/client/hooks/chat/composer/history.test.ts +267 -0
  88. package/src/client/hooks/chat/composer/history.ts +146 -0
  89. package/src/client/hooks/chat/timeline/ask-frames.test.ts +54 -0
  90. package/src/client/hooks/chat/timeline/ask-frames.ts +29 -1
  91. package/src/client/hooks/chat/timeline/timeline-rail.test.ts +34 -2
  92. package/src/client/hooks/chat/timeline/user-turns.ts +31 -2
  93. package/src/client/hooks/editor/file-editor-types.ts +15 -0
  94. package/src/client/hooks/editor/save-bytes.ts +79 -0
  95. package/src/client/hooks/editor/use-file-editor.test.ts +30 -0
  96. package/src/client/hooks/editor/use-file-editor.ts +53 -5
  97. package/src/client/hooks/editor/use-file-read.ts +21 -2
  98. package/src/client/hooks/editor/use-grid-selection.ts +160 -0
  99. package/src/client/hooks/models/use-harness-update.test.ts +35 -2
  100. package/src/client/hooks/models/use-harness-update.ts +49 -10
  101. package/src/client/hooks/workspace/diff-file.test.ts +72 -0
  102. package/src/client/hooks/workspace/diff-file.ts +12 -6
  103. package/src/client/hooks/workspace/file-archive.ts +220 -0
  104. package/src/client/hooks/workspace/file-clipboard.test.ts +4 -4
  105. package/src/client/hooks/workspace/file-clipboard.ts +37 -26
  106. package/src/client/hooks/workspace/file-selection.test.ts +67 -0
  107. package/src/client/hooks/workspace/file-selection.ts +156 -0
  108. package/src/client/hooks/workspace/file-tree-actions-clipboard.test.ts +5 -5
  109. package/src/client/hooks/workspace/file-tree-actions.ts +36 -8
  110. package/src/client/lib/editor/workbook-drafts.ts +42 -0
  111. package/src/client/lib/launch/file-handlers.ts +2 -2
  112. package/src/client/lib/scrollbar-activity.test.ts +21 -88
  113. package/src/client/lib/scrollbar-activity.ts +71 -73
  114. package/src/client/lib/scrollbar-events.ts +143 -0
  115. package/src/client/lib/scrollbar-input.test.ts +126 -0
  116. package/src/client/lib/scrollbar-probe.test-util.ts +107 -0
  117. package/src/client/tailwind.css +32 -1
  118. package/src/server/db.server.test.ts +50 -1
  119. package/src/server/db.server.ts +36 -3
  120. package/src/server/lib/chat/prompt-history.server.test.ts +92 -0
  121. package/src/server/lib/chat/prompt-history.server.ts +65 -0
  122. package/src/server/lib/chat/schema.server.ts +35 -0
  123. package/src/server/lib/db/schema.ts +3 -0
  124. package/src/server/lib/fs/archive.test.ts +139 -0
  125. package/src/server/lib/fs/archive.ts +259 -0
  126. package/src/server/lib/fs/git-diff.test.ts +26 -1
  127. package/src/server/lib/fs/git-diff.ts +43 -15
  128. package/src/server/lib/harness/launch-table.ts +19 -0
  129. package/src/server/lib/harness/provider-entry.ts +1 -1
  130. package/src/server/lib/harness/provider-file.server.ts +1 -1
  131. package/src/server/lib/harness/provider-sources.server.ts +2 -1
  132. package/src/server/lib/harness/provider-write.server.ts +2 -1
  133. package/src/server/lib/harness/update-job-store.ts +12 -0
  134. package/src/server/lib/harness/update-queue.server.ts +15 -10
  135. package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +5 -1
  136. package/src/server/lib/omp/rpc/frame-fold.test.ts +5 -1
  137. package/src/server/lib/omp/rpc/lifecycle.test.ts +4 -0
  138. package/src/server/lib/omp/session/auto-title.server.test.ts +4 -0
  139. package/src/server/lib/omp/session/delete.server.ts +1 -0
  140. package/src/server/lib/omp/session/goal-driver.test.ts +5 -1
  141. package/src/server/lib/omp/session/goal-settings.test.ts +5 -1
  142. package/src/server/lib/panels/auto-update.server.test.ts +5 -2
  143. package/src/server/lib/panels/git-update.server.test.ts +5 -2
  144. package/src/server/lib/panels/install.server.test.ts +5 -2
  145. package/src/server/lib/panels/remove.server.test.ts +5 -2
  146. package/src/server/routes/agent/command.ts +11 -0
  147. package/src/server/routes/agent/new.ts +5 -0
  148. package/src/server/routes/chat/index.ts +5 -0
  149. package/src/server/routes/chat/prompt-history.test.ts +67 -0
  150. package/src/server/routes/chat/prompt-history.ts +31 -0
  151. package/src/server/routes/chat/stream.test.ts +21 -0
  152. package/src/server/routes/chat/stream.ts +5 -0
  153. package/src/server/routes/fs/action-archive.test.ts +128 -0
  154. package/src/server/routes/fs/action-bulk.ts +106 -0
  155. package/src/server/routes/fs/action-save-bytes.test.ts +59 -0
  156. package/src/server/routes/fs/action-transfer.test.ts +26 -0
  157. package/src/server/routes/fs/action.ts +91 -11
  158. package/src/server/routes/fs/archive.ts +20 -0
  159. package/src/server/routes/fs/grant.test.ts +5 -2
  160. package/src/server/routes/fs/index.ts +2 -0
  161. package/src/server/routes/fs/scope.test.ts +6 -2
  162. package/src/server/routes/harness/import-action.ts +1 -1
  163. package/src/server/routes/harness/root.ts +6 -1
  164. package/src/server/routes/harness/summary.test.ts +50 -0
  165. package/src/server/routes/harness/update-status.ts +41 -2
  166. package/src/server/routes/harness/update.test.ts +56 -2
  167. package/src/server/routes/sessions/delete.test.ts +4 -0
  168. package/src/shared/lib/chat/ask-form/index.ts +39 -31
  169. package/src/shared/lib/chat/ask-form/labels.ts +46 -0
  170. package/src/shared/lib/chat/ask-form/tokens.ts +11 -2
  171. package/src/shared/lib/chat/ask-form.test.ts +57 -0
  172. package/src/shared/lib/chat/ask-questions.ts +31 -0
  173. package/src/shared/lib/chat/composer/history.test.ts +67 -0
  174. package/src/shared/lib/chat/composer/history.ts +61 -0
  175. package/src/shared/lib/chat/irc-notice.ts +42 -0
  176. package/src/shared/lib/chat/timeline/fork-anchor.test.ts +2 -0
  177. package/src/shared/lib/chat/todo/parser.ts +6 -4
  178. package/src/shared/lib/fs/archive.test.ts +101 -0
  179. package/src/shared/lib/fs/archive.ts +191 -0
  180. package/src/shared/lib/fs/clipboard.test.ts +32 -7
  181. package/src/shared/lib/fs/clipboard.ts +59 -14
  182. package/src/shared/lib/fs/csv.test.ts +50 -0
  183. package/src/shared/lib/fs/csv.ts +40 -0
  184. package/src/shared/lib/fs/document-kind.test.ts +13 -6
  185. package/src/shared/lib/fs/document-kind.ts +18 -6
  186. package/src/shared/lib/fs/file-kind-classify.test.ts +4 -0
  187. package/src/shared/lib/fs/file-kind.test.ts +2 -7
  188. package/src/shared/lib/fs/file-kind.ts +4 -2
  189. package/src/shared/lib/fs/grid-edit.test.ts +24 -0
  190. package/src/shared/lib/fs/grid-edit.ts +29 -0
  191. package/src/shared/lib/fs/grid-selection.test.ts +137 -0
  192. package/src/shared/lib/fs/grid-selection.ts +138 -0
  193. package/src/shared/lib/harness/brand-color.ts +5 -0
  194. package/src/shared/lib/harness/catalog.test.ts +22 -0
  195. package/src/shared/lib/harness/catalog.ts +12 -1
  196. package/src/shared/lib/harness/config-fields.test.ts +25 -0
  197. package/src/shared/lib/harness/config-fields.ts +33 -3
  198. package/src/shared/lib/harness/dialects.ts +1 -1
  199. package/src/shared/lib/harness/mcp-facts.ts +4 -0
  200. package/src/shared/lib/harness/provider-contracts.ts +109 -0
  201. package/src/shared/lib/harness/provider-facts.test.ts +2 -1
  202. package/src/shared/lib/harness/provider-facts.ts +24 -115
  203. package/src/shared/lib/harness/provider-lookup.ts +37 -0
  204. package/src/shared/lib/harness/providers.ts +2 -1
  205. package/src/shared/lib/harness/updates.ts +10 -0
  206. package/src/shared/lib/omp/session/mapper.test.ts +31 -0
  207. package/src/shared/lib/omp/session/mapper.ts +17 -0
  208. package/src/shared/lib/omp/session/messages-map-notice.test.ts +68 -0
  209. package/src/shared/lib/omp/session/messages-map.test.ts +1 -35
  210. package/src/shared/lib/omp/session/messages-map.ts +17 -0
  211. package/src/shared/lib/omp/session/wait.ts +10 -1
  212. package/src/shared/lib/settings/sections.ts +8 -4
  213. package/src/shared/lib/ui/picker-filter.test.ts +23 -0
  214. package/src/shared/lib/ui/picker-filter.ts +20 -0
  215. package/src/shared/types/chat.ts +4 -0
  216. package/src/shared/types/harness.ts +5 -1
  217. package/src/shared/types/omp/session.ts +18 -0
  218. package/src/shared/types/settings/state.ts +6 -6
  219. package/src/shared/types/todo.ts +3 -1
  220. package/src/test-support/file-actions.test-util.ts +4 -0
  221. package/src/test-support/file-archive.test-util.ts +41 -0
  222. package/src/test-support/file-clipboard.test-util.ts +9 -6
  223. package/src/test-support/harness-table.test-util.ts +2 -0
  224. package/src/test-support/preload.ts +46 -0
  225. package/dist/client/static/js/index-81f7berm.css +0 -1
@@ -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
+ });
@@ -113,6 +113,32 @@ describe('fs paste', () => {
113
113
  expect(fs.readFileSync(path.join(DIR, 'a.ts'), 'utf8')).toBe('A');
114
114
  });
115
115
 
116
+ test('a multi-entry cut moves every source in one request', async () => {
117
+ reset({
118
+ 'tmp-fs-transfer-probe/a.ts': 'A',
119
+ 'tmp-fs-transfer-probe/b.ts': 'B',
120
+ 'tmp-fs-transfer-probe/dest/.keep': '',
121
+ });
122
+
123
+ const form = new FormData();
124
+ for (const [key, value] of Object.entries({
125
+ root: process.cwd(),
126
+ actionType: 'paste',
127
+ mode: 'cut',
128
+ targetPath: 'tmp-fs-transfer-probe/dest',
129
+ targetKind: 'folder',
130
+ })) form.append(key, value);
131
+ form.append('sourcePath', 'tmp-fs-transfer-probe/a.ts');
132
+ form.append('sourcePath', 'tmp-fs-transfer-probe/b.ts');
133
+ const res = await action({ request: new Request('http://localhost/api/fs/action', { method: 'POST', body: form }) } as never);
134
+ const body = (await res.json()) as { success?: boolean; paths?: string[]; failures?: unknown[] };
135
+
136
+ expect(res.status).toBe(200);
137
+ expect(body.paths?.sort()).toEqual(['tmp-fs-transfer-probe/dest/a.ts', 'tmp-fs-transfer-probe/dest/b.ts']);
138
+ expect(fs.existsSync(path.join(DIR, 'a.ts'))).toBe(false);
139
+ expect(fs.readFileSync(path.join(DIR, 'dest/b.ts'), 'utf8')).toBe('B');
140
+ });
141
+
116
142
  test('refuses a folder pasted into its own subtree', async () => {
117
143
  reset({ 'tmp-fs-transfer-probe/src/a.ts': 'A', 'tmp-fs-transfer-probe/src/deep/.keep': '' });
118
144
 
@@ -7,12 +7,14 @@ import { getDefaultFsRoot, isWithinRoot, resolveRoot, resolveWithinRoot } from '
7
7
  import { runShell } from '@/server/lib/fs/shell';
8
8
  import { revealInFileManager } from '@/server/lib/fs/reveal';
9
9
  import { duplicateEntry, nextDuplicateName, pasteEntry, toRelPath } from '@/server/lib/fs/transfer';
10
+ import { runArchiveAction, runBatchDeleteAction } from '@/server/routes/fs/action-bulk';
10
11
  import { normalizeRelativePath } from '@/server/lib/fs/relative-path';
11
12
  import { isSinglePathSegment } from '@/server/lib/fs/path-segment';
12
13
  import { checkWriteConflict, parseBaseMtime, stableMtime } from '@/server/lib/fs/write-conflict';
13
14
  import { transferRefusal } from '@/shared/lib/fs/clipboard';
14
15
  import { toDiskText } from '@/shared/lib/code/line-endings';
15
16
  import { contentHash } from '@/shared/lib/fs/content-hash';
17
+ import { DOCUMENT_MAX_FILE_BYTES } from '@/shared/lib/fs/file-kind';
16
18
 
17
19
  /** The two shapes a transfer action answers with, ready for `json`. */
18
20
  function transferResponse(outcome: { path?: string; error?: string; status?: number }) {
@@ -51,22 +53,54 @@ async function runDuplicateAction(options: { filePath: string; scopedRoot: strin
51
53
  async function runPasteAction(options: { formData: FormData; scopedRoot: string }) {
52
54
  const { formData, scopedRoot } = options;
53
55
  const mode = formData.get('mode') === 'cut' ? 'cut' : 'copy';
54
- const sourceRel = ((formData.get('sourcePath') as string) ?? '').trim();
55
- const sourcePath = resolveWithinRoot(scopedRoot, sourceRel);
56
- if (!sourcePath) return json({ error: 'Invalid path' }, { status: 403 });
57
- const sourceStat = await Bun.file(sourcePath).stat().catch(() => null);
58
- if (!sourceStat) return json({ error: 'The entry on the clipboard no longer exists' }, { status: 404 });
56
+ // Repeated fields carry a whole selection; a single `sourcePath` from an older
57
+ // client is the same list of one.
58
+ const sourceRels = formData.getAll('sourcePath').map((value) => String(value).trim()).filter(Boolean);
59
+ if (sourceRels.length === 0) return json({ error: 'Nothing to paste' }, { status: 400 });
59
60
  const rawTarget = ((formData.get('targetPath') as string) ?? '').trim() || '.';
60
61
  const rawTargetKind = formData.get('targetKind') === 'folder' ? 'folder' : 'file';
61
62
  const targetDir = rawTargetKind === 'folder' ? rawTarget : path.dirname(rawTarget);
62
- const refusal = transferRefusal(
63
- { path: sourceRel, kind: sourceStat.isDirectory() ? 'folder' : 'file' },
64
- targetDir,
65
- );
66
- if (refusal) return json({ error: refusal }, { status: 409 });
67
63
  const fullDir = resolveWithinRoot(scopedRoot, targetDir);
68
64
  if (!fullDir) return json({ error: 'Invalid path' }, { status: 403 });
69
- return transferResponse(await pasteEntry({ scopedRoot, sourcePath, destinationDir: fullDir, mode }));
65
+
66
+ // VALIDATE the whole batch before moving anything: a refusal on the third
67
+ // entry must leave the first two where they were, or the answer says "no"
68
+ // while the tree has already changed.
69
+ const sources: { rel: string; full: string }[] = [];
70
+ const failures: { path: string; error: string }[] = [];
71
+ for (const sourceRel of sourceRels) {
72
+ const sourcePath = resolveWithinRoot(scopedRoot, sourceRel);
73
+ if (!sourcePath) return json({ error: 'Invalid path' }, { status: 403 });
74
+ const sourceStat = await Bun.file(sourcePath).stat().catch(() => null);
75
+ if (!sourceStat) {
76
+ failures.push({ path: sourceRel, error: 'The entry on the clipboard no longer exists' });
77
+ continue;
78
+ }
79
+ const refusal = transferRefusal(
80
+ { path: sourceRel, kind: sourceStat.isDirectory() ? 'folder' : 'file' },
81
+ targetDir,
82
+ );
83
+ if (refusal) return json({ error: refusal }, { status: 409 });
84
+ sources.push({ rel: sourceRel, full: sourcePath });
85
+ }
86
+
87
+ const paths: string[] = [];
88
+ for (const source of sources) {
89
+ const outcome = await pasteEntry({ scopedRoot, sourcePath: source.full, destinationDir: fullDir, mode });
90
+ if (outcome.error) failures.push({ path: source.rel, error: outcome.error });
91
+ else if (outcome.path) paths.push(outcome.path);
92
+ }
93
+
94
+ if (paths.length === 0 && failures.length > 0) {
95
+ // The single-entry answer keeps the status it always had, so a stale tab
96
+ // still reads "that entry is gone" rather than a generic 400.
97
+ const missing = failures.every((failure) => failure.error.includes('no longer exists'));
98
+ return json({ error: failures[0]!.error }, { status: missing ? 404 : 400 });
99
+ }
100
+ // One source answers the shape the panel has always read; a batch names the
101
+ // whole list so the reload after it can reveal what moved.
102
+ if (sourceRels.length === 1) return json({ success: true, path: paths[0] });
103
+ return json(failures.length > 0 ? { success: true, paths, failures } : { success: true, paths });
70
104
  }
71
105
 
72
106
  export async function action({ request }: ActionFunctionArgs) {
@@ -89,6 +123,16 @@ export async function action({ request }: ActionFunctionArgs) {
89
123
  return await runPasteAction({ formData, scopedRoot });
90
124
  }
91
125
 
126
+ // The archive verbs name their own paths (`path`/`paths`), so they are
127
+ // dispatched BEFORE the single-`path` resolution: a compress request has no
128
+ // `path` field at all, and resolving `undefined` is a crash, not a refusal.
129
+ if (actionType === 'extract' || actionType === 'compress') {
130
+ return await runArchiveAction({ actionType, formData, scopedRoot });
131
+ }
132
+ if (actionType === 'delete' && typeof formData.get('paths') === 'string') {
133
+ return await runBatchDeleteAction({ formData, scopedRoot });
134
+ }
135
+
92
136
  const fullPath = resolveWithinRoot(scopedRoot, filePath);
93
137
 
94
138
  if (!fullPath) {
@@ -137,6 +181,42 @@ export async function action({ request }: ActionFunctionArgs) {
137
181
  mtimeMs: written ? stableMtime(written.mtimeMs) : null,
138
182
  hash: await contentHash(content),
139
183
  });
184
+ } else if (actionType === 'saveBytes') {
185
+ // A workbook the grid edited: the bytes are the file, so they travel as a
186
+ // Blob rather than as a text field. `content` cannot carry them — a
187
+ // multipart text field is UTF-8 and normalizes line endings, which would
188
+ // corrupt a ZIP container.
189
+ const blob = formData.get('bytes');
190
+ if (!(blob instanceof Blob)) {
191
+ return json({ error: 'No file bytes' }, { status: 400 });
192
+ }
193
+ if (blob.size > DOCUMENT_MAX_FILE_BYTES) {
194
+ return json({ error: 'The edited file is larger than the editor writes.' }, { status: 413 });
195
+ }
196
+ const verdict = await checkWriteConflict(
197
+ fullPath,
198
+ parseBaseMtime(formData.get('baseMtime')),
199
+ async (target) => {
200
+ const stat = await Bun.file(target).stat().catch(() => null);
201
+ return stat && !stat.isDirectory() ? { mtimeMs: stat.mtimeMs } : null;
202
+ },
203
+ );
204
+ if (!verdict.write) {
205
+ return json(
206
+ {
207
+ error: 'This file changed on disk since it was opened.',
208
+ conflict: true,
209
+ mtimeMs: verdict.diskMtimeMs,
210
+ },
211
+ { status: 409 },
212
+ );
213
+ }
214
+ await fs.promises.mkdir(path.dirname(fullPath), { recursive: true });
215
+ await Bun.write(fullPath, blob);
216
+ const written = await Bun.file(fullPath).stat().catch(() => null);
217
+ // No content hash: the digest route hashes TEXT, and a workbook is not
218
+ // text. The mtime is what the next save's conflict base needs.
219
+ return json({ success: true, mtimeMs: written ? stableMtime(written.mtimeMs) : null, hash: null });
140
220
  } else if (actionType === 'saveAs') {
141
221
  // Write the buffer to a NEW path. The destination is `path` (a directory) plus
142
222
  // `name` (ONE segment), both resolved against this route's own scope — a
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `GET /api/fs/archive` — which compress formats this machine can write.
8
+ *
9
+ * The dialog cannot guess: `rar` is almost never installed and `7z` is not on
10
+ * a stock macOS. Offering a format the server then refuses with ENOENT is a
11
+ * dead row; asking here means the dialog lists exactly the tools the machine
12
+ * has, and the user learns the reason before typing a name.
13
+ */
14
+
15
+ import { json } from '@/server/lib/remix-compat';
16
+ import { compressFormats } from '@/server/lib/fs/archive';
17
+
18
+ export async function loader() {
19
+ return json({ formats: compressFormats() });
20
+ }
@@ -20,21 +20,24 @@ import path from 'path';
20
20
  import { action } from '@/server/routes/fs/grant';
21
21
  import { resolveFileScope } from '@/server/routes/fs/scope';
22
22
  import { clearExternalRoots, externalRoots, isExternalRoot } from '@/server/lib/fs/external-roots';
23
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
23
24
 
24
25
  /** A file OUTSIDE the app root and outside every workspace. */
25
26
  let outside: string;
26
27
  let outsideFile: string;
27
28
 
28
- beforeEach(() => {
29
+ beforeEach(async () => {
30
+ await isolateDb();
29
31
  clearExternalRoots();
30
32
  outside = fs.mkdtempSync(path.join(os.tmpdir(), 'kabmo-grant-'));
31
33
  outsideFile = path.join(outside, 'report.md');
32
34
  fs.writeFileSync(outsideFile, '# report\n');
33
35
  });
34
36
 
35
- afterEach(() => {
37
+ afterEach(async () => {
36
38
  clearExternalRoots();
37
39
  fs.rmSync(outside, { recursive: true, force: true });
40
+ await releaseDb();
38
41
  });
39
42
 
40
43
  function grantRequest(body: unknown, headers: Record<string, string> = {}): Request {
@@ -5,6 +5,7 @@ import { fileExists } from '@/server/routes/fs/exists';
5
5
  import { fileDigest } from '@/server/routes/fs/digest';
6
6
  import { serveRawFile } from '@/server/routes/fs/raw';
7
7
  import * as fsAction from '@/server/routes/fs/action';
8
+ import * as fsArchive from '@/server/routes/fs/archive';
8
9
  import * as fsGit from '@/server/routes/fs/git';
9
10
  import * as fsGrant from '@/server/routes/fs/grant';
10
11
  import * as fsReplace from '@/server/routes/fs/replace';
@@ -13,6 +14,7 @@ import * as fsValidate from '@/server/routes/fs/validate';
13
14
 
14
15
  export const fsBindings: HandlerBinding[] = [
15
16
  ...bindingsFor(fsAction, '/api/fs/action'),
17
+ ...bindingsFor(fsArchive, '/api/fs/archive'),
16
18
  ...bindingsFor(fsGit, '/api/fs/git'),
17
19
  ...bindingsFor(fsGrant, '/api/fs/grant', { mutating: ['POST'] }),
18
20
  ...bindingsFor(fsReplace, '/api/fs/replace'),
@@ -15,19 +15,23 @@
15
15
  * scoped to).
16
16
  */
17
17
 
18
- import { afterEach, describe, expect, test } from 'bun:test';
18
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
19
19
  import fs from 'fs';
20
20
  import path from 'path';
21
21
  import { testPosix } from '@/test-support/platform';
22
22
  import { resolveFileScope } from '@/server/routes/fs/scope';
23
23
  import { DOCUMENT_MAX_FILE_BYTES, EDITOR_MAX_FILE_BYTES, PDF_MAX_FILE_BYTES } from '@/shared/lib/fs/file-kind';
24
24
  import { formatBytes } from '@/shared/lib/format/number';
25
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
25
26
 
26
27
  const APP = process.cwd();
27
28
  const DIR = path.join(APP, 'tmp-scope-probe');
28
29
 
29
- afterEach(() => {
30
+ beforeEach(isolateDb);
31
+
32
+ afterEach(async () => {
30
33
  fs.rmSync(DIR, { recursive: true, force: true });
34
+ await releaseDb();
31
35
  });
32
36
 
33
37
  async function scope(rawPath: string) {
@@ -26,7 +26,7 @@
26
26
  import { json } from '@/server/lib/remix-compat';
27
27
  import { isBuiltinHarness, type HarnessId } from '@/shared/lib/harness/catalog';
28
28
  import { adaptBaseUrl, planProtocol, supportedProtocols, type CanonicalProtocol } from '@/shared/lib/harness/dialects';
29
- import { providerFacts } from '@/shared/lib/harness/provider-facts';
29
+ import { providerFacts } from '@/shared/lib/harness/provider-lookup';
30
30
  import { providerEnv, providerLevel, registryLabel } from '@/shared/lib/harness/providers';
31
31
  import { providerIdProblem, providerSlugFrom } from '@/shared/lib/harness/provider-slug';
32
32
  import { withEnvValues } from '@/shared/lib/harness/config';
@@ -35,7 +35,7 @@ import {
35
35
  providerLevel,
36
36
  registryLabel,
37
37
  } from '@/shared/lib/harness/providers';
38
- import { providerFacts } from '@/shared/lib/harness/provider-facts';
38
+ import { providerFacts } from '@/shared/lib/harness/provider-lookup';
39
39
  import type { HarnessProviderSupport } from '@/shared/types/harness';
40
40
  import { parseHarnessConfig, type HarnessConfig } from '@/shared/lib/harness/config';
41
41
 
@@ -60,6 +60,8 @@ export interface HarnessSummary {
60
60
  /** The letter the UI draws when there is no vendor mark. */
61
61
  initial: string;
62
62
  install?: string;
63
+ /** The built-in launch line, as the config form should show it. */
64
+ command?: string;
63
65
  note?: string;
64
66
  probe: HarnessProbe | null;
65
67
  /** Why it cannot run, without probing: the launch command is missing. */
@@ -102,6 +104,9 @@ export async function listHarnesses(): Promise<HarnessSummary[]> {
102
104
  ...(descriptor?.builtIn ? { builtIn: true as const } : {}),
103
105
  ...(isBuiltinHarness(id) ? {} : { custom: true as const }),
104
106
  ...(launch?.install ? { install: launch.install } : {}),
107
+ // The line a spawn actually runs when the config's command is empty —
108
+ // what the settings card's placeholder must name.
109
+ ...(launch?.command.length ? { command: launch.command.join(' ') } : {}),
105
110
  ...(launch?.note ? { note: launch.note } : {}),
106
111
  probe: fresh,
107
112
  ...(available ? {} : {
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * What the settings card's launch box is told about the agent.
8
+ *
9
+ * The box advertised `agy acp` on every card — Antigravity's line, printed on
10
+ * omp's and Claude's too — and its hint quoted the INSTALL command as "the
11
+ * built-in line". A user typing that hint's example launches nothing, and the
12
+ * form's placeholder claimed a command this harness does not run.
13
+ *
14
+ * So the catalog now carries the line the spawn would actually run, and this
15
+ * pins it to the launch table itself rather than to a second copy.
16
+ */
17
+
18
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
19
+
20
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
21
+ import { HARNESS_LAUNCH } from '@/server/lib/harness/launch-table';
22
+ import { listHarnesses } from '@/server/routes/harness/root';
23
+
24
+ beforeEach(async () => {
25
+ await isolateDb();
26
+ });
27
+
28
+ afterEach(async () => {
29
+ await releaseDb();
30
+ });
31
+
32
+ describe('the catalog carries each harness’s own launch line', () => {
33
+ test('every harness with a launch entry reports that entry’s command', async () => {
34
+ const rows = new Map((await listHarnesses()).map((row) => [row.id, row]));
35
+ for (const [id, launch] of Object.entries(HARNESS_LAUNCH)) {
36
+ if (!launch) continue;
37
+ expect(rows.get(id)?.command, id).toBe(launch.command.join(' '));
38
+ }
39
+ });
40
+
41
+ test('omp and Claude name their own binaries, not Antigravity’s', async () => {
42
+ const rows = new Map((await listHarnesses()).map((row) => [row.id, row]));
43
+ expect(rows.get('omp-acp')?.command).toBe('omp acp');
44
+ expect(rows.get('claude')?.command).toBe(
45
+ 'npx -y @agentclientprotocol/claude-agent-acp@0.100.0',
46
+ );
47
+ // The install line is a different fact and must not stand in for the command.
48
+ expect(rows.get('omp-acp')?.command).not.toBe(rows.get('omp-acp')?.install);
49
+ });
50
+ });
@@ -4,7 +4,8 @@
4
4
  */
5
5
 
6
6
  /**
7
- * `GET /api/harness/update/status` — every harness's background update record.
7
+ * `GET /api/harness/update/status` — every harness's background update record —
8
+ * and `DELETE` on the same path, which dismisses one settled result.
8
9
  *
9
10
  * The POST answers in milliseconds and the install keeps running in a detached
10
11
  * worker, so this is how the dialog learns where each run is and whether it
@@ -21,12 +22,50 @@
21
22
  * An empty array is a real answer — no update has ever run — and it must not be
22
23
  * a 404: the About card asks this on every open, and a "not found" would read as
23
24
  * a broken route rather than "nothing is running".
25
+ *
26
+ * **A settled record is history, and history can be dismissed.** The row used to
27
+ * keep "claude updated (adapter) — it now reports 0.106.0" forever, because the
28
+ * record had no way out: a dismissal has to delete it (or the next open reads it
29
+ * back) and must refuse while the run is still moving — deleting a live record
30
+ * would hide the spinner and let a second install start.
24
31
  */
25
32
 
26
33
  import { json, NO_STORE_HEADERS } from '@/server/lib/remix-compat';
27
- import { pumpUpdateQueue } from '@/server/lib/harness/update-queue.server';
34
+ import type { ActionFunctionArgs } from '@/server/lib/remix-compat';
35
+ import { methodNotAllowed, parseJsonBody } from '@/server/lib/route-adapter';
36
+ import { getHarnessUpdateStatusPath } from '@/server/lib/lifecycle/paths';
37
+ import { pumpUpdateQueue, serializeUpdateWork } from '@/server/lib/harness/update-queue.server';
38
+ import { readUpdateJob, removeUpdateJob } from '@/server/lib/harness/update-job-store';
39
+ import { isBuiltinHarness } from '@/shared/lib/harness/catalog';
40
+ import { jobUnfinished } from '@/shared/lib/harness/update-job';
28
41
 
29
42
  export async function loader() {
30
43
  const jobs = await pumpUpdateQueue();
31
44
  return json({ jobs }, { headers: NO_STORE_HEADERS });
32
45
  }
46
+
47
+ export async function action({ request, params }: ActionFunctionArgs) {
48
+ if (request.method !== 'DELETE') return methodNotAllowed({ request, params });
49
+
50
+ const parsed = await parseJsonBody<{ harness?: unknown }>(request);
51
+ if (!parsed.ok) return json({ error: 'Request body is not valid JSON' }, { status: 400 });
52
+ const id = parsed.body?.harness;
53
+ if (typeof id !== 'string' || !isBuiltinHarness(id)) {
54
+ return json({ error: 'Unknown harness' }, { status: 400 });
55
+ }
56
+
57
+ // Serialized with the queue's own reads/writes: the post-install probe writes
58
+ // the record after answering, so a delete between its read and its write would
59
+ // otherwise be undone and the dismissed message would come back.
60
+ return serializeUpdateWork(async () => {
61
+ const path = getHarnessUpdateStatusPath(id);
62
+ const job = await readUpdateJob(path);
63
+ if (job && jobUnfinished(job)) {
64
+ return json({
65
+ error: `${job.label} update is still ${job.queuedAt !== null ? 'queued' : 'running'} — nothing to dismiss yet`,
66
+ }, { status: 409, headers: NO_STORE_HEADERS });
67
+ }
68
+ await removeUpdateJob(path);
69
+ return json({ dismissed: true }, { headers: NO_STORE_HEADERS });
70
+ });
71
+ }
@@ -22,8 +22,8 @@ import { mkdtempSync, rmSync } from 'node:fs';
22
22
  import { tmpdir } from 'node:os';
23
23
  import { join } from 'node:path';
24
24
  import { action } from '@/server/routes/harness/update';
25
- import { loader as statusLoader } from '@/server/routes/harness/update-status';
26
- import { writeUpdateJob } from '@/server/lib/harness/update-job-store';
25
+ import { action as statusAction, loader as statusLoader } from '@/server/routes/harness/update-status';
26
+ import { readUpdateJob, writeUpdateJob } from '@/server/lib/harness/update-job-store';
27
27
  import { getHarnessUpdateStatusPath } from '@/server/lib/lifecycle/paths';
28
28
  import type { HarnessUpdateJob } from '@/shared/types/harness-update';
29
29
 
@@ -53,6 +53,17 @@ function post(harness: string): Parameters<typeof action>[0] {
53
53
  } as Parameters<typeof action>[0];
54
54
  }
55
55
 
56
+ function dismiss(harness: string): Parameters<typeof statusAction>[0] {
57
+ return {
58
+ request: new Request('http://localhost/api/harness/update/status', {
59
+ method: 'DELETE',
60
+ headers: { 'content-type': 'application/json' },
61
+ body: JSON.stringify({ harness }),
62
+ }),
63
+ params: {},
64
+ } as Parameters<typeof statusAction>[0];
65
+ }
66
+
56
67
  function job(overrides: Partial<HarnessUpdateJob> = {}): HarnessUpdateJob {
57
68
  return {
58
69
  harness: 'claude',
@@ -154,3 +165,46 @@ describe('GET /api/harness/update/status', () => {
154
165
  expect(codex?.pid).toBeNull();
155
166
  });
156
167
  });
168
+
169
+ describe('DELETE /api/harness/update/status', () => {
170
+ test('an unknown harness is refused', async () => {
171
+ const response = (await statusAction(dismiss('nope'))) as Response;
172
+ expect(response.status).toBe(400);
173
+ expect(((await response.json()) as { error: string }).error).toBe('Unknown harness');
174
+ });
175
+
176
+ test('a settled record is deleted, so the row stops quoting it', async () => {
177
+ // The reported defect: "claude updated (adapter) — it now reports 0.106.0"
178
+ // stayed in About after the update finished, with no way out. The dismissal
179
+ // removes the record itself, because a closed card reads it back from disk.
180
+ await writeUpdateJob(job({
181
+ pid: null,
182
+ finishedAt: Date.now(),
183
+ ok: true,
184
+ applied: true,
185
+ probe: 'done',
186
+ message: 'claude updated (adapter) — it now reports 0.106.0',
187
+ }), getHarnessUpdateStatusPath('claude'));
188
+
189
+ const response = (await statusAction(dismiss('claude'))) as Response;
190
+ expect(response.status).toBe(200);
191
+ expect(((await response.json()) as { dismissed: boolean }).dismissed).toBe(true);
192
+ expect(await readUpdateJob(getHarnessUpdateStatusPath('claude'))).toBeNull();
193
+
194
+ const list = (await statusLoader()) as Response;
195
+ expect(((await list.json()) as { jobs: unknown[] }).jobs).toEqual([]);
196
+ });
197
+
198
+ test('a run that is still installing or QUEUED is refused, and its record survives', async () => {
199
+ // Deleting a live record would hide the spinner and let a second install
200
+ // start over the same global prefix.
201
+ await writeUpdateJob(
202
+ job({ harness: 'codex', label: 'codex', pid: null, queuedAt: Date.now() }),
203
+ getHarnessUpdateStatusPath('codex'),
204
+ );
205
+ const response = (await statusAction(dismiss('codex'))) as Response;
206
+ expect(response.status).toBe(409);
207
+ expect(((await response.json()) as { error: string }).error).toContain('still queued');
208
+ expect(await readUpdateJob(getHarnessUpdateStatusPath('codex'))).not.toBeNull();
209
+ });
210
+ });