@kabmo-labs/kabmo 0.17.0 → 0.18.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.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +538 -457
- package/dist/client/static/js/index-hp75vsv9.css +1 -0
- package/dist/client/static/js/{index-rerjq5th.js → index-tc09dtca.js} +823 -814
- package/package.json +1 -1
- package/src/client/components/common/MarkdownRenderer.tsx +136 -89
- package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
- package/src/client/components/common/anchored-menu/index.tsx +143 -0
- package/src/client/components/common/markdown-review/ReviewPopover.tsx +144 -0
- package/src/client/components/common/markdown-review/ReviewSummary.tsx +108 -0
- package/src/client/components/common/markdown-review/index.tsx +129 -0
- package/src/client/components/common/server-control/Panel.tsx +33 -23
- package/src/client/components/common/server-control/index.test.tsx +11 -5
- package/src/client/components/common/server-control/index.tsx +10 -8
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +42 -21
- package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +36 -17
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -7
- package/src/client/components/layout/session-sidebar/about-modal/NotesDialog.tsx +94 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.test.tsx +68 -0
- package/src/client/components/layout/session-sidebar/about-modal/VersionLine.tsx +36 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +57 -34
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +28 -10
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +7 -6
- package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +1 -1
- package/src/client/components/layout/update-popup/ReleaseNotes.tsx +8 -3
- package/src/client/components/layout/update-popup/index.tsx +5 -1
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +13 -15
- package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +23 -1
- package/src/client/components/mobile/mobile-right-sidebar/MissingFileBanner.tsx +30 -0
- package/src/client/components/mobile/mobile-right-sidebar/PreviewScroller.tsx +18 -2
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +22 -67
- package/src/client/components/mobile/mobile-session-sidebar/ItemMenu.tsx +110 -0
- package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
- package/src/client/components/settings/categories/AgentSettings.tsx +23 -50
- package/src/client/components/settings/categories/CommandSettings.tsx +2 -2
- package/src/client/components/settings/categories/McpSettings.tsx +4 -21
- package/src/client/components/settings/categories/OmpSettings.tsx +147 -194
- package/src/client/components/settings/categories/SkillSettings.tsx +2 -2
- package/src/client/components/settings/categories/TokenUsageSettings.tsx +211 -229
- package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +229 -237
- package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +71 -0
- package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +9 -2
- package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
- package/src/client/components/settings/categories/behavior-settings/Editor.tsx +27 -7
- package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +23 -5
- package/src/client/components/settings/categories/command-settings/DetailPane.tsx +75 -33
- package/src/client/components/settings/categories/command-settings/SidebarList.tsx +7 -0
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +91 -76
- package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +26 -13
- package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +20 -0
- package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +97 -36
- package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +151 -0
- package/src/client/components/settings/categories/omp-settings/ExtensionsPanel.tsx +68 -32
- package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +119 -0
- package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +14 -7
- package/src/client/components/settings/categories/omp-settings/RoleEditor.tsx +15 -6
- package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +165 -226
- package/src/client/components/settings/categories/omp-settings/types.ts +28 -0
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +35 -7
- package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +34 -14
- package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +21 -0
- package/src/client/components/settings/categories/skill-settings/pane.test.tsx +15 -6
- package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +242 -102
- package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +130 -56
- package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +135 -0
- package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +55 -33
- package/src/client/components/settings/categories/token-usage-settings/Provenance.tsx +59 -0
- package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +239 -0
- package/src/client/components/workspace/browser-panel/Screencast.test.ts +1 -0
- package/src/client/components/workspace/browser-panel/Screencast.tsx +17 -22
- package/src/client/components/workspace/browser-panel/TabStrip.test.tsx +158 -0
- package/src/client/components/workspace/browser-panel/TabStrip.tsx +90 -0
- package/src/client/components/workspace/browser-panel/index.tsx +50 -4
- package/src/client/components/workspace/browser-toolbar/index.tsx +41 -1
- package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +3 -1
- package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +88 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +24 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +34 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +5 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +237 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +191 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +1 -1
- package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +21 -7
- package/src/client/components/workspace/diff-panel/changes.test.ts +51 -0
- package/src/client/components/workspace/diff-panel/changes.ts +28 -12
- package/src/client/components/workspace/diff-panel/merge.test.ts +28 -0
- package/src/client/components/workspace/diff-panel/merge.ts +21 -1
- package/src/client/components/workspace/editor/Body.tsx +7 -0
- package/src/client/components/workspace/editor/FileDocument.tsx +15 -21
- package/src/client/components/workspace/editor/FilePane.tsx +12 -0
- package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
- package/src/client/components/workspace/editor/Toolbar.tsx +17 -1
- package/src/client/components/workspace/editor/index.tsx +25 -22
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +14 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +12 -86
- package/src/client/components/workspace/editor/toolbar-toggle.tsx +53 -0
- package/src/client/components/workspace/editor/toolbar-write-clusters.tsx +112 -0
- package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
- package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +201 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +112 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.test.tsx +225 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +217 -0
- package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +99 -0
- package/src/client/components/workspace/user-browser-panel/Frame.tsx +30 -1
- package/src/client/components/workspace/user-browser-panel/index.tsx +81 -2
- package/src/client/data/agent-data/builtin.ts +0 -10
- package/src/client/data/agent-data/orchestrator.ts +0 -45
- package/src/client/data/agent-data/specialist.ts +0 -100
- package/src/client/data/mock/token-usage.ts +170 -120
- package/src/client/data/settings/omp-schema.json +33 -1
- package/src/client/hooks/browser/use-annotate.test.ts +143 -0
- package/src/client/hooks/browser/use-annotate.ts +98 -0
- package/src/client/hooks/browser/use-close-tab.test.ts +148 -0
- package/src/client/hooks/browser/use-close-tab.ts +67 -0
- package/src/client/hooks/browser/use-screencast.ts +13 -1
- package/src/client/hooks/chat/composer/browser-context.test.ts +117 -0
- package/src/client/hooks/chat/composer/browser-context.ts +40 -16
- package/src/client/hooks/chat/composer/items.test.ts +1 -1
- package/src/client/hooks/chat/composer/review-context.ts +38 -0
- package/src/client/hooks/chat/composer/use-draft.test.ts +132 -0
- package/src/client/hooks/chat/composer/use-draft.ts +31 -2
- package/src/client/hooks/chat/timeline/row-window.test.ts +15 -2
- package/src/client/hooks/editor/use-document-annotations.ts +124 -0
- package/src/client/hooks/editor/use-editor-panel-ui.ts +52 -0
- package/src/client/hooks/editor/use-file-review-mode.ts +35 -0
- package/src/client/hooks/editor/use-preview-review.ts +148 -0
- package/src/client/hooks/settings/agents.ts +149 -0
- package/src/client/hooks/settings/crud-list.test.ts +28 -6
- package/src/client/hooks/settings/crud-list.ts +96 -57
- package/src/client/hooks/settings/omp-config.ts +164 -0
- package/src/client/hooks/settings/useTokenUsage.ts +125 -0
- package/src/client/hooks/settings/write-feedback.test.ts +104 -0
- package/src/client/hooks/settings/write-feedback.ts +63 -0
- package/src/client/hooks/ui/markdown-hydration.ts +125 -0
- package/src/client/hooks/ui/updates/index.test.ts +100 -1
- package/src/client/hooks/ui/updates/index.ts +50 -0
- package/src/client/hooks/ui/updates/notes.test.ts +138 -0
- package/src/client/hooks/ui/updates/notes.ts +57 -0
- package/src/client/lib/browser/element-at.test.ts +229 -0
- package/src/client/lib/browser/element-at.ts +139 -0
- package/src/client/lib/review/client.ts +73 -0
- package/src/client/lib/router/search-params.ts +42 -20
- package/src/client/tailwind.css +65 -0
- package/src/server/lib/btw/lifecycle.server.ts +2 -2
- package/src/server/lib/db/schema.ts +7 -0
- package/src/server/lib/db/seed-terminal.test.ts +4 -0
- package/src/server/lib/omp/config/agent-definitions.test.ts +273 -0
- package/src/server/lib/omp/config/agents.ts +231 -61
- package/src/server/lib/omp/config/definitions.test.ts +9 -105
- package/src/server/lib/omp/config/extensions.ts +16 -7
- package/src/server/lib/omp/config/omp-config-files.test.ts +27 -0
- package/src/server/lib/omp/rpc/constants.test.ts +11 -0
- package/src/server/lib/omp/rpc/constants.ts +15 -0
- package/src/server/lib/omp/rpc/process.ts +11 -14
- package/src/server/lib/omp/rpc/session-commands.ts +6 -3
- package/src/server/lib/omp/rpc/utility-agent-dir.test.ts +134 -0
- package/src/server/lib/omp/rpc/utility-agent-dir.ts +138 -0
- package/src/server/lib/omp/rpc/utility.ts +12 -0
- package/src/server/lib/review/schema.server.ts +45 -0
- package/src/server/lib/review/store.server.ts +138 -0
- package/src/server/lib/terminal/attach-replay.test.ts +132 -0
- package/src/server/lib/terminal/output.test.ts +166 -0
- package/src/server/lib/terminal/output.ts +104 -0
- package/src/server/lib/terminal/runtime.server.ts +5 -0
- package/src/server/lib/terminal/send-result.test.ts +33 -0
- package/src/server/lib/terminal/send-result.ts +32 -0
- package/src/server/lib/terminal/session.server.ts +45 -11
- package/src/server/lib/terminal/store-liveness.test.ts +4 -0
- package/src/server/lib/updates/active-notes.test.ts +149 -0
- package/src/server/lib/updates/active-notes.ts +75 -0
- package/src/server/lib/updates/changelog-file.ts +42 -11
- package/src/server/lib/updates/changelog.test.ts +15 -1
- package/src/server/lib/updates/omp.ts +42 -15
- package/src/server/lib/updates/release-url.ts +27 -1
- package/src/server/lib/usage/index-parse.test.ts +200 -0
- package/src/server/lib/usage/index-parse.ts +178 -0
- package/src/server/lib/usage/index-query.server.ts +248 -0
- package/src/server/lib/usage/index-scan.server.ts +343 -0
- package/src/server/lib/usage/index-schema.server.ts +82 -0
- package/src/server/lib/usage/index.test.ts +234 -0
- package/src/server/lib/usage/providers.server.ts +4 -53
- package/src/server/routes/browser/index.ts +3 -0
- package/src/server/routes/browser/stream.ts +31 -2
- package/src/server/routes/browser/tabs.test.ts +94 -0
- package/src/server/routes/browser/tabs.ts +85 -0
- package/src/server/routes/index.ts +2 -0
- package/src/server/routes/review/bindings.ts +11 -0
- package/src/server/routes/review/index.ts +127 -0
- package/src/server/routes/review/routes.test.ts +191 -0
- package/src/server/routes/settings/agents.test.ts +180 -0
- package/src/server/routes/settings/agents.ts +95 -102
- package/src/server/routes/settings/mcp.test.ts +135 -0
- package/src/server/routes/settings/mcp.ts +14 -6
- package/src/server/routes/settings/settings-store-routes.test.ts +6 -113
- package/src/server/routes/telemetry/tokens.test.ts +145 -0
- package/src/server/routes/telemetry/tokens.ts +70 -149
- package/src/server/routes/terminal/ws.ts +6 -5
- package/src/server/routes/updates/index.ts +2 -0
- package/src/server/routes/updates/notes.ts +34 -0
- package/src/server/routes/updates/routes.test.ts +49 -0
- package/src/shared/lib/browser/annotate.test.ts +283 -0
- package/src/shared/lib/browser/annotate.ts +231 -0
- package/src/shared/lib/browser/browser-viewer.test.ts +26 -4
- package/src/shared/lib/browser/frame-gate.test.ts +91 -0
- package/src/shared/lib/browser/frame-gate.ts +69 -0
- package/src/shared/lib/browser/frame-params.test.ts +43 -0
- package/src/shared/lib/browser/frame-params.ts +60 -0
- package/src/shared/lib/browser/frame-pipeline.test.ts +132 -0
- package/src/shared/lib/browser/frame-pipeline.ts +80 -0
- package/src/shared/lib/browser/page-context.ts +60 -4
- package/src/shared/lib/browser/snapshot.test.ts +115 -0
- package/src/shared/lib/browser/snapshot.ts +112 -0
- package/src/shared/lib/browser/tab-close.test.ts +74 -0
- package/src/shared/lib/browser/tab-close.ts +77 -0
- package/src/shared/lib/browser/viewer.ts +45 -26
- package/src/shared/lib/chat/timeline/block-chrome.ts +19 -0
- package/src/shared/lib/chat/timeline/tool-render-mode.ts +17 -4
- package/src/shared/lib/chat/tool/artifact.ts +55 -20
- package/src/shared/lib/chat/tool/bash-facts.ts +96 -0
- package/src/shared/lib/chat/tool/minimized.test.ts +98 -0
- package/src/shared/lib/chat/tool/minimized.ts +64 -0
- package/src/shared/lib/chat/tool/summary.test.ts +28 -8
- package/src/shared/lib/chat/tool/summary.ts +3 -32
- package/src/shared/lib/markdown/blocks/anchor.ts +63 -0
- package/src/shared/lib/markdown/blocks/blocks.test.ts +141 -0
- package/src/shared/lib/markdown/blocks/renderer.ts +120 -0
- package/src/shared/lib/markdown/blocks/scan.ts +100 -0
- package/src/shared/lib/markdown/blocks/types.ts +62 -0
- package/src/shared/lib/markdown/marked.ts +58 -147
- package/src/shared/lib/markdown/math-extensions.ts +168 -0
- package/src/shared/lib/markdown/review/prompt.ts +77 -0
- package/src/shared/lib/markdown/review/reconcile.ts +55 -0
- package/src/shared/lib/markdown/review/review.test.ts +96 -0
- package/src/shared/lib/markdown/xml-sections.test.ts +140 -0
- package/src/shared/lib/markdown/xml-sections.ts +139 -0
- package/src/shared/lib/models/provider/label.ts +57 -0
- package/src/shared/lib/omp/config/agent-file.test.ts +54 -0
- package/src/shared/lib/omp/config/agent-file.ts +43 -0
- package/src/shared/lib/omp/config/row-value.test.ts +95 -0
- package/src/shared/lib/omp/config/row-value.ts +97 -0
- package/src/shared/lib/omp/config/schema.test.ts +31 -0
- package/src/shared/lib/omp/config/schema.ts +6 -0
- package/src/shared/lib/omp/rpc/frame.test.ts +48 -47
- package/src/shared/lib/omp/rpc/frame.ts +49 -40
- package/src/shared/lib/ui/menu-anchor.test.ts +69 -0
- package/src/shared/lib/ui/menu-anchor.ts +89 -0
- package/src/shared/lib/usage/breakdown.test.ts +197 -0
- package/src/shared/lib/usage/breakdown.ts +241 -0
- package/src/shared/lib/usage/range.test.ts +204 -0
- package/src/shared/lib/usage/range.ts +240 -0
- package/src/shared/lib/usage/view.test.ts +85 -0
- package/src/shared/lib/usage/view.ts +74 -0
- package/src/shared/types/browser.ts +78 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/settings/agent.ts +28 -6
- package/src/shared/types/settings/state.ts +4 -3
- package/src/shared/types/settings/write.ts +6 -0
- package/src/shared/types/tokenUsage.ts +128 -21
- package/src/shared/types/updates.ts +20 -0
- package/dist/client/static/js/index-3ve31rzx.css +0 -1
- package/src/server/lib/omp/session/usage/aggregate-shaping.test.ts +0 -149
- package/src/server/lib/omp/session/usage/aggregate.test.ts +0 -243
- package/src/server/lib/omp/session/usage/aggregate.ts +0 -330
- package/src/server/lib/omp/session/usage/shaping.ts +0 -130
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useEffect, useState } from 'preact/hooks';
|
|
2
2
|
import type { FormEvent, FunctionComponent } from 'preact/compat';
|
|
3
|
-
import { Check, Code, Globe,
|
|
4
|
-
import type { McpEnvVar, McpScope, McpServerItem } from '@/shared/types';
|
|
3
|
+
import { AlertCircle, Check, Code, Globe, Loader2, Save, Terminal, Trash2 } from 'lucide-preact';
|
|
4
|
+
import type { McpEnvVar, McpScope, McpServerItem, WriteOutcome } from '@/shared/types';
|
|
5
5
|
import { ConnectionTest } from '@/client/components/settings/categories/mcp-settings/ConnectionTest';
|
|
6
|
+
import { McpEnvVarsSection } from '@/client/components/settings/categories/mcp-settings/EnvVarsSection';
|
|
7
|
+
import { useWriteFeedback } from '@/client/hooks/settings/write-feedback';
|
|
6
8
|
|
|
7
9
|
function parseCommandArgs(text: string): string[] {
|
|
8
10
|
return text.split('\n').map((s) => s.trim()).filter(Boolean);
|
|
@@ -11,8 +13,8 @@ function parseCommandArgs(text: string): string[] {
|
|
|
11
13
|
interface McpDetailPaneProps {
|
|
12
14
|
server: McpServerItem;
|
|
13
15
|
isNew?: boolean;
|
|
14
|
-
onSave: (updatedServer: McpServerItem) =>
|
|
15
|
-
onDelete?: (serverId: string) =>
|
|
16
|
+
onSave: (updatedServer: McpServerItem) => Promise<WriteOutcome>;
|
|
17
|
+
onDelete?: (serverId: string) => Promise<WriteOutcome>;
|
|
16
18
|
onOpenImportModal: () => void;
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -25,26 +27,49 @@ export const McpDetailPane: FunctionComponent<McpDetailPaneProps> = ({
|
|
|
25
27
|
}) => {
|
|
26
28
|
const [formData, setFormData] = useState<McpServerItem>(server);
|
|
27
29
|
const [commandText, setCommandText] = useState('');
|
|
28
|
-
const [
|
|
30
|
+
const [confirmDelete, setConfirmDelete] = useState(false);
|
|
31
|
+
const feedback = useWriteFeedback();
|
|
29
32
|
|
|
30
33
|
useEffect(() => {
|
|
31
34
|
setFormData(server);
|
|
32
35
|
setCommandText(server.commandArgs.join('\n'));
|
|
33
|
-
|
|
36
|
+
setConfirmDelete(false);
|
|
34
37
|
}, [server]);
|
|
35
38
|
|
|
39
|
+
/**
|
|
40
|
+
* A server is reachable by a command or a link, and neither may be blank: an
|
|
41
|
+
* empty command writes a config entry omp connects to and fails, which reads
|
|
42
|
+
* as "the server is broken" rather than "the form was empty".
|
|
43
|
+
*/
|
|
44
|
+
const validationError = (() => {
|
|
45
|
+
if (!formData.name.trim()) return 'A server needs a name — omp keys its config by it.';
|
|
46
|
+
if (formData.reachType === 'command' && parseCommandArgs(commandText).length === 0) {
|
|
47
|
+
return 'Paste the command that starts the server, one argument per line.';
|
|
48
|
+
}
|
|
49
|
+
if (formData.reachType === 'link' && !(formData.linkUrl ?? '').trim()) {
|
|
50
|
+
return 'Paste the server’s MCP endpoint URL.';
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
})();
|
|
54
|
+
|
|
36
55
|
const handleSave = (e: FormEvent) => {
|
|
37
56
|
e.preventDefault();
|
|
38
|
-
|
|
39
|
-
|
|
57
|
+
if (validationError || feedback.saving) return;
|
|
40
58
|
const updated: McpServerItem = {
|
|
41
59
|
...formData,
|
|
42
|
-
|
|
60
|
+
name: formData.name.trim(),
|
|
61
|
+
commandArgs: parseCommandArgs(commandText),
|
|
43
62
|
};
|
|
63
|
+
void feedback.run(() => onSave(updated));
|
|
64
|
+
};
|
|
44
65
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
66
|
+
const handleDelete = () => {
|
|
67
|
+
if (!onDelete) return;
|
|
68
|
+
void feedback.run(async () => {
|
|
69
|
+
const outcome = await onDelete(formData.id);
|
|
70
|
+
if (!outcome.ok) setConfirmDelete(false);
|
|
71
|
+
return outcome;
|
|
72
|
+
});
|
|
48
73
|
};
|
|
49
74
|
|
|
50
75
|
const handleAddEnvVar = () => {
|
|
@@ -218,90 +243,80 @@ export const McpDetailPane: FunctionComponent<McpDetailPaneProps> = ({
|
|
|
218
243
|
<div className="border-t border-ink/10" />
|
|
219
244
|
|
|
220
245
|
{/* SECTION: Environment Variables */}
|
|
221
|
-
<
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
246
|
+
<McpEnvVarsSection
|
|
247
|
+
envVars={formData.envVars}
|
|
248
|
+
onAdd={handleAddEnvVar}
|
|
249
|
+
onUpdate={handleUpdateEnvVar}
|
|
250
|
+
onRemove={handleRemoveEnvVar}
|
|
251
|
+
/>
|
|
252
|
+
|
|
253
|
+
{validationError && (
|
|
254
|
+
<div className="rounded-lg border border-error/30 bg-error/5 px-3 py-2 text-[11px] text-error">
|
|
255
|
+
{validationError}
|
|
256
|
+
</div>
|
|
257
|
+
)}
|
|
258
|
+
|
|
259
|
+
{feedback.error && (
|
|
260
|
+
<div className="flex items-start gap-1.5 rounded-lg border border-error/30 bg-error/5 px-3 py-2 text-[11px] text-error">
|
|
261
|
+
<AlertCircle className="mt-px h-3.5 w-3.5 flex-shrink-0" />
|
|
262
|
+
<span className="flex-1 break-words">{feedback.error}</span>
|
|
263
|
+
<button type="button" onClick={feedback.dismissError} className="cursor-pointer text-error/60 hover:text-error" aria-label="Dismiss error">
|
|
264
|
+
×
|
|
238
265
|
</button>
|
|
239
266
|
</div>
|
|
267
|
+
)}
|
|
240
268
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
<div key={env.id} className="flex items-center gap-2">
|
|
249
|
-
<input
|
|
250
|
-
type="text"
|
|
251
|
-
value={env.key}
|
|
252
|
-
onChange={(e) => handleUpdateEnvVar(env.id, e.currentTarget.value, env.value)}
|
|
253
|
-
placeholder="KEY"
|
|
254
|
-
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"
|
|
255
|
-
/>
|
|
256
|
-
<input
|
|
257
|
-
type="text"
|
|
258
|
-
value={env.value}
|
|
259
|
-
onChange={(e) => handleUpdateEnvVar(env.id, env.key, e.currentTarget.value)}
|
|
260
|
-
placeholder="VALUE"
|
|
261
|
-
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"
|
|
262
|
-
/>
|
|
269
|
+
{/* Footer Controls */}
|
|
270
|
+
<div className="pt-3 border-t border-ink/10 flex flex-wrap items-center justify-between gap-3">
|
|
271
|
+
<div className="flex items-center gap-2">
|
|
272
|
+
{!isNew && onDelete && (
|
|
273
|
+
confirmDelete ? (
|
|
274
|
+
<>
|
|
275
|
+
<span className="text-[11px] text-ink/70">Delete “{formData.name}”?</span>
|
|
263
276
|
<button
|
|
264
277
|
type="button"
|
|
265
|
-
onClick={
|
|
266
|
-
|
|
267
|
-
|
|
278
|
+
onClick={handleDelete}
|
|
279
|
+
disabled={feedback.saving}
|
|
280
|
+
className="px-2.5 py-1 rounded-lg border border-error/40 text-error text-xs font-medium hover:bg-error/10 transition-colors cursor-pointer disabled:opacity-50"
|
|
268
281
|
>
|
|
269
|
-
|
|
282
|
+
Delete
|
|
270
283
|
</button>
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
284
|
+
<button
|
|
285
|
+
type="button"
|
|
286
|
+
onClick={() => setConfirmDelete(false)}
|
|
287
|
+
className="px-2 py-1 text-xs text-ink/50 hover:text-ink cursor-pointer"
|
|
288
|
+
>
|
|
289
|
+
Cancel
|
|
290
|
+
</button>
|
|
291
|
+
</>
|
|
292
|
+
) : (
|
|
293
|
+
<button
|
|
294
|
+
type="button"
|
|
295
|
+
onClick={() => setConfirmDelete(true)}
|
|
296
|
+
className="flex items-center gap-1.5 px-3.5 py-2 rounded-lg border border-ink/20 hover:border-error hover:text-error text-ink/70 text-xs font-medium transition-colors cursor-pointer"
|
|
297
|
+
>
|
|
298
|
+
<Trash2 className="w-3.5 h-3.5" />
|
|
299
|
+
Delete
|
|
300
|
+
</button>
|
|
301
|
+
)
|
|
289
302
|
)}
|
|
290
303
|
|
|
291
304
|
<ConnectionTest server={serverForTest} />
|
|
292
305
|
</div>
|
|
293
306
|
|
|
294
307
|
<div className="flex items-center gap-3">
|
|
295
|
-
{
|
|
308
|
+
{feedback.saved && (
|
|
296
309
|
<span className="flex items-center gap-1 text-xs text-ink font-medium">
|
|
297
310
|
<Check className="w-3.5 h-3.5" />
|
|
298
|
-
Saved
|
|
311
|
+
Saved
|
|
299
312
|
</span>
|
|
300
313
|
)}
|
|
301
314
|
<button
|
|
302
315
|
type="submit"
|
|
303
|
-
|
|
316
|
+
disabled={feedback.saving || Boolean(validationError)}
|
|
317
|
+
className="flex items-center gap-1.5 px-4 py-2 rounded-lg bg-ink text-paper text-xs font-medium hover:bg-ink/90 transition-colors shadow-xs cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed"
|
|
304
318
|
>
|
|
319
|
+
{feedback.saving ? <Loader2 className="w-3.5 h-3.5 animate-spin" /> : <Save className="w-3.5 h-3.5" />}
|
|
305
320
|
{isNew ? 'Create Server' : 'Save Changes'}
|
|
306
321
|
</button>
|
|
307
322
|
</div>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The environment variables an MCP server is launched with.
|
|
8
|
+
*
|
|
9
|
+
* Keys are shown as typed and never masked here: this is the file the user is
|
|
10
|
+
* writing, and hiding a value in the form while showing it in `mcp.json` on the
|
|
11
|
+
* next screen is the worse of the two. A blank key is kept (it is a half-typed
|
|
12
|
+
* row, not a decision) and the server-side writer is what refuses an empty
|
|
13
|
+
* name, so a save cannot invent an `""` variable.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { Plus, Trash2 } from 'lucide-preact';
|
|
17
|
+
import type { McpEnvVar } from '@/shared/types';
|
|
18
|
+
|
|
19
|
+
interface EnvVarsSectionProps {
|
|
20
|
+
envVars: McpEnvVar[];
|
|
21
|
+
onAdd: () => void;
|
|
22
|
+
onUpdate: (id: string, key: string, value: string) => void;
|
|
23
|
+
onRemove: (id: string) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function McpEnvVarsSection({ envVars, onAdd, onUpdate, onRemove }: EnvVarsSectionProps) {
|
|
27
|
+
return (
|
|
28
|
+
<div className="space-y-3">
|
|
29
|
+
<div className="flex items-center justify-between gap-3">
|
|
30
|
+
<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>
|
|
33
|
+
</div>
|
|
34
|
+
<button
|
|
35
|
+
type="button"
|
|
36
|
+
onClick={onAdd}
|
|
37
|
+
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
|
+
>
|
|
39
|
+
<Plus className="w-3.5 h-3.5" />
|
|
40
|
+
<span>Add variable</span>
|
|
41
|
+
</button>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
{envVars.length === 0 ? (
|
|
45
|
+
<div className="p-4 rounded-lg border border-dashed border-ink/20 text-center text-xs text-ink/50">
|
|
46
|
+
No environment variables configured.
|
|
47
|
+
</div>
|
|
48
|
+
) : (
|
|
49
|
+
<div className="space-y-2">
|
|
50
|
+
{envVars.map((env) => (
|
|
51
|
+
<div key={env.id} className="flex items-center gap-2">
|
|
52
|
+
<input
|
|
53
|
+
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"
|
|
58
|
+
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
|
+
/>
|
|
60
|
+
<input
|
|
61
|
+
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'}`}
|
|
66
|
+
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
|
+
/>
|
|
68
|
+
<button
|
|
69
|
+
type="button"
|
|
70
|
+
onClick={() => onRemove(env.id)}
|
|
71
|
+
aria-label={`Remove ${env.key || 'the variable'}`}
|
|
72
|
+
title="Remove variable"
|
|
73
|
+
className="p-1.5 text-ink/40 hover:text-error transition-colors rounded-md cursor-pointer"
|
|
74
|
+
>
|
|
75
|
+
<Trash2 className="w-4 h-4" />
|
|
76
|
+
</button>
|
|
77
|
+
</div>
|
|
78
|
+
))}
|
|
79
|
+
</div>
|
|
80
|
+
)}
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { useState } from 'preact/hooks';
|
|
2
2
|
import type { FunctionComponent } from 'preact/compat';
|
|
3
|
-
import { AlertCircle, Code, X } from 'lucide-preact';
|
|
4
|
-
import type { McpEnvVar, McpServerItem } from '@/shared/types';
|
|
3
|
+
import { AlertCircle, Code, Loader2, X } from 'lucide-preact';
|
|
4
|
+
import type { McpEnvVar, McpServerItem, WriteOutcome } from '@/shared/types';
|
|
5
5
|
|
|
6
6
|
interface McpImportModalProps {
|
|
7
7
|
isOpen: boolean;
|
|
8
8
|
onClose: () => void;
|
|
9
|
-
|
|
9
|
+
/** Resolves with the save's outcome; a refusal keeps this dialog open. */
|
|
10
|
+
onImport: (server: McpServerItem) => Promise<WriteOutcome>;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const SAMPLE_JSON = `{
|
|
@@ -28,10 +29,11 @@ export const McpImportModal: FunctionComponent<McpImportModalProps> = ({
|
|
|
28
29
|
}) => {
|
|
29
30
|
const [jsonText, setJsonText] = useState(SAMPLE_JSON);
|
|
30
31
|
const [error, setError] = useState<string | null>(null);
|
|
32
|
+
const [importing, setImporting] = useState(false);
|
|
31
33
|
|
|
32
34
|
if (!isOpen) return null;
|
|
33
35
|
|
|
34
|
-
const handleParseAndImport = () => {
|
|
36
|
+
const handleParseAndImport = async () => {
|
|
35
37
|
setError(null);
|
|
36
38
|
try {
|
|
37
39
|
const parsed = JSON.parse(jsonText);
|
|
@@ -44,20 +46,20 @@ export const McpImportModal: FunctionComponent<McpImportModalProps> = ({
|
|
|
44
46
|
}
|
|
45
47
|
const firstKey = serverKeys[0];
|
|
46
48
|
const serverConfig = parsed.mcpServers[firstKey];
|
|
47
|
-
importConfig(firstKey, serverConfig);
|
|
49
|
+
await importConfig(firstKey, serverConfig);
|
|
48
50
|
return;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
// Handle direct config: { name, command, args, env } or { command, args }
|
|
52
54
|
const name = parsed.name || 'imported-mcp-server';
|
|
53
|
-
importConfig(name, parsed);
|
|
55
|
+
await importConfig(name, parsed);
|
|
54
56
|
} catch (err: unknown) {
|
|
55
57
|
const message = err instanceof Error ? err.message : 'Invalid JSON format';
|
|
56
58
|
setError(message);
|
|
57
59
|
}
|
|
58
60
|
};
|
|
59
61
|
|
|
60
|
-
const importConfig = (serverName: string, cfg: Record<string, unknown>) => {
|
|
62
|
+
const importConfig = async (serverName: string, cfg: Record<string, unknown>) => {
|
|
61
63
|
const isUrl = typeof cfg.url === 'string' && cfg.url.length > 0;
|
|
62
64
|
const reachType = isUrl ? 'link' : 'command';
|
|
63
65
|
|
|
@@ -82,6 +84,7 @@ export const McpImportModal: FunctionComponent<McpImportModalProps> = ({
|
|
|
82
84
|
});
|
|
83
85
|
}
|
|
84
86
|
|
|
87
|
+
const resolvedUrl = typeof cfg.url === 'string' ? cfg.url : undefined;
|
|
85
88
|
const newServer: McpServerItem = {
|
|
86
89
|
id: `mcp-${Date.now()}`,
|
|
87
90
|
name: serverName,
|
|
@@ -89,13 +92,21 @@ export const McpImportModal: FunctionComponent<McpImportModalProps> = ({
|
|
|
89
92
|
enabled: true,
|
|
90
93
|
reachType,
|
|
91
94
|
commandArgs,
|
|
92
|
-
|
|
95
|
+
...(resolvedUrl ? { linkUrl: resolvedUrl } : {}),
|
|
93
96
|
envVars,
|
|
94
97
|
status: 'active',
|
|
95
98
|
};
|
|
96
99
|
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
// The dialog closes on the SAVE's answer, not on the click: a refused
|
|
101
|
+
// write has to be readable against the JSON that produced it.
|
|
102
|
+
setImporting(true);
|
|
103
|
+
try {
|
|
104
|
+
const outcome = await onImport(newServer);
|
|
105
|
+
if (outcome.ok) onClose();
|
|
106
|
+
else setError(outcome.error ?? 'The server refused the import.');
|
|
107
|
+
} finally {
|
|
108
|
+
setImporting(false);
|
|
109
|
+
}
|
|
99
110
|
};
|
|
100
111
|
|
|
101
112
|
return (
|
|
@@ -149,10 +160,12 @@ export const McpImportModal: FunctionComponent<McpImportModalProps> = ({
|
|
|
149
160
|
</button>
|
|
150
161
|
<button
|
|
151
162
|
type="button"
|
|
152
|
-
onClick={handleParseAndImport}
|
|
153
|
-
|
|
163
|
+
onClick={() => void handleParseAndImport()}
|
|
164
|
+
disabled={importing}
|
|
165
|
+
className="flex items-center gap-1.5 px-4 py-2 rounded-lg bg-ink text-paper text-xs font-medium hover:bg-ink/90 transition-colors shadow-xs cursor-pointer disabled:opacity-50 disabled:cursor-progress"
|
|
154
166
|
>
|
|
155
|
-
|
|
167
|
+
{importing && <Loader2 className="w-3.5 h-3.5 animate-spin" />}
|
|
168
|
+
{importing ? 'Importing…' : 'Import Server'}
|
|
156
169
|
</button>
|
|
157
170
|
</div>
|
|
158
171
|
</div>
|
|
@@ -17,6 +17,9 @@ interface McpSidebarListProps {
|
|
|
17
17
|
onAddNewServer: () => void;
|
|
18
18
|
selectedProject: string;
|
|
19
19
|
onChangeProject: (projectPath: string) => void;
|
|
20
|
+
/** Why the list could not be read, and how to try again. */
|
|
21
|
+
loadError?: string;
|
|
22
|
+
onRetry?: () => void;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export const McpSidebarList: FunctionComponent<McpSidebarListProps> = ({
|
|
@@ -27,6 +30,8 @@ export const McpSidebarList: FunctionComponent<McpSidebarListProps> = ({
|
|
|
27
30
|
onAddNewServer,
|
|
28
31
|
selectedProject,
|
|
29
32
|
onChangeProject,
|
|
33
|
+
loadError,
|
|
34
|
+
onRetry,
|
|
30
35
|
}) => {
|
|
31
36
|
const activeProjectName = projects.find((proj) => proj.path === selectedProject)?.name ?? 'Global (all projects)';
|
|
32
37
|
|
|
@@ -59,6 +64,21 @@ export const McpSidebarList: FunctionComponent<McpSidebarListProps> = ({
|
|
|
59
64
|
</div>
|
|
60
65
|
|
|
61
66
|
<div className="flex-1 scrollbar-overlay-container p-1.5 space-y-3 text-xs">
|
|
67
|
+
{loadError && (
|
|
68
|
+
<div className="mx-1 rounded-lg border border-error/30 bg-error/5 px-2.5 py-2 text-[11px] leading-snug text-error">
|
|
69
|
+
<div className="font-semibold">Could not read the list</div>
|
|
70
|
+
<div className="mt-0.5 break-words text-error/80">{loadError}</div>
|
|
71
|
+
{onRetry && (
|
|
72
|
+
<button
|
|
73
|
+
type="button"
|
|
74
|
+
onClick={onRetry}
|
|
75
|
+
className="mt-1.5 rounded border border-error/40 px-2 py-0.5 font-medium hover:bg-error/10 cursor-pointer"
|
|
76
|
+
>
|
|
77
|
+
Retry
|
|
78
|
+
</button>
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
)}
|
|
62
82
|
<div>
|
|
63
83
|
<div className="px-2.5 pt-1.5 pb-1 text-[10px] font-bold text-ink/50 uppercase tracking-wider flex items-center justify-between">
|
|
64
84
|
<span>User Servers</span>
|