@kabmo-labs/kabmo 0.30.1 → 0.31.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 (107) hide show
  1. package/README.md +79 -21
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +481 -462
  4. package/dist/client/static/js/{index-bwhhehnh.js → index-r3bhgvkt.js} +772 -773
  5. package/marketplace/plugins/stats/package.json +2 -2
  6. package/marketplace/plugins/stats/src/format.test.ts +7 -1
  7. package/package.json +2 -2
  8. package/src/client/components/common/context-usage-button/McpSection.tsx +133 -0
  9. package/src/client/components/common/context-usage-button/Ring.tsx +12 -6
  10. package/src/client/components/common/context-usage-button/index.test.tsx +24 -13
  11. package/src/client/components/common/context-usage-button/index.tsx +32 -34
  12. package/src/client/components/common/session-row/TrailingSlot.tsx +6 -2
  13. package/src/client/components/common/session-row/session-row.test.tsx +13 -0
  14. package/src/client/components/layout/desktop-layout/index.tsx +5 -1
  15. package/src/client/components/mobile/RightSidebar.tsx +2 -1
  16. package/src/client/components/settings/categories/McpSettings.tsx +10 -3
  17. package/src/client/components/settings/categories/mcp-settings/AdvancedSection.tsx +244 -0
  18. package/src/client/components/settings/categories/mcp-settings/ConnectionTest.tsx +3 -3
  19. package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +55 -97
  20. package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +12 -64
  21. package/src/client/components/settings/categories/mcp-settings/{EnvVarsSection.tsx → KeyValueSection.tsx} +42 -24
  22. package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +1 -1
  23. package/src/client/components/settings/categories/mcp-settings/TransportSection.tsx +101 -0
  24. package/src/client/components/workspace/browser-panel/EngineNotice.test.tsx +109 -0
  25. package/src/client/components/workspace/browser-panel/EngineNotice.tsx +112 -0
  26. package/src/client/components/workspace/browser-panel/index.tsx +45 -12
  27. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.test.ts +63 -0
  28. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +18 -6
  29. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +3 -1
  30. package/src/client/components/workspace/chat-timeline/chat-input/access-levels.ts +39 -1
  31. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Eval.test.tsx +13 -7
  32. package/src/client/components/workspace/editor/plugin-rail.test.tsx +6 -1
  33. package/src/client/components/workspace/terminal-panel/scroll-hold.test.ts +20 -5
  34. package/src/client/data/settings/mcp.ts +4 -2
  35. package/src/client/data/settings/omp-schema.json +22 -2
  36. package/src/client/hooks/browser/use-browser-engine.ts +99 -0
  37. package/src/client/hooks/chat/context/mcp.ts +159 -0
  38. package/src/client/hooks/chat/timeline/access-mode.ts +45 -15
  39. package/src/client/hooks/chat/timeline/index.ts +7 -3
  40. package/src/client/hooks/chat/timeline/timeline-mode-state.test.ts +33 -4
  41. package/src/client/hooks/ui/ui-listeners.test.ts +13 -18
  42. package/src/server/lib/browser/engine.test.ts +118 -0
  43. package/src/server/lib/browser/engine.ts +102 -0
  44. package/src/server/lib/db/schema.ts +4 -0
  45. package/src/server/lib/fs/toolchain-path.test.ts +87 -0
  46. package/src/server/lib/fs/toolchain-path.ts +49 -0
  47. package/src/server/lib/harness/acp/protocol.ts +9 -1
  48. package/src/server/lib/harness/auto-probe.server.ts +3 -2
  49. package/src/server/lib/harness/launch-table.ts +3 -2
  50. package/src/server/lib/harness/spawn.server.ts +5 -1
  51. package/src/server/lib/harness/update-queue.server.ts +2 -1
  52. package/src/server/lib/harness/update-state.server.ts +6 -2
  53. package/src/server/lib/mcp/probe.server.ts +71 -0
  54. package/src/server/lib/mcp/registry.server.ts +195 -46
  55. package/src/server/lib/mcp/registry.test.ts +76 -4
  56. package/src/server/lib/mcp/schema.server.ts +35 -0
  57. package/src/server/lib/mcp/session-mcp.test.ts +164 -0
  58. package/src/server/lib/mcp/session-overlay.server.ts +152 -0
  59. package/src/server/lib/mcp/session-state.server.ts +75 -0
  60. package/src/server/lib/mcp/store.server.ts +6 -1
  61. package/src/server/lib/omp/config/config-cli.ts +4 -0
  62. package/src/server/lib/omp/config/mcp-and-cli.test.ts +12 -183
  63. package/src/server/lib/omp/config/mcp-config.test.ts +277 -0
  64. package/src/server/lib/omp/config/mcp-shared.ts +36 -0
  65. package/src/server/lib/omp/config/mcp-test-protocol.ts +89 -0
  66. package/src/server/lib/omp/config/mcp-test-remote.ts +167 -0
  67. package/src/server/lib/omp/config/mcp-test.ts +21 -123
  68. package/src/server/lib/omp/config/mcp-write.ts +179 -0
  69. package/src/server/lib/omp/config/mcp.ts +138 -118
  70. package/src/server/lib/omp/core/cli.ts +4 -14
  71. package/src/server/lib/omp/rpc/manager.ts +12 -17
  72. package/src/server/lib/omp/rpc/reload-mcp.ts +39 -0
  73. package/src/server/lib/omp/rpc/session-registry.ts +6 -2
  74. package/src/server/lib/omp/rpc/spawn-mcp.ts +43 -0
  75. package/src/server/lib/omp/session/delete.server.ts +7 -0
  76. package/src/server/lib/plugins/mcp.server.ts +2 -2
  77. package/src/server/lib/realtime/topics/workspace.server.test.ts +44 -0
  78. package/src/server/lib/realtime/topics/workspace.server.ts +3 -2
  79. package/src/server/routes/browser/engine.test.ts +70 -0
  80. package/src/server/routes/browser/engine.ts +51 -0
  81. package/src/server/routes/browser/index.ts +5 -0
  82. package/src/server/routes/fs/git.ts +4 -3
  83. package/src/server/routes/harness/versions.test.ts +5 -0
  84. package/src/server/routes/sessions/index.ts +7 -0
  85. package/src/server/routes/sessions/mcp.test.ts +154 -0
  86. package/src/server/routes/sessions/mcp.ts +202 -0
  87. package/src/server/routes/settings/mcp-test.ts +5 -4
  88. package/src/server/routes/settings/mcp.test.ts +42 -1
  89. package/src/server/routes/settings/mcp.ts +80 -24
  90. package/src/shared/lib/code/highlight-memo.test.ts +18 -0
  91. package/src/shared/lib/code/highlight-memo.ts +46 -17
  92. package/src/shared/lib/mcp/import.ts +112 -0
  93. package/src/shared/lib/mcp/item.ts +61 -0
  94. package/src/shared/lib/mcp/key-value.ts +37 -0
  95. package/src/shared/lib/mcp/mcp-lib.test.ts +119 -0
  96. package/src/shared/lib/mcp/status.test.ts +36 -0
  97. package/src/shared/lib/mcp/status.ts +38 -0
  98. package/src/shared/lib/models/client.ts +27 -6
  99. package/src/shared/lib/models/provider/models.test.ts +31 -0
  100. package/src/shared/lib/omp/config/access-mode.test.ts +73 -0
  101. package/src/shared/lib/omp/config/access-mode.ts +49 -0
  102. package/src/shared/lib/workspace/right-panels.ts +13 -0
  103. package/src/shared/lib/workspace/workspace-modules.test.ts +3 -1
  104. package/src/shared/types/browser.ts +21 -0
  105. package/src/shared/types/settings/mcp.ts +73 -4
  106. package/src/test-support/pristine-globals.test.ts +53 -0
  107. package/src/test-support/pristine-globals.ts +6 -1
