@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
@@ -16,7 +16,7 @@ export type SettingsCategoryId =
16
16
  | 'usage'
17
17
  | 'token-usage'
18
18
  /** Panel plugins — Kabmo's own extension surface (marketplaces of
19
- * sandboxed panel views). Deliberately NOT under LIBRARY, which holds omp's
19
+ * sandboxed panel views). Deliberately NOT under OMP → Plugins, which holds
20
20
  * plugins: these are Kabmo surfaces omp has no concept of. */
21
21
  | 'panel-plugins'
22
22
  // WORKSPACE
@@ -28,6 +28,10 @@ export type SettingsCategoryId =
28
28
  | 'behavior'
29
29
  | 'commands'
30
30
  | 'mcp'
31
+ // omp's extension surface: plugins, skills and the skills catalog.
32
+ | 'plugins'
33
+ | 'skills'
34
+ | 'skills-catalog'
31
35
  // HARNESSES — the agents Kabmo can drive, one PAGE each. Their own group in
32
36
  // the sidebar: a different transport and a different config file from omp.
33
37
  // The single-harness pages carry a dynamic id (`harness:claude`, from
@@ -35,11 +39,7 @@ export type SettingsCategoryId =
35
39
  // what decides which agents exist, and a build-time union entry per harness
36
40
  // would have to be edited for every adapter added at runtime.
37
41
  | 'harness-index'
38
- | `harness:${string}`
39
- // LIBRARY
40
- | 'plugins'
41
- | 'skills'
42
- | 'skills-catalog';
42
+ | `harness:${string}`;
43
43
 
