@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
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The Files panel's BACKGROUND as a drop target — the listing root.
|
|
8
|
+
*
|
|
9
|
+
* It is a target like any other row: it is the only way to move an entry back
|
|
10
|
+
* out of a folder, since a drop on a file lands in that file's own directory
|
|
11
|
+
* instead. Two facts decide its shape:
|
|
12
|
+
*
|
|
13
|
+
* - **The tint is the POINTER, not the capability.** `accepts` is true from the
|
|
14
|
+
* instant a drag starts, so tinting on it painted the whole tree blue for the
|
|
15
|
+
* entire gesture and read as "every row is selected". The tint follows the
|
|
16
|
+
* pointer being on the background's own drop area.
|
|
17
|
+
* - **A row between two gaps claims `dragover` with `stopPropagation`**, so the
|
|
18
|
+
* reach that matters here is `dragenter`: it fires whenever the pointer moves
|
|
19
|
+
* off a row and back onto bare background. `dragleave` therefore ignores a
|
|
20
|
+
* move onto a CHILD — the pointer is still inside the scroller, and it is
|
|
21
|
+
* about to be claimed by the row it landed on.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import { useEffect, useState } from 'preact/hooks';
|
|
25
|
+
import type { TargetedDragEvent } from 'preact';
|
|
26
|
+
import type { ClipboardTarget, FileClipboard } from '@/client/hooks/workspace/file-clipboard';
|
|
27
|
+
|
|
28
|
+
export interface RootDropTargetOptions {
|
|
29
|
+
/** The row the tree is currently dragging, or null. */
|
|
30
|
+
dragging: ClipboardTarget | null;
|
|
31
|
+
clipboard: FileClipboard;
|
|
32
|
+
/** The listing root's own identity — `.` and a folder. */
|
|
33
|
+
target: ClipboardTarget;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface RootDropTarget {
|
|
37
|
+
/** Whether the background would accept the drag in flight. */
|
|
38
|
+
accepts: boolean;
|
|
39
|
+
/** Whether the pointer is on the background AND it would accept the drag. */
|
|
40
|
+
highlighted: boolean;
|
|
41
|
+
onDragEnter: () => void;
|
|
42
|
+
onDragLeave: (e: TargetedDragEvent<HTMLElement>) => void;
|
|
43
|
+
onDragOver: (e: TargetedDragEvent<HTMLElement>) => void;
|
|
44
|
+
onDrop: (e: TargetedDragEvent<HTMLElement>) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function useRootDropTarget({ dragging, clipboard, target }: RootDropTargetOptions): RootDropTarget {
|
|
48
|
+
const accepts = Boolean(dragging) && clipboard.moveRefusalFor(dragging!, target) === null;
|
|
49
|
+
const [hovered, setHovered] = useState(false);
|
|
50
|
+
// A drag that ended (dropped, cancelled, or left the window) leaves nothing
|
|
51
|
+
// hovering, and `dragleave` is not guaranteed for the element it ended on.
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!dragging) setHovered(false);
|
|
54
|
+
}, [dragging]);
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
accepts,
|
|
58
|
+
highlighted: hovered && accepts,
|
|
59
|
+
onDragEnter: () => {
|
|
60
|
+
if (dragging) setHovered(true);
|
|
61
|
+
},
|
|
62
|
+
onDragLeave: (e) => {
|
|
63
|
+
if (!e.currentTarget.contains(e.relatedTarget as Node | null)) setHovered(false);
|
|
64
|
+
},
|
|
65
|
+
onDragOver: (e) => {
|
|
66
|
+
if (!accepts) return;
|
|
67
|
+
e.preventDefault();
|
|
68
|
+
if (e.dataTransfer) e.dataTransfer.dropEffect = 'move';
|
|
69
|
+
},
|
|
70
|
+
onDrop: (e) => {
|
|
71
|
+
if (!accepts) return;
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
setHovered(false);
|
|
74
|
+
clipboard.move(dragging!, target);
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The collapsed folder chains the reader has UNFOLDED, and the expansion that
|
|
8
|
+
* makes the levels they expose visible.
|
|
9
|
+
*
|
|
10
|
+
* A chain row (`dev/src/main/code`) stands for four directories but is one row,
|
|
11
|
+
* so the three levels inside its label have no row: they cannot be dropped on,
|
|
12
|
+
* renamed, or created inside, and a drop on the one row lands in the deepest
|
|
13
|
+
* directory instead. Unfolding turns each level back into a row of its own
|
|
14
|
+
* (`unfoldChains` renders that projection), and this hook owns the set the
|
|
15
|
+
* projection reads plus the three halves that make it usable:
|
|
16
|
+
*
|
|
17
|
+
* - **The levels are OPENED**, because a row that hid the level below it would
|
|
18
|
+
* hide the destination one step further down. They are ordinary folders whose
|
|
19
|
+
* children are already projected, so opening them reads nothing.
|
|
20
|
+
* - **It is an explicit decision, reversed by Fold.** A hover that unfolded
|
|
21
|
+
* does not refold on its own — folding is what CLOSES the levels, so doing it
|
|
22
|
+
* silently would take a branch away from someone midway through a drag.
|
|
23
|
+
* - **It is keyed by the chain's DEEPEST path**, the identity the listing gives
|
|
24
|
+
* the row. A rename re-points that key and every level with it, so an
|
|
25
|
+
* unfolded chain stays unfolded across the rename instead of drawing rows at
|
|
26
|
+
* addresses that no longer exist.
|
|
27
|
+
*
|
|
28
|
+
* The set is tagged with the listing scope it was made in, the way every other
|
|
29
|
+
* path this panel caches is: paths are relative to the listed root, so a chain
|
|
30
|
+
* unfolded in one repository must not unfold a same-named row in the next.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import { useCallback, useState } from 'preact/hooks';
|
|
34
|
+
import { chainLevelPaths } from '@/shared/lib/fs/folder-chain';
|
|
35
|
+
import type { ClipboardTarget } from '@/client/hooks/workspace/file-clipboard';
|
|
36
|
+
|
|
37
|
+
/** The unfolded chains of one listing: deepest path → every level of the chain. */
|
|
38
|
+
interface UnfoldedChainsState {
|
|
39
|
+
scope: string;
|
|
40
|
+
chains: Map<string, string[]>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** A chain nothing has unfolded — the answer for every scope not yet touched. */
|
|
44
|
+
const NO_CHAINS: ReadonlySet<string> = new Set();
|
|
45
|
+
|
|
46
|
+
export interface UnfoldedChainsDeps {
|
|
47
|
+
/** The listing scope (`root\0repo`) this set belongs to. */
|
|
48
|
+
scope: string;
|
|
49
|
+
setExpandedPaths: (updater: (prev: Set<string>) => Set<string>) => void;
|
|
50
|
+
setStoredExpandedPaths: (value: string[]) => void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface UnfoldedChains {
|
|
54
|
+
/** The chain rows (by their deepest path) drawn as one row per directory. */
|
|
55
|
+
unfolded: ReadonlySet<string>;
|
|
56
|
+
/** Unfold the chain `target` names; a plain folder is left alone. */
|
|
57
|
+
unfold: (target: ClipboardTarget) => void;
|
|
58
|
+
/** Fold the chain identified by its deepest path back into the one row it is listed as. */
|
|
59
|
+
fold: (deepestPath: string) => void;
|
|
60
|
+
/** Re-point an unfolded chain at a renamed row, so it stays unfolded. */
|
|
61
|
+
rekey: (fromPath: string, toPath: string) => void;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function useUnfoldedChains({ scope, setExpandedPaths, setStoredExpandedPaths }: UnfoldedChainsDeps): UnfoldedChains {
|
|
65
|
+
const [state, setState] = useState<UnfoldedChainsState>({ scope, chains: new Map() });
|
|
66
|
+
|
|
67
|
+
const unfold = useCallback((target: ClipboardTarget) => {
|
|
68
|
+
const levels = chainLevelPaths(target.path, target.name);
|
|
69
|
+
if (!levels) return;
|
|
70
|
+
setState((prev) => {
|
|
71
|
+
const chains = prev.scope === scope ? prev.chains : new Map<string, string[]>();
|
|
72
|
+
// `dragover` fires on every pointer move, so the repeat has to cost
|
|
73
|
+
// nothing at all — not a new Map, not a render.
|
|
74
|
+
const known = chains.get(target.path);
|
|
75
|
+
if (known?.length === levels.length) return prev;
|
|
76
|
+
const next = new Map(chains);
|
|
77
|
+
next.set(target.path, levels);
|
|
78
|
+
return { scope, chains: next };
|
|
79
|
+
});
|
|
80
|
+
const exposed = levels.slice(0, -1);
|
|
81
|
+
setExpandedPaths((prev) => {
|
|
82
|
+
if (exposed.every((folder) => prev.has(folder))) return prev;
|
|
83
|
+
const next = new Set(prev);
|
|
84
|
+
for (const folder of exposed) next.add(folder);
|
|
85
|
+
setStoredExpandedPaths(Array.from(next));
|
|
86
|
+
return next;
|
|
87
|
+
});
|
|
88
|
+
}, [scope, setExpandedPaths, setStoredExpandedPaths]);
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Folding also CLOSES the levels it exposed: the chain row hides them again,
|
|
92
|
+
* so leaving them in the expansion set would have the next refresh read each
|
|
93
|
+
* of them from disk to fill in rows nothing draws.
|
|
94
|
+
*/
|
|
95
|
+
const fold = useCallback((deepestPath: string) => {
|
|
96
|
+
const levels = state.scope === scope ? state.chains.get(deepestPath) : undefined;
|
|
97
|
+
if (!levels) return;
|
|
98
|
+
const exposed = levels.slice(0, -1);
|
|
99
|
+
setState((prev) => {
|
|
100
|
+
if (prev.scope !== scope) return prev;
|
|
101
|
+
const next = new Map(prev.chains);
|
|
102
|
+
next.delete(deepestPath);
|
|
103
|
+
return { scope, chains: next };
|
|
104
|
+
});
|
|
105
|
+
setExpandedPaths((prev) => {
|
|
106
|
+
if (!exposed.some((folder) => prev.has(folder))) return prev;
|
|
107
|
+
const next = new Set(prev);
|
|
108
|
+
for (const folder of exposed) next.delete(folder);
|
|
109
|
+
setStoredExpandedPaths(Array.from(next));
|
|
110
|
+
return next;
|
|
111
|
+
});
|
|
112
|
+
}, [scope, state, setExpandedPaths, setStoredExpandedPaths]);
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A chain whose row was renamed keeps its unfold — unless the rename split the
|
|
116
|
+
* chain apart.
|
|
117
|
+
*
|
|
118
|
+
* A chain is a run of contiguous single-child directories, so only two renames
|
|
119
|
+
* preserve it: one of a level ABOVE the chain (every level shifts by the same
|
|
120
|
+
* prefix) and one of its DEEPEST directory (only the last level moves). A
|
|
121
|
+
* rename of a level in BETWEEN leaves `dev/` holding nothing and
|
|
122
|
+
* `dev2/src/main/` holding the rest, which is no longer one row — the entry is
|
|
123
|
+
* dropped rather than re-pointed at a chain that does not exist. The exposed
|
|
124
|
+
* levels are re-opened by name, because the expansion set is keyed by path and
|
|
125
|
+
* the rows that were open just moved.
|
|
126
|
+
*/
|
|
127
|
+
const rekey = useCallback((fromPath: string, toPath: string) => {
|
|
128
|
+
const chains = state.scope === scope ? state.chains : null;
|
|
129
|
+
if (!chains) return;
|
|
130
|
+
const next = new Map<string, string[]>();
|
|
131
|
+
const exposed: string[] = [];
|
|
132
|
+
let changed = false;
|
|
133
|
+
for (const [deepest, levels] of chains) {
|
|
134
|
+
const interior = levels.findIndex((path, index) => path === fromPath && index > 0 && index < levels.length - 1);
|
|
135
|
+
if (interior !== -1) {
|
|
136
|
+
changed = true;
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
const moved = levels.map((path) => path === fromPath
|
|
140
|
+
? toPath
|
|
141
|
+
: path.startsWith(`${fromPath}/`) ? `${toPath}${path.slice(fromPath.length)}`
|
|
142
|
+
: path);
|
|
143
|
+
const nextDeepest = moved[moved.length - 1]!;
|
|
144
|
+
if (nextDeepest !== deepest || moved.some((path, index) => path !== levels[index])) changed = true;
|
|
145
|
+
next.set(nextDeepest, moved);
|
|
146
|
+
exposed.push(...moved.slice(0, -1));
|
|
147
|
+
}
|
|
148
|
+
if (!changed) return;
|
|
149
|
+
setState({ scope, chains: next });
|
|
150
|
+
setExpandedPaths((prev) => {
|
|
151
|
+
if (exposed.every((folder) => prev.has(folder))) return prev;
|
|
152
|
+
const nextExpanded = new Set(prev);
|
|
153
|
+
for (const folder of exposed) nextExpanded.add(folder);
|
|
154
|
+
setStoredExpandedPaths(Array.from(nextExpanded));
|
|
155
|
+
return nextExpanded;
|
|
156
|
+
});
|
|
157
|
+
}, [scope, state, setExpandedPaths, setStoredExpandedPaths]);
|
|
158
|
+
|
|
159
|
+
return {
|
|
160
|
+
unfolded: state.scope === scope && state.chains.size > 0 ? new Set(state.chains.keys()) : NO_CHAINS,
|
|
161
|
+
unfold,
|
|
162
|
+
fold,
|
|
163
|
+
rekey,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
* wrong file later. The clock is the shell's own, and it runs on this machine.
|
|
39
39
|
*/
|
|
40
40
|
|
|
41
|
-
import { isDesktopShell } from '@/client/lib/
|
|
41
|
+
import { isDesktopShell } from '@/client/lib/shell/transport';
|
|
42
42
|
|
|
43
43
|
/** What the shell answers with. */
|
|
44
44
|
export interface ShellDroppedPaths {
|
|
@@ -29,6 +29,8 @@ import { afterEach, describe, expect, test } from 'bun:test';
|
|
|
29
29
|
type Shell = {
|
|
30
30
|
__kabmoCall?: (method: string, params?: Record<string, unknown>) => Promise<unknown>;
|
|
31
31
|
__kabmoDesktop?: Record<string, unknown>;
|
|
32
|
+
/** macOS and Linux post through this handler — the SAME name iOS uses. */
|
|
33
|
+
webkit?: { messageHandlers?: { kabmo?: { postMessage: (message: unknown) => void } } };
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
const scope = () => globalThis as unknown as { window?: Shell };
|
|
@@ -38,9 +40,16 @@ async function titlebar() {
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
function shell(identity: Record<string, unknown> | null) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
// The WebKit handler is part of the REAL desktop shape, not test decoration:
|
|
44
|
+
// macOS and Linux post over `window.webkit.messageHandlers.kabmo`, so a fixture
|
|
45
|
+
// without it let a phone-first host check read every desktop shell as `ios` and
|
|
46
|
+
// drop this inset — the wordmark was drawn under the traffic lights.
|
|
47
|
+
const window: Shell = {
|
|
48
|
+
__kabmoCall: async () => null,
|
|
49
|
+
webkit: { messageHandlers: { kabmo: { postMessage: () => {} } } },
|
|
50
|
+
};
|
|
51
|
+
if (identity !== null) window.__kabmoDesktop = identity;
|
|
52
|
+
scope().window = window;
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
const MACOS = { platform: 'macos', shellVersion: '0.1.0', overlayTitlebar: true, trafficLightInset: '5rem' };
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
* identity, and the answer is the caller's own padding rather than a guess.
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
|
-
import { isDesktopShell } from '@/client/lib/
|
|
39
|
+
import { isDesktopShell } from '@/client/lib/shell/transport';
|
|
40
40
|
|
|
41
41
|
/** Width macOS reserves for its traffic lights, plus the gap after them. */
|
|
42
42
|
export const TRAFFIC_LIGHT_INSET = '5rem';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The commands only the DESKTOP shells answer: their identity, their window
|
|
8
|
+
* verbs, and installing their own update.
|
|
9
|
+
*
|
|
10
|
+
* A phone has none of these. It draws no window chrome (its buttons are the
|
|
11
|
+
* system's), it cannot replace the app it runs inside, and its identity arrives
|
|
12
|
+
* on the User-Agent rather than over a bridge. Keeping them out of
|
|
13
|
+
* `transport.ts` is what lets that module stay about one question — "which shell
|
|
14
|
+
* is this?" — instead of about every verb five shells do not share.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { callShell, isDesktopShell } from '@/client/lib/shell/transport';
|
|
18
|
+
|
|
19
|
+
/** What the desktop shells report about themselves. */
|
|
20
|
+
export interface DesktopInfo {
|
|
21
|
+
platform: string;
|
|
22
|
+
shellVersion: string;
|
|
23
|
+
/**
|
|
24
|
+
* The machine's architecture, in the canonical vocabulary (`arm64` / `x64`).
|
|
25
|
+
*
|
|
26
|
+
* Every desktop artifact is per-architecture, so without this the console can
|
|
27
|
+
* only offer the release page. Absent on a shell too old to report it, which
|
|
28
|
+
* degrades the offer to that page rather than breaking it.
|
|
29
|
+
*/
|
|
30
|
+
arch?: string;
|
|
31
|
+
/** True when the shell hides the native title bar and the page draws it. */
|
|
32
|
+
overlayTitlebar: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* macOS: the width of the traffic lights, which float over the page's LEFT
|
|
35
|
+
* edge. Absent on a platform whose window controls are not on the left.
|
|
36
|
+
*/
|
|
37
|
+
trafficLightInset?: string;
|
|
38
|
+
/**
|
|
39
|
+
* True when the shell is borderless and has NO controls of its own, so the page
|
|
40
|
+
* must draw minimise / maximise / close.
|
|
41
|
+
*
|
|
42
|
+
* Windows and Linux. macOS gets its traffic lights from the system over a
|
|
43
|
+
* full-size content view; a borderless Windows window has nothing at all, and
|
|
44
|
+
* the webview there is an HWND — a WPF element cannot be drawn on top of it
|
|
45
|
+
* (the airspace problem) — so the page is the only surface that can. Linux could
|
|
46
|
+
* draw native buttons in a `GtkOverlay` (measured: an overlay child does receive
|
|
47
|
+
* clicks over a WebView), but the page's set already exists, is tested, and is
|
|
48
|
+
* the one every other shell's users see.
|
|
49
|
+
*/
|
|
50
|
+
windowControls?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
declare global {
|
|
54
|
+
interface Window {
|
|
55
|
+
__kabmoDesktop?: DesktopInfo;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function desktopInfo(): Promise<DesktopInfo | null> {
|
|
60
|
+
if (!isDesktopShell()) return Promise.resolve(null);
|
|
61
|
+
const injected = typeof window === 'undefined' ? undefined : window.__kabmoDesktop;
|
|
62
|
+
// The shell injects this before the page's first script, so the navbar's first
|
|
63
|
+
// paint is already correct; the command is only a fallback for a shell that did
|
|
64
|
+
// not (an older build).
|
|
65
|
+
if (injected) return Promise.resolve(injected);
|
|
66
|
+
return callShell<DesktopInfo>('desktop_info');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Minimise, maximise/restore and close, for a shell that draws no controls. */
|
|
70
|
+
export function windowMinimize(): Promise<void> {
|
|
71
|
+
return callShell<void>('window_minimize');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function windowToggleMaximize(): Promise<void> {
|
|
75
|
+
return callShell<void>('window_maximize');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function windowClose(): Promise<void> {
|
|
79
|
+
return callShell<void>('window_close');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* What the shell did with an update it was handed.
|
|
84
|
+
*
|
|
85
|
+
* The shell owns the whole run — download, verify, replace, relaunch — because
|
|
86
|
+
* only it can do any of those things: a page cannot replace the executable it is
|
|
87
|
+
* running inside, and a page's "download" leaves a file in a folder the user has
|
|
88
|
+
* to find. This is the report it sends back.
|
|
89
|
+
*
|
|
90
|
+
* `relaunching` is the honest terminal state on success: the shell is about to
|
|
91
|
+
* quit, so a caller that keeps a spinner going is describing a page that is
|
|
92
|
+
* already gone.
|
|
93
|
+
*/
|
|
94
|
+
export interface ShellUpdateOutcome {
|
|
95
|
+
success: boolean;
|
|
96
|
+
/** The version the shell installed, when it could read one. */
|
|
97
|
+
version?: string | null;
|
|
98
|
+
/** A sentence for the user — the shell's own, never a generic failure. */
|
|
99
|
+
message: string;
|
|
100
|
+
relaunching?: boolean;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Ask the shell to install the build it just offered.
|
|
105
|
+
*
|
|
106
|
+
* `url` and `version` are the console's answer, passed through rather than
|
|
107
|
+
* re-derived: the shell has no release list of its own, and asking it to fetch one
|
|
108
|
+
* would be a second reader of the same GitHub endpoint.
|
|
109
|
+
*
|
|
110
|
+
* The shell VERIFIES the bytes before installing them (the platform's own check —
|
|
111
|
+
* a code signature, an archive shape, a version floor). A console that is
|
|
112
|
+
* compromised can therefore make the shell download, but not make it run
|
|
113
|
+
* something the platform will not vouch for.
|
|
114
|
+
*/
|
|
115
|
+
export function applyShellUpdate(url: string, version: string): Promise<ShellUpdateOutcome> {
|
|
116
|
+
return callShell<ShellUpdateOutcome>('update_apply', { url, version });
|
|
117
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The shell's server list, as the console reads and changes it.
|
|
8
|
+
*
|
|
9
|
+
* The same four commands work in all five shells. Two more — `servers_start` and
|
|
10
|
+
* `servers_stop` — exist only where a shell can own a child process (the desktop
|
|
11
|
+
* trio). A phone refuses them, and the panel knows not to offer them from
|
|
12
|
+
* `startable: false` in the state rather than from a user agent.
|
|
13
|
+
*
|
|
14
|
+
* Nothing here decides which shell answered; that is `transport.ts`.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { callShell } from '@/client/lib/shell/transport';
|
|
18
|
+
|
|
19
|
+
/** One server in the shell's list, or one found on this machine. */
|
|
20
|
+
export interface ShellServer {
|
|
21
|
+
id: string;
|
|
22
|
+
label: string;
|
|
23
|
+
url: string;
|
|
24
|
+
kind: 'remote' | 'managed';
|
|
25
|
+
port?: number;
|
|
26
|
+
running: boolean;
|
|
27
|
+
/** This shell started it (as opposed to a server found on the machine). */
|
|
28
|
+
owned: boolean;
|
|
29
|
+
version?: string;
|
|
30
|
+
mode?: string;
|
|
31
|
+
pid?: number;
|
|
32
|
+
startedAt?: string;
|
|
33
|
+
/** `stored` for the list, `record` for a local instance found on disk. */
|
|
34
|
+
source: 'stored' | 'record';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ShellServersState {
|
|
38
|
+
entries: ShellServer[];
|
|
39
|
+
/** Local instances this shell did NOT start — a `kabmo serve`, a dev server. */
|
|
40
|
+
detected: ShellServer[];
|
|
41
|
+
activeId?: string;
|
|
42
|
+
activeUrl?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Whether this shell can start a server of its own. Absent reads as `true`, so
|
|
45
|
+
* the three desktop shells (which all can) need no change; a phone answers
|
|
46
|
+
* `false` and the panel then says nothing about starting one.
|
|
47
|
+
*/
|
|
48
|
+
startable?: boolean;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function readServers(): Promise<ShellServersState> {
|
|
52
|
+
return callShell<ShellServersState>('servers_state');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function addRemoteServer(label: string, url: string): Promise<ShellServersState> {
|
|
56
|
+
return callShell<ShellServersState>('servers_add', { label, url });
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function removeServer(id: string): Promise<ShellServersState> {
|
|
60
|
+
return callShell<ShellServersState>('servers_remove', { id });
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Point the window at a server. The shell navigates, so this page goes away. */
|
|
64
|
+
export function activateServer(id: string): Promise<ShellServersState> {
|
|
65
|
+
return callShell<ShellServersState>('servers_activate', { id });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Start a local server as the shell's child, then navigate to it. */
|
|
69
|
+
export function startLocalServer(port?: number, label?: string): Promise<ShellServersState> {
|
|
70
|
+
return callShell<ShellServersState>('servers_start', { port: port ?? null, label: label ?? null });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function stopLocalServer(id: string): Promise<ShellServersState> {
|
|
74
|
+
return callShell<ShellServersState>('servers_stop', { id });
|
|
75
|
+
}
|