@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
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The bridge, driven through the transport the macOS shell installs.
|
|
3
|
-
*
|
|
4
|
-
* The interesting failures are about what the page can tell apart: a browser has
|
|
5
|
-
* no shell at all, a shell announces itself before the first render, and a
|
|
6
|
-
* refused command keeps the shell's own sentence. None of that is visible in the
|
|
7
|
-
* panel's markup — a control that never works looks exactly like one that does
|
|
8
|
-
* until it is pressed.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { describe, expect, test, beforeEach } from 'bun:test';
|
|
12
|
-
|
|
13
|
-
type Reply = (id: number, ok: boolean, payload: unknown) => void;
|
|
14
|
-
|
|
15
|
-
interface ShellWindow {
|
|
16
|
-
__kabmoCall?: (method: string, params?: Record<string, unknown>) => Promise<unknown>;
|
|
17
|
-
__kabmoDesktop?: unknown;
|
|
18
|
-
__kabmoReply?: Reply;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const shell = () => globalThis as unknown as { window?: ShellWindow };
|
|
22
|
-
|
|
23
|
-
describe('desktop bridge', () => {
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
delete shell().window;
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('a browser has no shell, and every call refuses', async () => {
|
|
29
|
-
shell().window = {};
|
|
30
|
-
const bridge = await import('@/client/lib/desktop/bridge');
|
|
31
|
-
expect(bridge.isDesktopShell()).toBe(false);
|
|
32
|
-
expect(await bridge.desktopInfo()).toBeNull();
|
|
33
|
-
await expect(bridge.readServers()).rejects.toThrow('Not running inside the Kabmo desktop shell.');
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('the injected identity is readable before any command runs', async () => {
|
|
37
|
-
shell().window = {
|
|
38
|
-
__kabmoCall: async () => null,
|
|
39
|
-
__kabmoDesktop: { platform: 'macos', shellVersion: '0.1.0', overlayTitlebar: true, trafficLightInset: '5rem' },
|
|
40
|
-
};
|
|
41
|
-
const bridge = await import('@/client/lib/desktop/bridge');
|
|
42
|
-
expect(bridge.isDesktopShell()).toBe(true);
|
|
43
|
-
const info = await bridge.desktopInfo();
|
|
44
|
-
expect(info?.overlayTitlebar).toBe(true);
|
|
45
|
-
expect(info?.trafficLightInset).toBe('5rem');
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('a command answers through __kabmoCall', async () => {
|
|
49
|
-
const seen: string[] = [];
|
|
50
|
-
shell().window = {
|
|
51
|
-
__kabmoCall: async (method) => {
|
|
52
|
-
seen.push(method);
|
|
53
|
-
return { entries: [], detected: [], activeId: 'local:1' };
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
const bridge = await import('@/client/lib/desktop/bridge');
|
|
57
|
-
const state = await bridge.readServers();
|
|
58
|
-
expect(seen).toEqual(['servers_state']);
|
|
59
|
-
expect(state.activeId).toBe('local:1');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The shell sends its own sentence, which is what the UI shows. Stripping a
|
|
64
|
-
* prefix would eat the first word of a message that starts with "Error".
|
|
65
|
-
*/
|
|
66
|
-
test('a refused command keeps the shell’s own sentence, unstripped', async () => {
|
|
67
|
-
const bridge = await import('@/client/lib/desktop/bridge');
|
|
68
|
-
expect(bridge.bridgeError(new Error('Use the server’s root address — a base path is not supported.'))).toBe(
|
|
69
|
-
'Use the server’s root address — a base path is not supported.',
|
|
70
|
-
);
|
|
71
|
-
expect(bridge.bridgeError('plain')).toBe('plain');
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The desktop shell's bridge, and the reason every other module asks this one
|
|
8
|
-
* whether it is running inside the shell.
|
|
9
|
-
*
|
|
10
|
-
* THREE shells install the same transport, and that is the point of this module:
|
|
11
|
-
*
|
|
12
|
-
* - `packages/macos` (macOS, Swift + WKWebView)
|
|
13
|
-
* - `packages/windows` (.NET + WPF + WebView2)
|
|
14
|
-
* - `packages/linux` (Rust + GTK 3 + WebKitGTK 4.1)
|
|
15
|
-
*
|
|
16
|
-
* Each installs ONE transport before the page's own scripts run:
|
|
17
|
-
* `window.__kabmoCall(method, params)` posts `{ id, method, params }` to a host
|
|
18
|
-
* message handler named `kabmo`, and the shell answers by evaluating
|
|
19
|
-
* `window.__kabmoReply(id, ok, payload)`. There is no capability file and no
|
|
20
|
-
* per-origin allowance — the shell owns the webview, so the page cannot be
|
|
21
|
-
* anything but one this window chose to load.
|
|
22
|
-
*
|
|
23
|
-
* This module must be safe in a BROWSER too: every function rejects with "not
|
|
24
|
-
* inside the shell" when there is no bridge, and the navbar draws no server
|
|
25
|
-
* control at all. A browser tab has no shell to control, and a control that
|
|
26
|
-
* opened onto "not available" would be a button that never works.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/** What the shell reports about itself. */
|
|
30
|
-
export interface DesktopInfo {
|
|
31
|
-
platform: string;
|
|
32
|
-
shellVersion: string;
|
|
33
|
-
/**
|
|
34
|
-
* The machine's architecture, in the canonical vocabulary (`arm64` / `x64`).
|
|
35
|
-
*
|
|
36
|
-
* Every desktop artifact is per-architecture, so without this the console can
|
|
37
|
-
* only offer the release page. Absent on a shell too old to report it, which
|
|
38
|
-
* degrades the offer to that page rather than breaking it.
|
|
39
|
-
*/
|
|
40
|
-
arch?: string;
|
|
41
|
-
/** True when the shell hides the native title bar and the page draws it. */
|
|
42
|
-
overlayTitlebar: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* macOS: the width of the traffic lights, which float over the page's LEFT
|
|
45
|
-
* edge. Absent on a platform whose window controls are not on the left.
|
|
46
|
-
*/
|
|
47
|
-
trafficLightInset?: string;
|
|
48
|
-
/**
|
|
49
|
-
* True when the shell is borderless and has NO controls of its own, so the
|
|
50
|
-
* page must draw minimise / maximise / close.
|
|
51
|
-
*
|
|
52
|
-
* Windows and Linux. macOS gets its traffic lights from the system over a
|
|
53
|
-
* full-size content view; a borderless Windows window has nothing at all, and
|
|
54
|
-
* the webview there is an HWND — a WPF element cannot be drawn on top of it
|
|
55
|
-
* (the airspace problem) — so the page is the only surface that can. Linux
|
|
56
|
-
* could draw native buttons in a `GtkOverlay` (measured: an overlay child does
|
|
57
|
-
* receive clicks over a WebView), but the page's set already exists, is tested,
|
|
58
|
-
* and is the one every other shell's users see.
|
|
59
|
-
*/
|
|
60
|
-
windowControls?: boolean;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** One server in the shell's list, or one found on this machine. */
|
|
64
|
-
export interface DesktopServer {
|
|
65
|
-
id: string;
|
|
66
|
-
label: string;
|
|
67
|
-
url: string;
|
|
68
|
-
kind: 'remote' | 'managed';
|
|
69
|
-
port?: number;
|
|
70
|
-
running: boolean;
|
|
71
|
-
/** This shell started it (as opposed to a server found on the machine). */
|
|
72
|
-
owned: boolean;
|
|
73
|
-
version?: string;
|
|
74
|
-
mode?: string;
|
|
75
|
-
pid?: number;
|
|
76
|
-
startedAt?: string;
|
|
77
|
-
/** `stored` for the list, `record` for a local instance found on disk. */
|
|
78
|
-
source: 'stored' | 'record';
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export interface DesktopServersState {
|
|
82
|
-
entries: DesktopServer[];
|
|
83
|
-
/** Local instances this shell did NOT start — a `kabmo serve`, a dev server. */
|
|
84
|
-
detected: DesktopServer[];
|
|
85
|
-
activeId?: string;
|
|
86
|
-
activeUrl?: string;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
declare global {
|
|
90
|
-
interface Window {
|
|
91
|
-
__kabmoCall?: (method: string, params?: Record<string, unknown>) => Promise<unknown>;
|
|
92
|
-
__kabmoDesktop?: DesktopInfo;
|
|
93
|
-
__kabmoReply?: (id: number, ok: boolean, payload: unknown) => void;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** True when this page is inside the desktop shell. */
|
|
98
|
-
export function isDesktopShell(): boolean {
|
|
99
|
-
return typeof window !== 'undefined' && typeof window.__kabmoCall === 'function';
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
async function call<T>(method: string, params: Record<string, unknown> = {}): Promise<T> {
|
|
103
|
-
const invoke = typeof window === 'undefined' ? undefined : window.__kabmoCall;
|
|
104
|
-
if (!invoke) throw new Error('Not running inside the Kabmo desktop shell.');
|
|
105
|
-
return (await invoke(method, params)) as T;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export function desktopInfo(): Promise<DesktopInfo | null> {
|
|
109
|
-
if (!isDesktopShell()) return Promise.resolve(null);
|
|
110
|
-
const injected = typeof window === 'undefined' ? undefined : window.__kabmoDesktop;
|
|
111
|
-
// The shell injects this before the page's first script, so the navbar's first
|
|
112
|
-
// paint is already correct; the command is only a fallback for a shell that
|
|
113
|
-
// did not (an older build).
|
|
114
|
-
if (injected) return Promise.resolve(injected);
|
|
115
|
-
return call<DesktopInfo>('desktop_info');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export function readServers(): Promise<DesktopServersState> {
|
|
119
|
-
return call<DesktopServersState>('servers_state');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function addRemoteServer(label: string, url: string): Promise<DesktopServersState> {
|
|
123
|
-
return call<DesktopServersState>('servers_add', { label, url });
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function removeServer(id: string): Promise<DesktopServersState> {
|
|
127
|
-
return call<DesktopServersState>('servers_remove', { id });
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/** Point the window at a server. The shell navigates, so this page goes away. */
|
|
131
|
-
export function activateServer(id: string): Promise<DesktopServersState> {
|
|
132
|
-
return call<DesktopServersState>('servers_activate', { id });
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** Start a local server as the shell's child, then navigate to it. */
|
|
136
|
-
export function startLocalServer(port?: number, label?: string): Promise<DesktopServersState> {
|
|
137
|
-
return call<DesktopServersState>('servers_start', { port: port ?? null, label: label ?? null });
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export function stopLocalServer(id: string): Promise<DesktopServersState> {
|
|
141
|
-
return call<DesktopServersState>('servers_stop', { id });
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* A refused command's message.
|
|
146
|
-
*
|
|
147
|
-
* The shell sends its own sentence (a refused URL, a server that exited), which
|
|
148
|
-
* is what the UI shows. Nothing is stripped: a message that genuinely starts with
|
|
149
|
-
* "Error" would lose its first word.
|
|
150
|
-
*/
|
|
151
|
-
export function bridgeError(error: unknown): string {
|
|
152
|
-
return error instanceof Error ? error.message : String(error);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/** Minimise, maximise/restore and close, for a shell that draws no controls. */
|
|
156
|
-
export function windowMinimize(): Promise<void> {
|
|
157
|
-
return call<void>('window_minimize');
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export function windowToggleMaximize(): Promise<void> {
|
|
161
|
-
return call<void>('window_maximize');
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
export function windowClose(): Promise<void> {
|
|
165
|
-
return call<void>('window_close');
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* What the shell did with an update it was handed.
|
|
170
|
-
*
|
|
171
|
-
* The shell owns the whole run — download, verify, replace, relaunch — because
|
|
172
|
-
* only it can do any of those things: a page cannot replace the executable it is
|
|
173
|
-
* running inside, and a page's "download" leaves a file in a folder the user has
|
|
174
|
-
* to find. This is the report it sends back.
|
|
175
|
-
*
|
|
176
|
-
* `relaunching` is the honest terminal state on success: the shell is about to
|
|
177
|
-
* quit, so a caller that keeps a spinner going is describing a page that is
|
|
178
|
-
* already gone.
|
|
179
|
-
*/
|
|
180
|
-
export interface ShellUpdateOutcome {
|
|
181
|
-
success: boolean;
|
|
182
|
-
/** The version the shell installed, when it could read one. */
|
|
183
|
-
version?: string | null;
|
|
184
|
-
/** A sentence for the user — the shell's own, never a generic failure. */
|
|
185
|
-
message: string;
|
|
186
|
-
relaunching?: boolean;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Ask the shell to install the build it just offered.
|
|
191
|
-
*
|
|
192
|
-
* `url` and `version` are the console's answer, passed through rather than
|
|
193
|
-
* re-derived: the shell has no release list of its own, and asking it to fetch
|
|
194
|
-
* one would be a second reader of the same GitHub endpoint.
|
|
195
|
-
*
|
|
196
|
-
* The shell VERIFIES the bytes before installing them (the platform's own check —
|
|
197
|
-
* a code signature, an archive shape, a version floor). A console that is
|
|
198
|
-
* compromised can therefore make the shell download, but not make it run
|
|
199
|
-
* something the platform will not vouch for.
|
|
200
|
-
*/
|
|
201
|
-
export function applyShellUpdate(url: string, version: string): Promise<ShellUpdateOutcome> {
|
|
202
|
-
return call<ShellUpdateOutcome>('update_apply', { url, version });
|
|
203
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* What an indent guide means.
|
|
8
|
-
*
|
|
9
|
-
* Three rules, and each is a case a naive version gets wrong: one guide per indented
|
|
10
|
-
* line (not one per column), none on a blank line (its whitespace is trailing noise),
|
|
11
|
-
* and none past the column cap (a minified file is one huge line).
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
import { describe, expect, test } from 'bun:test';
|
|
15
|
-
|
|
16
|
-
import { MAX_GUIDE_COLUMNS, guideColumn, guideColumns } from '@/shared/lib/code/editor/indent-guide-rule';
|
|
17
|
-
|
|
18
|
-
describe('guideColumn', () => {
|
|
19
|
-
test('an indented line gets one guide, at the first level', () => {
|
|
20
|
-
expect(guideColumn(' const a = 1;', 2)).toBe(2);
|
|
21
|
-
expect(guideColumn(' const a = 1;', 2)).toBe(2);
|
|
22
|
-
expect(guideColumn(' const a = 1;', 4)).toBe(4);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test('a line at column 0 gets none', () => {
|
|
26
|
-
expect(guideColumn('const a = 1;', 2)).toBeNull();
|
|
27
|
-
expect(guideColumn(' const a = 1;', 2)).toBeNull();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('a blank line gets none, whatever its whitespace', () => {
|
|
31
|
-
// Its indentation is trailing whitespace, not structure — a guide there would
|
|
32
|
-
// draw a rule through the gap that makes a block readable.
|
|
33
|
-
expect(guideColumn('', 2)).toBeNull();
|
|
34
|
-
expect(guideColumn(' ', 2)).toBeNull();
|
|
35
|
-
expect(guideColumn('\t', 2)).toBeNull();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('a tab counts as one column of indent', () => {
|
|
39
|
-
expect(guideColumn('\tconst a = 1;', 1)).toBe(1);
|
|
40
|
-
expect(guideColumn('\tconst a = 1;', 2)).toBeNull();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('a line past the cap gets none, because counting it is work nobody can see', () => {
|
|
44
|
-
const huge = ' '.repeat(MAX_GUIDE_COLUMNS + 1) + 'x';
|
|
45
|
-
expect(guideColumn(huge, 2)).toBeNull();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('a unit of zero or less answers null rather than dividing by nothing', () => {
|
|
49
|
-
expect(guideColumn(' x', 0)).toBeNull();
|
|
50
|
-
expect(guideColumn(' x', -2)).toBeNull();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe('guideColumns', () => {
|
|
55
|
-
test('reports the index and column for each line that gets one', () => {
|
|
56
|
-
expect(guideColumns(['a', ' b', '', ' c'], 2)).toEqual([
|
|
57
|
-
{ index: 1, column: 2 },
|
|
58
|
-
{ index: 3, column: 2 },
|
|
59
|
-
]);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('a document with no indentation reports nothing', () => {
|
|
63
|
-
expect(guideColumns(['a', 'b'], 2)).toEqual([]);
|
|
64
|
-
});
|
|
65
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The indent guide's decisions, as a pure function.
|
|
8
|
-
*
|
|
9
|
-
* The plugin (`indent-guide.ts`) is a view layer; what a guide MEANS is decided here,
|
|
10
|
-
* so it can be tested without a mounted editor. Three rules, and each is a case the
|
|
11
|
-
* naive version gets wrong:
|
|
12
|
-
*
|
|
13
|
-
* - a line indented at least one level gets exactly ONE guide (at the first level),
|
|
14
|
-
* not one per column;
|
|
15
|
-
* - a blank line's whitespace is trailing noise, not structure, so it gets none;
|
|
16
|
-
* - a line past `MAX_GUIDE_COLUMNS` gets none, because a minified file is one huge
|
|
17
|
-
* line and counting its indentation per frame is work nobody can see.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/** Columns past which a line gets no guide. */
|
|
21
|
-
export const MAX_GUIDE_COLUMNS = 200;
|
|
22
|
-
|
|
23
|
-
/** The first level's column, in `ch`, or null when this line gets no guide. */
|
|
24
|
-
export function guideColumn(text: string, unit: number): number | null {
|
|
25
|
-
if (unit <= 0) return null;
|
|
26
|
-
// A blank line is a gap between blocks; its own indentation says nothing.
|
|
27
|
-
if (!text.trim()) return null;
|
|
28
|
-
const indent = /^[ \t]*/.exec(text)?.[0].length ?? 0;
|
|
29
|
-
if (indent < unit) return null;
|
|
30
|
-
if (indent > MAX_GUIDE_COLUMNS) return null;
|
|
31
|
-
return unit;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* The guides for a run of lines, as `[lineIndex, column]` pairs.
|
|
36
|
-
*
|
|
37
|
-
* `lineIndex` is 0-based within `texts`, which is what a caller mapping back to
|
|
38
|
-
* document positions already has.
|
|
39
|
-
*/
|
|
40
|
-
export function guideColumns(texts: readonly string[], unit: number): Array<{ index: number; column: number }> {
|
|
41
|
-
const guides: Array<{ index: number; column: number }> = [];
|
|
42
|
-
texts.forEach((text, index) => {
|
|
43
|
-
const column = guideColumn(text, unit);
|
|
44
|
-
if (column !== null) guides.push({ index, column });
|
|
45
|
-
});
|
|
46
|
-
return guides;
|
|
47
|
-
}
|