my-durable 0.0.57 → 0.0.58

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.
@@ -47,13 +47,17 @@ const busy = computed(() => session.value?.busy || agent.value?.busy);
47
47
  * oldest devices predate the rename and report `durableVersion` instead of
48
48
  * `packageVersion` — they are exactly the ones the badge exists for. */
49
49
  const behind = computed(() => {
50
- const info = device.value?.info as { packageVersion?: string; durableVersion?: string } | undefined;
50
+ const info = device.value?.info as
51
+ | { packageVersion?: string; durableVersion?: string }
52
+ | undefined;
51
53
  const theirs = info?.packageVersion ?? info?.durableVersion;
52
54
  const ours = hubVersion.value;
53
55
  return Boolean(theirs && ours && ours !== "unknown" && theirs !== ours);
54
56
  });
55
57
  const theirVersion = computed(() => {
56
- const info = device.value?.info as { packageVersion?: string; durableVersion?: string } | undefined;
58
+ const info = device.value?.info as
59
+ | { packageVersion?: string; durableVersion?: string }
60
+ | undefined;
57
61
  return info?.packageVersion ?? info?.durableVersion ?? "?";
58
62
  });
59
63
  const statusText = computed(() => {
@@ -87,8 +91,11 @@ const label = computed(
87
91
  () => device.value?.name ?? device.value?.id ?? session.value?.name ?? agent.value?.name ?? "",
88
92
  );
89
93
  const title = computed(() => {
90
- if (device.value)
91
- return `${device.value.name} · ${device.value.url}${device.value.error ? `\n${device.value.error}` : ""}`;
94
+ // A tunnel device has no url (NetworkDevice.url is nullable) — never render `· null`.
95
+ if (device.value) {
96
+ const d = device.value;
97
+ return `${d.name}${d.url ? ` · ${d.url}` : ""}${d.error ? `\n${d.error}` : ""}`;
98
+ }
92
99
  if (session.value) return `${session.value.name}\n${session.value.cwd}`;
93
100
  const a = agent.value!;
94
101
  return a.kind === "fork"
@@ -176,7 +183,9 @@ const title = computed(() => {
176
183
  <FolderOpen class="ico" :size="16" />
177
184
  <b class="name">{{ label }}</b>
178
185
  <span class="path">…/{{ session.cwd.split("/").filter(Boolean).at(-1) }}</span>
179
- <span v-if="branch" class="branch" :title="`git branch of ${session.cwd}`">⎇ {{ branch }}</span>
186
+ <span v-if="branch" class="branch" :title="`git branch of ${session.cwd}`"
187
+ >⎇ {{ branch }}</span
188
+ >
180
189
  <span
181
190
  v-if="session.model"
182
191
  class="tag"
@@ -250,4 +259,9 @@ const title = computed(() => {
250
259
  </div>
251
260
  </template>
252
261
 
253
- <style scoped>.bulk-check { margin-left: 2px; flex-shrink: 0; }</style>
262
+ <style scoped>
263
+ .bulk-check {
264
+ margin-left: 2px;
265
+ flex-shrink: 0;
266
+ }
267
+ </style>
@@ -25,6 +25,7 @@ export function run(cmd: string, args: string[], options: RunOptions = {}): Prom
25
25
  cwd: options.cwd,
26
26
  env: options.env ?? process.env,
27
27
  stdio: ["pipe", "pipe", "pipe"],
28
+ windowsHide: true,
28
29
  });
29
30
  let stdout = "";
30
31
  let stderr = "";
@@ -42,7 +42,7 @@ import {
42
42
  } from "./views.ts";
43
43
  import { appendFileSync } from "node:fs";
44
44
  import { fetchHubNetwork } from "./hub-feed.ts";
45
- import { HubMux } from "./hub-mux.ts";
45
+ import { HubMux, type MuxState } from "./hub-mux.ts";
46
46
  import { box, c, STATE_COLOR, STATE_GLYPH, type RowState } from "./theme.ts";
47
47
 
48
48
  export interface DeviceRef {
@@ -175,6 +175,10 @@ export class App {
175
175
  }
176
176
  /** The hub's /api/stream mux — tunnel-device attach (same transport as the web). */
177
177
  private mux?: HubMux;
178
+ /** Last mux state, surfaced in the header (R4 finding 5: the loss used to be silent). */
179
+ private muxState?: MuxState;
180
+ /** One-shot disconnect toast: shown once per outage, echoed by the reconnect note. */
181
+ private muxToastShown = false;
178
182
  /** True while the current device is reached through the hub proxy. */
179
183
  private viaHub = false;
180
184
  private hubRows: DeviceRow[] = [];
@@ -240,6 +244,8 @@ export class App {
240
244
  private deviceOnline = false;
241
245
  private events: { at: string; glyph: string; text: string }[] = [];
242
246
  private selectedId?: string;
247
+ /** Long-running fetch note (dirs on a cold tunnel, R4 finding 8): message line. */
248
+ private pendingNote: string | null = null;
243
249
 
244
250
  constructor(
245
251
  device: DeviceRef,
@@ -265,10 +271,7 @@ export class App {
265
271
  this.model.subscribe(() => this.requestRender());
266
272
  this.session.subscribe(() => this.requestRender());
267
273
  this.ticker = setInterval(() => this.tick(), 120);
268
- if (this.hub)
269
- void fetchHubNetwork(this.hub.url, this.hub.token).then((rows) => {
270
- if (rows) (this.hubRows = rows), this.requestRender();
271
- });
274
+ this.refreshHubNetwork();
272
275
  this.tui.start();
273
276
  void this.refreshSessions();
274
277
  this.requestRender();
@@ -338,7 +341,7 @@ export class App {
338
341
  // (REST) + the hub's stream mux (events), exactly like the web FE.
339
342
  if (!this.hub) return this.notify(`${row.name} is tunnel-only — start the TUI with --hub-url/--hub-token`, true);
340
343
  const client = new DpiClient(`${this.hub.url}/api/devices/${row.id}`, this.hub.token);
341
- this.mux ??= new HubMux(this.hub);
344
+ this.mux ??= new HubMux(this.hub, (state) => this.onMuxState(state));
342
345
  return void this.run(async () => {
343
346
  this.info = await client.device({ timeoutMs: 10_000 });
344
347
  this.streams?.abort();
@@ -384,6 +387,42 @@ export class App {
384
387
  }
385
388
  }
386
389
 
390
+ /** One /api/network poll — boot, tick, mux reconnect and network entry all ride this. */
391
+ private refreshHubNetwork() {
392
+ if (!this.hub) return;
393
+ void fetchHubNetwork(this.hub.url, this.hub.token).then((rows) => {
394
+ if (rows) {
395
+ this.hubRows = rows;
396
+ if (this.view === "network") this.devicesCache = this.networkDevices();
397
+ this.requestRender();
398
+ }
399
+ });
400
+ }
401
+
402
+ /**
403
+ * Hub mux state → header chip + one-shot toast. Live-caught (R4 finding 5):
404
+ * killing the hub left the header at stale `● live` with zero feedback — the
405
+ * agent stream never errors, it just stops delivering frames.
406
+ */
407
+ private onMuxState(state: MuxState) {
408
+ this.muxState = state;
409
+ if (state === "offline") {
410
+ if (!this.muxToastShown) {
411
+ this.muxToastShown = true;
412
+ this.notify("hub offline — reconnecting…", true);
413
+ }
414
+ } else if (state === "live") {
415
+ if (this.muxToastShown) {
416
+ this.muxToastShown = false;
417
+ this.notify("hub back online");
418
+ }
419
+ // Frames flow again: re-fetch the network rows that froze with the old
420
+ // connection (R4 finding 6 — the view stayed empty through every switch).
421
+ this.refreshHubNetwork();
422
+ }
423
+ this.requestRender();
424
+ }
425
+
387
426
  /** The open session's working folder — what /git operates on. */
388
427
  cwd(): string | undefined {
389
428
  return this.sessionSummary()?.cwd ?? undefined;
@@ -410,7 +449,12 @@ export class App {
410
449
  this.scrollOffset = 0;
411
450
  if (view === "herd") void this.refreshSessions();
412
451
  if (view === "herd") this.refreshBranches();
413
- if (view === "network") this.devicesCache = this.networkDevices();
452
+ if (view === "network") {
453
+ this.devicesCache = this.networkDevices();
454
+ // Entering an empty network view while the mux is live means the rows were
455
+ // lost with a reconnecting hub — poll once instead of waiting out the tick.
456
+ if (!this.devicesCache.length && this.mux?.live) this.refreshHubNetwork();
457
+ }
414
458
  this.requestRender();
415
459
  }
416
460
 
@@ -418,11 +462,14 @@ export class App {
418
462
  // The hub feed is the same source the web sidebar renders; fall back to
419
463
  // the local registry when no hub is configured or before the first poll.
420
464
  let rows = this.hubRows.length ? this.hubRows : this.registry ? this.registry.list() : [];
421
- // The current device also appears as a hub row (same deviceUid) — drop
422
- // that one and keep the direct LAN row, but inherit the hub's tree so its
423
- // sessions still list here.
465
+ // The current device also appears as a hub row (same deviceUid) — drop that
466
+ // one ONLY when a sibling row for the same device survives (the direct LAN
467
+ // row, whose tree the hub row was enriching). A tunnel-only current device
468
+ // must keep its hub row: dropping the only row emptied the network view
469
+ // through every view switch (R4 finding 6).
424
470
  const mine = this.info?.uid ? rows.find((r) => r.deviceUid === this.info!.uid) : undefined;
425
- if (mine) rows = rows.filter((r) => r !== mine);
471
+ if (mine && rows.some((r) => r !== mine && r.deviceUid === mine.deviceUid))
472
+ rows = rows.filter((r) => r !== mine);
426
473
  if (this.device.id !== "adhoc" || rows.some((r) => r.id === "adhoc")) return rows;
427
474
  return [
428
475
  ...rows,
@@ -562,6 +609,25 @@ export class App {
562
609
  this.notify(`thinking: ${next}`);
563
610
  }
564
611
 
612
+ /**
613
+ * Shared reset tail. The x key lands here AFTER its own y/n line; the /reset
614
+ * command door asks its own confirm first (R4 finding 4 — the command used to
615
+ * wipe the context with no question at all).
616
+ */
617
+ resetContext(note?: string) {
618
+ if (!this.handle) return Promise.resolve(this.notify("Pick a session first (g, then ↵).", true));
619
+ return this.run(async () => {
620
+ await this.handle!.reset(note);
621
+ this.notify("New context started; history stays stored");
622
+ });
623
+ }
624
+
625
+ /** A long fetch (dirs on a cold tunnel) holds the message line with a ◌ note. */
626
+ setPending(text: string | null) {
627
+ this.pendingNote = text;
628
+ this.requestRender();
629
+ }
630
+
565
631
  // ------------------------------------------------------------------- input
566
632
 
567
633
  handleInput(data: string): TuiInputListenerResult {
@@ -742,7 +808,9 @@ export class App {
742
808
  if (cmd) cmd.run(this);
743
809
  else this.notify(`no command “${value.trim()}”`);
744
810
  } else if (input.kind === "kill") {
745
- if (value.trim().toLowerCase().startsWith("y")) void this.command("reset");
811
+ // The x line IS the confirm — run the shared tail, not the command door
812
+ // (which asks its own y/n and would double-prompt).
813
+ if (value.trim().toLowerCase().startsWith("y")) void this.resetContext();
746
814
  else this.notify("reset cancelled");
747
815
  } else if (input.kind === "new") void newSession(this, value);
748
816
  return true;
@@ -849,8 +917,12 @@ export class App {
849
917
  // ------------------------------------------------------------- overlays
850
918
 
851
919
  overlay(component: Component, onClose?: () => void) {
920
+ // minWidth 60 fits the widest picker hint ("↑↓/j/k move │ enter select │
921
+ // type to filter │ esc close" = 55 visible cols + padding) at a bare 80-col
922
+ // terminal — at the old 40 the hint's operative verb clipped to `esc c…`
923
+ // (R4 finding 7).
852
924
  this.overlays.push({
853
- handle: this.tui.showOverlay(component, { width: "70%", minWidth: 40, maxHeight: "80%" }),
925
+ handle: this.tui.showOverlay(component, { width: "70%", minWidth: 60, maxHeight: "80%" }),
854
926
  onClose,
855
927
  });
856
928
  this.tui.requestRender();
@@ -860,12 +932,17 @@ export class App {
860
932
  return this.overlays.length;
861
933
  }
862
934
 
863
- closeOverlay(exitIfNothing = false) {
935
+ /**
936
+ * Esc must never surprise-quit (the 0.0.52 decision): closing the last
937
+ * overlay lands on the live view, and quitting stays on q / ctrl+c / /quit.
938
+ * Live-caught (R4 finding 1): the session picker passed `exitIfNothing` so
939
+ * picker→Esc→Esc with no attached session silently killed the process.
940
+ */
941
+ closeOverlay() {
864
942
  const overlay = this.overlays.pop();
865
943
  overlay?.handle.hide();
866
944
  overlay?.onClose?.();
867
945
  if (!this.overlays.length) this.tui.setFocus(this.root);
868
- if (exitIfNothing) return this.exit();
869
946
  this.tui.requestRender();
870
947
  }
871
948
 
@@ -974,13 +1051,7 @@ export class App {
974
1051
  // paired from the CLI shows up while the operator is looking at the list.
975
1052
  if (this.hub && ++this.hubTick >= 42) {
976
1053
  this.hubTick = 0;
977
- void fetchHubNetwork(this.hub.url, this.hub.token).then((rows) => {
978
- if (rows) {
979
- this.hubRows = rows;
980
- if (this.view === "network") this.devicesCache = this.networkDevices();
981
- this.requestRender();
982
- }
983
- });
1054
+ this.refreshHubNetwork();
984
1055
  }
985
1056
  this.requestRender();
986
1057
  }
@@ -1014,6 +1085,18 @@ export class App {
1014
1085
 
1015
1086
  private header(w: number): string {
1016
1087
  const devices = this.registry ? this.networkDevices() : [];
1088
+ // A hub-routed device reports the MUX truth first: when the SSE died the
1089
+ // agent stream stays nominally "live" while frames stop (R4 finding 5).
1090
+ const hubDown = this.viaHub && this.mux && this.muxState !== "live";
1091
+ const conn = hubDown
1092
+ ? this.muxState === "offline"
1093
+ ? "hub offline"
1094
+ : "hub connecting"
1095
+ : this.connection === "live"
1096
+ ? "live"
1097
+ : this.connection === "idle"
1098
+ ? "no agent"
1099
+ : String(this.connection);
1017
1100
  return (
1018
1101
  " " +
1019
1102
  renderHeader(w - 2, {
@@ -1021,8 +1104,8 @@ export class App {
1021
1104
  sessions: this.sessions.length,
1022
1105
  devicesOnline: devices.filter((d) => d.lastStatus === "online").length,
1023
1106
  devicesTotal: devices.length || undefined,
1024
- conn: this.connection === "live" ? "live" : this.connection === "idle" ? "no agent" : String(this.connection),
1025
- connOk: this.connection === "live",
1107
+ conn,
1108
+ connOk: hubDown ? false : this.connection === "live",
1026
1109
  })
1027
1110
  );
1028
1111
  }
@@ -1245,6 +1328,7 @@ export class App {
1245
1328
  return " " + `${c.muted(this.toast)}${c.text(shown)}${c.accent("▌")}`.slice(0, w);
1246
1329
  }
1247
1330
  if (this.toast) return " " + `${this.toast.startsWith("✗") ? c.err(this.toast) : c.accent("◆") + " " + c.text(this.toast)}`.slice(0, w);
1331
+ if (this.pendingNote) return " " + c.warn(`◌ ${this.pendingNote}`).slice(0, w);
1248
1332
  if (this.view === "agent") {
1249
1333
  const hint =
1250
1334
  this.tab === "transcript"
@@ -1310,6 +1394,7 @@ export class App {
1310
1394
  `${c.muted("·")} every turn is checkpointed on the device`,
1311
1395
  `${c.muted("·")} interrupt leaves the run resumable; only reset starts fresh`,
1312
1396
  `${c.muted("·")} sends retry by requestId — the device admits each exactly once`,
1397
+ `${c.muted("·")} a lost hub shows ○ hub offline in the header and reconnects alone`,
1313
1398
  `${c.muted("·")} /commands still work: type them in the message line`,
1314
1399
  ];
1315
1400
  const height = Math.min(rows.length + 2, h);
@@ -2,7 +2,7 @@
2
2
  import type { SlashCommand } from "@earendil-works/pi-tui";
3
3
  import { THINKING_LEVELS, type ThinkingLevel } from "../../dpi-sdk/src/api.ts";
4
4
  import type { App } from "./app.ts";
5
- import { Panel, pickAgent, pickDevice, pickModel, pickSession } from "./pickers.ts";
5
+ import { Panel, pickAgent, pickDevice, pickModel, pickSession, pickThinking } from "./pickers.ts";
6
6
  import { parsePairArgs, runPairing } from "./pairing.ts";
7
7
  import { c } from "./theme.ts";
8
8
  import { basename, dirname, isAbsolute, join } from "node:path";
@@ -155,11 +155,23 @@ export async function runCommand(app: App, text: string): Promise<boolean> {
155
155
  break;
156
156
  }
157
157
  case "thinking": {
158
- if (!THINKING_LEVELS.includes(arg as ThinkingLevel))
159
- return app.flash(`Levels: ${THINKING_LEVELS.join(", ")}`, true), true;
160
- await app.run(async () => {
161
- await handle!.configure({ thinkingLevel: arg as ThinkingLevel });
162
- });
158
+ // A bare /thinking (the palette door) opens the same picker the
159
+ // new-session flow uses — it used to dead-end in a "Levels: …" flash
160
+ // (R4 finding 2). A valid argument still sets directly.
161
+ const apply = async (level: ThinkingLevel) => {
162
+ if (!handle) return app.flash("Pick a session first (g, then ↵).", true);
163
+ await app.run(async () => {
164
+ await handle!.configure({ thinkingLevel: level });
165
+ app.flash(`thinking: ${level}`);
166
+ });
167
+ };
168
+ if (!THINKING_LEVELS.includes(arg as ThinkingLevel)) {
169
+ const picked = await pickThinking(app, String(app.model.state.agent.thinkingLevel ?? "low"));
170
+ if (!picked) break;
171
+ await apply(picked);
172
+ break;
173
+ }
174
+ await apply(arg as ThinkingLevel);
163
175
  break;
164
176
  }
165
177
  case "compact":
@@ -169,18 +181,33 @@ export async function runCommand(app: App, text: string): Promise<boolean> {
169
181
  });
170
182
  break;
171
183
  case "reset":
172
- await app.run(async () => {
173
- await handle!.reset(arg || undefined);
174
- app.flash("New context started; history stays stored");
175
- });
184
+ // The x key confirms y/n before reset (app.ts) — the command door must
185
+ // not skip that gate (R4 finding 4: the palette entry used to wipe the
186
+ // context unconditionally). A typed handoff note carries its own intent.
187
+ if (!arg) {
188
+ const ok = await app.prompt(`Reset ${app.sessionSummary()?.name ?? "context"}? y/n`, "");
189
+ if (ok === undefined || !ok.trim().toLowerCase().startsWith("y"))
190
+ return app.flash("reset cancelled"), true;
191
+ }
192
+ await app.resetContext(arg || undefined);
176
193
  break;
177
- case "name":
178
- if (!arg) return app.flash("Usage: /name <name>", true), true;
194
+ case "name": {
195
+ // A bare /name (the palette door) opens the rename Prompt instead of the
196
+ // dead-end usage flash (R4 finding 2).
197
+ let value = arg;
198
+ if (!value) {
199
+ const current = app.sessionSummary()?.agents.find((a) => a.id === app.agentId)?.name ?? "";
200
+ const typed = await app.prompt("Agent name", current && current !== "main" ? current : "");
201
+ value = (typed ?? "").trim();
202
+ if (!value) return app.flash("rename cancelled"), true;
203
+ }
204
+ if (!handle) return app.flash("Pick a session first (g, then ↵).", true), true;
179
205
  await app.run(async () => {
180
- await handle!.rename(arg);
181
- app.flash(`Agent renamed to ${arg}`);
206
+ await handle!.rename(value);
207
+ app.flash(`Agent renamed to ${value}`);
182
208
  });
183
209
  break;
210
+ }
184
211
  case "git":
185
212
  await gitCommand(app, arg);
186
213
  break;
@@ -269,7 +269,13 @@ export async function pickSession(app: App) {
269
269
  const s = tree.sessions.find((x) => x.id === item.value)!;
270
270
  const root = s.agents.find((a) => a.kind === "root") ?? s.agents[0];
271
271
  void app.attach(s.id, root?.id ?? 1);
272
- }, () => app.closeOverlay(!app.sessionId)),
272
+ }, () => {
273
+ // Esc must never surprise-quit (0.0.52): with no attached session the
274
+ // cancel used to pass exitIfNothing=true and picker→Esc→Esc killed the
275
+ // whole process (R4 finding 1). Landing in the herd/network view is the
276
+ // honest cancel; quitting stays on q / ctrl+c / /quit.
277
+ app.closeOverlay();
278
+ }),
273
279
  );
274
280
  }
275
281
 
@@ -278,7 +284,12 @@ export async function newSession(app: App, presetName?: string) {
278
284
  const name = presetName !== undefined ? presetName : await app.prompt("Session name", "");
279
285
  if (name === undefined) return app.sessionId ? undefined : pickSession(app);
280
286
  const cwd = await walkDirs(app, "");
281
- if (!cwd) return app.sessionId ? undefined : pickSession(app);
287
+ // undefined = esc (back to the sessions picker when detached); null = the
288
+ // device could not list directories — the error is already flashed, so
289
+ // dead-end HERE instead of silently swapping to the unrelated "Sessions on…"
290
+ // picker (R4 finding 8).
291
+ if (cwd === undefined) return app.sessionId ? undefined : pickSession(app);
292
+ if (cwd === null) return;
282
293
  // A device without a provider key (the Windows default) lists ZERO models —
283
294
  // the picker would be empty and creation dead-ends. Fall back to the device's
284
295
  // own default exactly like the web dialog's "(device default)" option.
@@ -289,26 +300,44 @@ export async function newSession(app: App, presetName?: string) {
289
300
  if (!model) return;
290
301
  // Thinking rides the create call: pick a level up front instead of paying
291
302
  // for "high" on a scratch session the device default never asked for.
292
- const thinking = await chooseThinking(app);
303
+ const thinking = await pickThinking(app);
293
304
  if (!thinking) return;
294
305
  await app.run(async () => {
295
- const s = await app.client.createSession({
296
- name: name || "New session",
297
- cwd,
298
- model: { provider: model.provider, modelId: model.id },
299
- thinkingLevel: thinking,
300
- });
301
- await app.attach(s.id, s.agents.find((a) => a.kind === "root")?.id ?? 1);
302
- app.flash(`Session created in ${cwd}`);
303
- if (!models.length) app.flash(`no model catalog on the device — using its default (${app.info.defaultModel})`);
306
+ // The create+attach round-trip is the silent 2-20s dead-air on a cold
307
+ // tunnel (R4 finding 8) — hold the message line while it flies.
308
+ app.setPending(`creating ${name || "New session"} on ${app.device.name}…`);
309
+ try {
310
+ const s = await app.client.createSession({
311
+ name: name || "New session",
312
+ cwd,
313
+ model: { provider: model.provider, modelId: model.id },
314
+ thinkingLevel: thinking,
315
+ });
316
+ await app.attach(s.id, s.agents.find((a) => a.kind === "root")?.id ?? 1);
317
+ app.flash(`Session created in ${cwd}`);
318
+ if (!models.length) app.flash(`no model catalog on the device — using its default (${app.info.defaultModel})`);
319
+ } finally {
320
+ app.setPending(null);
321
+ }
304
322
  });
305
323
  }
306
324
 
307
- function walkDirs(app: App, path: string): Promise<string | undefined> {
325
+ /**
326
+ * The directory walk for a new session's working folder. Resolves:
327
+ * string — the chosen directory;
328
+ * undefined — the user canceled (esc);
329
+ * null — the device RPC failed (the error is already flashed).
330
+ * Exported for the busy-note / failure-path unit tests.
331
+ */
332
+ export function walkDirs(app: App, path: string): Promise<string | undefined | null> {
308
333
  return new Promise((done) => {
309
334
  const step = async (at: string) => {
335
+ // A cold tunnel lists in 2-20s — hold the message line so the silence
336
+ // never reads as a dead app (R4 finding 8).
337
+ app.setPending(`listing ${at || "start dirs"} on ${app.device.name}…`);
310
338
  const listing = await app.client.dirs(at).catch((e: Error) => (app.flash(e.message, true), undefined));
311
- if (!listing) return done(undefined);
339
+ app.setPending(null);
340
+ if (!listing) return done(null);
312
341
  const items: SelectItem[] = [
313
342
  ...(listing.path ? [{ value: `use:${listing.path}`, label: `✓ Use ${listing.path}` }] : []),
314
343
  ...(listing.path ? [{ value: listing.parent ?? "", label: listing.parent ? ".." : "⌂ start dirs" }] : []),
@@ -356,8 +385,12 @@ function chooseModel(app: App, current?: string) {
356
385
  });
357
386
  }
358
387
 
359
- /** The new-session thinking step: the same levels `y` cycles in-session. */
360
- function chooseThinking(app: App) {
388
+ /**
389
+ * The thinking-level picker: the new-session step AND the /thinking command
390
+ * door (R4 finding 2 — the palette entry used to dead-end in a usage flash).
391
+ * Preselects the agent's current level, else the backend create default.
392
+ */
393
+ export function pickThinking(app: App, current?: string) {
361
394
  return new Promise<ThinkingLevel | undefined>((done) => {
362
395
  const picker = new Picker(
363
396
  "Thinking level",
@@ -371,8 +404,8 @@ function chooseThinking(app: App) {
371
404
  done(undefined);
372
405
  },
373
406
  );
374
- // Preselect the backend's create default, so a bare enter keeps "medium".
375
- const index = THINKING_LEVELS.indexOf("medium");
407
+ const wanted = current && THINKING_LEVELS.includes(current as ThinkingLevel) ? current : "medium";
408
+ const index = THINKING_LEVELS.indexOf(wanted as ThinkingLevel);
376
409
  if (index >= 0) picker.list.setSelectedIndex(index);
377
410
  app.overlay(picker);
378
411
  });
package/bin/update.mjs CHANGED
@@ -159,6 +159,7 @@ export function spawnNpm(args) {
159
159
  const child = spawn(onWindows ? "npm.cmd" : "npm", args, {
160
160
  stdio: ["ignore", "pipe", "pipe"],
161
161
  shell: onWindows,
162
+ windowsHide: true,
162
163
  });
163
164
  let output = "";
164
165
  child.stdout?.on("data", (x) => {
@@ -191,7 +192,7 @@ export async function fetchLatestVersion() {
191
192
  export function daemonControl(dpiPath, port) {
192
193
  const call = (args) =>
193
194
  new Promise((resolve) => {
194
- const child = spawn(process.execPath, [dpiPath, ...args], { stdio: "ignore" });
195
+ const child = spawn(process.execPath, [dpiPath, ...args], { stdio: "ignore", windowsHide: true });
195
196
  child.on("error", () => resolve(1));
196
197
  child.on("exit", (code) => resolve(code ?? 1));
197
198
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-durable",
3
- "version": "0.0.57",
3
+ "version": "0.0.58",
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": {
@@ -185,12 +185,19 @@ function run(name, suite) {
185
185
  const cwd = join(ROOT, suite.cwd);
186
186
  process.stdout.write(`\n▶ ${name} — ${suite.title}\n cwd: ${suite.cwd}\n cmd: ${suite.cmd.join(" ")}\n`);
187
187
  const t0 = Date.now();
188
+ // Bare npm/npx are .cmd shims on Windows — a shell-less spawn cannot find
189
+ // them and fails with ENOENT. The suite commands are fixed arrays with no
190
+ // user input, so a shell is safe there; windowsHide keeps the runner
191
+ // console-free on both platforms.
192
+ const onWindows = process.platform === "win32";
188
193
  const r = spawnSync(suite.cmd[0], suite.cmd.slice(1), {
189
194
  cwd,
190
195
  env: { ...process.env, DPI_TEST: "1", NO_COLOR: "1" },
191
196
  encoding: "utf8",
192
197
  timeout: 1_800_000,
193
198
  maxBuffer: 256 * 1024 * 1024,
199
+ shell: onWindows,
200
+ windowsHide: true,
194
201
  });
195
202
  const secs = ((Date.now() - t0) / 1000).toFixed(1);
196
203
  const out = `${r.stdout ?? ""}${r.stderr ?? ""}`;