@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
|
@@ -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
|
}
|