@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
|
@@ -40,6 +40,7 @@ import type { ProcProbe, ProcessInfo } from './types';
|
|
|
40
40
|
const LIBPROC_SYMBOLS = {
|
|
41
41
|
proc_listpids: { args: [FFIType.u32, FFIType.u32, FFIType.ptr, FFIType.i32], returns: FFIType.i32 },
|
|
42
42
|
proc_pidinfo: { args: [FFIType.i32, FFIType.i32, FFIType.u64, FFIType.ptr, FFIType.i32], returns: FFIType.i32 },
|
|
43
|
+
proc_pid_rusage: { args: [FFIType.i32, FFIType.i32, FFIType.ptr], returns: FFIType.i32 },
|
|
43
44
|
} satisfies Record<string, FFIFunction>;
|
|
44
45
|
|
|
45
46
|
const LIBC_SYMBOLS = {
|
|
@@ -76,6 +77,15 @@ const TASKINFO_SYSTEM_OFFSET = 24;
|
|
|
76
77
|
const TASKINFO_THREADS_OFFSET = 84;
|
|
77
78
|
/** `PROC_PIDVNODEPATHINFO`, and `pvi_cdir.vip_path` inside its reply. */
|
|
78
79
|
const PROC_PIDVNODEPATHINFO = 9;
|
|
80
|
+
/** `RUSAGE_INFO_V4` — the flavor whose struct carries `ri_phys_footprint`. */
|
|
81
|
+
const RUSAGE_INFO_V4 = 4;
|
|
82
|
+
/**
|
|
83
|
+
* `ri_phys_footprint` inside `struct rusage_info_v4`: 16 bytes of uuid, then
|
|
84
|
+
* seven u64 fields (user/system time, wakeups, pageins, wired, resident).
|
|
85
|
+
* Verified on this host against `footprint -p`: the same pid read
|
|
86
|
+
* 134,252,248 bytes here and `Footprint: 128 MB` there.
|
|
87
|
+
*/
|
|
88
|
+
const RUSAGE_FOOTPRINT_OFFSET = 72;
|
|
79
89
|
/**
|
|
80
90
|
* `sizeof(struct proc_vnodepathinfo)` — TWO `vnode_info_path`s (the cwd and the
|
|
81
91
|
* root dir), so 2 × (152 + 1024) = 2352. A buffer of one `vnode_info_path` is
|
|
@@ -146,6 +156,10 @@ const argvView = new DataView(argvBuffer.buffer);
|
|
|
146
156
|
const argvMib = new Int32Array([CTL_KERN, KERN_PROCARGS2, 0]);
|
|
147
157
|
const argvSize = new BigUint64Array([BigInt(ARGV_BUFFER_BYTES)]);
|
|
148
158
|
const cwdBuffer = new Uint8Array(VNODE_PATH_BYTES);
|
|
159
|
+
/** `struct rusage_info_v4` is ~300 bytes; the kernel writes the flavor's own
|
|
160
|
+
* size, so a generous buffer is the safe read. */
|
|
161
|
+
const rusageBuffer = new Uint8Array(1024);
|
|
162
|
+
const rusageView = new DataView(rusageBuffer.buffer);
|
|
149
163
|
const decoder = new TextDecoder();
|
|
150
164
|
|
|
151
165
|
/** Every pid on the system, via the documented two-call sizing pattern. */
|
|
@@ -208,6 +222,29 @@ function usageOf(bound: DarwinLibs, pid: number): { rss: number; cpuNs: number;
|
|
|
208
222
|
};
|
|
209
223
|
}
|
|
210
224
|
|
|
225
|
+
/**
|
|
226
|
+
* `ri_phys_footprint` for one pid, or null.
|
|
227
|
+
*
|
|
228
|
+
* This is the number `footprint -p` prints and `vmmap` calls "Physical
|
|
229
|
+
* footprint" — what the OS actually charges the process, after Bun (or any
|
|
230
|
+
* other allocator) frees an arena it does not return. Verified on this host
|
|
231
|
+
* against the live server: this call read 134,252,248 bytes while `footprint`
|
|
232
|
+
* printed `128 MB`, and `pti_resident_size` read 317 MB for the same process.
|
|
233
|
+
*
|
|
234
|
+
* A note for whoever reads the old doc first: `proc_pid_rusage` is not a decoy
|
|
235
|
+
* for footprint — it is a decoy for RESIDENT, whose field here is the one at
|
|
236
|
+
* offset 64 (`ri_resident_size`). The earlier measurement that dismissed the
|
|
237
|
+
* call read its first u64s, which are CPU times.
|
|
238
|
+
*
|
|
239
|
+
* A pid owned by another user, or one that exited mid-sweep, answers non-zero
|
|
240
|
+
* and yields null; the sampler then falls back to RSS for that row.
|
|
241
|
+
*/
|
|
242
|
+
function footprintOf(bound: DarwinLibs, pid: number): number | null {
|
|
243
|
+
if (bound.libproc.symbols.proc_pid_rusage(pid, RUSAGE_INFO_V4, ptr(rusageBuffer)) !== 0) return null;
|
|
244
|
+
const bytes = Number(rusageView.getBigUint64(RUSAGE_FOOTPRINT_OFFSET, true));
|
|
245
|
+
return bytes > 0 ? bytes : null;
|
|
246
|
+
}
|
|
247
|
+
|
|
211
248
|
/**
|
|
212
249
|
* argv for one pid, or null.
|
|
213
250
|
*
|
|
@@ -256,6 +293,7 @@ export const darwinProbe: ProcProbe = {
|
|
|
256
293
|
pid,
|
|
257
294
|
ppid: parent?.ppid ?? 0,
|
|
258
295
|
rss: usage.rss,
|
|
296
|
+
footprint: footprintOf(bound, pid),
|
|
259
297
|
cpuNs: usage.cpuNs,
|
|
260
298
|
threads: usage.threads,
|
|
261
299
|
argv: argvOf(bound, pid),
|
|
@@ -174,6 +174,10 @@ export const linuxProbe: ProcProbe = {
|
|
|
174
174
|
pid,
|
|
175
175
|
ppid: stat.ppid,
|
|
176
176
|
rss: status.rss,
|
|
177
|
+
// No Linux analogue at this budget: `Pss` would mean a
|
|
178
|
+
// `/proc/<pid>/smaps_rollup` read per process per tick, and Linux RSS
|
|
179
|
+
// does not carry macOS's freed-arena gap. The sampler falls back.
|
|
180
|
+
footprint: null,
|
|
177
181
|
cpuNs: stat.cpuNs,
|
|
178
182
|
threads: status.threads,
|
|
179
183
|
argv: argvOf(pid),
|
|
@@ -105,6 +105,7 @@ export const psProbe: ProcProbe = {
|
|
|
105
105
|
ppid: Number(match[2]),
|
|
106
106
|
// `ps rss` is kB on every platform this runs on.
|
|
107
107
|
rss: Number(match[3]) * 1024,
|
|
108
|
+
footprint: null,
|
|
108
109
|
cpuNs: cpuNs ?? 0,
|
|
109
110
|
threads: 0,
|
|
110
111
|
argv: match[6].trim() ? [match[6].trim()] : null,
|
|
@@ -28,6 +28,17 @@ export interface ProcessInfo {
|
|
|
28
28
|
ppid: number;
|
|
29
29
|
/** Resident set size in bytes. */
|
|
30
30
|
rss: number;
|
|
31
|
+
/**
|
|
32
|
+
* The operating system's charge for this process, in bytes, or null.
|
|
33
|
+
*
|
|
34
|
+
* Not the same quantity as `rss`: on macOS a Bun process that has read and
|
|
35
|
+
* dropped a transcript keeps the freed pages resident, so RSS read 317 MB for
|
|
36
|
+
* a process whose physical footprint was 134 MB (measured on the live server
|
|
37
|
+
* with `proc_pid_rusage(RUSAGE_INFO_V4).ri_phys_footprint` against
|
|
38
|
+
* `footprint -p`). Linux has no such gap at this scale, so its probe answers
|
|
39
|
+
* null and the sampler falls back to RSS there.
|
|
40
|
+
*/
|
|
41
|
+
footprint: number | null;
|
|
31
42
|
/** Cumulative CPU time (user + system) in nanoseconds. */
|
|
32
43
|
cpuNs: number;
|
|
33
44
|
/** Thread count, 0 when the platform cannot report it. */
|
|
@@ -25,7 +25,7 @@ import { createSampler, type SampleDeps } from './sampler';
|
|
|
25
25
|
const SERVER_PID = 100;
|
|
26
26
|
|
|
27
27
|
function proc(pid: number, ppid: number, argv: string[] | null, extra: Partial<ProcessInfo> = {}): ProcessInfo {
|
|
28
|
-
return { pid, ppid, rss: 1024, cpuNs: 0, threads: 1, argv, cwd: null, startedAt: 1, ...extra };
|
|
28
|
+
return { pid, ppid, rss: 1024, footprint: null, cpuNs: 0, threads: 1, argv, cwd: null, startedAt: 1, ...extra };
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/** A probe whose table the test controls, so the sampler's math is deterministic. */
|
|
@@ -42,6 +42,8 @@ function deps(rows: ProcessInfo[], overrides: Partial<SampleDeps> = {}): SampleD
|
|
|
42
42
|
readDaemons: () => [],
|
|
43
43
|
includeDaemons: false,
|
|
44
44
|
historyPoints: 5,
|
|
45
|
+
// Injected so a sample never spawns `vm_stat` in a unit test.
|
|
46
|
+
readMachine: () => ({ totalMemBytes: 16 * 1024 ** 3, freeMemBytes: 8 * 1024 ** 3, cpuCount: 8, loadPerCore: 0.1 }),
|
|
45
47
|
// No leases by default: every rpc-ui host reads as a prewarm unless a test
|
|
46
48
|
// supplies one, which is exactly what a fresh pool looks like.
|
|
47
49
|
readLease: () => null,
|
|
@@ -104,7 +106,7 @@ describe('createSampler', () => {
|
|
|
104
106
|
const pids = snapshot.rows.map((row) => row.pid).sort((a, b) => a - b);
|
|
105
107
|
expect(pids).toEqual([SERVER_PID, 101, 199, 200, 201]);
|
|
106
108
|
expect(snapshot.total.processes).toBe(5);
|
|
107
|
-
expect(snapshot.total.
|
|
109
|
+
expect(snapshot.total.memory).toBe(1500);
|
|
108
110
|
// Deduped: pid 199 is reached by the daemon walk AND (via its own child
|
|
109
111
|
// chain) by nothing else, but the browser subtree must appear once each.
|
|
110
112
|
expect(new Set(pids).size).toBe(pids.length);
|
|
@@ -143,7 +145,7 @@ describe('createSampler', () => {
|
|
|
143
145
|
const host = snapshot.groups.find((group) => group.key === 'prewarm:101');
|
|
144
146
|
expect(host).toBeDefined();
|
|
145
147
|
expect(host?.processes).toBe(2);
|
|
146
|
-
expect(host?.
|
|
148
|
+
expect(host?.memory).toBe(500);
|
|
147
149
|
// The rows carry the same key, so the table can group them.
|
|
148
150
|
expect(snapshot.rows.find((row) => row.pid === 102)?.groupKey).toBe('prewarm:101');
|
|
149
151
|
});
|
|
@@ -179,12 +181,48 @@ describe('createSampler', () => {
|
|
|
179
181
|
const sampler = createSampler(deps(rows, { historyPoints: 3 }));
|
|
180
182
|
for (let i = 0; i < 6; i += 1) sampler.sample();
|
|
181
183
|
const bounded = sampler.sample();
|
|
182
|
-
expect(bounded.history?.
|
|
184
|
+
expect(bounded.history?.memory).toHaveLength(3);
|
|
183
185
|
|
|
184
186
|
const noHistory = createSampler(deps(rows, { historyPoints: 0 })).sample();
|
|
185
187
|
expect(noHistory.history).toBeUndefined();
|
|
186
188
|
});
|
|
187
189
|
|
|
190
|
+
test('the memory figure is the footprint when the probe has one, and RSS when it does not', () => {
|
|
191
|
+
// Measured on the live server: 317 MB resident for a process whose
|
|
192
|
+
// footprint was 134 MB. The panel shows the second, because that is what
|
|
193
|
+
// the OS is actually charging; a row that cannot report one keeps RSS
|
|
194
|
+
// rather than contributing nothing.
|
|
195
|
+
const rows: ProcessInfo[] = [
|
|
196
|
+
proc(SERVER_PID, 1, ['bun', '--kabmo-server'], { rss: 317, footprint: 134 }),
|
|
197
|
+
proc(101, SERVER_PID, ['bun', '/bin/omp', '--mode', 'rpc-ui'], { rss: 200, footprint: null }),
|
|
198
|
+
];
|
|
199
|
+
const snapshot = createSampler(deps(rows)).sample();
|
|
200
|
+
const server = snapshot.rows.find((row) => row.pid === SERVER_PID);
|
|
201
|
+
const host = snapshot.rows.find((row) => row.pid === 101);
|
|
202
|
+
expect(server?.memory).toBe(134);
|
|
203
|
+
expect(server?.memorySource).toBe('footprint');
|
|
204
|
+
expect(server?.rss).toBe(317);
|
|
205
|
+
expect(host?.memory).toBe(200);
|
|
206
|
+
expect(host?.memorySource).toBe('rss');
|
|
207
|
+
// One of each: the totals sum what the rows print, and say they mixed.
|
|
208
|
+
expect(snapshot.total.memory).toBe(334);
|
|
209
|
+
expect(snapshot.memorySource).toBe('mixed');
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
test('a fully-footprint sample says so, and a fully-resident one says that', () => {
|
|
213
|
+
const footprinted = createSampler(
|
|
214
|
+
deps([proc(SERVER_PID, 1, ['bun', '--kabmo-server'], { rss: 317, footprint: 134 })]),
|
|
215
|
+
).sample();
|
|
216
|
+
expect(footprinted.memorySource).toBe('footprint');
|
|
217
|
+
expect(footprinted.total.memory).toBe(134);
|
|
218
|
+
|
|
219
|
+
const resident = createSampler(
|
|
220
|
+
deps([proc(SERVER_PID, 1, ['bun', '--kabmo-server'], { rss: 317, footprint: null })]),
|
|
221
|
+
).sample();
|
|
222
|
+
expect(resident.memorySource).toBe('rss');
|
|
223
|
+
expect(resident.total.memory).toBe(317);
|
|
224
|
+
});
|
|
225
|
+
|
|
188
226
|
test('an unsupported probe reports its reason instead of an empty table', () => {
|
|
189
227
|
const sampler = createSampler(
|
|
190
228
|
deps([], {
|
|
@@ -37,11 +37,19 @@
|
|
|
37
37
|
*
|
|
38
38
|
* A process that appeared since the last sweep has no baseline and reports no
|
|
39
39
|
* rate for one sample — the same honest gap, for the same reason.
|
|
40
|
+
*
|
|
41
|
+
* ## The memory figure is the OS's charge, not RSS
|
|
42
|
+
*
|
|
43
|
+
* RSS on macOS counts pages Bun has freed but not returned: measured on the
|
|
44
|
+
* live server, 317 MB resident for a process whose physical footprint was
|
|
45
|
+
* 134 MB. The panel is what a reader uses to decide whether to restart
|
|
46
|
+
* something, so each row reports `footprint ?? rss` and remembers which it is;
|
|
47
|
+
* the totals sum that same figure, and `memorySource` says when the sample
|
|
48
|
+
* mixed the two (see `./machine` for the platform rules).
|
|
40
49
|
*/
|
|
41
50
|
|
|
42
|
-
import os from 'node:os';
|
|
43
|
-
|
|
44
51
|
import { type DaemonEntry, readDaemonRegistry } from './daemons';
|
|
52
|
+
import { readMachine } from './machine';
|
|
45
53
|
import { assignGroups, type GroupKind } from './groups';
|
|
46
54
|
import { describeProcess } from './labels';
|
|
47
55
|
import { leaseOfPid } from './proc/identity';
|
|
@@ -151,15 +159,16 @@ export function createSampler(deps: SampleDeps): Sampler {
|
|
|
151
159
|
const readLease = deps.readLease ?? leaseOfPid;
|
|
152
160
|
const includeDaemons = deps.includeDaemons ?? true;
|
|
153
161
|
const historyPoints = deps.historyPoints ?? 60;
|
|
162
|
+
const readFacts = deps.readMachine ?? readMachine;
|
|
154
163
|
|
|
155
164
|
let baseline: Baseline | null = null;
|
|
156
|
-
const
|
|
165
|
+
const memoryHistory: number[] = [];
|
|
157
166
|
const cpuHistory: number[] = [];
|
|
158
167
|
|
|
159
168
|
return {
|
|
160
169
|
reset() {
|
|
161
170
|
baseline = null;
|
|
162
|
-
|
|
171
|
+
memoryHistory.length = 0;
|
|
163
172
|
cpuHistory.length = 0;
|
|
164
173
|
},
|
|
165
174
|
sample(): StatsSnapshot {
|
|
@@ -204,6 +213,8 @@ export function createSampler(deps: SampleDeps): Sampler {
|
|
|
204
213
|
serverPid: deps.serverPid,
|
|
205
214
|
lease: leases.get(process.pid) ?? null,
|
|
206
215
|
});
|
|
216
|
+
const footprint = process.footprint;
|
|
217
|
+
const memory = footprint ?? process.rss;
|
|
207
218
|
|
|
208
219
|
rows.push({
|
|
209
220
|
pid: process.pid,
|
|
@@ -212,6 +223,8 @@ export function createSampler(deps: SampleDeps): Sampler {
|
|
|
212
223
|
detail: label.detail,
|
|
213
224
|
groupKey: assignment.key,
|
|
214
225
|
depth: assignment.depth,
|
|
226
|
+
memory,
|
|
227
|
+
memorySource: footprint === null ? 'rss' : 'footprint',
|
|
215
228
|
rss: process.rss,
|
|
216
229
|
cpuPercent,
|
|
217
230
|
threads: process.threads,
|
|
@@ -226,11 +239,11 @@ export function createSampler(deps: SampleDeps): Sampler {
|
|
|
226
239
|
title: label.title,
|
|
227
240
|
detail: label.detail,
|
|
228
241
|
processes: 0,
|
|
229
|
-
|
|
242
|
+
memory: 0,
|
|
230
243
|
cpuPercent: 0,
|
|
231
244
|
};
|
|
232
245
|
group.processes += 1;
|
|
233
|
-
group.
|
|
246
|
+
group.memory += memory;
|
|
234
247
|
group.cpuPercent += cpuPercent ?? 0;
|
|
235
248
|
if (process.pid === assignment.ownerPid) {
|
|
236
249
|
group.title = label.title;
|
|
@@ -241,21 +254,26 @@ export function createSampler(deps: SampleDeps): Sampler {
|
|
|
241
254
|
|
|
242
255
|
baseline = { at, cpuNs: cpuNsNow };
|
|
243
256
|
|
|
244
|
-
rows.
|
|
245
|
-
const
|
|
257
|
+
const footprints = rows.filter((row) => row.memorySource === 'footprint').length;
|
|
258
|
+
const memorySource: StatsSnapshot['memorySource'] = footprints === 0 ? 'rss'
|
|
259
|
+
: footprints === rows.length ? 'footprint'
|
|
260
|
+
: 'mixed';
|
|
261
|
+
|
|
262
|
+
rows.sort((a, b) => b.memory - a.memory);
|
|
263
|
+
const groups = [...byGroup.values()].sort((a, b) => groupRank(a) - groupRank(b) || b.memory - a.memory);
|
|
246
264
|
const total = {
|
|
247
265
|
processes: rows.length,
|
|
248
|
-
|
|
266
|
+
memory: groups.reduce((sum, entry) => sum + entry.memory, 0),
|
|
249
267
|
cpuPercent: groups.reduce((sum, entry) => sum + entry.cpuPercent, 0),
|
|
250
268
|
};
|
|
251
269
|
|
|
252
270
|
let history: StatsSnapshot['history'];
|
|
253
271
|
if (historyPoints > 0) {
|
|
254
|
-
|
|
272
|
+
memoryHistory.push(total.memory);
|
|
255
273
|
cpuHistory.push(Number(total.cpuPercent.toFixed(1)));
|
|
256
|
-
while (
|
|
274
|
+
while (memoryHistory.length > historyPoints) memoryHistory.shift();
|
|
257
275
|
while (cpuHistory.length > historyPoints) cpuHistory.shift();
|
|
258
|
-
history = {
|
|
276
|
+
history = { memory: [...memoryHistory], cpuPercent: [...cpuHistory] };
|
|
259
277
|
}
|
|
260
278
|
|
|
261
279
|
const snapshot: StatsSnapshot = {
|
|
@@ -264,12 +282,8 @@ export function createSampler(deps: SampleDeps): Sampler {
|
|
|
264
282
|
rows,
|
|
265
283
|
groups,
|
|
266
284
|
total,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
freeMemBytes: os.freemem(),
|
|
270
|
-
cpuCount: os.cpus().length,
|
|
271
|
-
loadPerCore: os.cpus().length > 0 ? os.loadavg()[0] / os.cpus().length : os.loadavg()[0],
|
|
272
|
-
},
|
|
285
|
+
memorySource,
|
|
286
|
+
machine: readFacts(),
|
|
273
287
|
daemons,
|
|
274
288
|
serverPid: deps.serverPid,
|
|
275
289
|
...(history ? { history } : {}),
|
|
@@ -36,6 +36,7 @@ import type { KabmoPluginApi, PluginJson } from '@kabmo-labs/kabmo-sdk';
|
|
|
36
36
|
|
|
37
37
|
import { createSampler, type StatsSnapshot } from './sampler';
|
|
38
38
|
import { readDaemonRegistry } from './daemons';
|
|
39
|
+
import { killStackProcess, type KillOutcome } from './kill';
|
|
39
40
|
|
|
40
41
|
/** The tick's floor: below this a CPU delta is noise against the clock. */
|
|
41
42
|
const MIN_SAMPLE_MS = 200;
|
|
@@ -113,7 +114,8 @@ export default function plugin(api: KabmoPluginApi) {
|
|
|
113
114
|
probe: { name: 'unknown', supported: false, reason },
|
|
114
115
|
rows: [],
|
|
115
116
|
groups: [],
|
|
116
|
-
total: { processes: 0,
|
|
117
|
+
total: { processes: 0, memory: 0, cpuPercent: 0 },
|
|
118
|
+
memorySource: 'rss',
|
|
117
119
|
machine: {
|
|
118
120
|
totalMemBytes: 0,
|
|
119
121
|
freeMemBytes: 0,
|
|
@@ -136,7 +138,8 @@ export default function plugin(api: KabmoPluginApi) {
|
|
|
136
138
|
probe: { name: 'pending', supported: true },
|
|
137
139
|
rows: [],
|
|
138
140
|
groups: [],
|
|
139
|
-
total: { processes: 0,
|
|
141
|
+
total: { processes: 0, memory: 0, cpuPercent: 0 },
|
|
142
|
+
memorySource: 'rss',
|
|
140
143
|
machine: { totalMemBytes: 0, freeMemBytes: 0, cpuCount: 0, loadPerCore: 0 },
|
|
141
144
|
daemons: [],
|
|
142
145
|
serverPid: process.pid,
|
|
@@ -219,6 +222,30 @@ export default function plugin(api: KabmoPluginApi) {
|
|
|
219
222
|
},
|
|
220
223
|
});
|
|
221
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Stop one process in the measured stack.
|
|
227
|
+
*
|
|
228
|
+
* The sample taken HERE is the authority, not the table the panel drew: a
|
|
229
|
+
* pid the caller read off a stale snapshot may since have been recycled, and
|
|
230
|
+
* the fresh union is what turns "some pid" into "a process this panel
|
|
231
|
+
* measured". `killStackProcess` owns the refusals and never throws; a
|
|
232
|
+
* refusal is a result the dialog renders, not a 500.
|
|
233
|
+
*/
|
|
234
|
+
api.rpc.register<{ pid: number }, KillOutcome>('kill', {
|
|
235
|
+
handler: ({ pid } = { pid: 0 }) => {
|
|
236
|
+
const outcome = killStackProcess(pid, {
|
|
237
|
+
sample: () => sampler.sample(),
|
|
238
|
+
serverPid: process.pid,
|
|
239
|
+
});
|
|
240
|
+
api.log.info(
|
|
241
|
+
outcome.killed
|
|
242
|
+
? `signalled pid ${outcome.pid} (${outcome.title})`
|
|
243
|
+
: `refused to signal pid ${String(pid)}: ${outcome.reason}`,
|
|
244
|
+
);
|
|
245
|
+
return outcome;
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
|
|
222
249
|
/**
|
|
223
250
|
* The HTTP surface: a first paint for anything that is not the panel, and the
|
|
224
251
|
* shape a `curl` or a monitor can read.
|
|
@@ -29,6 +29,20 @@ export interface ProcessRow {
|
|
|
29
29
|
groupKey: string;
|
|
30
30
|
/** Distance from the group's owner; 0 is the owner itself. */
|
|
31
31
|
depth: number;
|
|
32
|
+
/**
|
|
33
|
+
* The figure the panel shows and sorts by: the OS's physical footprint when
|
|
34
|
+
* it reports one, resident size otherwise. See `memorySource`.
|
|
35
|
+
*/
|
|
36
|
+
memory: number;
|
|
37
|
+
/**
|
|
38
|
+
* Which of the two `memory` is, per row.
|
|
39
|
+
*
|
|
40
|
+
* Both exist because a row can fall back independently: on macOS a process
|
|
41
|
+
* owned by another user answers no footprint, and dropping its RSS would
|
|
42
|
+
* remove it from the totals instead of reporting what is known.
|
|
43
|
+
*/
|
|
44
|
+
memorySource: 'footprint' | 'rss';
|
|
45
|
+
/** Resident set size, kept beside `memory` so a row can explain the gap. */
|
|
32
46
|
rss: number;
|
|
33
47
|
cpuPercent: number | null;
|
|
34
48
|
threads: number;
|
|
@@ -52,7 +66,8 @@ export interface GroupSummary {
|
|
|
52
66
|
/** The owner's detail line. */
|
|
53
67
|
detail: string;
|
|
54
68
|
processes: number;
|
|
55
|
-
|
|
69
|
+
/** Sum of the members' `memory` — the same figures the rows print. */
|
|
70
|
+
memory: number;
|
|
56
71
|
cpuPercent: number;
|
|
57
72
|
}
|
|
58
73
|
|
|
@@ -84,14 +99,22 @@ export interface StatsSnapshot {
|
|
|
84
99
|
*/
|
|
85
100
|
groups: GroupSummary[];
|
|
86
101
|
/** The whole union. */
|
|
87
|
-
total: { processes: number;
|
|
102
|
+
total: { processes: number; memory: number; cpuPercent: number };
|
|
103
|
+
/**
|
|
104
|
+
* Which figure `memory` is across the sample.
|
|
105
|
+
*
|
|
106
|
+
* `footprint` when every row reported one, `rss` when none did, `mixed` when
|
|
107
|
+
* both appear — the panel needs to say which, because a sum of two different
|
|
108
|
+
* quantities must not be labelled as one of them.
|
|
109
|
+
*/
|
|
110
|
+
memorySource: 'footprint' | 'rss' | 'mixed';
|
|
88
111
|
machine: MachineContext;
|
|
89
112
|
/** omp daemons the registry reports, so a row can be named by its daemon. */
|
|
90
113
|
daemons: DaemonEntry[];
|
|
91
114
|
/** The Kabmo's own pid, so the panel can mark it. */
|
|
92
115
|
serverPid: number;
|
|
93
116
|
/** Sparkline series, oldest first. Absent when history is disabled. */
|
|
94
|
-
history?: {
|
|
117
|
+
history?: { memory: number[]; cpuPercent: number[] };
|
|
95
118
|
/** Why the table is empty, when it is. */
|
|
96
119
|
error?: string;
|
|
97
120
|
}
|
|
@@ -110,6 +133,11 @@ export interface SampleDeps {
|
|
|
110
133
|
includeDaemons?: boolean;
|
|
111
134
|
/** Samples retained for the sparklines; 0 disables history. */
|
|
112
135
|
historyPoints?: number;
|
|
136
|
+
/**
|
|
137
|
+
* The machine reading, injected so a unit test does not spawn `vm_stat`.
|
|
138
|
+
* Defaults to `readMachine` from `./machine`.
|
|
139
|
+
*/
|
|
140
|
+
readMachine?: () => MachineContext;
|
|
113
141
|
/**
|
|
114
142
|
* The lease lookup, injected so the sampler is testable without libproc.
|
|
115
143
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kabmo-labs/kabmo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "Web console and diagnostic workbench for AI coding agents — Elysia + Preact on Bun.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Wijanarko Putra Rajeb <wijanarko.rajeb@gmail.com>",
|
|
@@ -61,6 +61,7 @@
|
|
|
61
61
|
"shell:docs": "bun run scripts/shell-document-types.mjs --write",
|
|
62
62
|
"shell:docs:check": "bun run scripts/shell-document-types.mjs --check",
|
|
63
63
|
"typecheck:e2e": "tsc --noEmit -p tests/e2e",
|
|
64
|
+
"typecheck:consumer": "tsc --noEmit -p tsconfig.consumer.json",
|
|
64
65
|
"publish:plugins": "bash .github/scripts/publish-plugin-packages.sh packages/kabmo-sdk packages/kabmo-ui"
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
@@ -74,7 +75,7 @@
|
|
|
74
75
|
"@codemirror/state": "6.7.6",
|
|
75
76
|
"@codemirror/view": "6.43.15",
|
|
76
77
|
"@fontsource/fira-code": "^5.3.0",
|
|
77
|
-
"@kabmo-labs/kabmo-sdk": "0.1.
|
|
78
|
+
"@kabmo-labs/kabmo-sdk": "0.1.3",
|
|
78
79
|
"@kabmo-labs/kabmo-ui": "0.0.2",
|
|
79
80
|
"@shikijs/langs": "^4.4.3",
|
|
80
81
|
"@shikijs/themes": "^4.4.3",
|
|
@@ -19,6 +19,11 @@ export interface ModalProps {
|
|
|
19
19
|
maxWidthClass?: string;
|
|
20
20
|
/** Backdrop z-index class. Default `z-[60]`. */
|
|
21
21
|
zClass?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Accessible name for the dialog. The header is ordinary content, so without
|
|
24
|
+
* this the `role="dialog"` announces itself anonymously to a screen reader.
|
|
25
|
+
*/
|
|
26
|
+
ariaLabel?: string;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
/**
|
|
@@ -34,6 +39,7 @@ export function Modal({
|
|
|
34
39
|
form,
|
|
35
40
|
maxWidthClass = 'max-w-md',
|
|
36
41
|
zClass = 'z-[60]',
|
|
42
|
+
ariaLabel,
|
|
37
43
|
}: ModalProps) {
|
|
38
44
|
const body = (
|
|
39
45
|
<>
|
|
@@ -62,6 +68,7 @@ export function Modal({
|
|
|
62
68
|
<div
|
|
63
69
|
role="dialog"
|
|
64
70
|
aria-modal="true"
|
|
71
|
+
aria-label={ariaLabel}
|
|
65
72
|
className={`bg-paper border border-ink/15 rounded-xl shadow-2xl w-full ${maxWidthClass} max-h-full flex flex-col overflow-hidden text-ink`}
|
|
66
73
|
onClick={(e) => e.stopPropagation()}
|
|
67
74
|
>
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* Three failure modes are silent here and each is a test:
|
|
10
10
|
*
|
|
11
11
|
* - A guide drawn at the line's LEFT edge instead of under the opening brace
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* points at the wrong column. The column is a decoration attribute, so the
|
|
13
|
+
* assertion is on the emitted style.
|
|
14
14
|
* - A guide through a BLANK line makes a block read as if it continued across
|
|
15
15
|
* the gap between two functions.
|
|
16
16
|
* - A mode table entry that does not exist in `@codemirror/legacy-modes` fails
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
* **The guide is driven by the CARET, not by every pair in the viewport.** A
|
|
16
16
|
* viewport-wide version (VS Code's `bracketPairGuides`) draws a rule for every
|
|
17
17
|
* brace on screen: on a 337-line component that is dozens of overlapping lines,
|
|
18
|
-
* which is
|
|
19
|
-
*
|
|
18
|
+
* which is noise that hides the one pair the reader is looking at. This shows
|
|
19
|
+
* the pair the caret is IN.
|
|
20
20
|
*
|
|
21
21
|
* **It reads `matchBrackets`, the same call `bracketMatching()` makes.** A second
|
|
22
22
|
* pairing rule would eventually disagree with the highlight, and a guide that
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
* still held their text, i.e. the line's content was swallowed by a decoration
|
|
30
30
|
* that should not have covered it.
|
|
31
31
|
*
|
|
32
|
-
* The walk below
|
|
33
|
-
*
|
|
32
|
+
* The walk below visits the VISIBLE lines only and is rebuilt on scroll and on
|
|
33
|
+
* edit, so a 20 MB file costs the viewport.
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
import type { Range } from '@codemirror/state';
|
|
@@ -84,9 +84,9 @@ function buildMarkers(view: EditorView): DecorationSet {
|
|
|
84
84
|
/**
|
|
85
85
|
* The marker bands, as a view plugin.
|
|
86
86
|
*
|
|
87
|
-
* A plugin rather than a state field
|
|
88
|
-
*
|
|
89
|
-
*
|
|
87
|
+
* A plugin rather than a state field because the bands are derived from what is
|
|
88
|
+
* RENDERED: a scroll has to rebuild them, and a field would hold a decoration
|
|
89
|
+
* set the document does not own.
|
|
90
90
|
*/
|
|
91
91
|
export function conflictMarkers() {
|
|
92
92
|
return ViewPlugin.fromClass(
|
|
@@ -57,7 +57,7 @@ import { indentDataExtension, indentExtensions } from '@/client/components/commo
|
|
|
57
57
|
import { typingExtensions, type EditorTypingOptions } from '@/client/components/common/code-surface/typing';
|
|
58
58
|
import { indentFoldService } from '@/client/components/common/code-surface/fold';
|
|
59
59
|
import { foldPlaceholderDom } from '@/client/components/common/code-surface/fold-placeholder';
|
|
60
|
-
import {
|
|
60
|
+
import { whitespaceMarks } from '@/client/components/common/code-surface/whitespace';
|
|
61
61
|
import { findMarksField } from '@/client/components/common/code-surface/marks';
|
|
62
62
|
import { surfaceKeymap } from '@/client/components/common/code-surface/keymap';
|
|
63
63
|
import { shikiHighlight, type ShikiThemeNames } from '@/client/components/common/code-surface/shiki';
|
|
@@ -228,9 +228,12 @@ export function surfaceExtensions({
|
|
|
228
228
|
// Control characters drawn as their glyph instead of nothing: a stray NUL or a
|
|
229
229
|
// zero-width space is invisible, which makes a corrupted file look fine.
|
|
230
230
|
highlightSpecialChars(),
|
|
231
|
-
// A
|
|
232
|
-
//
|
|
233
|
-
|
|
231
|
+
// A space drawn as a dot and a tab as an arrow, on the SELECTION only — VS Code's
|
|
232
|
+
// `renderWhitespace: 'selection'`, its default. The package's own
|
|
233
|
+
// `highlightWhitespace()` marks every space in the viewport, which is a permanent
|
|
234
|
+
// dotted layer over the code; these marks appear when a reader drags over a
|
|
235
|
+
// block, which is the moment they are asking about the bytes.
|
|
236
|
+
whitespaceMarks,
|
|
234
237
|
history(),
|
|
235
238
|
drawSelection(),
|
|
236
239
|
dropCursor(),
|
|
@@ -214,15 +214,40 @@ export function surfaceTheme(): Extension {
|
|
|
214
214
|
backgroundColor: 'var(--editor-active-line, color-mix(in srgb, var(--theme-ink) 4%, transparent))',
|
|
215
215
|
color: 'var(--editor-fg, var(--theme-ink))',
|
|
216
216
|
},
|
|
217
|
-
//
|
|
218
|
-
//
|
|
219
|
-
//
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
217
|
+
// Whitespace marks (`whitespace.ts`): a dot per space and an arrow per tab,
|
|
218
|
+
// drawn only for characters the reader has SELECTED — VS Code's
|
|
219
|
+
// `renderWhitespace: 'selection'`. Nothing is painted for a bare caret.
|
|
220
|
+
//
|
|
221
|
+
// The ink is read from `--editor-fg`, NOT from `currentColor`: a mark that lands
|
|
222
|
+
// inside a Shiki token inherits that token's colour, so the dots in one line
|
|
223
|
+
// would come out in as many colours as the highlighting uses.
|
|
224
|
+
//
|
|
225
|
+
// The dot geometry is the package's own (`.4em`, centred at 55%): a dot wide
|
|
226
|
+
// enough to read at 8px would touch its neighbours at 24px. The tab draws an
|
|
227
|
+
// ARROW rather than a second dot, because one tab and a run of spaces are the
|
|
228
|
+
// same width and must not look alike. The arrow is a MASK, not a background
|
|
229
|
+
// image: an SVG in `url()` is its own document, so `currentColor` inside it
|
|
230
|
+
// resolves to black and the arrow would vanish in a dark theme.
|
|
231
|
+
'.cm-whitespace-space': {
|
|
232
|
+
background:
|
|
233
|
+
'radial-gradient(circle at 50% 55%, var(--editor-fg, var(--theme-ink)) 20%, transparent 0) no-repeat',
|
|
234
|
+
backgroundSize: '.4em',
|
|
235
|
+
backgroundPosition: 'calc(min(50%, 0px)) center',
|
|
236
|
+
opacity: '0.45',
|
|
237
|
+
},
|
|
238
|
+
'.cm-whitespace-tab': {
|
|
239
|
+
backgroundColor: 'var(--editor-fg, var(--theme-ink))',
|
|
240
|
+
maskImage:
|
|
241
|
+
"url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"200\" height=\"20\"><path stroke=\"%23000\" stroke-width=\"1\" fill=\"none\" d=\"M1 10H196L190 5M190 15L196 10M197 4L197 16\"/></svg>')",
|
|
242
|
+
WebkitMaskImage:
|
|
243
|
+
"url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"200\" height=\"20\"><path stroke=\"%23000\" stroke-width=\"1\" fill=\"none\" d=\"M1 10H196L190 5M190 15L196 10M197 4L197 16\"/></svg>')",
|
|
244
|
+
maskSize: 'auto 100%',
|
|
245
|
+
WebkitMaskSize: 'auto 100%',
|
|
246
|
+
maskPosition: 'right 90%',
|
|
247
|
+
WebkitMaskPosition: 'right 90%',
|
|
248
|
+
maskRepeat: 'no-repeat',
|
|
249
|
+
WebkitMaskRepeat: 'no-repeat',
|
|
250
|
+
opacity: '0.45',
|
|
226
251
|
},
|
|
227
252
|
// The line-blame label at the end of a run's first line.
|
|
228
253
|
//
|