@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
@@ -23,11 +23,15 @@
23
23
  * per-file ceiling.
24
24
  */
25
25
 
26
- import { describe, expect, test } from 'bun:test';
26
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
27
27
 
28
28
  import { foldSessionFrame } from '@/server/lib/omp/rpc/frame-fold';
29
29
  import { makeHost } from '@/server/lib/omp/rpc/frame-fold-host.test-util';
30
30
  import { onRealtimeSignal } from '@/server/lib/realtime/signals.server';
31
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
32
+
33
+ beforeEach(isolateDb);
34
+ afterEach(releaseDb);
31
35
 
32
36
  /**
33
37
  * The `tool_execution_end` frame is what moves a running session's sidebar row
@@ -17,12 +17,16 @@
17
17
  * observable proof that the branch was reached.
18
18
  */
19
19
 
20
- import { describe, expect, test } from 'bun:test';
20
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
21
21
 
22
22
  import { foldSessionFrame } from '@/server/lib/omp/rpc/frame-fold';
23
23
  import type { SessionFrameHost } from '@/server/lib/omp/rpc/frame-fold-contract';
24
24
  import type { AgentEvent } from '@/server/lib/omp/rpc/constants';
25
25
  import { makeHost } from '@/server/lib/omp/rpc/frame-fold-host.test-util';
26
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
27
+
28
+ beforeEach(isolateDb);
29
+ afterEach(releaseDb);
26
30
 
27
31
  /** Fold one frame and report the flags the trigger leaves behind. */
28
32
  function fold(host: SessionFrameHost, event: AgentEvent): void {
@@ -13,6 +13,10 @@ import { afterEach, beforeEach, describe, expect, test, vi } from 'bun:test';
13
13
 
14
14
  import { AgentSessionWrapper, WebRpcError } from '@/server/lib/omp/rpc/manager';
15
15
  import { RpcCommandTimeoutError, type RpcProcess } from '@/server/lib/omp/rpc/process';
16
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
17
+
18
+ beforeEach(isolateDb);
19
+ afterEach(releaseDb);
16
20
 
17
21
  /** Commands whose ack is fabricated as timed out; everything else resolves, so
18
22
  * only the timeout policy is under test. */
@@ -38,6 +38,10 @@ import {
38
38
  type AutoTitleHost,
39
39
  } from '@/server/lib/omp/session/auto-title.server';
40
40
  import { titleModelOverlayPath } from '@/server/lib/omp/session/title-model-overlay.server';
41
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
42
+
43
+ beforeAll(isolateDb);
44
+ afterAll(releaseDb);
41
45
 
42
46
  /**
43
47
  * The model pin is a FILE under the agent dir, so the suite points that dir at
@@ -65,6 +65,7 @@ const SESSION_ROW_DELETES: readonly (readonly [string, string])[] = [
65
65
  ['session_ui_state', 'session_id'],
66
66
  ['session_stream_state', 'session_id'],
67
67
  ['queued_messages', 'session_id'],
68
+ ['prompt_history', 'session_id'],
68
69
  ['chat_sessions', 'session_id'],
69
70
  ['files', 'session_id'],
70
71
  // An ACP chat has no transcript for the scan to lose: `harness_sessions` IS
@@ -15,7 +15,7 @@
15
15
  * or read session files (same reason `runScheduledTask` takes its deps).
16
16
  */
17
17
 
18
- import { describe, expect, test } from 'bun:test';
18
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
19
19
  import {
20
20
  driveGoalAfterTurn,
21
21
  lastAssistantText,
@@ -25,6 +25,10 @@ import {
25
25
  } from '@/server/lib/omp/session/goal-driver.server';
26
26
  import type { GoalAuditAnswers } from '@/server/lib/omp/session/goal-auditor.server';
27
27
  import type { GoalRecord } from '@/shared/lib/omp/mode/types';
28
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
29
+
30
+ beforeEach(isolateDb);
31
+ afterEach(releaseDb);
28
32
 
29
33
  const goal: GoalRecord = {
30
34
  id: 'g1',
@@ -13,9 +13,13 @@
13
13
  * loop's own guard.
14
14
  */
15
15
 
16
- import { describe, expect, test } from 'bun:test';
16
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
17
17
  import { normalizeGoalBudget } from '@/shared/lib/omp/mode/budget';
18
18
  import { readGoalSettings } from '@/server/lib/omp/session/goal-settings.server';
19
+ import { isolateDb, releaseDb } from '@/test-support/isolated-db';
20
+
21
+ beforeEach(isolateDb);
22
+ afterEach(releaseDb);
19
23
 
20
24
  describe('normalizeGoalBudget', () => {
21
25
  test('a positive integer is a budget, whatever shape it arrived in', () => {
@@ -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
+ });