@kabmo-labs/kabmo 0.18.0 → 0.21.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 (219) hide show
  1. package/README.md +43 -13
  2. package/dist/client/index.html +3 -3
  3. package/dist/client/index.js +485 -484
  4. package/dist/client/static/js/index-0721wrkf.css +1 -0
  5. package/dist/client/static/js/{index-tc09dtca.js → index-zg32n2sk.js} +778 -777
  6. package/dist/client/static/{manifest-42r8wcmg.webmanifest → manifest-q6h8k9e0.webmanifest} +1 -1
  7. package/index.html +1 -1
  8. package/marketplace/plugins/command-runner/package.json +3 -2
  9. package/marketplace/plugins/git-forge/package.json +3 -2
  10. package/marketplace/plugins/session-info/package.json +3 -2
  11. package/marketplace/plugins/stats/package.json +3 -2
  12. package/package.json +3 -1
  13. package/public/manifest.webmanifest +1 -1
  14. package/src/client/components/auth/login-screen/index.tsx +2 -1
  15. package/src/client/components/common/ComposerPicker.tsx +1 -1
  16. package/src/client/components/common/FolderPicker.tsx +2 -2
  17. package/src/client/components/common/Modal.tsx +2 -2
  18. package/src/client/components/common/PWAInstallButton.tsx +2 -2
  19. package/src/client/components/common/ViewportSelector.tsx +1 -1
  20. package/src/client/components/common/anchored-menu/index.tsx +5 -1
  21. package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
  22. package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
  23. package/src/client/components/common/brand-wordmark/index.tsx +13 -2
  24. package/src/client/components/common/checkbox/style.test.ts +142 -0
  25. package/src/client/components/common/checkbox/style.ts +51 -0
  26. package/src/client/components/common/context-usage-button/index.tsx +2 -2
  27. package/src/client/components/common/file-icon/index.tsx +23 -9
  28. package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
  29. package/src/client/components/common/markdown-review/ReviewPopover.tsx +1 -1
  30. package/src/client/components/common/panel-mark/index.test.tsx +124 -0
  31. package/src/client/components/common/panel-mark/index.tsx +105 -0
  32. package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
  33. package/src/client/components/common/provider-icon/index.test.ts +14 -0
  34. package/src/client/components/common/provider-icon/index.tsx +4 -0
  35. package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
  36. package/src/client/components/common/provider-icon/resolve.ts +16 -3
  37. package/src/client/components/common/session-actions-menu/index.tsx +1 -1
  38. package/src/client/components/common/toolbar-row/index.tsx +1 -1
  39. package/src/client/components/layout/ActivityBar.tsx +22 -3
  40. package/src/client/components/layout/LeftDock.tsx +9 -2
  41. package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
  42. package/src/client/components/layout/WindowAura.tsx +27 -0
  43. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
  44. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
  45. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
  46. package/src/client/components/layout/desktop-layout/index.tsx +3 -1
  47. package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +3 -3
  48. package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
  49. package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
  50. package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
  51. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +2 -2
  52. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
  53. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +13 -5
  54. package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
  55. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
  56. package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
  57. package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
  58. package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
  59. package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
  60. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
  61. package/src/client/components/mobile/panel-chips.tsx +10 -2
  62. package/src/client/components/settings/Modal.tsx +4 -4
  63. package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
  64. package/src/client/components/settings/apply-side-effects.test.ts +30 -0
  65. package/src/client/components/settings/apply-side-effects.ts +14 -0
  66. package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
  67. package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
  68. package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
  69. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
  70. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
  71. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
  72. package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +2 -1
  73. package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +2 -2
  74. package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +1 -1
  75. package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
  76. package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
  77. package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +46 -0
  78. package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +1 -1
  79. package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +7 -9
  80. package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +149 -0
  81. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +34 -7
  82. package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +66 -2
  83. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +47 -10
  84. package/src/client/components/settings/categories/panel-plugins/Section.tsx +7 -1
  85. package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +35 -2
  86. package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
  87. package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
  88. package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
  89. package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
  90. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
  91. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
  92. package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
  93. package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
  94. package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +2 -1
  95. package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +1 -1
  96. package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
  97. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
  98. package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
  99. package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
  100. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
  101. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
  102. package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
  103. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
  104. package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
  105. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
  106. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
  107. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
  108. package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
  109. package/src/client/components/workspace/diff-panel/index.tsx +2 -2
  110. package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
  111. package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
  112. package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
  113. package/src/client/components/workspace/editor/Tabs.tsx +1 -1
  114. package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
  115. package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
  116. package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
  117. package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
  118. package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
  119. package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
  120. package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
  121. package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
  122. package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
  123. package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
  124. package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
  125. package/src/client/components/workspace/git-panel/index.tsx +7 -0
  126. package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
  127. package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
  128. package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
  129. package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
  130. package/src/client/components/workspace/search-panel/Body.tsx +1 -1
  131. package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
  132. package/src/client/glass-sticky.test.ts +46 -0
  133. package/src/client/glass.css +795 -0
  134. package/src/client/glass.test.ts +306 -0
  135. package/src/client/hooks/ui/glass-support.ts +57 -0
  136. package/src/client/hooks/ui/icon-style.ts +59 -0
  137. package/src/client/hooks/ui/stuck-header.test.ts +213 -0
  138. package/src/client/hooks/ui/stuck-header.ts +122 -0
  139. package/src/client/hooks/ui/style-attributes.test.ts +120 -0
  140. package/src/client/hooks/ui/surface-style.ts +56 -0
  141. package/src/client/hooks/workspace/panel-hues.ts +23 -0
  142. package/src/client/hooks/workspace/panel-registry.ts +8 -4
  143. package/src/client/main.tsx +10 -0
  144. package/src/client/tailwind.css +264 -11
  145. package/src/server/lib/assets/shell-attributes.server.ts +80 -0
  146. package/src/server/lib/assets/shell-attributes.test.ts +86 -0
  147. package/src/server/lib/lifecycle/tls.test.ts +6 -1
  148. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
  149. package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
  150. package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
  151. package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
  152. package/src/server/lib/omp/rpc/manager.ts +2 -2
  153. package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
  154. package/src/server/lib/omp/rpc/process.test.ts +106 -0
  155. package/src/server/lib/omp/rpc/process.ts +28 -4
  156. package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
  157. package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
  158. package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
  159. package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
  160. package/src/server/lib/omp/rpc/session-commands.ts +11 -0
  161. package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
  162. package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
  163. package/src/server/lib/panels/git-update.server.test.ts +20 -0
  164. package/src/server/lib/panels/git-update.server.ts +20 -4
  165. package/src/server/lib/panels/manifest.test.ts +20 -0
  166. package/src/server/lib/panels/manifest.ts +12 -0
  167. package/src/server/lib/panels/scan.server.ts +4 -0
  168. package/src/server/lib/panels/sync.server.ts +9 -1
  169. package/src/server/lib/panels/update.server.test.ts +193 -0
  170. package/src/server/lib/panels/update.server.ts +210 -0
  171. package/src/server/lib/plugins/server-half.server.ts +42 -0
  172. package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
  173. package/src/server/lib/queue/delivery-harness.ts +8 -4
  174. package/src/server/lib/queue/delivery.server.test.ts +29 -0
  175. package/src/server/lib/queue/delivery.server.ts +39 -0
  176. package/src/server/lib/queue/store.server.test.ts +22 -2
  177. package/src/server/lib/queue/store.server.ts +33 -11
  178. package/src/server/lib/terminal/attach-replay.test.ts +26 -8
  179. package/src/server/plugins/ssr.ts +22 -5
  180. package/src/server/routes/panels/install-route.test.ts +238 -0
  181. package/src/server/routes/panels/install.ts +36 -64
  182. package/src/server/routes/panels/panel-routes.test-util.ts +6 -1
  183. package/src/server/routes/panels/routes.test.ts +1 -118
  184. package/src/shared/lib/icons/file-brand-color.ts +38 -0
  185. package/src/shared/lib/icons/icon-paint-css.test.ts +235 -0
  186. package/src/shared/lib/icons/icon-paint-css.ts +285 -0
  187. package/src/shared/lib/icons/icon-paint-panel.ts +109 -0
  188. package/src/shared/lib/icons/icon-tone.ts +166 -0
  189. package/src/shared/lib/icons/tint-hues.generated.ts +277 -0
  190. package/src/shared/lib/icons/tint.test.ts +333 -0
  191. package/src/shared/lib/icons/tint.ts +248 -0
  192. package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
  193. package/src/shared/lib/models/provider/brand-color.ts +103 -0
  194. package/src/shared/lib/omp/rpc/frame.test.ts +65 -0
  195. package/src/shared/lib/omp/rpc/frame.ts +58 -3
  196. package/src/shared/lib/panels/update.test.ts +107 -0
  197. package/src/shared/lib/panels/update.ts +73 -0
  198. package/src/shared/lib/settings/defaults.ts +4 -0
  199. package/src/shared/lib/theme/catalog.test.ts +5 -4
  200. package/src/shared/lib/theme/catalog.ts +18 -3
  201. package/src/shared/lib/theme/color.ts +50 -0
  202. package/src/shared/lib/theme/glass-support.test.ts +38 -0
  203. package/src/shared/lib/theme/glass-support.ts +73 -0
  204. package/src/shared/lib/theme/icon-style.test.ts +74 -0
  205. package/src/shared/lib/theme/icon-style.ts +90 -0
  206. package/src/shared/lib/theme/legibility.ts +91 -0
  207. package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
  208. package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
  209. package/src/shared/lib/theme/surface-style.test.ts +68 -0
  210. package/src/shared/lib/theme/surface-style.ts +91 -0
  211. package/src/shared/lib/theme/theme.test.ts +11 -7
  212. package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
  213. package/src/shared/lib/workspace/panel-hues.ts +57 -0
  214. package/src/shared/types/panels-registry.ts +6 -0
  215. package/src/shared/types/panels.ts +14 -0
  216. package/src/shared/types/settings/state.ts +26 -0
  217. package/src/test-support/fake-omp-frames.ts +163 -0
  218. package/dist/client/static/js/index-hp75vsv9.css +0 -1
  219. /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
