@kabmo-labs/kabmo 0.16.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 +2 -2
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +417 -417
- package/dist/client/static/js/index-3ve31rzx.css +1 -0
- package/dist/client/static/js/{index-cpydmygd.js → index-rerjq5th.js} +839 -837
- package/package.json +1 -1
- 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/desktop-layout/TopNavbar.tsx +8 -50
- 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/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/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/fs/git-merge-conflict.test.ts +14 -1
- 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/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-fjnq2z2d.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
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
import { X } from 'lucide-preact';
|
|
2
2
|
import { BrandWordmark } from '@/client/components/common/brand-wordmark';
|
|
3
|
+
import { ServerControl } from '@/client/components/common/server-control';
|
|
3
4
|
import { titlebarPaddingLeft, titlebarPaddingRight } from '@/shared/lib/ui/titlebar';
|
|
4
5
|
import { dragRegionProps, titlebarInsetLeft } from '@/client/lib/desktop/titlebar';
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* The session drawer's title bar.
|
|
9
|
+
*
|
|
10
|
+
* Two controls on the right, and the second one is why this row exists in the
|
|
11
|
+
* shape it does:
|
|
12
|
+
*
|
|
13
|
+
* - the **server chip** — which server this window is on. A PHONE puts its
|
|
14
|
+
* server control here rather than in the chat header because this row has the
|
|
15
|
+
* room and that one does not: measured at 390px with a password set, the chat
|
|
16
|
+
* header has ~100px spare while the session title is the one thing that may
|
|
17
|
+
* give up width, and adding 40px there left the title 49px. This row has
|
|
18
|
+
* ~158px spare and truncates nothing to pay for the chip.
|
|
19
|
+
* - the **close** button.
|
|
20
|
+
*
|
|
21
|
+
* The chip is also what a DESKTOP shell window narrowed below the layout
|
|
22
|
+
* breakpoint relies on: it renders the phone layout, so its navbar — and the
|
|
23
|
+
* server control in it — is gone, and this is the only surface left.
|
|
24
|
+
*
|
|
25
|
+
* `viewLabel` says what the drawer is showing (Sessions, or a panel's name), so
|
|
26
|
+
* the chip is available in every view the drawer has.
|
|
27
|
+
*/
|
|
6
28
|
export function MobileSessionHeader({ onClose, viewLabel = 'Sessions' }: { onClose: () => void; viewLabel?: string }) {
|
|
7
29
|
return (
|
|
8
30
|
<div
|
|
@@ -22,23 +44,29 @@ export function MobileSessionHeader({ onClose, viewLabel = 'Sessions' }: { onClo
|
|
|
22
44
|
paddingTop: 'env(safe-area-inset-top, 0px)',
|
|
23
45
|
}}
|
|
24
46
|
>
|
|
25
|
-
<div className="flex items-center space-x-2.5 titlebar-no-drag">
|
|
26
|
-
<span className="font-bold text-sm tracking-tight flex items-center">
|
|
47
|
+
<div className="flex items-center space-x-2.5 titlebar-no-drag min-w-0">
|
|
48
|
+
<span className="font-bold text-sm tracking-tight flex items-center flex-shrink-0">
|
|
27
49
|
<BrandWordmark className="text-[16px]" />
|
|
28
50
|
</span>
|
|
29
|
-
<span className="text-ink/25 text-xs select-none">/</span>
|
|
30
|
-
<span className="text-[11px] font-semibold text-ink/60 uppercase tracking-wider font-mono">{viewLabel}</span>
|
|
51
|
+
<span className="text-ink/25 text-xs select-none flex-shrink-0">/</span>
|
|
52
|
+
<span className="text-[11px] font-semibold text-ink/60 uppercase tracking-wider font-mono truncate">{viewLabel}</span>
|
|
31
53
|
</div>
|
|
32
54
|
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
<div className="flex items-center gap-1 titlebar-no-drag flex-shrink-0">
|
|
56
|
+
{/* Draws nothing in a browser: `ServerControl` hides itself when no
|
|
57
|
+
native host is present, which is the same rule the desktop navbar
|
|
58
|
+
follows rather than a second one stated here. */}
|
|
59
|
+
<ServerControl variant="chip" />
|
|
60
|
+
<button
|
|
61
|
+
type="button"
|
|
62
|
+
onClick={onClose}
|
|
63
|
+
className="w-9 h-9 rounded-xl hover:bg-ink/5 active:bg-ink/10 text-ink flex items-center justify-center transition-colors cursor-pointer"
|
|
64
|
+
title="Close sidebar"
|
|
65
|
+
aria-label="Close sidebar"
|
|
66
|
+
>
|
|
67
|
+
<X size={19} strokeWidth={2} />
|
|
68
|
+
</button>
|
|
69
|
+
</div>
|
|
42
70
|
</div>
|
|
43
71
|
);
|
|
44
72
|
}
|
|
@@ -21,7 +21,7 @@ import { McpSettings } from '@/client/components/settings/categories/McpSettings
|
|
|
21
21
|
import { SkillSettings } from '@/client/components/settings/categories/SkillSettings';
|
|
22
22
|
import { PluginSettings } from '@/client/components/settings/categories/PluginSettings';
|
|
23
23
|
import { PanelPluginSettings } from '@/client/components/settings/categories/PanelPluginSettings';
|
|
24
|
-
import { SkillCatalogSettings } from '@/client/components/settings/categories/SkillCatalogSettings';
|
|
24
|
+
import { SkillCatalogSettings, type CatalogTab } from '@/client/components/settings/categories/SkillCatalogSettings';
|
|
25
25
|
import { OtherSettings } from '@/client/components/settings/categories/OtherSettings';
|
|
26
26
|
import { OmpSettings } from '@/client/components/settings/categories/OmpSettings';
|
|
27
27
|
import { TokenUsageSettings } from '@/client/components/settings/categories/TokenUsageSettings';
|
|
@@ -44,6 +44,9 @@ export function SettingsModal({
|
|
|
44
44
|
autoOpenAddProvider = false,
|
|
45
45
|
}: SettingsModalProps) {
|
|
46
46
|
const [activeCategory, setActiveCategory] = useState<SettingsCategoryId>(initialCategory);
|
|
47
|
+
// Which catalog tab a navigation asked for; the catalog itself owns the state
|
|
48
|
+
// once it is mounted, so this only seeds the mount.
|
|
49
|
+
const [catalogTab, setCatalogTab] = useState<CatalogTab>('browse');
|
|
47
50
|
const [autoOpenAdd, setAutoOpenAdd] = useState(autoOpenAddProvider);
|
|
48
51
|
const [searchQuery, setSearchQuery] = useState('');
|
|
49
52
|
const [isMobileDrilled, setIsMobileDrilled] = useState(false);
|
|
@@ -167,11 +170,14 @@ export function SettingsModal({
|
|
|
167
170
|
<SkillSettings
|
|
168
171
|
settings={settings}
|
|
169
172
|
onUpdate={handleUpdateSettings}
|
|
170
|
-
onNavigateToCatalog={() =>
|
|
173
|
+
onNavigateToCatalog={(tab) => {
|
|
174
|
+
setCatalogTab(tab ?? 'browse');
|
|
175
|
+
setActiveCategory('skills-catalog');
|
|
176
|
+
}}
|
|
171
177
|
/>
|
|
172
178
|
);
|
|
173
179
|
case 'skills-catalog':
|
|
174
|
-
return <SkillCatalogSettings />;
|
|
180
|
+
return <SkillCatalogSettings initialTab={catalogTab} />;
|
|
175
181
|
case 'omp':
|
|
176
182
|
return <OmpSettings settings={settings} onUpdate={handleUpdateSettings} />;
|
|
177
183
|
case 'usage':
|
|
@@ -13,13 +13,6 @@ export interface ProjectOption {
|
|
|
13
13
|
value?: string;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
/** Static project list shared by the agent, command, and skill sidebars. */
|
|
17
|
-
export const PROJECT_OPTIONS: ProjectOption[] = [
|
|
18
|
-
{ id: 'kabmo', name: 'kabmo', label: 'kabmo' },
|
|
19
|
-
{ id: 'workspace-edge', name: 'workspace-edge', label: 'workspace-edge' },
|
|
20
|
-
{ id: 'global', name: 'global config', label: 'Global (All Projects)' },
|
|
21
|
-
];
|
|
22
|
-
|
|
23
16
|
const optionValue = (option: ProjectOption): string => option.value ?? option.id;
|
|
24
17
|
|
|
25
18
|
/**
|
|
@@ -34,7 +27,11 @@ const defaultTriggerLabel = (options: ProjectOption[], selectedProject: string):
|
|
|
34
27
|
interface ProjectSelectorDropdownProps {
|
|
35
28
|
selectedProject: string;
|
|
36
29
|
onChangeProject: (value: string) => void;
|
|
37
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* The real workspace folders (`useWorkspaceRoots`). Defaults to NONE: this
|
|
32
|
+
* used to fall back to a hardcoded list of made-up projects, so a panel that
|
|
33
|
+
* forgot to pass its options offered scopes that resolved to nothing.
|
|
34
|
+
*/
|
|
38
35
|
options?: ProjectOption[];
|
|
39
36
|
/** Trigger label resolver; defaults to a `name` lookup by value. */
|
|
40
37
|
getTriggerLabel?: (options: ProjectOption[], selectedProject: string) => string;
|
|
@@ -50,7 +47,7 @@ interface ProjectSelectorDropdownProps {
|
|
|
50
47
|
export const ProjectSelectorDropdown: FunctionComponent<ProjectSelectorDropdownProps> = ({
|
|
51
48
|
selectedProject,
|
|
52
49
|
onChangeProject,
|
|
53
|
-
options =
|
|
50
|
+
options = [],
|
|
54
51
|
getTriggerLabel = defaultTriggerLabel,
|
|
55
52
|
variant = 'default',
|
|
56
53
|
}) => {
|
|
@@ -97,6 +94,19 @@ export const ProjectSelectorDropdown: FunctionComponent<ProjectSelectorDropdownP
|
|
|
97
94
|
);
|
|
98
95
|
});
|
|
99
96
|
|
|
97
|
+
// No projects at all: the trigger says why instead of opening an empty menu
|
|
98
|
+
// (or, worse, naming a scope that does not exist).
|
|
99
|
+
if (options.length === 0) {
|
|
100
|
+
return (
|
|
101
|
+
<div className={variant === 'compact' ? 'p-2.5 border-b border-ink/10' : 'p-3 border-b border-ink/10'}>
|
|
102
|
+
<div className="flex items-center gap-2 px-2.5 py-1.5 rounded-lg border border-dashed border-ink/15 text-[11px] text-ink/50">
|
|
103
|
+
<Folder size={13} className="text-ink/40 flex-shrink-0" />
|
|
104
|
+
<span className="truncate">No projects yet — add one in Settings → Projects</span>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
100
110
|
if (variant === 'compact') {
|
|
101
111
|
return (
|
|
102
112
|
<div className="p-2.5 border-b border-ink/10 relative" ref={dropdownRef}>
|
|
@@ -7,18 +7,33 @@ import { LoadingState } from '@/client/components/settings/LoadingState';
|
|
|
7
7
|
import { useCrudList } from '@/client/hooks/settings/crud-list';
|
|
8
8
|
import { useSettingsMasterDetail } from '@/client/hooks/settings/master-detail';
|
|
9
9
|
import { SettingsMasterDetail } from '@/client/components/settings/master-detail';
|
|
10
|
+
import { GLOBAL_SCOPE_ID, useWorkspaceRoots } from '@/client/hooks/settings/workspace-roots';
|
|
10
11
|
|
|
11
12
|
interface AgentSettingsProps {
|
|
12
13
|
settings: SettingsState;
|
|
13
14
|
onUpdate: (settings: SettingsState) => void;
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The Agents panel, scoped to one project at a time.
|
|
19
|
+
*
|
|
20
|
+
* The project picker used to offer three hardcoded names and do nothing with
|
|
21
|
+
* the choice — `selectedProject` was local state no request read, so
|
|
22
|
+
* `<workspace>/.omp/agents` was unreachable from the one screen whose job is
|
|
23
|
+
* listing agents. It now scopes the read through the same `?root=` contract the
|
|
24
|
+
* skills and commands panels use, so the three panels agree about what a
|
|
25
|
+
* project scope is.
|
|
26
|
+
*/
|
|
16
27
|
export const AgentSettings: FunctionComponent<AgentSettingsProps> = () => {
|
|
17
28
|
const masterDetail = useSettingsMasterDetail();
|
|
18
|
-
const
|
|
29
|
+
const roots = useWorkspaceRoots();
|
|
30
|
+
const [selectedRootId, setSelectedRootId] = useState<string>(GLOBAL_SCOPE_ID);
|
|
31
|
+
const query = roots.queryFor(selectedRootId);
|
|
32
|
+
|
|
19
33
|
const { items: agents, selectedId, selected: selectedAgent, isCreatingNew, isLoading, select, startCreate, save, remove } =
|
|
20
34
|
useCrudList<AgentItem>({
|
|
21
35
|
endpoint: '/api/settings/agents',
|
|
36
|
+
query,
|
|
22
37
|
listKey: 'agents',
|
|
23
38
|
bodyKey: 'agent',
|
|
24
39
|
messages: {
|
|
@@ -46,8 +61,11 @@ export const AgentSettings: FunctionComponent<AgentSettingsProps> = () => {
|
|
|
46
61
|
isBuiltIn: false,
|
|
47
62
|
};
|
|
48
63
|
|
|
64
|
+
// A different scope is a different list: `useCrudList` re-reads when the query
|
|
65
|
+
// changes and resolves its selection against the new list, so no extra reset
|
|
66
|
+
// is needed here.
|
|
49
67
|
if (isLoading) {
|
|
50
|
-
return <LoadingState>Loading agents
|
|
68
|
+
return <LoadingState>Loading agents…</LoadingState>;
|
|
51
69
|
}
|
|
52
70
|
|
|
53
71
|
return (
|
|
@@ -68,8 +86,9 @@ export const AgentSettings: FunctionComponent<AgentSettingsProps> = () => {
|
|
|
68
86
|
startCreate();
|
|
69
87
|
masterDetail.openDetail();
|
|
70
88
|
}}
|
|
71
|
-
selectedProject={
|
|
72
|
-
onChangeProject={
|
|
89
|
+
selectedProject={selectedRootId}
|
|
90
|
+
onChangeProject={setSelectedRootId}
|
|
91
|
+
projectOptions={roots.options}
|
|
73
92
|
/>
|
|
74
93
|
}
|
|
75
94
|
detail={
|
|
@@ -89,8 +108,10 @@ export const AgentSettings: FunctionComponent<AgentSettingsProps> = () => {
|
|
|
89
108
|
onDelete={remove}
|
|
90
109
|
/>
|
|
91
110
|
) : (
|
|
92
|
-
<div className="flex-1 flex items-center justify-center text-
|
|
93
|
-
|
|
111
|
+
<div className="flex-1 flex items-center justify-center px-6 text-center text-xs text-ink/40">
|
|
112
|
+
{roots.isWorkspace(selectedRootId)
|
|
113
|
+
? 'No agents in this project. Create one, or pick Global.'
|
|
114
|
+
: 'Select an agent or click + to create one.'}
|
|
94
115
|
</div>
|
|
95
116
|
)}
|
|
96
117
|
</div>
|
|
@@ -1,168 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { AccentColorOption, ProjectConfigItem } from '@/shared/types';
|
|
1
|
+
import { useState } from 'preact/hooks';
|
|
3
2
|
import { ProjectSidebarList } from '@/client/components/settings/categories/project-settings/SidebarList';
|
|
4
3
|
import { ProjectDetailsForm } from '@/client/components/settings/categories/project-settings/DetailsForm';
|
|
4
|
+
import { AddProjectModal } from '@/client/components/settings/categories/project-settings/AddProjectModal';
|
|
5
|
+
import { DeleteProjectModal } from '@/client/components/settings/categories/project-settings/DeleteProjectModal';
|
|
6
|
+
import { WorktreeSettings } from '@/client/components/settings/categories/project-settings/WorktreeSettings';
|
|
5
7
|
import { LoadingState } from '@/client/components/settings/LoadingState';
|
|
8
|
+
import { ToastStack } from '@/client/components/common/ToastStack';
|
|
9
|
+
import { SettingsMasterDetail } from '@/client/components/settings/master-detail';
|
|
6
10
|
import { useSettingsMasterDetail } from '@/client/hooks/settings/master-detail';
|
|
7
11
|
import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
|
|
8
|
-
import {
|
|
9
|
-
import { WorktreeSettings } from '@/client/components/settings/categories/project-settings/WorktreeSettings';
|
|
12
|
+
import { useProjectSettings } from '@/client/hooks/settings/projects';
|
|
10
13
|
import { useToasts } from '@/client/hooks/ui/toasts';
|
|
14
|
+
import type { ProjectConfigItem } from '@/shared/types';
|
|
11
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Settings → Projects.
|
|
18
|
+
*
|
|
19
|
+
* One pane owns every project fact: identity (name, directory, icon, accent),
|
|
20
|
+
* the default model a chat born here starts on, pinning, worktrees, and the
|
|
21
|
+
* destructive delete. Each is a real write with a real failure path — the pane
|
|
22
|
+
* reports what the server refused and puts the row back, instead of showing a
|
|
23
|
+
* value the server never accepted.
|
|
24
|
+
*/
|
|
12
25
|
export function ProjectSettings() {
|
|
13
26
|
const masterDetail = useSettingsMasterDetail();
|
|
14
|
-
const { pushToast } = useToasts();
|
|
15
|
-
const [projects, setProjects] = useState<ProjectConfigItem[]>([]);
|
|
16
|
-
const [availableModels, setAvailableModels] = useState<string[]>([]);
|
|
17
|
-
const [accentColorOptions, setAccentColorOptions] = useState<AccentColorOption[]>([]);
|
|
18
|
-
const [selectedProjectId, setSelectedProjectId] = useState<string>('proj-workspace');
|
|
19
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
27
|
+
const { toasts, pushToast, dismissToast } = useToasts();
|
|
20
28
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const response = await fetch('/api/settings/projects');
|
|
26
|
-
const data = await response.json();
|
|
27
|
-
if (!active) return;
|
|
28
|
-
if (Array.isArray(data?.projects)) {
|
|
29
|
-
setProjects(data.projects);
|
|
30
|
-
setSelectedProjectId((current) =>
|
|
31
|
-
data.projects.some((project: ProjectConfigItem) => project.id === current)
|
|
32
|
-
? current
|
|
33
|
-
: data.projects[0]?.id || '',
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
if (Array.isArray(data?.availableModels)) setAvailableModels(data.availableModels);
|
|
37
|
-
if (Array.isArray(data?.accentColorOptions)) setAccentColorOptions(data.accentColorOptions);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error('Failed to load projects from API:', error);
|
|
40
|
-
} finally {
|
|
41
|
-
if (active) setIsLoading(false);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
29
|
+
const [isAddOpen, setIsAddOpen] = useState(false);
|
|
30
|
+
const [deleteTarget, setDeleteTarget] = useState<ProjectConfigItem | null>(null);
|
|
31
|
+
const [deleteError, setDeleteError] = useState<string | null>(null);
|
|
32
|
+
const [revealingId, setRevealingId] = useState<string | null>(null);
|
|
44
33
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}, []);
|
|
34
|
+
const state = useProjectSettings((message) => pushToast(message, 'error', { duration: 7000 }));
|
|
35
|
+
const { folders } = useSidebarData();
|
|
48
36
|
|
|
49
|
-
const
|
|
50
|
-
project
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
) => {
|
|
54
|
-
if (project.folderId === undefined) return;
|
|
55
|
-
try {
|
|
56
|
-
const response = await fetch('/api/settings/projects', {
|
|
57
|
-
method: 'PATCH',
|
|
58
|
-
headers: { 'Content-Type': 'application/json' },
|
|
59
|
-
body: JSON.stringify({
|
|
60
|
-
project: {
|
|
61
|
-
folderId: project.folderId,
|
|
62
|
-
[field]: value === undefined ? null : value,
|
|
63
|
-
},
|
|
64
|
-
}),
|
|
65
|
-
});
|
|
66
|
-
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
console.error('Failed to save project settings:', error);
|
|
37
|
+
const reveal = async (project: ProjectConfigItem) => {
|
|
38
|
+
if (!project.path || project.folderId === undefined) {
|
|
39
|
+
pushToast('This project is not bound to a directory.', 'error');
|
|
40
|
+
return;
|
|
69
41
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const selectedProject = projects.find((p) => p.id === selectedProjectId) || projects[0];
|
|
73
|
-
|
|
74
|
-
const handleAddProject = async () => {
|
|
75
|
-
const newName = `Project ${projects.length + 1}`;
|
|
42
|
+
setRevealingId(project.id);
|
|
76
43
|
try {
|
|
77
|
-
const response = await fetch(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (typeof folderId !== 'number') throw new Error('Created workspace has no folder id');
|
|
86
|
-
|
|
87
|
-
const newProject: ProjectConfigItem = {
|
|
88
|
-
id: `folder-${folderId}`,
|
|
89
|
-
folderId,
|
|
90
|
-
name: data.folder.name,
|
|
91
|
-
path: data.folder.project_path || '',
|
|
92
|
-
model: 'Not selected',
|
|
93
|
-
accentColor: '',
|
|
94
|
-
icon: 'default',
|
|
95
|
-
isPinned: false,
|
|
96
|
-
isExpanded: true,
|
|
97
|
-
};
|
|
98
|
-
setProjects((current) => [...current, newProject]);
|
|
99
|
-
setSelectedProjectId(newProject.id);
|
|
100
|
-
// On a phone the new project's details are the point of adding it; the
|
|
101
|
-
// list pane would hide the row that was just created.
|
|
102
|
-
masterDetail.openDetail();
|
|
44
|
+
const response = await fetch(`/api/folders/${project.folderId}/open`, { method: 'POST' });
|
|
45
|
+
const data: unknown = await response.json().catch(() => null);
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
const reason = data && typeof data === 'object' && 'error' in data && typeof data.error === 'string'
|
|
48
|
+
? data.error
|
|
49
|
+
: `HTTP ${response.status}`;
|
|
50
|
+
throw new Error(reason);
|
|
51
|
+
}
|
|
103
52
|
} catch (error) {
|
|
104
|
-
|
|
53
|
+
pushToast(error instanceof Error ? error.message : String(error), 'error');
|
|
54
|
+
} finally {
|
|
55
|
+
setRevealingId(null);
|
|
105
56
|
}
|
|
106
57
|
};
|
|
107
58
|
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
|
|
59
|
+
const confirmDelete = async () => {
|
|
60
|
+
if (!deleteTarget) return;
|
|
61
|
+
setDeleteError(null);
|
|
111
62
|
try {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
116
|
-
const updated = projects.filter((project) => project.id !== targetId);
|
|
117
|
-
setProjects(updated);
|
|
118
|
-
setSelectedProjectId(updated[0]?.id || '');
|
|
63
|
+
await state.deleteProject(deleteTarget);
|
|
64
|
+
setDeleteTarget(null);
|
|
65
|
+
masterDetail.back();
|
|
119
66
|
} catch (error) {
|
|
120
|
-
|
|
67
|
+
// The dialog stays up with the server's reason: closing it would leave a
|
|
68
|
+
// row the user believes they removed sitting in the list.
|
|
69
|
+
setDeleteError(error instanceof Error ? error.message : String(error));
|
|
121
70
|
}
|
|
122
71
|
};
|
|
123
72
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
value: ProjectConfigItem[K]
|
|
127
|
-
) => {
|
|
128
|
-
if (!selectedProject) return;
|
|
129
|
-
setProjects((current) => current.map((project) => (
|
|
130
|
-
project.id === selectedProject.id ? { ...project, [field]: value } : project
|
|
131
|
-
)));
|
|
132
|
-
void persistProjectField(selectedProject, field, value);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
// Folder rows ride the `sidebar` topic, so every writer (this pane, the
|
|
136
|
-
// sidebar menu, another tab) reaches this list through one signal rather than
|
|
137
|
-
// through a window event each caller had to remember to dispatch.
|
|
138
|
-
const sidebarFolders = useSidebarData().folders;
|
|
139
|
-
const refreshKey = useMemo(
|
|
140
|
-
() => sidebarFolders.map((folder) => `${folder.id}:${folder.name}:${folder.model ?? ''}:${folder.icon ?? ''}:${folder.accentColor ?? ''}:${folder.isPinned ? 1 : 0}`).join('|'),
|
|
141
|
-
[sidebarFolders],
|
|
142
|
-
);
|
|
143
|
-
useEffect(() => {
|
|
144
|
-
if (!refreshKey) return;
|
|
145
|
-
void fetch('/api/settings/projects')
|
|
146
|
-
.then((response) => response.json())
|
|
147
|
-
.then((data) => {
|
|
148
|
-
if (Array.isArray(data?.projects)) {
|
|
149
|
-
setProjects(data.projects);
|
|
150
|
-
setSelectedProjectId((current) =>
|
|
151
|
-
data.projects.some((project: ProjectConfigItem) => project.id === current)
|
|
152
|
-
? current
|
|
153
|
-
: data.projects[0]?.id || '',
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
})
|
|
157
|
-
.catch((error: unknown) => {
|
|
158
|
-
console.error('Failed to refresh projects:', error);
|
|
159
|
-
});
|
|
160
|
-
}, [refreshKey]);
|
|
161
|
-
|
|
162
|
-
if (isLoading) {
|
|
163
|
-
return <LoadingState>Loading projects from database...</LoadingState>;
|
|
73
|
+
if (state.isLoading) {
|
|
74
|
+
return <LoadingState>Loading projects…</LoadingState>;
|
|
164
75
|
}
|
|
165
76
|
|
|
77
|
+
const selected = state.selected;
|
|
78
|
+
|
|
166
79
|
return (
|
|
167
80
|
<div className="w-full h-full flex flex-col overflow-hidden bg-paper text-ink">
|
|
168
81
|
<SettingsMasterDetail
|
|
@@ -171,39 +84,92 @@ export function ProjectSettings() {
|
|
|
171
84
|
listLabel="Projects"
|
|
172
85
|
list={
|
|
173
86
|
<ProjectSidebarList
|
|
174
|
-
projects={projects}
|
|
175
|
-
selectedProjectId={
|
|
87
|
+
projects={state.projects}
|
|
88
|
+
selectedProjectId={selected?.id ?? ''}
|
|
176
89
|
onSelectProject={(id) => {
|
|
177
|
-
|
|
90
|
+
state.select(id);
|
|
178
91
|
masterDetail.openDetail();
|
|
179
92
|
}}
|
|
180
|
-
onAddProject={
|
|
93
|
+
onAddProject={() => setIsAddOpen(true)}
|
|
94
|
+
onTogglePin={(project) => {
|
|
95
|
+
void state.updateField(project, 'isPinned', !project.isPinned);
|
|
96
|
+
}}
|
|
97
|
+
isAdding={state.isAdding}
|
|
98
|
+
folderFacts={folders}
|
|
99
|
+
loadError={state.loadError}
|
|
181
100
|
/>
|
|
182
101
|
}
|
|
183
102
|
detail={
|
|
184
|
-
|
|
185
|
-
<div className="flex flex-col">
|
|
103
|
+
selected ? (
|
|
104
|
+
<div className="flex-1 min-h-0 scrollbar-overlay-container flex flex-col">
|
|
186
105
|
<ProjectDetailsForm
|
|
187
|
-
project={
|
|
188
|
-
canDelete={projects.length > 1}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
accentColorOptions={accentColorOptions}
|
|
106
|
+
project={selected}
|
|
107
|
+
canDelete={state.projects.length > 1}
|
|
108
|
+
isDeleting={state.isDeleting && deleteTarget?.id === selected.id}
|
|
109
|
+
isRevealing={revealingId === selected.id}
|
|
110
|
+
models={state.models}
|
|
111
|
+
accentColorOptions={state.accentColorOptions}
|
|
112
|
+
onUpdateField={(field, value) => {
|
|
113
|
+
void state.updateField(selected, field, value);
|
|
114
|
+
}}
|
|
115
|
+
onUpdateFields={(fields) => {
|
|
116
|
+
void state.updateFields(selected, fields);
|
|
117
|
+
}}
|
|
118
|
+
onReveal={() => void reveal(selected)}
|
|
119
|
+
onDeleteProject={() => {
|
|
120
|
+
setDeleteError(null);
|
|
121
|
+
setDeleteTarget(selected);
|
|
122
|
+
}}
|
|
193
123
|
/>
|
|
194
124
|
{/* Worktrees belong to the PROJECT, not to a session: a create here
|
|
195
125
|
has no chat, and the next chat picks it from the composer. */}
|
|
196
|
-
<div className="border-t border-ink/10 px-
|
|
126
|
+
<div className="border-t border-ink/10 px-6 md:px-8 py-4">
|
|
197
127
|
<WorktreeSettings
|
|
198
|
-
root={
|
|
199
|
-
folderId={
|
|
128
|
+
root={selected.path || null}
|
|
129
|
+
folderId={selected.folderId ?? null}
|
|
200
130
|
onReport={(message, tone) => pushToast(message, tone ?? 'success', { duration: 6000 })}
|
|
201
131
|
/>
|
|
202
132
|
</div>
|
|
203
133
|
</div>
|
|
204
|
-
) :
|
|
134
|
+
) : (
|
|
135
|
+
<div className="flex-1 flex items-center justify-center px-6 text-center">
|
|
136
|
+
<div className="space-y-2">
|
|
137
|
+
<p className="text-xs text-ink/60">No project selected.</p>
|
|
138
|
+
<button
|
|
139
|
+
type="button"
|
|
140
|
+
onClick={() => setIsAddOpen(true)}
|
|
141
|
+
className="text-[11px] font-medium text-ink underline underline-offset-2 hover:no-underline cursor-pointer"
|
|
142
|
+
>
|
|
143
|
+
Add a project
|
|
144
|
+
</button>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
)
|
|
205
148
|
}
|
|
206
149
|
/>
|
|
150
|
+
|
|
151
|
+
<AddProjectModal
|
|
152
|
+
isOpen={isAddOpen}
|
|
153
|
+
isSaving={state.isAdding}
|
|
154
|
+
onClose={() => setIsAddOpen(false)}
|
|
155
|
+
onSubmit={async (input) => {
|
|
156
|
+
await state.addProject(input);
|
|
157
|
+
masterDetail.openDetail();
|
|
158
|
+
}}
|
|
159
|
+
/>
|
|
160
|
+
|
|
161
|
+
<DeleteProjectModal
|
|
162
|
+
project={deleteTarget}
|
|
163
|
+
isDeleting={state.isDeleting}
|
|
164
|
+
error={deleteError}
|
|
165
|
+
onClose={() => {
|
|
166
|
+
setDeleteTarget(null);
|
|
167
|
+
setDeleteError(null);
|
|
168
|
+
}}
|
|
169
|
+
onConfirm={() => void confirmDelete()}
|
|
170
|
+
/>
|
|
171
|
+
|
|
172
|
+
<ToastStack toasts={toasts} onDismiss={dismissToast} />
|
|
207
173
|
</div>
|
|
208
174
|
);
|
|
209
175
|
}
|