44
44
  export interface SettingsCategoryItem {
45
45
  id: SettingsCategoryId;
@@ -18,7 +18,9 @@
18
18
  * timeline never rendered before: `blocked` (waiting on something, with an
19
19
  * optional note) and `abandoned` (deliberately dropped). Both are settled-but-
20
20
  * not-done, which is why `isClosedTodo` — not `status === 'completed'` — is
21
- * what any progress counter must use.
21
+ * what any progress counter must use. omp 18.19.0 removed `blocked` (and the
22
+ * `block` / `unblock` ops below); the type keeps them because snapshots saved
23
+ * before that pin still carry the status, and omp reads them back as `pending`.
22
24
  */
23
25
 
24
26
  /** Lifecycle state of one todo item (omp's `TodoStatus`). */
@@ -21,6 +21,7 @@ import type { h as PreactH, render as PreactRender } from 'preact';
21
21
  import type { act as PreactAct } from 'preact/test-utils';
22
22
  import type { FileActions, useFileActions as UseFileActionsHook } from '@/client/hooks/workspace/file-tree-actions';
23
23
  import { createStubClipboard, type StubClipboard, type StubClipboardOptions } from '@/test-support/file-clipboard.test-util';
24
+ import { createStubArchive } from '@/test-support/file-archive.test-util';
24
25
 
25
26
  /** What the stubbed endpoint was asked, and what it answers. */
26
27
  export interface FileActionsServer {
@@ -140,6 +141,9 @@ export function createFileActionsHarness(): FileActionsHarness {
140
141
  onOpenFile: (target) => opened.push({ path: target.path, name: target.name }),
141
142
  onActionComplete: () => refreshes++,
142
143
  clipboard,
144
+ selection: [],
145
+ selected: false,
146
+ archive: createStubArchive(),
143
147
  isFolder: file.path === file.name,
144
148
  });
145
149
  return null;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * A stand-in for the Files panel's archive dialogs, for specs that exercise a
8
+ * ROW (`useFileActions`) rather than the panel.
9
+ *
10
+ * The real hook is owned by the panel; a row only needs the two openers and a
11
+ * busy flag, and the calls it made are what the menu assertions read.
12
+ */
13
+
14
+ import type { ClipboardTarget } from '@/client/hooks/workspace/file-clipboard';
15
+ import type { FileArchive } from '@/client/hooks/workspace/file-archive';
16
+
17
+ export interface StubArchive extends FileArchive {
18
+ /** Every dialog a row asked the panel to open, in order. */
19
+ calls: Array<{ action: 'compress' | 'extract'; targets: ClipboardTarget[] }>;
20
+ }
21
+
22
+ export function createStubArchive(): StubArchive {
23
+ const calls: StubArchive['calls'] = [];
24
+ return {
25
+ formats: [],
26
+ compress: null,
27
+ extract: null,
28
+ error: null,
29
+ busy: false,
30
+ calls,
31
+ openCompress: (targets) => calls.push({ action: 'compress', targets: [...targets] }),
32
+ openExtract: (target) => calls.push({ action: 'extract', targets: [target] }),
33
+ setFormat: () => {},
34
+ setName: () => {},
35
+ setCompressDestination: () => {},
36
+ setExtractDestination: () => {},
37
+ cancel: () => {},
38
+ submitCompress: () => {},
39
+ submitExtract: () => {},
40
+ };
41
+ }
@@ -28,14 +28,17 @@ export interface StubClipboardOptions {
28
28
 
29
29
  export interface StubClipboard extends FileClipboard {
30
30
  /** Every call the row made, in order. */
31
- calls: Array<{ action: string; target: ClipboardTarget }>;
31
+ calls: Array<{ action: string; targets: ClipboardTarget[] }>;
32
32
  }
33
33
 
34
34
  export function createStubClipboard(options: StubClipboardOptions = {}): StubClipboard {
35
35
  const calls: StubClipboard['calls'] = [];
36
36
  const clip = options.clip ?? null;
37
- const record = (action: string) => (target: ClipboardTarget) => {
38
- calls.push({ action, target });
37
+ const record = (action: string) => (targets: readonly ClipboardTarget[]) => {
38
+ calls.push({ action, targets: [...targets] });
39
+ };
40
+ const single = (action: string) => (target: ClipboardTarget) => {
41
+ calls.push({ action, targets: [target] });
39
42
  };
40
43
  return {
41
44
  clip,
@@ -45,8 +48,8 @@ export function createStubClipboard(options: StubClipboardOptions = {}): StubCli
45
48
  moveRefusalFor: () => options.moveRefusal ?? options.refusal ?? null,
46
49
  copy: record('copy'),
47
50
  cut: record('cut'),
48
- duplicate: record('duplicate'),
49
- paste: record('paste'),
50
- move: record('move'),
51
+ duplicate: single('duplicate'),
52
+ paste: single('paste'),
53
+ move: single('move'),
51
54
  };
52
55
  }
@@ -21,6 +21,7 @@ import type { h as PreactH, render as PreactRender } from 'preact';
21
21
  import type { act as PreactAct } from 'preact/test-utils';
22
22
  import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
23
23
  import type {
24
+ FileEditorTarget,
24
25
  UseFileEditorOptions,
25
26
  UseFileEditorResult,
26
27
  useFileEditor as UseFileEditorHook,
@@ -143,7 +144,7 @@ export interface EditorHarness {
143
144
  /** Latest render's result — re-read after every settle, never held across one. */
144
145
  readonly mounted: UseFileEditorResult | null;
145
146
  settle(): Promise<void>;
146
- mount(target?: typeof TARGET, options?: UseFileEditorOptions): Promise<void>;
147
+ mount(target?: FileEditorTarget, options?: UseFileEditorOptions): Promise<void>;
147
148
  /** Run a state update inside Preact's `act`, then settle. */
148
149
  run(update: () => void): Promise<void>;
149
150
  /**
@@ -177,7 +178,7 @@ export function createEditorHarness(): EditorHarness {
177
178
  });
178
179
  }
179
180
 
180
- async function mount(target: typeof TARGET = TARGET, options: UseFileEditorOptions = {}) {
181
+ async function mount(target: FileEditorTarget = TARGET, options: UseFileEditorOptions = {}) {
181
182
  const Probe = () => {
182
183
  mounted = useFileEditor(target, options);
183
184
  return null;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Reading the client's own CSS in a test.
8
+ *
9
+ * The glass contract is asserted against the stylesheets themselves — a token
10
+ * declared in the wrong block is invisible to `getComputedStyle` in a way no
11
+ * component test can see — so more than one spec needs to read a file and pull
12
+ * one rule's body out of it. Both helpers live here rather than in each spec:
13
+ * a second copy of `ruleBody`'s selector escaping is how one spec starts
14
+ * matching a rule the other does not.
15
+ */
16
+
17
+ const CLIENT_DIR = new URL('../client/', import.meta.url);
18
+
19
+ /** The text of a stylesheet under `src/client/`, e.g. `readClientCss('glass.css')`. */
20
+ export const readClientCss = (file: string): Promise<string> => Bun.file(new URL(file, CLIENT_DIR)).text();
21
+
22
+ /** The body of the first rule whose selector starts a line, e.g. `[x] {`. */
23
+ export function ruleBody(css: string, selector: string): string {
24
+ const start = css.search(new RegExp(`^${selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} \\{`, 'm'));
25
+ if (start < 0) throw new Error(`no rule for ${selector}`);
26
+ const open = css.indexOf('{', start);
27
+ const close = css.indexOf('\n}', open);
28
+ if (close < 0) throw new Error(`unterminated rule for ${selector}`);
29
+ return css.slice(open + 1, close);
30
+ }
@@ -91,6 +91,7 @@ export function mountHarnessTable(
91
91
  state?: {
92
92
  jobs?: HarnessUpdateJob[];
93
93
  onOpenLog?: (harness: string) => void;
94
+ onDismiss?: (harness: string) => Promise<string | null>;
94
95
  },
95
96
  ): HTMLElement {
96
97
  act(() =>
@@ -102,6 +103,7 @@ export function mountHarnessTable(
102
103
  onUpdate: onUpdate ?? (async () => null),
103
104
  jobs: state?.jobs ?? [],
104
105
  onOpenLog: state?.onOpenLog,
106
+ onDismiss: state?.onDismiss,
105
107
  }),
106
108
  container,
107
109
  ),
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The run-wide fallback database, loaded by `bunfig.toml`'s `[test] preload`.
8
+ *
9
+ * Per-suite isolation (`isolateDb`/`releaseDb`) is the contract, and it is what
10
+ * keeps a suite's writes inside its own temp file. It cannot cover work that
11
+ * outlives its suite: production code fires writes and forgets them
12
+ * (`void noteChildOutcome(...)`, `void syncDiscoveryRootsWatch()`), and such a
13
+ * continuation can call `getDb()` AFTER `releaseDb` deleted `KABMO_DB_PATH`.
14
+ * The path is then the default one — the developer's real `~/.kabmo/db.sqlite`.
15
+ *
16
+ * `DB_PATH` is the LOWEST-precedence spelling (`KABMO_DB_PATH` ->
17
+ * `OMPCHAMBER_DB_PATH` -> `DB_PATH`), so a suite that isolates still wins, and
18
+ * `releaseDb` (which deletes only `KABMO_DB_PATH`) hands late work back to this
19
+ * temp file instead of the developer's home. Measured on a full `bun test` with
20
+ * a tracer around `createDb`: two opens of the real path remained after every
21
+ * suite was isolated, one from a debounced roots-watch reconcile and one from
22
+ * an ACP child-outcome write; both fall to this file and the tracer reports
23
+ * zero.
24
+ *
25
+ * `afterAll` here runs ONCE for the whole run (measured: a preload hook is not
26
+ * per file), which is where the directory is removed. The handle is closed
27
+ * first — a live SQLite handle makes the delete fail with `EBUSY` on Windows.
28
+ */
29
+
30
+ import { afterAll } from 'bun:test';
31
+ import { mkdtempSync } from 'node:fs';
32
+ import { tmpdir } from 'node:os';
33
+ import { join } from 'node:path';
34
+
35
+ import { closeDb } from '@/server/db.server';
36
+ import { removeDir } from '@/test-support/remove-dir';
37
+
38
+ const dir = mkdtempSync(join(tmpdir(), 'kabmo-test-fallback-db-'));
39
+ // Assigned, not overwritten: an operator running `bun test` with `DB_PATH` set
40
+ // asked for that file, and no suite should silently redirect it.
41
+ Bun.env.DB_PATH ??= join(dir, 'db.sqlite');
42
+
43
+ afterAll(async () => {
44
+ await closeDb();
45
+ removeDir(dir);
46
+ });