@@ -4,32 +4,50 @@
4
4
  */
5
5
 
6
6
  /**
7
- * The environment variables an MCP server is launched with.
7
+ * One editable key/value list — environment variables for a stdio server,
8
+ * request headers for an HTTP/SSE one.
8
9
  *
9
10
  * Keys are shown as typed and never masked here: this is the file the user is
10
11
  * writing, and hiding a value in the form while showing it in `mcp.json` on the
11
12
  * next screen is the worse of the two. A blank key is kept (it is a half-typed
12
13
  * row, not a decision) and the server-side writer is what refuses an empty
13
- * name, so a save cannot invent an `""` variable.
14
+ * name, so a save cannot invent an `""` entry.
14
15
  */
15
16
 
16
17
  import { Plus, Trash2 } from 'lucide-preact';
17
- import type { McpEnvVar } from '@/shared/types';
18
+ import type { McpKeyValue } from '@/shared/types';
18
19
 
19
- interface EnvVarsSectionProps {
20
- envVars: McpEnvVar[];
20
+ interface McpKeyValueSectionProps {
21
+ title: string;
22
+ description: string;
23
+ addLabel: string;
24
+ emptyLabel: string;
25
+ keyPlaceholder: string;
26
+ valuePlaceholder: string;
27
+ rows: McpKeyValue[];
21
28
  onAdd: () => void;
22
29
  onUpdate: (id: string, key: string, value: string) => void;
23
30
  onRemove: (id: string) => void;
24
31
  }
25
32
 
26
- export function McpEnvVarsSection({ envVars, onAdd, onUpdate, onRemove }: EnvVarsSectionProps) {
33
+ export function McpKeyValueSection({
34
+ title,
35
+ description,
36
+ addLabel,
37
+ emptyLabel,
38
+ keyPlaceholder,
39
+ valuePlaceholder,
40
+ rows,
41
+ onAdd,
42
+ onUpdate,
43
+ onRemove,
44
+ }: McpKeyValueSectionProps) {
27
45
  return (
28
46
  <div className="space-y-3">
29
47
  <div className="flex items-center justify-between gap-3">
30
48
  <div>
31
- <h3 className="text-xs font-bold uppercase tracking-wider text-ink">Environment Variables</h3>
32
- <p className="text-[11px] text-ink/60 mt-0.5">Values the server needs, such as an API key.</p>
49
+ <h3 className="text-xs font-bold uppercase tracking-wider text-ink">{title}</h3>
50
+ <p className="text-[11px] text-ink/60 mt-0.5">{description}</p>
33
51
  </div>
34
52
  <button
35
53
  type="button"
@@ -37,39 +55,39 @@ export function McpEnvVarsSection({ envVars, onAdd, onUpdate, onRemove }: EnvVar
37
55
  className="flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-lg border border-ink/20 hover:border-ink/40 hover:bg-ink/5 text-ink transition-colors cursor-pointer"
38
56
  >
39
57
  <Plus className="w-3.5 h-3.5" />
40
- <span>Add variable</span>
58
+ <span>{addLabel}</span>
41
59
  </button>
42
60
  </div>
43
61
 
44
- {envVars.length === 0 ? (
62
+ {rows.length === 0 ? (
45
63
  <div className="p-4 rounded-lg border border-dashed border-ink/20 text-center text-xs text-ink/50">
46
- No environment variables configured.
64
+ {emptyLabel}
47
65
  </div>
48
66
  ) : (
49
67
  <div className="space-y-2">
50
- {envVars.map((env) => (
51
- <div key={env.id} className="flex items-center gap-2">
68
+ {rows.map((row) => (
69
+ <div key={row.id} className="flex items-center gap-2">
52
70
  <input
53
71
  type="text"
54
- value={env.key}
55
- onChange={(e) => onUpdate(env.id, e.currentTarget.value, env.value)}
56
- placeholder="KEY"
57
- aria-label="Variable name"
72
+ value={row.key}
73
+ onChange={(e) => onUpdate(row.id, e.currentTarget.value, row.value)}
74
+ placeholder={keyPlaceholder}
75
+ aria-label={`${title} name`}
58
76
  className="w-1/3 text-xs font-mono px-3 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors"
59
77
  />
60
78
  <input
61
79
  type="text"
62
- value={env.value}
63
- onChange={(e) => onUpdate(env.id, env.key, e.currentTarget.value)}
64
- placeholder="VALUE"
65
- aria-label={`Value for ${env.key || 'the variable'}`}
80
+ value={row.value}
81
+ onChange={(e) => onUpdate(row.id, row.key, e.currentTarget.value)}
82
+ placeholder={valuePlaceholder}
83
+ aria-label={`Value for ${row.key || 'the entry'}`}
66
84
  className="flex-1 text-xs font-mono px-3 py-1.5 rounded-lg border border-ink/20 hover:border-ink/40 bg-paper focus:outline-none focus:border-ink text-ink transition-colors"
67
85
  />
68
86
  <button
69
87
  type="button"
70
- onClick={() => onRemove(env.id)}
71
- aria-label={`Remove ${env.key || 'the variable'}`}
72
- title="Remove variable"
88
+ onClick={() => onRemove(row.id)}
89
+ aria-label={`Remove ${row.key || 'the entry'}`}
90
+ title="Remove"
73
91
  className="p-1.5 text-ink/40 hover:text-error transition-colors rounded-md cursor-pointer"
74
92
  >
75
93
  <Trash2 className="w-4 h-4" />
@@ -88,7 +88,7 @@ export const McpSidebarList: FunctionComponent<McpSidebarListProps> = ({
88
88
  <div className="space-y-0.5">
89
89
  {servers.map((server) => {
90
90
  const isSelected = server.id === selectedServerId;
91
- const isCommand = server.reachType === 'command';
91
+ const isCommand = server.transport === 'stdio';
92
92
  const summary = isCommand
93
93
  ? server.commandArgs.join(' ')
94
94
  : server.linkUrl || 'No URL configured';
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * How the server is reached: a local command (stdio), a streamable HTTP
8
+ * endpoint, or a legacy SSE endpoint.
9
+ *
10
+ * The three are separate transports in omp's schema, not a cosmetic label:
11
+ * `type` is written into `mcp.json`, and an SSE endpoint sent as `http` fails
12
+ * to connect. The selector therefore writes the transport, and the input below
13
+ * it follows.
14
+ */
15
+
16
+ import { Globe, Radio, Terminal } from 'lucide-preact';
17
+ import type { McpTransport } from '@/shared/types';
18
+
19
+ const OPTIONS: Array<{ value: McpTransport; label: string; icon: typeof Terminal }> = [
20
+ { value: 'stdio', label: 'Command', icon: Terminal },
21
+ { value: 'http', label: 'HTTP', icon: Globe },
22
+ { value: 'sse', label: 'SSE', icon: Radio },
23
+ ];
24
+
25
+ interface McpTransportSectionProps {
26
+ transport: McpTransport;
27
+ onTransportChange: (transport: McpTransport) => void;
28
+ commandText: string;
29
+ onCommandTextChange: (text: string) => void;
30
+ linkUrl: string;
31
+ onLinkUrlChange: (url: string) => void;
32
+ }
33
+
34
+ export function McpTransportSection({
35
+ transport,
36
+ onTransportChange,
37
+ commandText,
38
+ onCommandTextChange,
39
+ linkUrl,
40
+ onLinkUrlChange,
41
+ }: McpTransportSectionProps) {
42
+ return (
43
+ <div className="space-y-3">
44
+ <div>
45
+ <h3 className="text-xs font-bold uppercase tracking-wider text-ink">How to reach it</h3>
46
+ <p className="text-[11px] text-ink/60 mt-0.5">
47
+ Paste the command that starts it, or the link to a hosted server.
48
+ </p>
49
+ </div>
50
+
51
+ <div className="inline-flex rounded-lg border border-ink/20 p-0.5 bg-ink/5">
52
+ {OPTIONS.map(({ value, label, icon: Icon }) => (
53
+ <button
54
+ key={value}
55
+ type="button"
56
+ onClick={() => onTransportChange(value)}
57
+ aria-pressed={transport === value}
58
+ className={`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors cursor-pointer ${
59
+ transport === value
60
+ ? 'bg-paper text-ink shadow-2xs font-semibold'
61
+ : 'text-ink/60 hover:text-ink'
62
+ }`}
63
+ >
64
+ <Icon className="w-3.5 h-3.5" />
65
+ {label}
66
+ </button>
67
+ ))}
68
+ </div>
69
+
70
+ {transport === 'stdio' ? (
71
+ <div>
72
+ <textarea
73
+ value={commandText}
74
+ onChange={(e) => onCommandTextChange(e.currentTarget.value)}
75
+ rows={4}
76
+ placeholder={`bunx\n@modelcontextprotocol/server-postgres\npostgresql://user:pass@host/db`}
77
+ className="w-full text-xs font-mono p-3 rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/5 focus:outline-none focus:border-ink resize-none leading-relaxed text-ink transition-colors"
78
+ />
79
+ <p className="text-[11px] text-ink/50 mt-1">
80
+ Runs on this machine. Paste a whole command and it is split into one argument per line.
81
+ </p>
82
+ </div>
83
+ ) : (
84
+ <div>
85
+ <input
86
+ type="url"
87
+ value={linkUrl}
88
+ onChange={(e) => onLinkUrlChange(e.currentTarget.value)}
89
+ placeholder={transport === 'sse' ? 'https://example.com/sse' : 'https://needmcp.com/mcp'}
90
+ className="w-full text-xs font-mono px-3 py-2 rounded-lg border border-ink/20 hover:border-ink/40 bg-ink/5 focus:outline-none focus:border-ink text-ink transition-colors"
91
+ />
92
+ <p className="text-[11px] text-ink/50 mt-1">
93
+ {transport === 'sse'
94
+ ? 'Legacy SSE endpoint. Prefer HTTP unless the server only speaks SSE.'
95
+ : 'Streamable HTTP endpoint. Add headers below when it needs a token.'}
96
+ </p>
97
+ </div>
98
+ )}
99
+ </div>
100
+ );
101
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The engine notice is the panel's only honest answer to a WebKit session.
8
+ *
9
+ * It has to name the engine, state the cost of switching, and offer the one
10
+ * write that fixes it — a notice without the button leaves the user with a
11
+ * dead panel and a config key to find by hand. These cases pin the copy, the
12
+ * button's disabled state while the write is in flight, and the server's
13
+ * refusal reaching the screen.
14
+ */
15
+
16
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
17
+ import { Window } from 'happy-dom';
18
+ import { render } from 'preact';
19
+ import { act } from 'preact/test-utils';
20
+ import { BrowserEngineNotice } from '@/client/components/workspace/browser-panel/EngineNotice';
21
+
22
+ const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event'] as const;
23
+ const native: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
24
+ let container: HTMLElement | undefined;
25
+
26
+ beforeAll(() => {
27
+ const win = new Window({ url: 'http://localhost' });
28
+ const target = globalThis as unknown as Record<string, unknown>;
29
+ for (const key of DOM_GLOBALS) {
30
+ if (!(key in native)) native[key] = target[key];
31
+ target[key] = (win as unknown as Record<string, unknown>)[key];
32
+ }
33
+ });
34
+
35
+ afterAll(() => {
36
+ const target = globalThis as unknown as Record<string, unknown>;
37
+ for (const key of DOM_GLOBALS) {
38
+ if (native[key] === undefined) delete target[key];
39
+ else target[key] = native[key];
40
+ }
41
+ });
42
+
43
+ afterEach(() => {
44
+ if (container) render(null, container);
45
+ container?.remove();
46
+ container = undefined;
47
+ });
48
+
49
+ function mount(props: Partial<Parameters<typeof BrowserEngineNotice>[0]> = {}): HTMLElement {
50
+ container = document.createElement('div');
51
+ document.body.appendChild(container);
52
+ act(() => {
53
+ render(
54
+ <BrowserEngineNotice
55
+ saving={false}
56
+ error={null}
57
+ onUseChromium={() => {}}
58
+ variant="body"
59
+ {...props}
60
+ />,
61
+ container!,
62
+ );
63
+ });
64
+ return container;
65
+ }
66
+
67
+ describe('BrowserEngineNotice', () => {
68
+ test('names the engine and the reason the panel is empty', () => {
69
+ const text = mount().textContent ?? '';
70
+ expect(text).toContain('WebKit');
71
+ expect(text).toContain('tidak bisa memantulkannya');
72
+ expect(text).toContain('CDP');
73
+ });
74
+
75
+ test('states the cost of switching, not just the button', () => {
76
+ const text = mount().textContent ?? '';
77
+ expect(text).toContain('RAM');
78
+ expect(text).toContain('Disk');
79
+ expect(text).toContain('Deteksi');
80
+ });
81
+
82
+ test('the button performs the switch', () => {
83
+ let calls = 0;
84
+ const root = mount({ onUseChromium: () => { calls += 1; } });
85
+ const button = root.querySelector('button');
86
+ expect(button?.textContent).toContain('Pakai Chromium');
87
+ act(() => button?.click());
88
+ expect(calls).toBe(1);
89
+ });
90
+
91
+ test('a write in flight disables the button and says so', () => {
92
+ const root = mount({ saving: true });
93
+ const button = root.querySelector('button');
94
+ expect(button?.disabled).toBe(true);
95
+ expect(button?.textContent).toContain('Mengaktifkan');
96
+ });
97
+
98
+ test('the server refusal reaches the screen', () => {
99
+ const text = mount({ error: 'config writes are unavailable in mock mode' }).textContent ?? '';
100
+ expect(text).toContain('config writes are unavailable in mock mode');
101
+ });
102
+
103
+ test('the strip variant is one line plus the button', () => {
104
+ const root = mount({ variant: 'strip' });
105
+ expect(root.textContent).toContain('Agen memakai WebKit');
106
+ expect(root.querySelector('button')?.textContent).toContain('Pakai Chromium');
107
+ expect(root.textContent).not.toContain('Biaya pindah');
108
+ });
109
+ });
@@ -0,0 +1,112 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Why the Browser Agent panel is empty, when the reason is the ENGINE.
8
+ *
9
+ * The panel mirrors the project-shared Chromium over CDP. omp opens tabs in its
10
+ * own WebKit engine (ABKit) by default when that engine is installed, and
11
+ * WebKit has no CDP endpoint and no frame stream — so a WebKit session can
12
+ * never appear here, no matter how long the panel waits. Without this notice
13
+ * the panel said "No browser is open" while the agent was browsing, which is
14
+ * the one explanation that is actively wrong.
15
+ *
16
+ * The button is the fix, and the cost is stated beside it: switching to
17
+ * Chromium buys the mirror and gives up the engine's anti-detection and its
18
+ * smaller footprint. The figures are the ones measured on this machine with a
19
+ * single tab open (WebKit ~93 MB across 2 processes, Chromium ~259 MB across 7;
20
+ * ABKit 419 MB on disk, Chrome for Testing 346 MB).
21
+ */
22
+
23
+ import { AlertTriangle, Loader2 } from 'lucide-preact';
24
+
25
+ interface BrowserEngineNoticeProps {
26
+ saving: boolean;
27
+ error: string | null;
28
+ onUseChromium: () => void;
29
+ /** `body` fills the panel; `strip` is the one-line banner above a live view. */
30
+ variant: 'body' | 'strip';
31
+ }
32
+
33
+ const COSTS: ReadonlyArray<readonly [string, string]> = [
34
+ ['RAM', '~93 MB → ~259 MB untuk satu tab'],
35
+ ['Disk', '~346 MB untuk Chrome for Testing bila belum terpasang'],
36
+ ['Idle', 'Tab Chromium terus melukis; omp membekukannya saat turn selesai'],
37
+ ['Deteksi', 'Halaman bisa melihat otomasi (navigator.webdriver, CDP)'],
38
+ ];
39
+
40
+ function SwitchButton({ saving, onUseChromium }: { saving: boolean; onUseChromium: () => void }) {
41
+ return (
42
+ <button
43
+ type="button"
44
+ onClick={onUseChromium}
45
+ disabled={saving}
46
+ className="inline-flex items-center gap-1.5 rounded-md border border-ink/15 bg-ink/5 px-2.5 py-1 text-[11px] font-medium text-ink transition-colors hover:bg-ink/10 disabled:cursor-not-allowed disabled:opacity-60"
47
+ >
48
+ {saving && <Loader2 size={11} className="animate-spin" />}
49
+ {saving ? 'Mengaktifkan…' : 'Pakai Chromium'}
50
+ </button>
51
+ );
52
+ }
53
+
54
+ export function BrowserEngineNotice({
55
+ saving,
56
+ error,
57
+ onUseChromium,
58
+ variant,
59
+ }: BrowserEngineNoticeProps) {
60
+ if (variant === 'strip') {
61
+ return (
62
+ <div className="flex items-center justify-between gap-2 border-b border-ink/10 bg-ink/[0.03] px-2.5 py-1.5 flex-shrink-0">
63
+ <span className="min-w-0 truncate text-[11px] text-ink/70">
64
+ Agen memakai WebKit — tab baru tidak akan muncul di panel ini.
65
+ </span>
66
+ <SwitchButton saving={saving} onUseChromium={onUseChromium} />
67
+ </div>
68
+ );
69
+ }
70
+
71
+ return (
72
+ <div className="flex-1 flex flex-col items-center justify-center overflow-y-auto p-6 text-center select-none my-auto">
73
+ <div className="w-12 h-12 rounded-xl bg-ink/5 border border-ink/10 flex items-center justify-center text-ink/40 mb-3">
74
+ <AlertTriangle size={24} />
75
+ </div>
76
+ <h3 className="text-sm font-semibold text-ink mb-1">
77
+ Agen memakai WebKit — panel ini tidak bisa memantulkannya
78
+ </h3>
79
+ <p className="text-xs text-ink/60 max-w-sm">
80
+ WebKit milik omp tidak punya CDP dan tidak mengekspos aliran frame, jadi tab yang
81
+ dijalankannya tidak bisa ditampilkan di sini. Panel ini hanya bisa memantulkan Chromium.
82
+ </p>
83
+
84
+ <div className="mt-4 w-full max-w-sm rounded-lg border border-ink/10 bg-paper text-left">
85
+ <div className="border-b border-ink/10 px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/50">
86
+ Biaya pindah ke Chromium
87
+ </div>
88
+ <dl className="divide-y divide-ink/5">
89
+ {COSTS.map(([label, value]) => (
90
+ <div key={label} className="flex gap-2 px-3 py-1.5">
91
+ <dt className="w-14 flex-shrink-0 text-[11px] font-medium text-ink/70">{label}</dt>
92
+ <dd className="text-[11px] text-ink/60">{value}</dd>
93
+ </div>
94
+ ))}
95
+ </dl>
96
+ </div>
97
+
98
+ <div className="mt-3 flex flex-col items-center gap-1.5">
99
+ <SwitchButton saving={saving} onUseChromium={onUseChromium} />
100
+ <p className="text-[10.5px] text-ink/45 max-w-sm">
101
+ Berlaku untuk tab yang dibuka berikutnya; sesi tidak perlu di-restart. Tab WebKit yang
102
+ sudah terbuka tetap tidak terlihat.
103
+ </p>
104
+ {error && (
105
+ <p role="alert" className="text-[11px] text-error max-w-sm">
106
+ {error}
107
+ </p>
108
+ )}
109
+ </div>
110
+ </div>
111
+ );
112
+ }
@@ -1,6 +1,8 @@
1
1
  import { useCallback, useState } from 'preact/hooks';
2
2
  import { BrowserAddressBar } from '@/client/components/workspace/browser-panel/AddressBar';
3
+ import { BrowserEngineNotice } from '@/client/components/workspace/browser-panel/EngineNotice';
3
4
  import { BrowserScreencast } from '@/client/components/workspace/browser-panel/Screencast';
5
+ import { useBrowserEngine } from '@/client/hooks/browser/use-browser-engine';
4
6
  import { useScreencast } from '@/client/hooks/browser/use-screencast';
5
7
  import { useCloseBrowserTab } from '@/client/hooks/browser/use-close-tab';
6
8
  import { useSessionState } from '@/client/hooks/workspace/session-state';
@@ -34,8 +36,21 @@ export function BrowserPanel({ className = '', active = true }: BrowserPanelProp
34
36
  const [zoomLevel, setZoomLevel] = useSessionState<number>('browser.zoomLevel', 100);
35
37
  const { status, url, title, tabs, targetId, frame, actions, sessionId, selectTarget, reconnect } = useScreencast(active);
36
38
  const { closeTab, closing } = useCloseBrowserTab(sessionId);
39
+ const engine = useBrowserEngine();
37
40
  const [closeError, setCloseError] = useState<string | null>(null);
38
41
 
42
+ // A WebKit session can never produce a frame here (no CDP, no screencast), so
43
+ // the panel explains the engine instead of waiting. `mock` is excluded: the
44
+ // stream is offline there for a different reason.
45
+ const webkitActive = engine.state?.effective === 'webkit' && !engine.state.mock;
46
+ const engineExplainsEmptyView = webkitActive && (status === 'browser-offline' || status === 'no-tab');
47
+
48
+ const handleUseChromium = useCallback(() => {
49
+ void engine.useChromium().then((ok) => {
50
+ if (ok) reconnect();
51
+ });
52
+ }, [engine.useChromium, reconnect]);
53
+
39
54
  const handleOpenExternal = () => {
40
55
  if (!url) return;
41
56
  const target =
@@ -98,18 +113,36 @@ export function BrowserPanel({ className = '', active = true }: BrowserPanelProp
98
113
  </div>
99
114
  )}
100
115
 
101
- <BrowserScreencast
102
- status={status}
103
- url={url}
104
- tabs={tabs}
105
- targetId={targetId}
106
- frame={frame}
107
- actions={actions}
108
- onSelectTarget={selectTarget}
109
- onCloseTarget={handleCloseTarget}
110
- closingTarget={closing}
111
- zoomLevel={zoomLevel}
112
- />
116
+ {webkitActive && status === 'live' && engine.state && (
117
+ <BrowserEngineNotice
118
+ saving={engine.saving}
119
+ error={engine.error}
120
+ onUseChromium={handleUseChromium}
121
+ variant="strip"
122
+ />
123
+ )}
124
+
125
+ {engineExplainsEmptyView && engine.state ? (
126
+ <BrowserEngineNotice
127
+ saving={engine.saving}
128
+ error={engine.error}
129
+ onUseChromium={handleUseChromium}
130
+ variant="body"
131
+ />
132
+ ) : (
133
+ <BrowserScreencast
134
+ status={status}
135
+ url={url}
136
+ tabs={tabs}
137
+ targetId={targetId}
138
+ frame={frame}
139
+ actions={actions}
140
+ onSelectTarget={selectTarget}
141
+ onCloseTarget={handleCloseTarget}
142
+ closingTarget={closing}
143
+ zoomLevel={zoomLevel}
144
+ />
145
+ )}
113
146
  </div>
114
147
  );
115
148
  }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The access chip's copy follows the HARNESS, because the same three tiers mean
8
+ * different things on the two transports: omp's tier IS the approval gate,
9
+ * while an ACP agent decides which calls it asks about and Kabmo's tier only
10
+ * answers those requests. The omp copy also promises `tools.restrictedFolders`
11
+ * behaviour, which does not exist on another agent.
12
+ */
13
+
14
+ import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
15
+ import { Window } from 'happy-dom';
16
+ import { h, render } from 'preact';
17
+ import { act } from 'preact/test-utils';
18
+ import { AccessDropdown } from '@/client/components/workspace/chat-timeline/chat-input/AccessDropdown';
19
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
20
+
21
+ let container: HTMLElement | undefined;
22
+
23
+ beforeEach(() => {
24
+ installDomGlobals(new Window({ url: 'http://localhost' }));
25
+ });
26
+
27
+ afterEach(() => {
28
+ if (container) render(null, container);
29
+ container?.remove();
30
+ container = undefined;
31
+ restoreDomGlobals();
32
+ });
33
+
34
+ afterAll(() => restoreDomGlobals());
35
+
36
+ async function open(harness?: string): Promise<HTMLElement> {
37
+ container = document.createElement('div');
38
+ document.body.appendChild(container);
39
+ await act(async () => {
40
+ render(h(AccessDropdown, { value: 'always-ask', onSelect: () => {}, ...(harness ? { harness } : {}) }), container!);
41
+ });
42
+ const trigger = container.querySelector('button') as HTMLButtonElement;
43
+ await act(async () => { trigger.click(); });
44
+ return container;
45
+ }
46
+
47
+ describe('AccessDropdown copy', () => {
48
+ test('omp keeps the restricted-folder promise', async () => {
49
+ const el = await open('omp-rpc');
50
+ const yolo = el.querySelector('[title*="restricted folder"]');
51
+ expect(yolo).not.toBeNull();
52
+ // omp's tier is the gate, so there is nothing to disclaim.
53
+ expect(el.textContent).not.toContain('decides which calls it asks about');
54
+ });
55
+
56
+ test('another agent gets the answer-policy wording and the disclaimer', async () => {
57
+ const el = await open('claude');
58
+ expect(el.textContent).toContain('decides which calls it asks about');
59
+ // The omp-only rule must not be promised on a transport that has no such gate.
60
+ expect(el.querySelector('[title*="restricted folder"]')).toBeNull();
61
+ expect(el.querySelector('[title*="Every approval the agent asks for"]')).not.toBeNull();
62
+ });
63
+ });
@@ -3,17 +3,24 @@ import { Check, LockKeyhole } from 'lucide-preact';
3
3
  import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
4
4
  import type { ApprovalMode } from '@/shared/lib/omp/config/access-mode';
5
5
  import { APPROVAL_MODES } from '@/shared/lib/omp/config/access-mode';
6
- import { ACCESS_LEVEL_DESCRIPTIONS, ACCESS_LEVEL_LABELS } from '@/client/components/workspace/chat-timeline/chat-input/access-levels';
6
+ import { accessLevelCopy } from '@/client/components/workspace/chat-timeline/chat-input/access-levels';
7
7
 
8
8
  export interface AccessDropdownProps {
9
9
  value: ApprovalMode;
10
10
  onSelect: (mode: ApprovalMode) => void;
11
+ /**
12
+ * The harness this composer runs (or will run). The tier means something
13
+ * narrower on an ACP agent — it answers the approvals the agent raises
14
+ * instead of gating the tools itself — so the copy follows the harness.
15
+ */
16
+ harness?: string;
11
17
  }
12
18
 
13
- export function AccessDropdown({ value, onSelect }: AccessDropdownProps) {
19
+ export function AccessDropdown({ value, onSelect, harness }: AccessDropdownProps) {
14
20
  const [showAccess, setShowAccess] = useState(false);
15
21
  const accessRef = useRef<HTMLDivElement>(null);
16
22
  useOnClickOutside(accessRef, () => setShowAccess(false));
23
+ const copy = accessLevelCopy(harness);
17
24
 
18
25
  // Selection is owned by ChatInput; this dropdown only reports user choices.
19
26
  const handleSelect = (mode: ApprovalMode) => {
@@ -29,23 +36,28 @@ export function AccessDropdown({ value, onSelect }: AccessDropdownProps) {
29
36
  className="tap-chip flex items-center space-x-1 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-muted"
30
37
  >
31
38
  <LockKeyhole size={12} className="text-ink/60" />
32
- <span className="hidden lg:inline">{ACCESS_LEVEL_LABELS[value]}</span>
39
+ <span className="hidden lg:inline">{copy.labels[value]}</span>
33
40
  </button>
34
41
  {showAccess && (
35
- <div className="glass-popover absolute bottom-full left-0 mb-1 w-40 bg-paper border border-ink/20 rounded-md shadow-lg z-50 py-1 text-xs">
42
+ <div className={`glass-popover absolute bottom-full left-0 mb-1 ${copy.note ? 'w-56' : 'w-40'} bg-paper border border-ink/20 rounded-md shadow-lg z-50 py-1 text-xs`}>
36
43
  <div className="px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold mb-1">Access Control</div>
37
44
  {APPROVAL_MODES.map(mode => (
38
45
  <button
39
46
  key={mode}
40
47
  type="button"
41
48
  onClick={() => handleSelect(mode)}
42
- title={ACCESS_LEVEL_DESCRIPTIONS[mode]}
49
+ title={copy.descriptions[mode]}
43
50
  className="w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center justify-between transition-colors"
44
51
  >
45
- <span>{ACCESS_LEVEL_LABELS[mode]}</span>
52
+ <span>{copy.labels[mode]}</span>
46
53
  {value === mode && <Check size={12} className="text-ink" />}
47
54
  </button>
48
55
  ))}
56
+ {copy.note && (
57
+ <p className="px-3 pt-1.5 pb-1 text-[10px] leading-snug text-ink/45 border-t border-ink/10 mt-1">
58
+ {copy.note}
59
+ </p>
60
+ )}
49
61
  </div>
50
62
  )}
51
63
  </div>
@@ -187,7 +187,9 @@ export function ComposerToolbar({
187
187
 
188
188
  {(showModel || showThinking) && showAccess && <div className="w-[1px] h-3 bg-ink/10" />}
189
189
 
190
- {showAccess && onSelectAccess && <AccessDropdown value={accessMode} onSelect={onSelectAccess} />}
190
+ {showAccess && onSelectAccess && (
191
+ <AccessDropdown value={accessMode} onSelect={onSelectAccess} harness={harness} />
192
+ )}
191
193
 
192
194
  {/* On a phone the mode toggles live in the row above (the attachment
193
195
  row), because this one is a single line already filled by the