@@ -0,0 +1,106 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The transport faults `RpcProcess` has to survive.
8
+ *
9
+ * Two behaviours are pinned here, and neither can be observed against a real
10
+ * child (omp 18.16.0 advertises one set of ceilings and never emits a malformed
11
+ * chunk), so the scripted child says what the test needs:
12
+ *
13
+ * - **The ceilings come from `ready`.** The same chunk record is valid under
14
+ * the default 1 MiB physical ceiling and invalid under an advertised 4 MiB
15
+ * one — a 2 MiB logical frame is never chunked at 4 MiB — so the two runs
16
+ * differ only in what the server advertised.
17
+ * - **A malformed chunk sequence does not kill the session.** It used to call
18
+ * `dispose(0)`, which took the child's LSP servers, browser targets and
19
+ * prewarm slot down for a transport fault; now the reader reports a notice,
20
+ * loses that one logical frame, and keeps answering.
21
+ */
22
+
23
+ import { afterEach, expect, test } from 'bun:test';
24
+ import { mkdtempSync, rmSync } from 'node:fs';
25
+ import { tmpdir } from 'node:os';
26
+ import { join } from 'node:path';
27
+
28
+ import { describePosix } from '@/test-support/platform';
29
+ import { RpcProcess, type RpcFrame } from '@/server/lib/omp/rpc/process';
30
+
31
+ const FAKE_OMP = join(import.meta.dir, '../../../../test-support/fake-omp-frames.ts');
32
+
33
+ const started: RpcProcess[] = [];
34
+ let root = '';
35
+
36
+ function start(env: Record<string, string>): { proc: RpcProcess; frames: RpcFrame[] } {
37
+ root ||= mkdtempSync(join(tmpdir(), 'omp-frames-test-'));
38
+ const frames: RpcFrame[] = [];
39
+ const proc = new RpcProcess({
40
+ cwd: root,
41
+ env,
42
+ onFrame: (frame) => frames.push(frame),
43
+ dependencies: { resolveOmpBin: () => FAKE_OMP },
44
+ });
45
+ started.push(proc);
46
+ return { proc, frames };
47
+ }
48
+
49
+ /** Ready + v2 negotiation, the state every chunk test needs. */
50
+ async function negotiated(env: Record<string, string>): Promise<{ proc: RpcProcess; frames: RpcFrame[] }> {
51
+ const { proc, frames } = start(env);
52
+ const ready = await proc.waitReady(20_000);
53
+ await proc.negotiateProtocol(ready);
54
+ return { proc, frames };
55
+ }
56
+
57
+ afterEach(async () => {
58
+ for (const proc of started.splice(0)) await proc.dispose(500);
59
+ if (root) {
60
+ rmSync(root, { recursive: true, force: true });
61
+ root = '';
62
+ }
63
+ });
64
+
65
+ describePosix('RpcProcess framing', () => {
66
+ test('the advertised frame ceiling is what the decoder applies', async () => {
67
+ // 4 MiB advertised: a 2 MiB logical frame is below it, so it would never be
68
+ // chunked — the record is a protocol fault and must be reported, once.
69
+ const { proc, frames } = await negotiated({
70
+ FAKE_OMP_READY_MAX_FRAME_BYTES: String(4 * 1024 * 1024),
71
+ FAKE_OMP_CHUNK: 'valid-1mib',
72
+ });
73
+
74
+ const result = await proc.sendCommand<{ exitCode?: number }>({ type: 'bash', command: 'true' }, 20_000);
75
+
76
+ // The response still arrived: the reader continued past the bad record.
77
+ expect(result.exitCode).toBe(0);
78
+ const notices = frames.filter((frame) => frame.type === 'notice');
79
+ expect(notices).toHaveLength(1);
80
+ expect(String(notices[0].message)).toContain('malformed RPC frame');
81
+ expect(proc.isAlive).toBe(true);
82
+ }, 30_000);
83
+
84
+ test('the same record is accepted under the default ceiling', async () => {
85
+ // Control for the test above: identical bytes, no advertised override. The
86
+ // record is a valid FIRST slice, so nothing is reported and nothing is lost.
87
+ const { proc, frames } = await negotiated({ FAKE_OMP_CHUNK: 'valid-1mib' });
88
+
89
+ const result = await proc.sendCommand<{ exitCode?: number }>({ type: 'bash', command: 'true' }, 20_000);
90
+
91
+ expect(result.exitCode).toBe(0);
92
+ expect(frames.filter((frame) => frame.type === 'notice')).toHaveLength(0);
93
+ }, 30_000);
94
+
95
+ test('a malformed sequence costs one frame, not the child', async () => {
96
+ const { proc, frames } = await negotiated({ FAKE_OMP_CHUNK: 'bad-index' });
97
+
98
+ await proc.sendCommand({ type: 'bash', command: 'true' }, 20_000);
99
+ expect(frames.filter((frame) => frame.type === 'notice')).toHaveLength(1);
100
+
101
+ // The session is still there: a later command is answered by the SAME child.
102
+ const state = await proc.sendCommand<{ sessionId?: string }>({ type: 'get_state' }, 20_000);
103
+ expect(state.sessionId).toBe('fake-session');
104
+ expect(proc.isAlive).toBe(true);
105
+ }, 30_000);
106
+ });
@@ -20,9 +20,10 @@ import { signalName, stripKabmoHostEnv } from '@kabmo-labs/kabmo-sdk';
20
20
  import { describeSpawnFailure } from '@/server/lib/lifecycle/fd-pressure';
