my-durable 0.0.51 → 0.0.53
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/apps/dpi-tui/src/app.ts +43 -23
- package/apps/dpi-tui/src/main.ts +13 -6
- package/apps/dpi-tui/src/views.ts +13 -5
- package/apps/dpi-tui/src/welcome.ts +9 -1
- package/package.json +1 -1
package/apps/dpi-tui/src/app.ts
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ProcessTerminal,
|
|
9
9
|
TuiAltScreen,
|
|
10
10
|
matchesKey,
|
|
11
|
+
truncateToWidth,
|
|
11
12
|
type Component,
|
|
12
13
|
type OverlayHandle,
|
|
13
14
|
type TuiInputListenerResult,
|
|
@@ -27,7 +28,18 @@ import {
|
|
|
27
28
|
import type { DeviceRow, NetworkRegistry } from "../../dpi-sdk/src/node/registry.ts";
|
|
28
29
|
import { COMMANDS, runCommand } from "./commands.ts";
|
|
29
30
|
import { Prompt, SecretPrompt, pickModel, newSession } from "./pickers.ts";
|
|
30
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
renderHeader,
|
|
33
|
+
renderHerd,
|
|
34
|
+
renderHerdPanel,
|
|
35
|
+
renderNetwork,
|
|
36
|
+
renderStatusbar,
|
|
37
|
+
renderViewbar,
|
|
38
|
+
herdRows,
|
|
39
|
+
joinPanel,
|
|
40
|
+
networkRows,
|
|
41
|
+
VIEW_TABS,
|
|
42
|
+
} from "./views.ts";
|
|
31
43
|
import { appendFileSync } from "node:fs";
|
|
32
44
|
import { fetchHubNetwork } from "./hub-feed.ts";
|
|
33
45
|
import { HubMux } from "./hub-mux.ts";
|
|
@@ -52,12 +64,10 @@ const AGENT_TABS: { id: AgentTab; label: string }[] = [
|
|
|
52
64
|
{ id: "config", label: "config" },
|
|
53
65
|
];
|
|
54
66
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
{ id: "log", label: "log" },
|
|
60
|
-
];
|
|
67
|
+
// VIEW_TABS lives in views.ts — ONE source of truth shared by the viewbar
|
|
68
|
+
// labels and the digit keys (live-caught: a local copy here kept the old
|
|
69
|
+
// order while the viewbar taught the new one, so 1 printed "network" but
|
|
70
|
+
// opened herd).
|
|
61
71
|
|
|
62
72
|
/**
|
|
63
73
|
* Slash-command autocomplete: the commands whose name extends the typed
|
|
@@ -466,16 +476,18 @@ export class App {
|
|
|
466
476
|
});
|
|
467
477
|
}
|
|
468
478
|
|
|
469
|
-
/** 1-
|
|
479
|
+
/** 1-4 switch views (see jump). */
|
|
480
|
+
/**
|
|
481
|
+
* 1-4 switch views — everywhere, matching the digits printed in the
|
|
482
|
+
* viewbar. Usability pass: digits used to jump the nth session, which only
|
|
483
|
+
* made sense in the herd list and left view switching to three mixed-case
|
|
484
|
+
* mnemonics (g/N/L). Sessions open with j/k + enter, which every list
|
|
485
|
+
* already teaches in its status line.
|
|
486
|
+
*/
|
|
470
487
|
private jump(n: number) {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
(r): r is { kind: "session"; sessionId: string; deviceId?: string; label: string } => !!r.sessionId,
|
|
475
|
-
);
|
|
476
|
-
const nth = rows[n - 1];
|
|
477
|
-
if (nth?.sessionId) this.openSession(nth.sessionId, nth.deviceId);
|
|
478
|
-
else this.notify(`no session #${n} in this view`);
|
|
488
|
+
const tab = VIEW_TABS[n - 1];
|
|
489
|
+
if (tab) this.setView(tab.id);
|
|
490
|
+
else this.notify("views are 1-4 (network · herd · agent · log)");
|
|
479
491
|
}
|
|
480
492
|
|
|
481
493
|
private async submit(text: string, mode?: "followUp") {
|
|
@@ -588,6 +600,7 @@ export class App {
|
|
|
588
600
|
else if (data === "m") this.beginInput("message", "follow-up ❯ ");
|
|
589
601
|
else if (data === "]" || matchesKey(data, "tab")) this.cycleTab(1);
|
|
590
602
|
else if (data === "[" || matchesKey(data, "shift+tab")) this.cycleTab(-1);
|
|
603
|
+
else if (data === "t") this.cycleTab(1); // t = tabs, same walk as ]
|
|
591
604
|
else if (/^[1-9]$/.test(data)) this.jump(Number(data));
|
|
592
605
|
// No catch-all: a stray letter used to jump views or open the composer with
|
|
593
606
|
// itself as the first character. herdr and piggery both require an explicit
|
|
@@ -1248,9 +1261,9 @@ export class App {
|
|
|
1248
1261
|
const rows = [
|
|
1249
1262
|
`${c.accent("▲")} ${c.bold("dpi keymap (herdr template)")}`,
|
|
1250
1263
|
"",
|
|
1251
|
-
`${c.accent("j k ↑ ↓")} move/scroll ${c.accent("1-
|
|
1252
|
-
`${c.accent("↵")} open ${c.accent("g N L")}
|
|
1253
|
-
`${c.accent("[ ]")}
|
|
1264
|
+
`${c.accent("j k ↑ ↓")} move/scroll ${c.accent("1-4")} views: net/herd/agent/log`,
|
|
1265
|
+
`${c.accent("↵")} open ${c.accent("g N L")} same views, aliases`,
|
|
1266
|
+
`${c.accent("[ ] t")} agent tabs ${c.accent("m")} message (enter sends)`,
|
|
1254
1267
|
`${c.accent("esc")} back/interrupt ${c.accent("i")} interrupt ≠ kill`,
|
|
1255
1268
|
`${c.accent("F")} fork ${c.accent("c")} compact context`,
|
|
1256
1269
|
`${c.accent("y")} thinking level ${c.accent("x")} reset (y/n confirm)`,
|
|
@@ -1289,9 +1302,13 @@ export class App {
|
|
|
1289
1302
|
|
|
1290
1303
|
private panelLine(width: number, content: string, active: boolean): string {
|
|
1291
1304
|
const inner = width - 4;
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1305
|
+
// Visible-width clip + pad, not raw length: the theme's truecolor spans
|
|
1306
|
+
// add ~19 invisible raw chars each, so raw slicing ate the overlay's
|
|
1307
|
+
// right column at every width (help's "views: net/herd/agent/log" never
|
|
1308
|
+
// rendered). truncateToWidth counts ANSI-stripped columns, keeps the
|
|
1309
|
+
// spans, closes any cut style and pads to exactly `inner` — the line can
|
|
1310
|
+
// never exceed the panel. Same helper views.ts already trusts.
|
|
1311
|
+
const padded = truncateToWidth(content, inner, "", true);
|
|
1295
1312
|
return `${c.muted(box.v)} ${active ? c.inverse(padded) : padded} ${c.muted(box.v)}`;
|
|
1296
1313
|
}
|
|
1297
1314
|
|
|
@@ -1321,7 +1338,10 @@ function place(panel: string[], width: number, height: number, x: number, y: num
|
|
|
1321
1338
|
panel.forEach((line, index) => {
|
|
1322
1339
|
const row = y + index;
|
|
1323
1340
|
if (row < 0 || row >= height) return;
|
|
1324
|
-
|
|
1341
|
+
// Visible columns again: raw slicing could cut an escape mid-sequence and
|
|
1342
|
+
// drop the right border; truncateToWidth clips safely and pads the row
|
|
1343
|
+
// to exactly the screen width.
|
|
1344
|
+
out[row] = rep(" ", x) + truncateToWidth(line, Math.max(0, width - x), "", true);
|
|
1325
1345
|
});
|
|
1326
1346
|
return out;
|
|
1327
1347
|
}
|
package/apps/dpi-tui/src/main.ts
CHANGED
|
@@ -136,17 +136,24 @@ const hubEnv = (() => {
|
|
|
136
136
|
const startup = resolveStartupAction({ devices: registry.list(), env: process.env, args: { deviceRef, url, pair: values.pair } });
|
|
137
137
|
|
|
138
138
|
if (startup.kind === "welcome") {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
if (hubEnv) {
|
|
140
|
+
// Hub-first boot: with hub credentials there is always something to show,
|
|
141
|
+
// so the app opens straight into the network view (devices + sessions) —
|
|
142
|
+
// no welcome wall to dismiss first. The welcome actions stay available
|
|
143
|
+
// behind the palette (pair, add-url) for the rare local-only path.
|
|
144
|
+
const app = new App(
|
|
143
145
|
WELCOME_DEVICE,
|
|
144
146
|
new DpiClient(WELCOME_DEVICE.url, WELCOME_DEVICE.token),
|
|
145
147
|
emptyDeviceInfo(),
|
|
146
148
|
registry,
|
|
147
149
|
hubEnv,
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
+
);
|
|
151
|
+
app.setView("network");
|
|
152
|
+
} else {
|
|
153
|
+
showWelcome(
|
|
154
|
+
new App(WELCOME_DEVICE, new DpiClient(WELCOME_DEVICE.url, WELCOME_DEVICE.token), emptyDeviceInfo(), registry),
|
|
155
|
+
);
|
|
156
|
+
}
|
|
150
157
|
} else if (startup.kind === "auto-open" || startup.kind === "picker") {
|
|
151
158
|
const row = startup.kind === "auto-open" ? startup.device : startup.devices[0]!;
|
|
152
159
|
const device: DeviceRef = { id: row.id, name: row.name, url: row.url!, token: row.token! };
|
|
@@ -10,8 +10,11 @@ import { c, STATE_COLOR, STATE_GLYPH, type RowState } from "./theme.ts";
|
|
|
10
10
|
export type View = "herd" | "network" | "agent" | "log";
|
|
11
11
|
|
|
12
12
|
export const VIEW_TABS: { id: View; label: string }[] = [
|
|
13
|
-
|
|
13
|
+
// Order = the user's journey (and the digit keys): land in the network
|
|
14
|
+
// (hub-first boot), pick a session into the herd dashboard, converse in the
|
|
15
|
+
// agent view, watch the log. Tab cycles the same order.
|
|
14
16
|
{ id: "network", label: "network" },
|
|
17
|
+
{ id: "herd", label: "herd" },
|
|
15
18
|
{ id: "agent", label: "agent" },
|
|
16
19
|
{ id: "log", label: "log" },
|
|
17
20
|
];
|
|
@@ -226,10 +229,15 @@ export function renderNetwork(
|
|
|
226
229
|
return lines.map((l) => fit(l, w));
|
|
227
230
|
}
|
|
228
231
|
|
|
229
|
-
/**
|
|
232
|
+
/**
|
|
233
|
+
* The one-line viewbar under the header: active tab inverse + a right-aligned
|
|
234
|
+
* hint. Every view carries its digit (1 network · 2 herd · 3 agent · 4 log) —
|
|
235
|
+
* the digit keys work EVERYWHERE, so view switching is one glance away instead
|
|
236
|
+
* of three mnemonics (g/N/L) to memorize.
|
|
237
|
+
*/
|
|
230
238
|
export function renderViewbar(w: number, view: View, right: string): string {
|
|
231
|
-
const tabs = VIEW_TABS.map((t) =>
|
|
232
|
-
t.id === view ? c.inverse(c.bold(` ${t.label} `)) : c.muted(` ${t.label} `),
|
|
239
|
+
const tabs = VIEW_TABS.map((t, i) =>
|
|
240
|
+
t.id === view ? c.inverse(c.bold(` ${i + 1} ${t.label} `)) : c.muted(` ${i + 1} ${t.label} `),
|
|
233
241
|
).join(c.muted("│"));
|
|
234
242
|
const gap = Math.max(1, w - visibleWidth(tabs) - visibleWidth(right) - 1);
|
|
235
243
|
return fit(`${tabs}${rep(" ", gap)}${c.muted(right)}`, w);
|
|
@@ -246,7 +254,7 @@ export function renderStatusbar(
|
|
|
246
254
|
? ["tab complete", "↑ history", "enter send", "esc cancel"]
|
|
247
255
|
: opts.view === "agent"
|
|
248
256
|
? ["g herd", "N network", "L log", "[ ] tabs", "m message"]
|
|
249
|
-
: ["j/k move", "↵ open", "1-
|
|
257
|
+
: ["j/k move", "↵ open", "1-4 views", "⇥ tabs", "esc agent"];
|
|
250
258
|
const right = `${c.muted("ctx")} ${opts.ctxLeft === undefined ? c.muted("—") : c.text(`${opts.ctxLeft}%`)}${opts.background ? c.muted(` · ${opts.background} bg`) : ""} ${c.muted("dev")} ${c.text(fit(opts.device, 18))}`;
|
|
251
259
|
const left = `${chip} ${keys.map((k) => c.muted(k)).join(c.muted(" • "))}`;
|
|
252
260
|
const gap = Math.max(1, w - visibleWidth(left) - visibleWidth(right));
|
|
@@ -290,7 +290,15 @@ export function showWelcome(app: App, opts: { notice?: string } = {}) {
|
|
|
290
290
|
},
|
|
291
291
|
() => {
|
|
292
292
|
picked = true;
|
|
293
|
-
|
|
293
|
+
// Usability pass: Esc must never surprise-quit. With a hub configured
|
|
294
|
+
// it lands in the network view (the feed is one key away); without one
|
|
295
|
+
// the old quit behavior stands — there is nothing else to show.
|
|
296
|
+
if (app.hubUrl) {
|
|
297
|
+
app.closeOverlay();
|
|
298
|
+
app.setView("network");
|
|
299
|
+
} else {
|
|
300
|
+
app.exit();
|
|
301
|
+
}
|
|
294
302
|
},
|
|
295
303
|
subtitle,
|
|
296
304
|
),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-durable",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.53",
|
|
4
4
|
"description": "Durable Pi — the durable agent network: hub web UI, device backend daemon, TUI admin and the shared SDK, packaged as one runnable monorepo install",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|