@kabmo-labs/kabmo 0.15.0 → 0.17.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/README.md +3 -2
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +412 -394
- package/dist/client/static/js/index-3ve31rzx.css +1 -0
- package/dist/client/static/js/{index-mx658m43.js → index-rerjq5th.js} +846 -844
- package/marketplace/plugins/stats/README.md +27 -8
- package/marketplace/plugins/stats/package.json +2 -2
- package/marketplace/plugins/stats/src/HeaderReadout.test.tsx +2 -1
- package/marketplace/plugins/stats/src/HeaderReadout.tsx +6 -2
- package/marketplace/plugins/stats/src/KillConfirm.test.tsx +159 -0
- package/marketplace/plugins/stats/src/KillConfirm.tsx +145 -0
- package/marketplace/plugins/stats/src/ProcessTable.tsx +54 -8
- package/marketplace/plugins/stats/src/TotalsBar.test.tsx +5 -2
- package/marketplace/plugins/stats/src/TotalsBar.tsx +13 -3
- package/marketplace/plugins/stats/src/app.test.tsx +100 -4
- package/marketplace/plugins/stats/src/app.tsx +51 -4
- package/marketplace/plugins/stats/src/groups.test.ts +1 -1
- package/marketplace/plugins/stats/src/kill.test.ts +131 -0
- package/marketplace/plugins/stats/src/kill.ts +74 -0
- package/marketplace/plugins/stats/src/labels.test.ts +1 -0
- package/marketplace/plugins/stats/src/machine.test.ts +77 -0
- package/marketplace/plugins/stats/src/machine.ts +115 -0
- package/marketplace/plugins/stats/src/proc/darwin.ts +38 -0
- package/marketplace/plugins/stats/src/proc/linux.ts +4 -0
- package/marketplace/plugins/stats/src/proc/ps.ts +1 -0
- package/marketplace/plugins/stats/src/proc/types.ts +11 -0
- package/marketplace/plugins/stats/src/sampler.test.ts +42 -4
- package/marketplace/plugins/stats/src/sampler.ts +32 -18
- package/marketplace/plugins/stats/src/server.ts +29 -2
- package/marketplace/plugins/stats/src/snapshot.ts +31 -3
- package/package.json +3 -2
- package/src/client/components/common/Modal.tsx +7 -0
- package/src/client/components/common/code-surface/bracket-guide.test.ts +2 -2
- package/src/client/components/common/code-surface/bracket-guide.ts +2 -2
- package/src/client/components/common/code-surface/conflict-markers.ts +5 -5
- package/src/client/components/common/code-surface/extensions.ts +7 -4
- package/src/client/components/common/code-surface/theme.ts +34 -9
- package/src/client/components/common/code-surface/whitespace.test.ts +223 -0
- package/src/client/components/common/code-surface/whitespace.ts +140 -0
- package/src/client/components/common/{server-switcher/index.tsx → server-control/Panel.tsx} +73 -35
- package/src/client/components/common/{server-switcher → server-control}/index.test.tsx +98 -37
- package/src/client/components/common/server-control/index.tsx +118 -0
- package/src/client/components/layout/LeftDock.tsx +1 -0
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +8 -50
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +1 -0
- package/src/client/components/mobile/RightSidebar.tsx +1 -0
- package/src/client/components/mobile/mobile-main-view/Header.tsx +6 -12
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +41 -13
- package/src/client/components/mobile/mobile-session-sidebar/use-dock.ts +1 -0
- package/src/client/components/settings/Modal.tsx +9 -3
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +19 -9
- package/src/client/components/settings/categories/AgentSettings.tsx +27 -6
- package/src/client/components/settings/categories/ProjectSettings.tsx +122 -156
- package/src/client/components/settings/categories/SkillCatalogSettings.tsx +220 -260
- package/src/client/components/settings/categories/SkillSettings.tsx +6 -3
- package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +5 -0
- package/src/client/components/settings/categories/project-settings/AccentPalette.test.tsx +189 -0
- package/src/client/components/settings/categories/project-settings/AccentPalette.tsx +156 -24
- package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +175 -0
- package/src/client/components/settings/categories/project-settings/DeleteProjectModal.tsx +107 -0
- package/src/client/components/settings/categories/project-settings/DetailsForm.tsx +40 -24
- package/src/client/components/settings/categories/project-settings/DetailsHeader.tsx +17 -7
- package/src/client/components/settings/categories/project-settings/IconGrid.tsx +164 -69
- package/src/client/components/settings/categories/project-settings/ModelDropdown.test.tsx +122 -0
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +124 -53
- package/src/client/components/settings/categories/project-settings/NameInput.tsx +57 -11
- package/src/client/components/settings/categories/project-settings/PathField.tsx +122 -0
- package/src/client/components/settings/categories/project-settings/SidebarList.tsx +100 -59
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +253 -0
- package/src/client/components/settings/categories/skill-catalog/SkillCard.tsx +89 -0
- package/src/client/components/settings/categories/skill-catalog/SourceRail.tsx +122 -0
- package/src/client/components/settings/categories/skill-catalog/catalog-ui.test.tsx +179 -0
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +208 -0
- package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +137 -232
- package/src/client/components/settings/categories/skill-settings/InstructionsEditor.tsx +84 -0
- package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +123 -87
- package/src/client/components/settings/categories/skill-settings/pane.test.tsx +179 -0
- package/src/client/components/settings/categories/skill-settings/row-meta.ts +58 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +6 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.test.ts +46 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -6
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +29 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +11 -3
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +24 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +6 -2
- package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +18 -2
- package/src/client/components/workspace/editor/viewers/viewers.test.ts +39 -0
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +18 -5
- package/src/client/components/workspace/file-explorer/Modals.tsx +15 -1
- package/src/client/components/workspace/file-explorer/RowLabel.tsx +68 -0
- package/src/client/components/workspace/file-explorer/TreeItem.tsx +47 -57
- package/src/client/components/workspace/file-explorer/collapsed-chain.test.ts +167 -0
- package/src/client/components/workspace/file-explorer/drag-props.ts +42 -0
- package/src/client/components/workspace/file-explorer/drag.test.ts +43 -0
- package/src/client/components/workspace/file-explorer/index.tsx +21 -20
- package/src/client/components/workspace/model-dropdown/Panel.tsx +7 -2
- package/src/client/components/workspace/model-dropdown/Section.test.tsx +13 -0
- package/src/client/components/workspace/model-dropdown/Section.tsx +5 -1
- package/src/client/components/workspace/panels/builtin.tsx +7 -0
- package/src/client/components/workspace/wiki-panel/NavModal.test.tsx +136 -0
- package/src/client/components/workspace/wiki-panel/NavModal.tsx +94 -0
- package/src/client/components/workspace/wiki-panel/PageView.tsx +16 -10
- package/src/client/components/workspace/wiki-panel/index.tsx +44 -9
- package/src/client/data/settings/omp-schema.json +91 -4
- package/src/client/data/settings/project.ts +9 -28
- package/src/client/data/settings/skill.ts +6 -32
- package/src/client/hooks/chat/timeline/pending-model.ts +28 -0
- package/src/client/hooks/settings/projects/index.ts +294 -0
- package/src/client/hooks/settings/projects.test.ts +237 -0
- package/src/client/hooks/settings/skill-catalog.ts +101 -9
- package/src/client/hooks/settings/skill-git-import.ts +153 -0
- package/src/client/hooks/shell/servers.test.ts +166 -0
- package/src/client/hooks/{desktop → shell}/servers.ts +17 -14
- package/src/client/hooks/ui/updates/shell-download.ts +1 -1
- package/src/client/hooks/ui/updates/shell-update.ts +2 -6
- package/src/client/hooks/workspace/file-row-drag.ts +41 -0
- package/src/client/hooks/workspace/file-tree-actions.ts +25 -1
- package/src/client/hooks/workspace/file-tree-edits.ts +23 -6
- package/src/client/hooks/workspace/root-drop-target.ts +77 -0
- package/src/client/hooks/workspace/unfolded-chains.ts +165 -0
- package/src/client/lib/desktop/dropped-paths.ts +1 -1
- package/src/client/lib/desktop/titlebar.test.ts +12 -3
- package/src/client/lib/desktop/titlebar.ts +1 -1
- package/src/client/lib/shell/desktop.ts +117 -0
- package/src/client/lib/shell/servers.ts +75 -0
- package/src/client/lib/shell/transport.ts +216 -0
- package/src/client/main.tsx +9 -0
- package/src/server/lib/db/schema.ts +11 -0
- package/src/server/lib/fs/git-merge-conflict.test.ts +14 -1
- package/src/server/lib/lifecycle/memory.test.ts +41 -1
- package/src/server/lib/lifecycle/memory.ts +131 -14
- package/src/server/lib/omp/config/skill-sources.ts +49 -0
- package/src/server/lib/omp/config/skills-git-install.ts +155 -0
- package/src/server/lib/omp/config/skills-git-repo.ts +288 -0
- package/src/server/lib/omp/config/skills-git.test.ts +220 -0
- package/src/server/lib/omp/session/subagent-presence-scan.test.ts +137 -0
- package/src/server/lib/omp/session/subagent-presence-scan.ts +120 -0
- package/src/server/lib/omp/session/subagent-presence-store.test.ts +120 -0
- package/src/server/lib/omp/session/subagent-presence-store.ts +65 -0
- package/src/server/lib/omp/session/subagent-presence.ts +52 -15
- package/src/server/lib/workspace/project-model.server.test.ts +102 -0
- package/src/server/lib/workspace/project-model.server.ts +47 -0
- package/src/server/lib/workspace/project-patch.server.ts +156 -0
- package/src/server/routes/agent/new.ts +8 -1
- package/src/server/routes/settings/agents.ts +19 -7
- package/src/server/routes/settings/projects.ts +53 -19
- package/src/server/routes/settings/settings-projects-routes.test.ts +214 -0
- package/src/server/routes/settings/settings-store-routes.test.ts +5 -2
- package/src/server/routes/settings/skills-catalog-actions.ts +195 -0
- package/src/server/routes/settings/skills.test.ts +225 -0
- package/src/server/routes/settings/skills.ts +18 -15
- package/src/shared/lib/fs/folder-chain.test.ts +81 -1
- package/src/shared/lib/fs/folder-chain.ts +84 -0
- package/src/shared/lib/omp/config/schema.test.ts +35 -0
- package/src/shared/lib/omp/session/job-progress.test.ts +37 -1
- package/src/shared/lib/omp/session/job-progress.ts +31 -0
- package/src/shared/lib/omp/session/proc.ts +5 -0
- package/src/shared/lib/omp/session/wait.ts +5 -0
- package/src/shared/lib/ui/mobile-overlay.ts +61 -0
- package/src/shared/lib/ui/svg-scope.test.ts +97 -0
- package/src/shared/lib/ui/svg-scope.ts +134 -0
- package/src/shared/lib/workspace/project-accent.test.ts +69 -0
- package/src/shared/lib/workspace/project-accent.ts +63 -0
- package/src/shared/lib/workspace/project-icon.ts +40 -0
- package/src/shared/lib/workspace/project-model.test.ts +79 -0
- package/src/shared/lib/workspace/project-model.ts +64 -0
- package/src/shared/types/settings/skill.ts +53 -3
- package/src/test-support/file-explorer-disk.test-util.ts +25 -1
- package/src/test-support/file-explorer-drag.test-util.ts +88 -0
- package/src/test-support/file-explorer.test-util.ts +47 -47
- package/dist/client/static/js/index-28pwtt69.css +0 -1
- package/src/client/components/common/code-surface/indent-guide.ts +0 -104
- package/src/client/components/settings/categories/skill-catalog/AddSourceModal.tsx +0 -133
- package/src/client/hooks/desktop/servers.test.ts +0 -73
- package/src/client/lib/desktop/bridge.ts +0 -203
- package/src/shared/lib/code/editor/indent-guide-rule.test.ts +0 -65
- package/src/shared/lib/code/editor/indent-guide-rule.ts +0 -47
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* "Defaults for new chats" — the value it stores and the row it renders.
|
|
8
|
+
*
|
|
9
|
+
* The control used to offer a hardcoded list of display names that no spawn
|
|
10
|
+
* could read; the stored value is now the composite `provider:modelId` the
|
|
11
|
+
* spawn applies, so these cases pin that the picker emits exactly that string,
|
|
12
|
+
* names the provider on every row (the registry serves one id from several
|
|
13
|
+
* providers), and can clear back to "inherit".
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
17
|
+
import { Window } from 'happy-dom';
|
|
18
|
+
import { h, render } from 'preact';
|
|
19
|
+
import { act } from 'preact/test-utils';
|
|
20
|
+
|
|
21
|
+
import { ProjectModelDropdown } from '@/client/components/settings/categories/project-settings/ModelDropdown';
|
|
22
|
+
import type { ProjectModelChoice } from '@/client/hooks/settings/projects';
|
|
23
|
+
import { NO_PROJECT_MODEL } from '@/shared/lib/workspace/project-model';
|
|
24
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
25
|
+
|
|
26
|
+
const MODELS: ProjectModelChoice[] = [
|
|
27
|
+
{ provider: 'kenari', id: 'deepseek-v4-flash', name: 'DeepSeek V4 Flash' },
|
|
28
|
+
{ provider: 'deepseek', id: 'deepseek-v4-flash', name: 'DeepSeek V4 Flash' },
|
|
29
|
+
{ provider: 'openai', id: 'gpt-5', name: 'GPT-5' },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
let container: HTMLElement;
|
|
33
|
+
const picks: string[] = [];
|
|
34
|
+
|
|
35
|
+
beforeAll(() => {
|
|
36
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
afterEach(() => {
|
|
40
|
+
if (container) render(null, container);
|
|
41
|
+
container?.remove();
|
|
42
|
+
picks.length = 0;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterAll(() => {
|
|
46
|
+
restoreDomGlobals();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
function mount(model: string, models: ProjectModelChoice[] = MODELS): HTMLElement {
|
|
50
|
+
container = document.body.appendChild(document.createElement('div'));
|
|
51
|
+
act(() =>
|
|
52
|
+
render(
|
|
53
|
+
h(ProjectModelDropdown, {
|
|
54
|
+
model,
|
|
55
|
+
models,
|
|
56
|
+
onSelectModel: (value: string) => picks.push(value),
|
|
57
|
+
}),
|
|
58
|
+
container,
|
|
59
|
+
),
|
|
60
|
+
);
|
|
61
|
+
return container;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function clickText(root: HTMLElement, text: string): void {
|
|
65
|
+
const target = [...root.querySelectorAll('button')].find((button) => button.textContent?.includes(text));
|
|
66
|
+
if (!target) throw new Error(`no button containing “${text}”`);
|
|
67
|
+
act(() => target.click());
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function openPicker(root: HTMLElement): void {
|
|
71
|
+
// The trigger is the only button whose text starts with a model label or the
|
|
72
|
+
// inherit label, and it is the first button in the component.
|
|
73
|
+
const trigger = root.querySelector('button');
|
|
74
|
+
if (!trigger) throw new Error('no trigger');
|
|
75
|
+
act(() => trigger.click());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
describe('ProjectModelDropdown', () => {
|
|
79
|
+
test('an unset project says it inherits Kabmo’s default', () => {
|
|
80
|
+
const root = mount(NO_PROJECT_MODEL);
|
|
81
|
+
const trigger = [...root.querySelectorAll('button')].find((button) => button.textContent?.includes('Inherit Kabmo'));
|
|
82
|
+
expect(trigger).toBeTruthy();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('a stored model is labelled with its provider and display name', () => {
|
|
86
|
+
const root = mount('kenari:deepseek-v4-flash');
|
|
87
|
+
expect(root.textContent).toContain('kenari · DeepSeek V4 Flash');
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('a stale stored model is still named rather than reading as "inherit"', () => {
|
|
91
|
+
const root = mount('kenari:gone');
|
|
92
|
+
expect(root.textContent).toContain('kenari · gone');
|
|
93
|
+
expect(root.textContent).not.toContain('Inherit Kabmo');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('picking a row emits the composite provider:modelId value', () => {
|
|
97
|
+
const root = mount(NO_PROJECT_MODEL);
|
|
98
|
+
openPicker(root);
|
|
99
|
+
// Both providers serve this id: the row clicked must decide the provider.
|
|
100
|
+
const rows = [...root.querySelectorAll('button')].filter(
|
|
101
|
+
(button) => button.textContent?.includes('DeepSeek V4 Flash'),
|
|
102
|
+
);
|
|
103
|
+
expect(rows).toHaveLength(2);
|
|
104
|
+
const deepseek = rows.find((button) => button.textContent?.includes('deepseek'));
|
|
105
|
+
if (!deepseek) throw new Error('no deepseek row');
|
|
106
|
+
act(() => deepseek.click());
|
|
107
|
+
expect(picks).toEqual(['deepseek:deepseek-v4-flash']);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('clearing returns the project to inheriting', () => {
|
|
111
|
+
const root = mount('openai:gpt-5');
|
|
112
|
+
openPicker(root);
|
|
113
|
+
clickText(root, 'Clear the project model');
|
|
114
|
+
expect(picks).toEqual([NO_PROJECT_MODEL]);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('an empty catalog explains itself instead of offering nothing', () => {
|
|
118
|
+
const root = mount(NO_PROJECT_MODEL, []);
|
|
119
|
+
openPicker(root);
|
|
120
|
+
expect(root.textContent).toContain('The catalog is empty.');
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -1,91 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
1
5
|
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
/**
|
|
7
|
+
* "Defaults for new chats" — the model a chat BORN in this project starts on.
|
|
8
|
+
*
|
|
9
|
+
* The value is the composite `provider:modelId` from the live `/api/models`
|
|
10
|
+
* catalog, and it is read by the spawn (`POST /api/agent/new`), so what this
|
|
11
|
+
* control says is what the first prompt actually runs on. It used to offer a
|
|
12
|
+
* hardcoded list of display names ("GPT-4o", "DeepSeek-V3") that nothing ever
|
|
13
|
+
* read: the spawn fell back to Kabmo's global pick, so the field was decorative.
|
|
14
|
+
*
|
|
15
|
+
* "Inherit Kabmo's default" is the empty state, and it is the honest name for
|
|
16
|
+
* what an unset project does.
|
|
17
|
+
*/
|
|
5
18
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'Claude 3.7 Sonnet',
|
|
12
|
-
'GPT-4o',
|
|
13
|
-
'Gemini 2.5 Pro',
|
|
14
|
-
];
|
|
19
|
+
import { useMemo, useRef, useState } from 'preact/hooks';
|
|
20
|
+
import { Check, ChevronDown, Info, Search, Sparkles, X } from 'lucide-preact';
|
|
21
|
+
import { useOnClickOutside } from '@/client/hooks/ui/on-click-outside';
|
|
22
|
+
import type { ProjectModelChoice } from '@/client/hooks/settings/projects';
|
|
23
|
+
import { NO_PROJECT_MODEL, projectModelLabel, projectModelValue } from '@/shared/lib/workspace/project-model';
|
|
15
24
|
|
|
16
25
|
interface ProjectModelDropdownProps {
|
|
26
|
+
/** Stored `provider:modelId`, or the schema's `Not selected`. */
|
|
17
27
|
model: string;
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
models: ProjectModelChoice[];
|
|
29
|
+
onSelectModel: (value: string) => void;
|
|
30
|
+
disabled?: boolean;
|
|
20
31
|
}
|
|
21
32
|
|
|
22
33
|
export function ProjectModelDropdown({
|
|
23
34
|
model,
|
|
35
|
+
models,
|
|
24
36
|
onSelectModel,
|
|
25
|
-
|
|
37
|
+
disabled = false,
|
|
26
38
|
}: ProjectModelDropdownProps) {
|
|
27
|
-
const modelList = models && models.length > 0 ? models : FALLBACK_MODELS;
|
|
28
39
|
const [isOpen, setIsOpen] = useState(false);
|
|
29
|
-
const [
|
|
40
|
+
const [search, setSearch] = useState('');
|
|
30
41
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
31
42
|
|
|
32
43
|
useOnClickOutside(dropdownRef, () => setIsOpen(false));
|
|
33
44
|
|
|
45
|
+
const label = projectModelLabel(model, models) ?? 'Inherit Kabmo’s default';
|
|
46
|
+
|
|
47
|
+
const filtered = useMemo(() => {
|
|
48
|
+
const needle = search.trim().toLowerCase();
|
|
49
|
+
if (!needle) return models;
|
|
50
|
+
return models.filter((entry) =>
|
|
51
|
+
entry.name.toLowerCase().includes(needle)
|
|
52
|
+
|| entry.id.toLowerCase().includes(needle)
|
|
53
|
+
|| entry.provider.toLowerCase().includes(needle),
|
|
54
|
+
);
|
|
55
|
+
}, [models, search]);
|
|
56
|
+
|
|
57
|
+
const pick = (value: string) => {
|
|
58
|
+
onSelectModel(value);
|
|
59
|
+
setIsOpen(false);
|
|
60
|
+
setSearch('');
|
|
61
|
+
};
|
|
62
|
+
|
|
34
63
|
return (
|
|
35
64
|
<div className="space-y-2.5">
|
|
36
|
-
<div className="flex items-center gap-1.5
|
|
37
|
-
<h4 className="text-xs font-semibold text-ink">
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
className="relative inline-block cursor-help"
|
|
42
|
-
onMouseEnter={() => setShowTooltip(true)}
|
|
43
|
-
onMouseLeave={() => setShowTooltip(false)}
|
|
65
|
+
<div className="flex items-center gap-1.5">
|
|
66
|
+
<h4 className="text-xs font-semibold text-ink">Defaults for new chats</h4>
|
|
67
|
+
<span
|
|
68
|
+
className="inline-flex text-ink/40 hover:text-ink/70 transition-colors cursor-help"
|
|
69
|
+
title="The model a chat started in this project uses until you pick another one in the composer."
|
|
44
70
|
>
|
|
45
|
-
<Info size={12}
|
|
46
|
-
|
|
47
|
-
<div className="absolute left-4 top-1/2 -translate-y-1/2 bg-ink text-canvas text-[10px] rounded px-2 py-1 shadow-lg whitespace-nowrap z-50 pointer-events-none">
|
|
48
|
-
Default model assigned when starting new sessions in this project
|
|
49
|
-
</div>
|
|
50
|
-
)}
|
|
51
|
-
</div>
|
|
71
|
+
<Info size={12} />
|
|
72
|
+
</span>
|
|
52
73
|
</div>
|
|
53
74
|
|
|
54
75
|
<div className="flex items-center justify-between gap-4 p-3 bg-paper border border-ink/15 rounded-lg">
|
|
55
|
-
<div>
|
|
56
|
-
<div className="text-xs font-medium text-ink">Project
|
|
57
|
-
<div className="text-[11px] text-ink/50">
|
|
76
|
+
<div className="min-w-0">
|
|
77
|
+
<div className="text-xs font-medium text-ink">Project model</div>
|
|
78
|
+
<div className="text-[11px] text-ink/50">
|
|
79
|
+
{models.length === 0
|
|
80
|
+
? 'No model catalog yet — connect a provider first.'
|
|
81
|
+
: 'Applied when the project starts a chat.'}
|
|
82
|
+
</div>
|
|
58
83
|
</div>
|
|
59
84
|
|
|
60
|
-
<div className="relative" ref={dropdownRef}>
|
|
85
|
+
<div className="relative shrink-0" ref={dropdownRef}>
|
|
61
86
|
<button
|
|
62
87
|
type="button"
|
|
63
|
-
onClick={() => setIsOpen(!
|
|
64
|
-
|
|
88
|
+
onClick={() => setIsOpen((open) => !open)}
|
|
89
|
+
disabled={disabled}
|
|
90
|
+
className="flex items-center gap-2 px-3 py-1.5 rounded-md border border-ink/20 hover:border-ink/40 bg-paper text-ink text-xs font-medium transition-colors cursor-pointer shadow-2xs max-w-[248px] disabled:opacity-50"
|
|
65
91
|
>
|
|
66
|
-
<Sparkles size={13} className="text-ink/70" />
|
|
67
|
-
<span>{
|
|
68
|
-
<ChevronDown size={13} className="text-ink/50
|
|
92
|
+
<Sparkles size={13} className="text-ink/70 shrink-0" />
|
|
93
|
+
<span className="truncate">{label}</span>
|
|
94
|
+
<ChevronDown size={13} className="text-ink/50 shrink-0" />
|
|
69
95
|
</button>
|
|
70
96
|
|
|
71
97
|
{isOpen && (
|
|
72
|
-
<div className="absolute right-0 mt-1 w-
|
|
73
|
-
|
|
98
|
+
<div className="absolute right-0 mt-1 w-[288px] bg-paper border border-ink/15 rounded-lg shadow-xl z-50 overflow-hidden">
|
|
99
|
+
<div className="flex items-center gap-1.5 px-2.5 py-2 border-b border-ink/10">
|
|
100
|
+
<Search size={12} className="text-ink/40 shrink-0" />
|
|
101
|
+
<input
|
|
102
|
+
autoFocus
|
|
103
|
+
value={search}
|
|
104
|
+
onInput={(e) => setSearch(e.currentTarget.value)}
|
|
105
|
+
placeholder="Search models…"
|
|
106
|
+
className="flex-1 bg-transparent text-xs text-ink outline-none placeholder:text-ink/35"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
<div className="max-h-64 scrollbar-overlay-container py-1">
|
|
74
111
|
<button
|
|
75
|
-
key={item}
|
|
76
112
|
type="button"
|
|
77
|
-
onClick={() =>
|
|
78
|
-
|
|
79
|
-
setIsOpen(false);
|
|
80
|
-
}}
|
|
81
|
-
className="w-full flex items-center justify-between px-3 py-1.5 text-left text-xs hover:bg-ink/5 transition-colors cursor-pointer"
|
|
113
|
+
onClick={() => pick(NO_PROJECT_MODEL)}
|
|
114
|
+
className="w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left text-xs hover:bg-ink/5 transition-colors cursor-pointer"
|
|
82
115
|
>
|
|
83
|
-
<span className={
|
|
84
|
-
|
|
116
|
+
<span className={model === NO_PROJECT_MODEL ? 'font-semibold text-ink' : 'text-ink/80'}>
|
|
117
|
+
Inherit Kabmo’s default
|
|
85
118
|
</span>
|
|
86
|
-
{
|
|
119
|
+
{model === NO_PROJECT_MODEL && <Check size={13} className="text-ink" />}
|
|
120
|
+
</button>
|
|
121
|
+
|
|
122
|
+
{filtered.length === 0 ? (
|
|
123
|
+
<p className="px-3 py-2 text-[11px] text-ink/50">
|
|
124
|
+
{models.length === 0 ? 'The catalog is empty.' : `No model matches “${search.trim()}”.`}
|
|
125
|
+
</p>
|
|
126
|
+
) : (
|
|
127
|
+
filtered.map((entry) => {
|
|
128
|
+
const value = projectModelValue({ provider: entry.provider, modelId: entry.id });
|
|
129
|
+
const isSelected = model === value;
|
|
130
|
+
return (
|
|
131
|
+
<button
|
|
132
|
+
key={value}
|
|
133
|
+
type="button"
|
|
134
|
+
onClick={() => pick(value)}
|
|
135
|
+
className="w-full flex items-center justify-between gap-2 px-3 py-1.5 text-left hover:bg-ink/5 transition-colors cursor-pointer"
|
|
136
|
+
>
|
|
137
|
+
<span className="min-w-0 flex flex-col">
|
|
138
|
+
<span className={`truncate text-xs ${isSelected ? 'font-semibold text-ink' : 'text-ink/85'}`}>
|
|
139
|
+
{entry.name}
|
|
140
|
+
</span>
|
|
141
|
+
<span className="truncate text-[10.5px] text-ink/45">{entry.provider}</span>
|
|
142
|
+
</span>
|
|
143
|
+
{isSelected && <Check size={13} className="text-ink shrink-0" />}
|
|
144
|
+
</button>
|
|
145
|
+
);
|
|
146
|
+
})
|
|
147
|
+
)}
|
|
148
|
+
</div>
|
|
149
|
+
|
|
150
|
+
{model !== NO_PROJECT_MODEL && (
|
|
151
|
+
<button
|
|
152
|
+
type="button"
|
|
153
|
+
onClick={() => pick(NO_PROJECT_MODEL)}
|
|
154
|
+
className="w-full flex items-center gap-1.5 px-3 py-2 border-t border-ink/10 text-[11px] text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer"
|
|
155
|
+
>
|
|
156
|
+
<X size={11} />
|
|
157
|
+
<span>Clear the project model</span>
|
|
87
158
|
</button>
|
|
88
|
-
)
|
|
159
|
+
)}
|
|
89
160
|
</div>
|
|
90
161
|
)}
|
|
91
162
|
</div>
|
|
@@ -1,26 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The project's name field.
|
|
8
|
+
*
|
|
9
|
+
* It COMMITS on blur and on Enter, and it reverts nothing on its own: the pane
|
|
10
|
+
* decides whether the name was accepted (the server enforces uniqueness
|
|
11
|
+
* case-insensitively) and the field follows the row it is given. Writing on
|
|
12
|
+
* every keystroke — what this used to do — fired one request per character, so
|
|
13
|
+
* a rename raced itself and the last response won regardless of order.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { useEffect, useState } from 'preact/hooks';
|
|
1
17
|
|
|
2
18
|
interface ProjectNameInputProps {
|
|
3
19
|
name: string;
|
|
4
|
-
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
onCommit: (name: string) => void;
|
|
5
22
|
}
|
|
6
23
|
|
|
7
|
-
export function ProjectNameInput({ name,
|
|
24
|
+
export function ProjectNameInput({ name, disabled = false, onCommit }: ProjectNameInputProps) {
|
|
25
|
+
const [draft, setDraft] = useState(name);
|
|
26
|
+
|
|
27
|
+
// The row is the truth: an accepted save trims, and a refused one reverts.
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
setDraft(name);
|
|
30
|
+
}, [name]);
|
|
31
|
+
|
|
32
|
+
const commit = () => {
|
|
33
|
+
const next = draft.trim();
|
|
34
|
+
if (!next) {
|
|
35
|
+
// An empty name is refused by the server; showing that as a field error
|
|
36
|
+
// is better than sending a write that cannot land.
|
|
37
|
+
setDraft(name);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (next === name) return;
|
|
41
|
+
onCommit(next);
|
|
42
|
+
};
|
|
43
|
+
|
|
8
44
|
return (
|
|
9
45
|
<div className="space-y-2">
|
|
10
|
-
<label
|
|
11
|
-
|
|
12
|
-
className="block text-xs font-semibold text-ink"
|
|
13
|
-
>
|
|
14
|
-
Project Name
|
|
46
|
+
<label htmlFor="project-name-input" className="block text-xs font-semibold text-ink">
|
|
47
|
+
Project name
|
|
15
48
|
</label>
|
|
16
49
|
<input
|
|
17
50
|
id="project-name-input"
|
|
18
51
|
type="text"
|
|
19
|
-
value={
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
52
|
+
value={draft}
|
|
53
|
+
disabled={disabled}
|
|
54
|
+
onChange={(e) => setDraft(e.currentTarget.value)}
|
|
55
|
+
onBlur={commit}
|
|
56
|
+
onKeyDown={(e) => {
|
|
57
|
+
if (e.key === 'Enter') {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
e.currentTarget.blur();
|
|
60
|
+
}
|
|
61
|
+
if (e.key === 'Escape') {
|
|
62
|
+
setDraft(name);
|
|
63
|
+
e.currentTarget.blur();
|
|
64
|
+
}
|
|
65
|
+
}}
|
|
66
|
+
placeholder="Enter project name…"
|
|
67
|
+
className="w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-xs font-medium text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"
|
|
23
68
|
/>
|
|
69
|
+
<p className="text-[11px] text-ink/50">Names are unique — the sidebar identifies a project by it.</p>
|
|
24
70
|
</div>
|
|
25
71
|
);
|
|
26
72
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The project's directory: one editable path, a Browse… picker, a Reveal
|
|
8
|
+
* action, and the state of the binding.
|
|
9
|
+
*
|
|
10
|
+
* The path used to be read-only text in the header, so a workspace bound to the
|
|
11
|
+
* wrong directory (or created before the directory existed) had to be deleted
|
|
12
|
+
* and re-created — losing its chats. It is editable here, committed on Enter or
|
|
13
|
+
* blur, and `~` is expanded server-side exactly like the New Workspace dialog.
|
|
14
|
+
*
|
|
15
|
+
* A folder that is NOT bound is a first-class state, not an error: it groups
|
|
16
|
+
* chats with no omp project behind it, and the field says so.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { useEffect, useState } from 'preact/hooks';
|
|
20
|
+
import { FolderOpen, Pencil } from 'lucide-preact';
|
|
21
|
+
import { FolderPicker } from '@/client/components/common/FolderPicker';
|
|
22
|
+
|
|
23
|
+
interface ProjectPathFieldProps {
|
|
24
|
+
path: string;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
onCommit: (path: string) => void;
|
|
27
|
+
/** Reveal the bound directory in the OS file manager. */
|
|
28
|
+
onReveal?: () => void;
|
|
29
|
+
/** True while the reveal request is in flight. */
|
|
30
|
+
isRevealing?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function ProjectPathField({
|
|
34
|
+
path,
|
|
35
|
+
disabled = false,
|
|
36
|
+
onCommit,
|
|
37
|
+
onReveal,
|
|
38
|
+
isRevealing = false,
|
|
39
|
+
}: ProjectPathFieldProps) {
|
|
40
|
+
const [draft, setDraft] = useState(path);
|
|
41
|
+
const [isPickerOpen, setIsPickerOpen] = useState(false);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
setDraft(path);
|
|
45
|
+
}, [path]);
|
|
46
|
+
|
|
47
|
+
const commit = (next: string) => {
|
|
48
|
+
const trimmed = next.trim();
|
|
49
|
+
if (trimmed === path) return;
|
|
50
|
+
onCommit(trimmed);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<div className="space-y-2">
|
|
55
|
+
<div className="flex items-center justify-between gap-2">
|
|
56
|
+
<label htmlFor="project-path-input" className="block text-xs font-semibold text-ink">
|
|
57
|
+
Project directory
|
|
58
|
+
</label>
|
|
59
|
+
<div className="flex items-center gap-1">
|
|
60
|
+
<button
|
|
61
|
+
type="button"
|
|
62
|
+
onClick={() => setIsPickerOpen(true)}
|
|
63
|
+
disabled={disabled}
|
|
64
|
+
className="inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-50"
|
|
65
|
+
>
|
|
66
|
+
<Pencil size={11} />
|
|
67
|
+
<span>Browse…</span>
|
|
68
|
+
</button>
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
onClick={onReveal}
|
|
72
|
+
disabled={disabled || !path || isRevealing}
|
|
73
|
+
title={path ? 'Reveal in the file manager' : 'This project is not bound to a directory'}
|
|
74
|
+
className="inline-flex items-center gap-1 px-2 py-1 rounded-md border border-ink/20 hover:border-ink/40 text-[11px] font-medium text-ink transition-colors cursor-pointer disabled:opacity-40"
|
|
75
|
+
>
|
|
76
|
+
<FolderOpen size={11} />
|
|
77
|
+
<span>Reveal</span>
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
|
|
82
|
+
<input
|
|
83
|
+
id="project-path-input"
|
|
84
|
+
type="text"
|
|
85
|
+
value={draft}
|
|
86
|
+
disabled={disabled}
|
|
87
|
+
onChange={(e) => setDraft(e.currentTarget.value)}
|
|
88
|
+
onBlur={() => commit(draft)}
|
|
89
|
+
onKeyDown={(e) => {
|
|
90
|
+
if (e.key === 'Enter') {
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
e.currentTarget.blur();
|
|
93
|
+
}
|
|
94
|
+
if (e.key === 'Escape') {
|
|
95
|
+
setDraft(path);
|
|
96
|
+
e.currentTarget.blur();
|
|
97
|
+
}
|
|
98
|
+
}}
|
|
99
|
+
placeholder="~ or /absolute/path — leave empty for an unbound grouping"
|
|
100
|
+
spellcheck={false}
|
|
101
|
+
className="w-full bg-paper border border-ink/20 rounded-md px-3 py-2 text-[11.5px] font-mono text-ink outline-none focus:border-ink/60 transition-colors shadow-2xs disabled:opacity-60"
|
|
102
|
+
/>
|
|
103
|
+
<p className="text-[11px] text-ink/50">
|
|
104
|
+
{path
|
|
105
|
+
? 'Sessions found under this directory appear in the project. One directory can belong to one project.'
|
|
106
|
+
: 'Not bound to a directory: this project groups chats only and discovers no sessions.'}
|
|
107
|
+
</p>
|
|
108
|
+
|
|
109
|
+
{isPickerOpen && (
|
|
110
|
+
<FolderPicker
|
|
111
|
+
initialPath={path || undefined}
|
|
112
|
+
onSelect={(picked) => {
|
|
113
|
+
setIsPickerOpen(false);
|
|
114
|
+
setDraft(picked);
|
|
115
|
+
commit(picked);
|
|
116
|
+
}}
|
|
117
|
+
onClose={() => setIsPickerOpen(false)}
|
|
118
|
+
/>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
);
|
|
122
|
+
}
|