21
21
  import { resolveOmpBin } from '@/server/lib/omp/core/cli';
22
22
  import { RpcFrameDecoder, encodeRpcFrameLine, type RpcFrameRecord, type RpcProtocolVersion } from '@/shared/lib/omp/rpc/frame';
23
+ import { isRecord } from '@/shared/lib/util/guards';
23
24
  import { killProcessTree } from '@/server/lib/lifecycle/kill-tree';
24
25
  import { readLines } from '@/server/lib/omp/rpc/lines';
25
- import { RpcCommandError, RpcCommandTimeoutError, STDERR_TAIL_LIMIT, type PendingCommand, type RpcFrame, type RpcProcessOptions, type RpcResponseFrame } from '@/server/lib/omp/rpc/process-helpers';
26
+ import { MAX_PROTOCOL_ERROR_NOTICES, RpcCommandError, RpcCommandTimeoutError, STDERR_TAIL_LIMIT, type PendingCommand, type RpcFrame, type RpcProcessOptions, type RpcResponseFrame } from '@/server/lib/omp/rpc/process-helpers';
26
27
 
27
28
  export { RpcCommandError, RpcCommandTimeoutError } from '@/server/lib/omp/rpc/process-helpers';
28
29
  export type { RpcFrame, RpcProcessOptions, RpcResponseFrame } from '@/server/lib/omp/rpc/process-helpers';
