@kabmo-labs/kabmo 0.14.1 → 0.16.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 +1 -0
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +374 -356
- package/dist/client/static/js/{index-w6jx0h0p.js → index-cpydmygd.js} +661 -661
- package/dist/client/static/js/index-fjnq2z2d.css +1 -0
- package/marketplace/plugins/command-runner/README.md +5 -3
- package/marketplace/plugins/command-runner/package.json +2 -2
- package/marketplace/plugins/command-runner/src/app.tsx +3 -3
- package/marketplace/plugins/command-runner/src/panel/Groups.test.tsx +25 -21
- package/marketplace/plugins/command-runner/src/panel/Groups.tsx +4 -1
- 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/layout/LeftDock.tsx +1 -0
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +1 -0
- package/src/client/components/mobile/LayoutWrapper.tsx +11 -10
- package/src/client/components/mobile/RightSidebar.tsx +1 -0
- package/src/client/components/mobile/mobile-session-sidebar/use-dock.ts +1 -0
- package/src/client/components/mobile/open-file-payload.test.ts +29 -1
- package/src/client/components/mobile/open-file-payload.ts +28 -0
- package/src/client/components/settings/Modal.tsx +2 -2
- package/src/client/components/workspace/editor/index.tsx +6 -8
- package/src/client/components/workspace/git-panel/branch-modal/index.tsx +4 -3
- package/src/client/components/workspace/git-panel/commit-modal/index.tsx +1 -1
- 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/hooks/chat/timeline/index.ts +3 -6
- package/src/client/hooks/chat/timeline/jump-landing.ts +121 -0
- package/src/client/hooks/chat/timeline/jump-rail.ts +19 -10
- package/src/client/hooks/chat/timeline/row-window.ts +44 -4
- package/src/client/hooks/chat/timeline/scroll-probe.test-util.ts +23 -10
- package/src/client/hooks/chat/timeline/scroll.test.ts +61 -4
- package/src/client/hooks/chat/timeline/scroll.ts +77 -26
- package/src/client/hooks/workspace/missing-files.test.ts +20 -3
- package/src/client/hooks/workspace/missing-files.ts +41 -7
- package/src/client/tailwind.css +12 -1
- package/src/server/lib/db/schema.ts +11 -0
- package/src/server/lib/lifecycle/memory.test.ts +41 -1
- package/src/server/lib/lifecycle/memory.ts +131 -14
- 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/routes/fs/exists.test.ts +26 -1
- package/dist/client/static/js/index-bnrrw242.css +0 -1
|
@@ -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.16.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
|
>
|
|
@@ -299,6 +299,7 @@ export function WorkspacePanels(props: WorkspacePanelsProps) {
|
|
|
299
299
|
onRefresh: onRefreshWorkspace,
|
|
300
300
|
onOpenFile,
|
|
301
301
|
onClose: onToggleRightPanel,
|
|
302
|
+
layout: 'desktop',
|
|
302
303
|
};
|
|
303
304
|
return (
|
|
304
305
|
<div key={panel.id} className={isActiveView ? 'w-full h-full' : 'hidden'}>
|
|
@@ -19,7 +19,7 @@ import { ToastStack } from '@/client/components/common/ToastStack';
|
|
|
19
19
|
import { useEditorDrop, type EditorDropResult } from '@/client/hooks/editor/use-editor-drop';
|
|
20
20
|
import { EditorDropOverlay } from '@/client/components/workspace/editor/EditorDropOverlay';
|
|
21
21
|
import { PluginBootstrap } from '@/client/lib/plugins/bootstrap';
|
|
22
|
-
import { mobileEditorFileFrom, type MobileEditorFile } from '@/client/components/mobile/open-file-payload';
|
|
22
|
+
import { mobileEditorFileFrom, mobileProbeTabs, type MobileEditorFile } from '@/client/components/mobile/open-file-payload';
|
|
23
23
|
import { useLeftDock } from '@/client/hooks/workspace/left-dock';
|
|
24
24
|
import { useSessionStateContext } from '@/client/hooks/workspace/session-state/context';
|
|
25
25
|
import { setSessionKey } from '@/shared/lib/workspace/session-state/store';
|
|
@@ -61,13 +61,11 @@ export function MobileLayoutWrapper({ onDesktopToggle, appSettings = {} }: Mobil
|
|
|
61
61
|
// The phone's full-screen editor shows ONE file at a time, so the probe has a
|
|
62
62
|
// single subject and a constant id. `refreshKey` is what carries a deletion
|
|
63
63
|
// here: the Files panel's delete, an agent `rm` that triggers a workspace
|
|
64
|
-
// refresh, and the editor's own save all bump it.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
refreshKey,
|
|
70
|
-
);
|
|
64
|
+
// refresh, and the editor's own save all bump it. The scope comes from
|
|
65
|
+
// `mobileProbeTabs` so `repo` travels with it — without it the server resolved
|
|
66
|
+
// a nested-repo file against the workspace root and answered "gone" for a file
|
|
67
|
+
// that had just been read.
|
|
68
|
+
const mobileEditorMissingIds = useMissingFiles(mobileProbeTabs(mobileEditorFile), refreshKey);
|
|
71
69
|
const { toasts, pushToast, dismissToast } = useToasts();
|
|
72
70
|
const handleDropResult = useCallback(
|
|
73
71
|
(result: EditorDropResult) => pushToast(result.message, result.ok ? 'success' : 'error'),
|
|
@@ -118,10 +116,13 @@ export function MobileLayoutWrapper({ onDesktopToggle, appSettings = {} }: Mobil
|
|
|
118
116
|
// never receive the first drop.
|
|
119
117
|
const editorDrop = useEditorDrop({ enabled: hasContext, onResult: handleDropResult });
|
|
120
118
|
|
|
121
|
-
// Listen to open-file event on mobile
|
|
119
|
+
// Listen to open-file event on mobile. The active project is the fallback
|
|
120
|
+
// root, exactly as the desktop tab opener applies it: a payload with no root
|
|
121
|
+
// of its own (a chat link, a plugin readout) then reads AND probes against the
|
|
122
|
+
// workspace it belongs to instead of the server's default root.
|
|
122
123
|
useKabmoEvent('omp:open-file', (e) => {
|
|
123
124
|
const customEvent = e as CustomEvent<unknown>;
|
|
124
|
-
const next = mobileEditorFileFrom(customEvent.detail);
|
|
125
|
+
const next = mobileEditorFileFrom(customEvent.detail, activeProjectPath);
|
|
125
126
|
if (next) setMobileEditorFile(next);
|
|
126
127
|
});
|
|
127
128
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { describe, expect, test } from 'bun:test';
|
|
19
|
-
import { mobileEditorFileFrom } from '@/client/components/mobile/open-file-payload';
|
|
19
|
+
import { mobileEditorFileFrom, mobileProbeTabs } from '@/client/components/mobile/open-file-payload';
|
|
20
20
|
|
|
21
21
|
describe('mobileEditorFileFrom', () => {
|
|
22
22
|
test('carries repo and handleId through', () => {
|
|
@@ -34,6 +34,7 @@ describe('mobileEditorFileFrom', () => {
|
|
|
34
34
|
root: '/ws',
|
|
35
35
|
repo: 'projects/token',
|
|
36
36
|
handleId: 'handle-7',
|
|
37
|
+
deviceFile: undefined,
|
|
37
38
|
});
|
|
38
39
|
});
|
|
39
40
|
|
|
@@ -68,4 +69,31 @@ describe('mobileEditorFileFrom', () => {
|
|
|
68
69
|
expect(result?.repo).toBeUndefined();
|
|
69
70
|
expect(result?.handleId).toBeUndefined();
|
|
70
71
|
});
|
|
72
|
+
|
|
73
|
+
test('a device file is marked, so the existence probe refuses it', () => {
|
|
74
|
+
expect(mobileEditorFileFrom({ path: 'report.md', deviceFile: true })?.deviceFile).toBe(true);
|
|
75
|
+
expect(mobileEditorFileFrom({ path: 'x.md', deviceFile: 'yes' })?.deviceFile).toBeUndefined();
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('mobileProbeTabs', () => {
|
|
80
|
+
test('carries the tree the file was opened from — repo included', () => {
|
|
81
|
+
// The regression: the phone's probe sent `root` + `path` and dropped `repo`,
|
|
82
|
+
// so the server resolved a nested-repo file against the workspace root and
|
|
83
|
+
// answered "gone" for a file the editor had just read.
|
|
84
|
+
const file = mobileEditorFileFrom({ path: 'src/inner.ts', root: '/ws', repo: 'pkg/nested' });
|
|
85
|
+
expect(mobileProbeTabs(file)).toEqual([{
|
|
86
|
+
id: 'mobile-editor',
|
|
87
|
+
path: 'src/inner.ts',
|
|
88
|
+
root: '/ws',
|
|
89
|
+
repo: 'pkg/nested',
|
|
90
|
+
content: undefined,
|
|
91
|
+
handleId: undefined,
|
|
92
|
+
deviceFile: undefined,
|
|
93
|
+
}]);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test('nothing open means nothing to probe', () => {
|
|
97
|
+
expect(mobileProbeTabs(null)).toEqual([]);
|
|
98
|
+
});
|
|
71
99
|
});
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* server-reachable path, so its bytes come from the live handle instead).
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import type { ProbeableTab } from '@/client/hooks/workspace/missing-files';
|
|
18
|
+
|
|
17
19
|
/** The one file the phone's full-screen editor has open. */
|
|
18
20
|
export interface MobileEditorFile {
|
|
19
21
|
name: string;
|
|
@@ -24,6 +26,8 @@ export interface MobileEditorFile {
|
|
|
24
26
|
repo?: string;
|
|
25
27
|
/** A dropped/launched file's live handle — its bytes have no server path. */
|
|
26
28
|
handleId?: string;
|
|
29
|
+
/** The bytes came from the DEVICE: renderable, with no path the server can stat. */
|
|
30
|
+
deviceFile?: boolean;
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
function readString(source: Record<string, unknown>, key: string): string | undefined {
|
|
@@ -56,5 +60,29 @@ export function mobileEditorFileFrom(payload: unknown, fallbackRoot?: string | n
|
|
|
56
60
|
root: readString(source, 'root') ?? fallbackRoot ?? undefined,
|
|
57
61
|
repo: readString(source, 'repo'),
|
|
58
62
|
handleId: readString(source, 'handleId'),
|
|
63
|
+
deviceFile: source.deviceFile === true ? true : undefined,
|
|
59
64
|
};
|
|
60
65
|
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The scope the phone's "is this file still there?" probe must ask about.
|
|
69
|
+
*
|
|
70
|
+
* `repo` is load-bearing and used to be dropped here: the server resolves
|
|
71
|
+
* `root` + `repo` + `path` exactly as the READ route does, so a file opened from
|
|
72
|
+
* a nested repository — the tree lists it relative to that repo — was read
|
|
73
|
+
* successfully and then reported as deleted by a probe that named the workspace
|
|
74
|
+
* root instead. Everything else (inline content, a launched handle, a device
|
|
75
|
+
* file) is carried through so `isProbeableTab` can refuse it in one place.
|
|
76
|
+
*/
|
|
77
|
+
export function mobileProbeTabs(file: MobileEditorFile | null): ProbeableTab[] {
|
|
78
|
+
if (!file) return [];
|
|
79
|
+
return [{
|
|
80
|
+
id: 'mobile-editor',
|
|
81
|
+
path: file.path,
|
|
82
|
+
root: file.root,
|
|
83
|
+
repo: file.repo,
|
|
84
|
+
content: file.content,
|
|
85
|
+
handleId: file.handleId,
|
|
86
|
+
deviceFile: file.deviceFile,
|
|
87
|
+
}];
|
|
88
|
+
}
|
|
@@ -187,11 +187,11 @@ export function SettingsModal({
|
|
|
187
187
|
onClick={onClose}
|
|
188
188
|
>
|
|
189
189
|
<div
|
|
190
|
-
className="relative bg-paper border border-ink/15 md:rounded-2xl shadow-2xl w-full h-full md:max-w-
|
|
190
|
+
className="relative bg-paper border border-ink/15 md:rounded-2xl shadow-2xl w-full h-full md:max-w-5xl lg:max-w-6xl xl:max-w-[1280px] md:h-[min(90vh,900px)] md:max-h-[92vh] flex flex-col md:flex-row overflow-hidden text-ink"
|
|
191
191
|
onClick={(e) => e.stopPropagation()}
|
|
192
192
|
>
|
|
193
193
|
{/* DESKTOP VIEW: 2-Column Split */}
|
|
194
|
-
<div className="hidden md:flex w-
|
|
194
|
+
<div className="hidden md:flex w-72 flex-shrink-0 h-full">
|
|
195
195
|
<SettingsSidebar
|
|
196
196
|
activeCategory={activeCategory}
|
|
197
197
|
onSelectCategory={(catId) => setActiveCategory(catId)}
|
|
@@ -79,14 +79,12 @@ export function Editor({
|
|
|
79
79
|
const editorTheme = useEditorTheme();
|
|
80
80
|
|
|
81
81
|
// A deleted file keeps its tab (its buffer is still on screen), but the tab
|
|
82
|
-
// strip must say so.
|
|
83
|
-
// a change rather than a document,
|
|
84
|
-
// `content` with no file behind its
|
|
85
|
-
// strike the chip through the moment
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
refreshKey,
|
|
89
|
-
);
|
|
82
|
+
// strip must say so. Which tabs can be probed is the hook's own rule
|
|
83
|
+
// (`isProbeableTab`): a diff tab's path names a change rather than a document,
|
|
84
|
+
// and an attachment chip carries inline `content` with no file behind its
|
|
85
|
+
// `path` at all — probing that name would strike the chip through the moment
|
|
86
|
+
// it was opened.
|
|
87
|
+
const missingIds = useMissingFiles(openedFiles, refreshKey);
|
|
90
88
|
const activeFileMissing = Boolean(activeFile && missingIds.has(activeFile.id));
|
|
91
89
|
|
|
92
90
|
const editor = useFileEditor(activeFile ?? null, {
|
|
@@ -39,9 +39,10 @@ interface GitBranchModalProps {
|
|
|
39
39
|
* actions — the row's click is already checkout — and a row that both checks
|
|
40
40
|
* out and merges is a row whose click means two things.
|
|
41
41
|
*
|
|
42
|
-
* Follows the commit modal's shell
|
|
43
|
-
* full-screen on phones
|
|
44
|
-
*
|
|
42
|
+
* Follows the commit modal's shell SHAPE — a desktop-capped, centred card that
|
|
43
|
+
* is full-screen on phones — but takes its own width from `Modal`
|
|
44
|
+
* (`max-w-[min(96vw,720px)]`): a branch list is one column, while the commit
|
|
45
|
+
* history spends the extra width on the graph gutter and the message column.
|
|
45
46
|
*
|
|
46
47
|
* **Everything the row shows comes from ONE read** (`?branches=1`, a single
|
|
47
48
|
* `for-each-ref` with the upstream/ahead-behind/date/subject fields), fetched
|
|
@@ -232,7 +232,7 @@ export function GitCommitModal({
|
|
|
232
232
|
<div
|
|
233
233
|
className="bg-paper border-ink/20 shadow-2xl flex flex-col overflow-hidden
|
|
234
234
|
w-full h-full rounded-none border-0
|
|
235
|
-
lg:w-[min(
|
|
235
|
+
lg:w-[min(94vw,1200px)] lg:h-[88vh] lg:rounded-xl lg:border
|
|
236
236
|
pt-[env(safe-area-inset-top,0px)] lg:pt-0"
|
|
237
237
|
onClick={(e) => e.stopPropagation()}
|
|
238
238
|
>
|
|
@@ -93,9 +93,14 @@ export function ModelDropdownPanel({
|
|
|
93
93
|
onAddProvider={onAddProvider}
|
|
94
94
|
/>
|
|
95
95
|
|
|
96
|
-
{/* Scrollable Model Lists
|
|
96
|
+
{/* Scrollable Model Lists. Deliberately no top padding: Chrome's
|
|
97
|
+
sticky view rectangle is the scrollport's CONTENT box, so a
|
|
98
|
+
`sticky top-0` heading inside a padded list pins below the padding
|
|
99
|
+
and leaves that strip showing rows sliding above it (measured: a
|
|
100
|
+
`p-1.5` list pinned its heading 6px down and `elementFromPoint` at
|
|
101
|
+
2px returned a row). The first heading sits flush instead. */}
|
|
97
102
|
<div
|
|
98
|
-
className="flex-1 scrollbar-overlay-container
|
|
103
|
+
className="flex-1 scrollbar-overlay-container px-1.5 pb-1.5 space-y-2 max-h-80"
|
|
99
104
|
onMouseLeave={onMouseLeave}
|
|
100
105
|
// The row under a resting pointer moves when the list scrolls; the
|
|
101
106
|
// card follows it instead of staying where the hover started.
|