my-durable 0.0.50 → 0.0.52

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.
@@ -6,6 +6,7 @@ import { computed, ref, watch } from "vue";
6
6
  import { CalendarClock, Play, Plus, RefreshCw, Trash2, Power } from "lucide-vue-next";
7
7
  import type { ScheduleView } from "@sdk/api";
8
8
  import { deviceClient, message } from "../client/hub";
9
+ import { isStaleDeviceError, staleDeviceHint } from "../client/stale";
9
10
  import { notify, selected, ui } from "../client/store";
10
11
 
11
12
  const schedules = ref<ScheduleView[]>([]);
@@ -27,11 +28,9 @@ async function load() {
27
28
  try {
28
29
  schedules.value = (await client().schedules()).schedules;
29
30
  } catch (e) {
30
- const code = (e as { code?: string }).code;
31
- error.value =
32
- code === "not_found" || /allowlist/i.test(message(e))
33
- ? "This device runs an older build: update it (`dpi update`) to use schedules."
34
- : message(e).slice(0, 160);
31
+ error.value = isStaleDeviceError(e)
32
+ ? staleDeviceHint(deviceId.value, "schedules")
33
+ : message(e).slice(0, 220);
35
34
  } finally {
36
35
  loading.value = false;
37
36
  }
@@ -7,6 +7,7 @@ import { computed, ref, watch } from "vue";
7
7
  import { Activity, Cpu, FolderGit2, RefreshCw } from "lucide-vue-next";
8
8
  import type { DeviceUsageReport } from "@sdk/api";
9
9
  import { deviceClient, message } from "../client/hub";
10
+ import { isStaleDeviceError, staleDeviceHint } from "../client/stale";
10
11
  import { notify, selected } from "../client/store";
11
12
 
12
13
  const usage = ref<DeviceUsageReport>();
@@ -54,11 +55,9 @@ async function load() {
54
55
  try {
55
56
  usage.value = await deviceClient(id).deviceUsage();
56
57
  } catch (e) {
57
- const text = message(e);
58
- error.value =
59
- (e as { code?: string }).code === "not_found" || /allowlist|not found/i.test(text)
60
- ? "This device runs an older build: update it (`dpi update`) to see usage."
61
- : text.slice(0, 160);
58
+ error.value = isStaleDeviceError(e)
59
+ ? staleDeviceHint(deviceId.value, "usage")
60
+ : message(e).slice(0, 220);
62
61
  } finally {
63
62
  busy.value = false;
64
63
  }
@@ -27,7 +27,18 @@ import {
27
27
  import type { DeviceRow, NetworkRegistry } from "../../dpi-sdk/src/node/registry.ts";
28
28
  import { COMMANDS, runCommand } from "./commands.ts";
29
29
  import { Prompt, SecretPrompt, pickModel, newSession } from "./pickers.ts";
30
- import { renderHeader, renderHerd, renderHerdPanel, renderNetwork, renderStatusbar, renderViewbar, herdRows, joinPanel, networkRows } from "./views.ts";
30
+ import {
31
+ renderHeader,
32
+ renderHerd,
33
+ renderHerdPanel,
34
+ renderNetwork,
35
+ renderStatusbar,
36
+ renderViewbar,
37
+ herdRows,
38
+ joinPanel,
39
+ networkRows,
40
+ VIEW_TABS,
41
+ } from "./views.ts";
31
42
  import { appendFileSync } from "node:fs";
32
43
  import { fetchHubNetwork } from "./hub-feed.ts";
33
44
  import { HubMux } from "./hub-mux.ts";
@@ -52,12 +63,10 @@ const AGENT_TABS: { id: AgentTab; label: string }[] = [
52
63
  { id: "config", label: "config" },
53
64
  ];
54
65
 
55
- const VIEW_TABS: { id: View; label: string }[] = [
56
- { id: "herd", label: "herd" },
57
- { id: "network", label: "network" },
58
- { id: "agent", label: "agent" },
59
- { id: "log", label: "log" },
60
- ];
66
+ // VIEW_TABS lives in views.ts — ONE source of truth shared by the viewbar
67
+ // labels and the digit keys (live-caught: a local copy here kept the old
68
+ // order while the viewbar taught the new one, so 1 printed "network" but
69
+ // opened herd).
61
70
 
62
71
  /**
63
72
  * Slash-command autocomplete: the commands whose name extends the typed
@@ -466,16 +475,18 @@ export class App {
466
475
  });
467
476
  }
468
477
 
469
- /** 1-9 jump: the nth session row of the current view. */
478
+ /** 1-4 switch views (see jump). */
479
+ /**
480
+ * 1-4 switch views — everywhere, matching the digits printed in the
481
+ * viewbar. Usability pass: digits used to jump the nth session, which only
482
+ * made sense in the herd list and left view switching to three mixed-case
483
+ * mnemonics (g/N/L). Sessions open with j/k + enter, which every list
484
+ * already teaches in its status line.
485
+ */
470
486
  private jump(n: number) {
471
- // Digits address sessions, so they work from the agent view as well — that
472
- // is the fastest way out of a session you no longer want.
473
- const rows = (this.view === "herd" ? this.rows() : herdRows(this.sessions, this.filter)).filter(
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`);
487
+ const tab = VIEW_TABS[n - 1];
488
+ if (tab) this.setView(tab.id);
489
+ else this.notify("views are 1-4 (network · herd · agent · log)");
479
490
  }
480
491
 
481
492
  private async submit(text: string, mode?: "followUp") {
@@ -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
- // Hub credentials ride along so the welcome offers the hub network — the
140
- // feed is one key away instead of invisible behind the overlay.
141
- showWelcome(
142
- new App(
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
- { id: "herd", label: "herd" },
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
- /** The one-line viewbar under the header: active tab inverse + a right-aligned hint. */
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-9 jump", "⇥ views", "esc agent"];
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
- app.exit();
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.50",
3
+ "version": "0.0.52",
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": {