@@ -90,6 +91,7 @@ export class RpcProcess {
90
91
  this.readyPromise.catch(() => {});
91
92
 
92
93
  const decoder = new RpcFrameDecoder();
94
+ let protocolErrorNotices = 0;
93
95
  void readLines(this.child.stdout, (line) => {
94
96
  const trimmed = line.trim();
95
97
  if (!trimmed) return;
@@ -102,18 +104,40 @@ export class RpcProcess {
102
104
  }
103
105
  let frame: RpcFrameRecord;
104
106
  try {
105
- if (parsed && typeof parsed === 'object' && (parsed as { type?: unknown }).type === 'rpc_chunk' && this.protocolVersion !== 2) {
107
+ if (isRecord(parsed) && parsed.type === 'rpc_chunk' && this.protocolVersion !== 2) {
106
108
  throw new Error('RPC chunk received before protocol negotiation');
107
109
  }
108
110
  const decoded = decoder.push(parsed);
109
111
  if (!decoded) return;
110
112
  frame = decoded;
111
113
  } catch (error) {
112
- this.stderrTail = (this.stderrTail + `\nRPC protocol error: ${error instanceof Error ? error.message : String(error)}`).slice(-STDERR_TAIL_LIMIT);
113
- void this.dispose(0);
114
+ // A malformed chunk sequence costs ONE logical frame, not the session:
115
+ // killing the child took its LSP servers, browser targets and prewarm
116
+ // slot down for a transport fault. Report the lost event, then resync.
117
+ const detail = error instanceof Error ? error.message : String(error);
118
+ decoder.resync();
119
+ this.stderrTail = (this.stderrTail + `\nRPC protocol error: ${detail}`).slice(-STDERR_TAIL_LIMIT);
120
+ if (protocolErrorNotices < MAX_PROTOCOL_ERROR_NOTICES) {
121
+ protocolErrorNotices++;
122
+ const notice: RpcFrame = {
123
+ type: 'notice',
124
+ level: 'warning',
125
+ message: `OMP sent a malformed RPC frame (${detail}). One event was dropped; the session is still running.`,
126
+ };
127
+ for (const listener of this.frameListeners) {
128
+ try {
129
+ listener(notice);
130
+ } catch {}
131
+ }
132
+ }
114
133
  return;
115
134
  }
116
135
  if (frame.type === 'ready') {
136
+ // The server's own ceilings, which may grow without a protocol bump.
137
+ decoder.setLimits({
138
+ maxFrameBytes: frame.maxFrameBytes,
139
+ maxReassembledFrameBytes: frame.maxReassembledFrameBytes,
140
+ });
117
141
  resolveReady(frame);
118
142
  return;
119
143
  }
@@ -154,6 +154,18 @@ export class RunSettle {
154
154
  this.#quietUntil = 0;
155
155
  }
156
156
 
157
+ /**
158
+ * Start watching a run the frame path did not announce.
159
+ *
160
+ * A refused dispatch (`agent_busy`) proves a turn is in flight even when this
161
+ * wrapper read idle. The wrapper records that verdict in its own flags, and
162
+ * this clock is what retires them again if the run's terminal frame never
163
+ * arrives — the same repair every other lost-frame run gets.
164
+ */
165
+ arm(): void {
166
+ this.#arm();
167
+ }
168
+
157
169
  /**
158
170
  * Probe omp and settle the run when omp itself reports the session quiescent.
159
171
  * Returns true when this call released a run.
@@ -213,6 +213,28 @@ describe('settling a run omp no longer owns', () => {
213
213
  }
214
214
  });
215
215
 
216
+ // A refusal is the only evidence some stranded runs ever leave: omp says a
217
+ // turn is in flight, the wrapper raised its flags from that verdict, and the
218
+ // terminal frame it expects may never arrive (that is what strands a queue —
219
+ // measured: 104 refusals in one session, one per retry). The clock is what
220
+ // retires the flags, exactly as it does for a lost terminal frame.
221
+ test('a run announced only by a refusal is settled on omp\'s quiescence verdict', async () => {
222
+ const { host, emitted } = makeHost(sessionState());
223
+ vi.useFakeTimers();
224
+ try {
225
+ const clock = settle(host, { silenceMs: 10 });
226
+ clock.arm();
227
+ vi.advanceTimersByTime(50);
228
+ await flushMicrotasks();
229
+ expect(host.streaming).toBe(false);
230
+ expect(host.promptRunning).toBe(false);
231
+ expect(emitted).toEqual([{ type: 'agent_end', isTerminal: true, messages: [] }]);
232
+ clock.stop();
233
+ } finally {
234
+ vi.useRealTimers();
235
+ }
236
+ });
237
+
216
238
  test('stop() cancels the clock', async () => {
217
239
  const { host, sent } = makeHost(sessionState());
218
240
  vi.useFakeTimers();
@@ -49,6 +49,11 @@ export interface SessionCommandHost extends WebStateHost {
49
49
  /** Arm the deadline watchdog for a dispatch whose turn never opened. Optional
50
50
  * so a test host can omit it; the real wrapper always implements it. */
51
51
  armAgentStartWatchdog?(): void;
52
+ /** The run-settle clock. A refused dispatch (`agent_busy`) reveals a run this
53
+ * wrapper did not see open, so the clock must be armed for it or a lost
54
+ * terminal frame leaves the session marked busy forever. Optional for the
55
+ * same reason as the watchdog. */
56
+ runSettle?: { arm(): void };
52
57
  /** The background `/rename` dispatch a following prompt must be ordered
53
58
  * behind (see `session/title-request.server.ts`). Absent on a host that
54
59
  * never titles, which is why the barrier treats it as idle. */
@@ -179,7 +179,8 @@ describe('prompt', () => {
179
179
  });
180
180
 
181
181
  test('a busy session refuses a retry, and omp\'s own mid-turn refusal is the typed `agent_busy`', async () => {
182
- const h = makeHarness({ isBusy: () => true });
182
+ let settleArms = 0;
183
+ const h = makeHarness({ isBusy: () => true, runSettle: { arm: () => { settleArms += 1; } } });
183
184
  h.respond(() => {
184
185
  throw new RpcCommandTimeoutError('prompt', 1);
185
186
  });
@@ -191,6 +192,13 @@ describe('prompt', () => {
191
192
  h.respond(() => { throw new RpcCommandError('prompt', 'Agent is already processing.'); });
192
193
  const busy = await rejectionOf(dispatchSessionCommand(h.host, { type: 'prompt', message: 'hi' })) as WebRpcError;
193
194
  expect([busy.code, busy.message]).toEqual(['agent_busy', AGENT_BUSY_MESSAGE]);
195
+ // The refusal is proof of a live turn, and the wrapper must keep it: the
196
+ // queue's delivery gate and the sidebar both read these flags, so clearing
197
+ // them here is what let a session dispatch at a busy child on every retry.
198
+ expect(h.host.streaming).toBe(true);
199
+ // ...and the settle clock must be able to retire that flag if the run's
200
+ // terminal frame never arrives.
201
+ expect(settleArms).toBe(1);
194
202
  });
195
203
 
196
204
  test('a command dispatched during a run\'s ack window does not settle the run', async () => {
@@ -142,6 +142,17 @@ export async function dispatchSessionCommand(host: SessionCommandHost, command:
142
142
  // not know a run was in flight (a second tab, a reload, another
143
143
  // instance) recover instead of losing the prompt.
144
144
  if (error instanceof RpcCommandError && AGENT_BUSY_REFUSAL_RE.test(error.message)) {
145
+ // omp's verdict outranks our flags: a turn IS in flight, whatever
146
+ // this wrapper believed. The queue's delivery gate reads `isBusy()`,
147
+ // so without this a stale-idle wrapper (a `get_state` probe whose
148
+ // answer landed after `agent_start` clears both flags) dispatched at
149
+ // the child every retry and collected `agent_busy` for the rest of
150
+ // the run — measured as 104 failures in one session, each one
151
+ // requeueing the head. `agent_end`, or the settle probe's `isSettled`,
152
+ // is what clears it again.
153
+ host.streaming = true;
154
+ // ...and the run-settle clock retires it if that frame never comes.
155
+ host.runSettle?.arm();
145
156
  throw new WebRpcError(AGENT_BUSY_MESSAGE, 'agent_busy');
146
157
  }
147
158
  throw error;
@@ -39,10 +39,32 @@ import { emitRealtimeSignal } from '@/server/lib/realtime/signals.server';
39
39
  import { publishSidebarStructure } from '@/server/lib/realtime/topics.server';
40
40
 
41
41
  /** The wrapper surface a terminal settle touches. */
42
- export interface TerminalSettleHost extends AutoTitleHost, QueueDeliveryHost {}
42
+ export interface TerminalSettleHost extends AutoTitleHost, QueueDeliveryHost {
43
+ /** Abort verdict captured from `message_end` — see `SessionFrameHost.runAborted`. */
44
+ runAborted: boolean;
45
+ }
43
46
 
44
- /** True when the ending turn was a user abort rather than a natural stop. */
45
- function endedAborted(messages: unknown): boolean {
47
+ /**
48
+ * True when the ending turn was a user abort rather than a natural stop.
49
+ *
50
+ * Two sources, because neither is sufficient alone. `host.runAborted` is read
51
+ * from `message_end`, where the message is still whole; `agent_end.messages` is
52
+ * a fallback for a host that attached mid-run (a reattached client, or a
53
+ * synthetic terminal frame from `run-settle.server.ts`), which never saw one.
54
+ *
55
+ * The frame's own array cannot be the primary source: omp compacts an oversized
56
+ * terminal frame by dropping every message it already delivered through
57
+ * `message_end` (keeping only `messageCount`), and the aborted assistant message
58
+ * is always among them — measured on 18.16.0, `message_end`
59
+ * (`role: "assistant"`, `stopReason: "aborted"`) arrives before `agent_end`.
60
+ * Reading only the frame therefore reports a stopped run as finished, and the
61
+ * settle then titles the session, audits the goal and releases the queue for a
62
+ * turn the operator cancelled. 12.7% of the runs in this workstation's own
63
+ * session store (494 of 3901) exceed the 1 MiB frame ceiling, so the trimmed
64
+ * case is routine, not exotic.
65
+ */
66
+ function endedAborted(host: TerminalSettleHost, messages: unknown): boolean {
67
+ if (host.runAborted) return true;
46
68
  return (
47
69
  Array.isArray(messages) &&
48
70
  messages.some((entry) => {
@@ -60,11 +82,11 @@ function endedAborted(messages: unknown): boolean {
60
82
  * Re-check the current row and only upgrade `stream` rows, so a `finish`
61
83
  * written here can never clobber a newer run's live `stream`/`abort`.
62
84
  */
63
- async function markEndStatus(sessionId: string, messages: unknown): Promise<void> {
85
+ async function markEndStatus(sessionId: string, host: TerminalSettleHost, messages: unknown): Promise<void> {
64
86
  if (!sessionId) return;
65
87
  const current = await loadStreamStatuses();
66
88
  if (current[sessionId] !== 'stream') return;
67
- await markStreamStatus(sessionId, endedAborted(messages) ? 'abort' : 'finish');
89
+ await markStreamStatus(sessionId, endedAborted(host, messages) ? 'abort' : 'finish');
68
90
  }
69
91
 
70
92
  /**
@@ -75,8 +97,8 @@ async function markEndStatus(sessionId: string, messages: unknown): Promise<void
75
97
  * machine, and this function only performs the work the settle triggers.
76
98
  */
77
99
  export function settleTerminalRun(host: TerminalSettleHost, messages: unknown): void {
78
- const aborted = endedAborted(messages);
79
- if (host.sessionId) void markEndStatus(host.sessionId, messages);
100
+ const aborted = endedAborted(host, messages);
101
+ if (host.sessionId) void markEndStatus(host.sessionId, host, messages);
80
102
  if (!aborted) {
81
103
  void triggerAutoSessionTitle(host, 'settle');
82
104
  void driveGoalAfterTurn({ host, messages });
@@ -46,6 +46,7 @@ export async function readBundledCatalog(bundledRoot: string, installed: Readonl
46
46
  // details before the plugin is installed. Both come from the bundled
47
47
  // directory, which the routes resolve through the same registry.
48
48
  ...(manifest.icon ? { iconUrl: await iconUrl(pluginDir, manifest.icon) } : {}),
49
+ ...(manifest.color ? { color: manifest.color } : {}),
49
50
  ...(await readmeUrlFor(pluginDir, manifest)),
50
51
  ...(manifest.author ? { author: manifest.author } : {}),
51
52
  ...(manifest.homepage ? { homepage: manifest.homepage } : {}),
@@ -220,6 +220,26 @@ describe('updateGitPlugin', () => {
220
220
  expect(fs.readFileSync(join(root, 'plugins', 'from-git', 'dist', 'app.js'), 'utf8')).toContain('edited');
221
221
  });
222
222
 
223
+ test.skipIf(!hasGit)('updates a clone whose only untracked files are Kabmo’s own build output', async () => {
224
+ // A repository that does not gitignore `dist/` is ordinary, and Kabmo's build
225
+ // writes `dist/` and `node_modules/` into every clone. Counting those as
226
+ // uncommitted work made such a plugin permanently un-updatable — measured on a
227
+ // fixture repo with no .gitignore, where Update answered "has uncommitted
228
+ // changes" forever. `reset --hard` never touches an untracked file, so they
229
+ // are not what the refusal is protecting.
230
+ const repo = makeRepo();
231
+ await installPanelPluginFromGit(repo);
232
+ advance(repo, '2.0.0');
233
+ fs.mkdirSync(join(root, 'plugins', 'from-git', 'node_modules', 'dep'), { recursive: true });
234
+ fs.writeFileSync(join(root, 'plugins', 'from-git', 'node_modules', 'dep', 'index.js'), 'export default 1;');
235
+
236
+ const result = await updateGitPlugin('from-git');
237
+ expect(result.ok).toBe(true);
238
+ expect(result.updated).toBe(true);
239
+ // The untracked file was left alone rather than swept away by the reset.
240
+ expect(fs.existsSync(join(root, 'plugins', 'from-git', 'node_modules', 'dep', 'index.js'))).toBe(true);
241
+ });
242
+
223
243
  test('refuses a plugin that is not a git clone', async () => {
224
244
  const dir = join(root, 'plugins', 'plain');
225
245
  fs.mkdirSync(dir, { recursive: true });
@@ -108,11 +108,27 @@ async function readRemoteVersion(dir: string): Promise<string | undefined> {
108
108
  return undefined;
109
109
  }
110
110
 
111
- /** Whether the clone has uncommitted work that an update would discard. */
111
+ /**
112
+ * Whether the clone has uncommitted work that an update would discard.
113
+ *
114
+ * `--untracked-files=no` is load-bearing, and it is not a shortcut: the update
115
+ * moves the tree with `git reset --hard`, which never touches an untracked file.
116
+ * Counting them refused every clone whose repository does not gitignore the
117
+ * build output — and Kabmo's OWN build writes `dist/` and `node_modules/` into
118
+ * the clone, so a perfectly ordinary plugin repo became permanently
119
+ * un-updatable the moment it was installed. Measured on a clone of a fixture
120
+ * repository with no `.gitignore`: `?? dist/` and `?? node_modules/` made Update
121
+ * answer "has uncommitted changes", and commiting nothing there is possible
122
+ * because the files are the install's, not the user's.
123
+ *
124
+ * A status that cannot be read is still treated as dirty: refusing an update is
125
+ * recoverable, discarding a user's edit is not.
126
+ */
112
127
  async function isDirty(dir: string): Promise<boolean> {
113
- const result = await gitRun(['status', '--porcelain'], { cwd: dir, timeoutMs: PROBE_TIMEOUT_MS });
114
- // A status that cannot be read is treated as dirty: refusing an update is
115
- // recoverable, discarding a user's edit is not.
128
+ const result = await gitRun(['status', '--porcelain', '--untracked-files=no'], {
129
+ cwd: dir,
130
+ timeoutMs: PROBE_TIMEOUT_MS,
131
+ });
116
132
  return result.exitCode !== 0 || result.stdout.trim().length > 0;
117
133
  }
118
134
 
@@ -188,6 +188,26 @@ describe('toManifest', () => {
188
188
  });
189
189
  });
190
190
 
191
+ describe('the manifest colour', () => {
192
+ test('a #RRGGBB is kept, lowercased', () => {
193
+ expect(toManifest({ ...MANIFEST, color: '#34D399' }, ROOT)).toMatchObject({ color: '#34d399' });
194
+ });
195
+
196
+ test('every other form is refused, because the value reaches an inline style', () => {
197
+ // `color` becomes a custom property on the rail's mark, so anything that is
198
+ // not a hex is a refusal rather than a value the host has to escape.
199
+ for (const color of ['red', 'rgb(0 0 0)', '#abc', '#12345', 'url(x)', 'red; background: url(x)', 'var(--x)', '']) {
200
+ const result = toManifest({ ...MANIFEST, color }, ROOT);
201
+ if (color === '') {
202
+ // An empty string is "not declared", not a refusal.
203
+ expect(result).not.toMatchObject({ error: expect.any(String) });
204
+ continue;
205
+ }
206
+ expect(result, color).toMatchObject({ error: expect.stringContaining('is not a #RRGGBB hex') });
207
+ }
208
+ });
209
+ });
210
+
191
211
  describe('toMarketplaceCatalog', () => {
192
212
 
193
213
  test('accepts a catalog with no plugins array as empty', () => {
@@ -34,6 +34,9 @@ import { isRemoteGitUrl } from '@/shared/lib/git/url';
34
34
  import { resolveInsideRoot } from '@/shared/lib/panels/resolve-asset';
35
35
 
36
36
  /** An id segment: what a plugin id may look like. */
37
+ /** The only colour form a manifest may declare: `#RRGGBB`. */
38
+ const HEX_COLOR = /^#[0-9a-f]{6}$/i;
39
+
37
40
  const ID_RE = /^[a-z0-9][a-z0-9._-]{0,63}$/i;
38
41
 
39
42
  function trimmed(value: unknown): string | undefined {
@@ -87,6 +90,14 @@ export function toManifest(raw: unknown, root: string): PanelPluginManifest | {
87
90
  return { error: `manifest readme "${readme}" escapes the plugin directory` };
88
91
  }
89
92
 
93
+ // A mark colour reaches an inline custom property, so it is a HEX and nothing
94
+ // else: `color: url(...)`, `red; background: …` or a `var()` that resolves
95
+ // elsewhere are all refusals rather than values the host has to escape.
96
+ const color = trimmed(raw.color);
97
+ if (color && !HEX_COLOR.test(color)) {
98
+ return { error: `manifest color ${JSON.stringify(raw.color)} is not a #RRGGBB hex` };
99
+ }
100
+
90
101
  const branding = isRecord(raw.branding) ? trimmed(raw.branding.icon) : undefined;
91
102
  const engines = toEngines(raw.engines);
92
103
  if ('error' in engines) return engines;
@@ -111,6 +122,7 @@ export function toManifest(raw: unknown, root: string): PanelPluginManifest | {
111
122
  ...(trimmed(raw.homepage) ? { homepage: trimmed(raw.homepage) } : {}),
112
123
  ...(icon ? { icon } : {}),
113
124
  ...(readme ? { readme } : {}),
125
+ ...(color ? { color: color.toLowerCase() } : {}),
114
126
  ...(branding ? { branding: { icon: branding } } : {}),
115
127
  ...(author ? { author } : {}),
116
128
  ...(slots ? { slots } : {}),
@@ -127,6 +127,7 @@ export async function scanInstalledPlugins(options: {
127
127
  ...(manifest.author ? { author: manifest.author } : {}),
128
128
  ...(manifest.homepage ? { homepage: manifest.homepage } : {}),
129
129
  ...(manifest.slots ? { slots: manifest.slots } : {}),
130
+ ...(manifest.color ? { color: manifest.color } : {}),
130
131
  ...(manifest.capabilities ? { capabilities: manifest.capabilities } : {}),
131
132
  ...(missingEntry ? { reason: `the build produced no ${missingEntry}` } : {}),
132
133
  });
@@ -154,6 +155,9 @@ export async function scanInstalledPlugins(options: {
154
155
  ? { cssUrl: await cssUrl(pluginDir, manifest.css) }
155
156
  : {}),
156
157
  ...(manifest.icon ? { iconUrl: await iconUrl(pluginDir, manifest.icon) } : {}),
158
+ // The plugin's own mark colour, so the activity bar can paint its brand
159
+ // instead of a hue hashed from its name.
160
+ ...(manifest.color ? { color: manifest.color } : {}),
157
161
  ...(await readmeUrlFor(pluginDir, manifest)),
158
162
  });
159
163
  }
@@ -171,7 +171,14 @@ async function applyStoreCopy(
171
171
  * say why, and it is cleared on the next pass that finds the tree unchanged, so a
172
172
  * user who reverts their edit gets the update without doing anything else.
173
173
  */
174
- export async function syncBundledPlugins(): Promise<{
174
+ export async function syncBundledPlugins(options: {
175
+ /**
176
+ * Only this plugin id. The pane's own Update action is what needs it: the
177
+ * whole-store pass is the BOOT question ("is anything behind?"), while a
178
+ * user naming one plugin must not touch the others.
179
+ */
180
+ only?: string;
181
+ } = {}): Promise<{
175
182
  updated: BundledSyncOutcome[];
176
183
  blocked: BundledSyncBlocked[];
177
184
  failed: Array<{ pluginId: string; error: string }>;
@@ -184,6 +191,7 @@ export async function syncBundledPlugins(): Promise<{
184
191
  const installedRoot = getMarketplacePluginsDir();
185
192
 
186
193
  for (const pluginId of await subdirectories(storeRoot)) {
194
+ if (options.only && pluginId !== options.only) continue;
187
195
  const destination = join(installedRoot, pluginId);
188
196
  if (!(await pathExists(destination))) continue;
189
197
  // A git-installed plugin is the user's own clone; the store's copy is not