@clagentic/console 1.7.0 → 1.8.0-beta.1

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.
Files changed (58) hide show
  1. package/bin/cli.js +198 -2542
  2. package/lib/build-sha.json +4 -0
  3. package/lib/cli/daemon-launch.js +797 -0
  4. package/lib/cli/ipc-subcommands.js +186 -0
  5. package/lib/cli/menus.js +849 -0
  6. package/lib/cli/net-detect.js +209 -0
  7. package/lib/cli/tui.js +589 -0
  8. package/lib/daemon.js +15 -6
  9. package/lib/memory-shed.js +81 -2
  10. package/lib/pages.js +13 -17
  11. package/lib/project-connection.js +13 -0
  12. package/lib/project-loop.js +4 -0
  13. package/lib/project-sessions.js +9 -3
  14. package/lib/project.js +3 -2
  15. package/lib/public/css/diagnostics.css +29 -1
  16. package/lib/public/css/home-hub.css +10 -0
  17. package/lib/public/css/overlays.css +19 -0
  18. package/lib/public/index.html +12 -11
  19. package/lib/public/manifest.json +1 -1
  20. package/lib/public/modules/app-connection.js +150 -4
  21. package/lib/public/modules/app-history-replay.js +155 -0
  22. package/lib/public/modules/app-home-hub.js +24 -14
  23. package/lib/public/modules/app-messages.js +1246 -1469
  24. package/lib/public/modules/app-notifications.js +4 -4
  25. package/lib/public/modules/app-rate-limit.js +128 -27
  26. package/lib/public/modules/command-palette.js +11 -22
  27. package/lib/public/modules/context-sources.js +1 -6
  28. package/lib/public/modules/filebrowser.js +25 -13
  29. package/lib/public/modules/input.js +47 -12
  30. package/lib/public/modules/mcp-ui.js +2 -2
  31. package/lib/public/modules/notifications.js +22 -1
  32. package/lib/public/modules/playbook.js +6 -6
  33. package/lib/public/modules/project-settings.js +5 -13
  34. package/lib/public/modules/qrcode.js +2 -2
  35. package/lib/public/modules/rate-limit-state.js +133 -0
  36. package/lib/public/modules/relative-time.js +27 -0
  37. package/lib/public/modules/scheduler-history.js +1 -5
  38. package/lib/public/modules/server-settings.js +28 -15
  39. package/lib/public/modules/sidebar-mobile.js +8 -3
  40. package/lib/public/modules/sidebar-projects.js +1 -1
  41. package/lib/public/modules/sidebar-sessions.js +1 -15
  42. package/lib/public/modules/sidebar.js +3 -3
  43. package/lib/public/modules/utils.js +1 -0
  44. package/lib/public/sw.js +24 -4
  45. package/lib/sdk-bridge.js +22 -0
  46. package/lib/sdk-message-processor.js +27 -1
  47. package/lib/server-auth.js +48 -2
  48. package/lib/server-palette.js +17 -1
  49. package/lib/server-settings.js +70 -4
  50. package/lib/server.js +200 -4
  51. package/lib/session-search.js +20 -5
  52. package/lib/sessions.js +84 -3
  53. package/lib/smtp.js +6 -6
  54. package/lib/yoke/adapters/codex.js +1 -1
  55. package/package.json +4 -2
  56. package/scripts/install-local-test.js +97 -0
  57. package/scripts/verify-installed-build.js +80 -0
  58. package/scripts/write-build-sha.js +53 -0
package/lib/cli/tui.js ADDED
@@ -0,0 +1,589 @@
1
+ // lib/cli/tui.js
2
+ //
3
+ // Terminal UI primitives for bin/cli.js: ANSI helpers, the startup logo, and
4
+ // the interactive prompt widgets (toggle / PIN / text / select / multi-select).
5
+ // Pure functions + callbacks — no shared mutable state beyond the
6
+ // `isBasicTerm` terminal-capability flag, which is fixed for the process
7
+ // lifetime. Extracted verbatim from bin/cli.js (lr-4e49 Part 1), no behavior
8
+ // change.
9
+
10
+ var fs = require("fs");
11
+ var path = require("path");
12
+ var REAL_HOME = require("../config").REAL_HOME;
13
+
14
+ // --- ANSI helpers ---
15
+ var isBasicTerm = process.env.TERM_PROGRAM === "Apple_Terminal";
16
+ var a = {
17
+ reset: "\x1b[0m",
18
+ bold: "\x1b[1m",
19
+ dim: "\x1b[2m",
20
+ indigo: isBasicTerm ? "\x1b[34m" : "\x1b[38;2;88;87;252m", // #5857FC Indigo — active interaction
21
+ green: "\x1b[32m",
22
+ yellow: "\x1b[33m",
23
+ red: "\x1b[31m",
24
+ cyan: "\x1b[36m",
25
+ };
26
+
27
+ function gradient(text) {
28
+ if (isBasicTerm) {
29
+ return a.yellow + text + a.reset;
30
+ }
31
+ // Terracotta (#FE7150) → Warm brown (#D09558) gradient
32
+ var r0 = 254, g0 = 113, b0 = 80;
33
+ var r1 = 208, g1 = 149, b1 = 88;
34
+ var out = "";
35
+ var len = text.length;
36
+ for (var i = 0; i < len; i++) {
37
+ var t = len > 1 ? i / (len - 1) : 0;
38
+ var r = Math.round(r0 + (r1 - r0) * t);
39
+ var g = Math.round(g0 + (g1 - g0) * t);
40
+ var b = Math.round(b0 + (b1 - b0) * t);
41
+ out += "\x1b[38;2;" + r + ";" + g + ";" + b + "m" + text[i];
42
+ }
43
+ return out + a.reset;
44
+ }
45
+
46
+ var sym = {
47
+ pointer: a.indigo + "◆" + a.reset,
48
+ done: a.green + "◇" + a.reset,
49
+ bar: a.dim + "│" + a.reset,
50
+ end: a.dim + "└" + a.reset,
51
+ warn: a.yellow + "▲" + a.reset,
52
+ };
53
+
54
+ function log(s) { console.log(" " + s); }
55
+
56
+ function clearUp(n) {
57
+ for (var i = 0; i < n; i++) {
58
+ process.stdout.write("\x1b[1A\x1b[2K");
59
+ }
60
+ }
61
+
62
+ // --- Logo ---
63
+ function printLogo() {
64
+ var r = a.reset;
65
+ // Clagentic: Console — startup banner (lr-5e26)
66
+ var lines = [
67
+ " ____ _ _ ____ _____ _ _ _____ ___ ____ ",
68
+ " / ___| | / \\ / ___| ____| \\ | |_ _|_ _/ ___| ",
69
+ "| | | | / _ \\| | _| _| | \\| | | | | | | ",
70
+ "| |___| |___ / ___ \\ |_| | |___| |\\ | | | | | |___ ",
71
+ " \\____|_____/_/ \\_\\____|_____|_| \\_| |_| |___\\____| ",
72
+ " : Console ",
73
+ ];
74
+ console.log("");
75
+ if (isBasicTerm) {
76
+ for (var i = 0; i < lines.length; i++) {
77
+ console.log(a.green + lines[i] + r);
78
+ }
79
+ return;
80
+ }
81
+ // Tri-accent vertical gradient: Green (#09E5A3) → Indigo (#5857FC) → Terracotta (#FE7150)
82
+ var stops = [
83
+ [9, 229, 163],
84
+ [88, 87, 252],
85
+ [254, 113, 80],
86
+ ];
87
+ for (var i = 0; i < lines.length; i++) {
88
+ var t = lines.length > 1 ? i / (lines.length - 1) : 0;
89
+ var cr, cg, cb;
90
+ if (t <= 0.5) {
91
+ var s = t * 2;
92
+ cr = Math.round(stops[0][0] + (stops[1][0] - stops[0][0]) * s);
93
+ cg = Math.round(stops[0][1] + (stops[1][1] - stops[0][1]) * s);
94
+ cb = Math.round(stops[0][2] + (stops[1][2] - stops[0][2]) * s);
95
+ } else {
96
+ var s = (t - 0.5) * 2;
97
+ cr = Math.round(stops[1][0] + (stops[2][0] - stops[1][0]) * s);
98
+ cg = Math.round(stops[1][1] + (stops[2][1] - stops[1][1]) * s);
99
+ cb = Math.round(stops[1][2] + (stops[2][2] - stops[1][2]) * s);
100
+ }
101
+ console.log("\x1b[38;2;" + cr + ";" + cg + ";" + cb + "m" + lines[i] + r);
102
+ }
103
+ }
104
+
105
+ // --- Interactive prompts ---
106
+ function promptToggle(title, desc, defaultValue, callback) {
107
+ var value = defaultValue || false;
108
+
109
+ function renderToggle() {
110
+ var yes = value
111
+ ? a.green + a.bold + "● Yes" + a.reset
112
+ : a.dim + "○ Yes" + a.reset;
113
+ var no = !value
114
+ ? a.green + a.bold + "● No" + a.reset
115
+ : a.dim + "○ No" + a.reset;
116
+ return yes + a.dim + " / " + a.reset + no;
117
+ }
118
+
119
+ var lines = 2;
120
+ log(sym.pointer + " " + a.bold + title + a.reset);
121
+ if (desc) {
122
+ log(sym.bar + " " + a.dim + desc + a.reset);
123
+ lines = 3;
124
+ }
125
+ process.stdout.write(" " + sym.bar + " " + renderToggle());
126
+
127
+ process.stdin.setRawMode(true);
128
+ process.stdin.resume();
129
+ process.stdin.setEncoding("utf8");
130
+
131
+ process.stdin.on("data", function onToggle(ch) {
132
+ if (ch === "\x1b[D" || ch === "\x1b[C" || ch === "\t") {
133
+ value = !value;
134
+ process.stdout.write("\x1b[2K\r " + sym.bar + " " + renderToggle());
135
+ } else if (ch === "y" || ch === "Y") {
136
+ value = true;
137
+ process.stdout.write("\x1b[2K\r " + sym.bar + " " + renderToggle());
138
+ } else if (ch === "n" || ch === "N") {
139
+ value = false;
140
+ process.stdout.write("\x1b[2K\r " + sym.bar + " " + renderToggle());
141
+ } else if (ch === "\r" || ch === "\n") {
142
+ process.stdin.setRawMode(false);
143
+ process.stdin.pause();
144
+ process.stdin.removeListener("data", onToggle);
145
+ process.stdout.write("\n");
146
+ clearUp(lines);
147
+ var result = value ? a.green + "Yes" + a.reset : a.dim + "No" + a.reset;
148
+ log(sym.done + " " + title + " " + a.dim + "·" + a.reset + " " + result);
149
+ callback(value);
150
+ } else if (ch === "\x03") {
151
+ process.stdout.write("\n");
152
+ clearUp(lines);
153
+ log(sym.end + " " + a.dim + "Cancelled" + a.reset);
154
+ process.exit(0);
155
+ }
156
+ });
157
+ }
158
+
159
+ function promptPin(callback) {
160
+ log(sym.pointer + " " + a.bold + "PIN protection" + a.reset);
161
+ log(sym.bar + " " + a.dim + "Require a 6-digit PIN to access the web UI. Enter to skip." + a.reset);
162
+ process.stdout.write(" " + sym.bar + " ");
163
+
164
+ var pin = "";
165
+ process.stdin.setRawMode(true);
166
+ process.stdin.resume();
167
+ process.stdin.setEncoding("utf8");
168
+
169
+ process.stdin.on("data", function onPin(ch) {
170
+ if (ch === "\r" || ch === "\n") {
171
+ process.stdin.setRawMode(false);
172
+ process.stdin.pause();
173
+ process.stdin.removeListener("data", onPin);
174
+ process.stdout.write("\n");
175
+
176
+ if (pin !== "" && !/^\d{6}$/.test(pin)) {
177
+ clearUp(3);
178
+ log(sym.done + " PIN protection " + a.red + "Must be exactly 6 digits" + a.reset);
179
+ log(sym.end);
180
+ process.exit(1);
181
+ return;
182
+ }
183
+
184
+ clearUp(3);
185
+ if (pin) {
186
+ log(sym.done + " PIN protection " + a.dim + "·" + a.reset + " " + a.green + "Enabled" + a.reset);
187
+ } else {
188
+ log(sym.done + " PIN protection " + a.dim + "· Skipped" + a.reset);
189
+ }
190
+ log(sym.bar);
191
+ callback(pin || null);
192
+ } else if (ch === "\x03") {
193
+ process.stdout.write("\n");
194
+ clearUp(3);
195
+ log(sym.end + " " + a.dim + "Cancelled" + a.reset);
196
+ process.exit(0);
197
+ } else if (ch === "\x7f" || ch === "\b") {
198
+ if (pin.length > 0) {
199
+ pin = pin.slice(0, -1);
200
+ process.stdout.write("\b \b");
201
+ }
202
+ } else if (/\d/.test(ch) && pin.length < 6) {
203
+ pin += ch;
204
+ process.stdout.write(a.indigo + "●" + a.reset);
205
+ }
206
+ });
207
+ }
208
+
209
+ /**
210
+ * Text input prompt with placeholder and Tab directory completion.
211
+ * title: prompt label, placeholder: dimmed hint, callback(value)
212
+ * Enter with empty input returns placeholder value.
213
+ * Tab completes directory paths.
214
+ */
215
+ function promptText(title, placeholder, callback, opts) {
216
+ var prefix = " " + sym.bar + " ";
217
+ var hintLine = "";
218
+ var lineCount = 2;
219
+ var escHint = (!title || (opts && opts.noEsc)) ? "" : " " + a.dim + "(esc to go back)" + a.reset;
220
+ log(sym.pointer + " " + a.bold + title + a.reset + escHint);
221
+ process.stdout.write(prefix + a.dim + placeholder + a.reset);
222
+ // Move cursor to start of placeholder
223
+ process.stdout.write("\r" + prefix);
224
+
225
+ var text = "";
226
+ var showingPlaceholder = true;
227
+ process.stdin.setRawMode(true);
228
+ process.stdin.resume();
229
+ process.stdin.setEncoding("utf8");
230
+
231
+ function redrawInput() {
232
+ process.stdout.write("\x1b[2K\r" + prefix + text);
233
+ }
234
+
235
+ function clearHint() {
236
+ if (hintLine) {
237
+ // Erase the hint line below
238
+ process.stdout.write("\n\x1b[2K\x1b[1A");
239
+ hintLine = "";
240
+ lineCount = 2;
241
+ }
242
+ }
243
+
244
+ function showHint(msg) {
245
+ clearHint();
246
+ hintLine = msg;
247
+ lineCount = 3;
248
+ // Print hint below, then move cursor back up
249
+ process.stdout.write("\n" + prefix + a.dim + msg + a.reset + "\x1b[1A");
250
+ redrawInput();
251
+ }
252
+
253
+ function tabComplete() {
254
+ var current = text || "";
255
+ if (!current) current = "/";
256
+
257
+ // Resolve ~ to home
258
+ if (current.charAt(0) === "~") {
259
+ current = REAL_HOME + current.substring(1);
260
+ }
261
+
262
+ var resolved = path.resolve(current);
263
+ var dir, partial;
264
+
265
+ try {
266
+ var st = fs.statSync(resolved);
267
+ if (st.isDirectory()) {
268
+ // Current text is a full directory — list its children
269
+ dir = resolved;
270
+ partial = "";
271
+ } else {
272
+ dir = path.dirname(resolved);
273
+ partial = path.basename(resolved);
274
+ }
275
+ } catch (e) {
276
+ // Path doesn't exist — complete from parent
277
+ dir = path.dirname(resolved);
278
+ partial = path.basename(resolved);
279
+ }
280
+
281
+ var entries;
282
+ try {
283
+ entries = fs.readdirSync(dir);
284
+ } catch (e) {
285
+ return; // Can't read directory
286
+ }
287
+
288
+ // Filter to directories only, matching partial prefix
289
+ var matches = [];
290
+ var lowerPartial = partial.toLowerCase();
291
+ for (var i = 0; i < entries.length; i++) {
292
+ if (entries[i].charAt(0) === "." && !partial.startsWith(".")) continue;
293
+ if (lowerPartial && entries[i].toLowerCase().indexOf(lowerPartial) !== 0) continue;
294
+ try {
295
+ var full = path.join(dir, entries[i]);
296
+ if (fs.statSync(full).isDirectory()) {
297
+ matches.push(entries[i]);
298
+ }
299
+ } catch (e) {}
300
+ }
301
+
302
+ if (matches.length === 0) return;
303
+
304
+ if (matches.length === 1) {
305
+ // Single match — complete it
306
+ var completed = path.join(dir, matches[0]) + path.sep;
307
+ text = completed;
308
+ showingPlaceholder = false;
309
+ clearHint();
310
+ redrawInput();
311
+ } else {
312
+ // Multiple matches — find longest common prefix and show candidates
313
+ var common = matches[0];
314
+ for (var m = 1; m < matches.length; m++) {
315
+ var k = 0;
316
+ while (k < common.length && k < matches[m].length && common.charAt(k) === matches[m].charAt(k)) k++;
317
+ common = common.substring(0, k);
318
+ }
319
+
320
+ if (common.length > partial.length) {
321
+ // Extend to common prefix
322
+ text = path.join(dir, common);
323
+ showingPlaceholder = false;
324
+ }
325
+
326
+ // Show candidates as hint
327
+ var display = matches.slice(0, 6).join(" ");
328
+ if (matches.length > 6) display += " " + a.dim + "+" + (matches.length - 6) + " more" + a.reset;
329
+ showHint(display);
330
+ }
331
+ }
332
+
333
+ process.stdin.on("data", function onText(ch) {
334
+ if (ch === "\r" || ch === "\n") {
335
+ process.stdin.setRawMode(false);
336
+ process.stdin.pause();
337
+ process.stdin.removeListener("data", onText);
338
+ var result = text || placeholder;
339
+ clearHint();
340
+ process.stdout.write("\n");
341
+ clearUp(2);
342
+ log(sym.done + " " + title + " " + a.dim + "·" + a.reset + " " + result);
343
+ callback(result);
344
+ } else if (ch === "\x1b" || ch === "\x03") {
345
+ process.stdin.setRawMode(false);
346
+ process.stdin.pause();
347
+ process.stdin.removeListener("data", onText);
348
+ clearHint();
349
+ process.stdout.write("\n");
350
+ clearUp(2);
351
+ if (ch === "\x03") {
352
+ log(sym.end + " " + a.dim + "Cancelled" + a.reset);
353
+ process.exit(0);
354
+ }
355
+ callback(null);
356
+ } else if (ch === "\t") {
357
+ if (showingPlaceholder) {
358
+ // Accept placeholder first
359
+ text = placeholder;
360
+ showingPlaceholder = false;
361
+ redrawInput();
362
+ }
363
+ tabComplete();
364
+ } else if (ch === "\x7f" || ch === "\b") {
365
+ if (text.length > 0) {
366
+ text = text.slice(0, -1);
367
+ clearHint();
368
+ if (text.length === 0) {
369
+ // Re-show placeholder
370
+ showingPlaceholder = true;
371
+ process.stdout.write("\x1b[2K\r" + prefix + a.dim + placeholder + a.reset);
372
+ process.stdout.write("\r" + prefix);
373
+ } else {
374
+ redrawInput();
375
+ }
376
+ }
377
+ } else if (ch >= " ") {
378
+ if (showingPlaceholder) {
379
+ showingPlaceholder = false;
380
+ }
381
+ clearHint();
382
+ text += ch;
383
+ redrawInput();
384
+ }
385
+ });
386
+ }
387
+
388
+ /**
389
+ * Select menu: arrow keys to navigate, enter to select.
390
+ * items: [{ label, value, desc? }]
391
+ */
392
+ function promptSelect(title, items, callback, opts) {
393
+ var idx = 0;
394
+ // Build hotkeys map: { key: handler }
395
+ var hotkeys = {};
396
+ if (opts && opts.key && opts.onKey) {
397
+ hotkeys[opts.key] = opts.onKey;
398
+ }
399
+ if (opts && opts.keys) {
400
+ for (var ki = 0; ki < opts.keys.length; ki++) {
401
+ hotkeys[opts.keys[ki].key] = opts.keys[ki].onKey;
402
+ }
403
+ }
404
+ var hintLines = null;
405
+ if (opts && opts.hint) {
406
+ hintLines = Array.isArray(opts.hint) ? opts.hint : [opts.hint];
407
+ }
408
+
409
+ function render() {
410
+ var out = "";
411
+ for (var i = 0; i < items.length; i++) {
412
+ var prefix = i === idx
413
+ ? a.green + a.bold + " ● " + a.reset
414
+ : a.dim + " ○ " + a.reset;
415
+ out += " " + sym.bar + prefix + items[i].label + "\n";
416
+ }
417
+ return out;
418
+ }
419
+
420
+ log(sym.pointer + " " + a.bold + title + a.reset);
421
+ process.stdout.write(render());
422
+
423
+ // Render hint lines below the menu tree
424
+ var hintBoxLines = 0;
425
+ if (hintLines) {
426
+ log(sym.end);
427
+ for (var h = 0; h < hintLines.length; h++) {
428
+ log(" " + gradient(hintLines[h]));
429
+ }
430
+ hintBoxLines = 1 + hintLines.length; // sym.end + lines
431
+ }
432
+
433
+ var lineCount = items.length + 1 + hintBoxLines;
434
+
435
+ process.stdin.setRawMode(true);
436
+ process.stdin.resume();
437
+ process.stdin.setEncoding("utf8");
438
+
439
+ process.stdin.on("data", function onSelect(ch) {
440
+ if (ch === "\x1b[A") { // up
441
+ if (idx > 0) idx--;
442
+ } else if (ch === "\x1b[B") { // down
443
+ if (idx < items.length - 1) idx++;
444
+ } else if (ch === "\r" || ch === "\n") {
445
+ process.stdin.setRawMode(false);
446
+ process.stdin.pause();
447
+ process.stdin.removeListener("data", onSelect);
448
+ clearUp(lineCount);
449
+ log(sym.done + " " + title + " " + a.dim + "·" + a.reset + " " + items[idx].label);
450
+ callback(items[idx].value);
451
+ return;
452
+ } else if (ch === "\x03") {
453
+ process.stdout.write("\n");
454
+ process.exit(0);
455
+ } else if (hotkeys[ch]) {
456
+ process.stdin.setRawMode(false);
457
+ process.stdin.pause();
458
+ process.stdin.removeListener("data", onSelect);
459
+ clearUp(lineCount);
460
+ hotkeys[ch]();
461
+ return;
462
+ } else if (ch === "\x7f" || ch === "\b") {
463
+ // Backspace — trigger "back" if available
464
+ for (var bi = 0; bi < items.length; bi++) {
465
+ if (items[bi].value === "back") {
466
+ process.stdin.setRawMode(false);
467
+ process.stdin.pause();
468
+ process.stdin.removeListener("data", onSelect);
469
+ clearUp(lineCount);
470
+ log(sym.done + " " + title + " " + a.dim + "·" + a.reset + " " + items[bi].label);
471
+ callback("back");
472
+ return;
473
+ }
474
+ }
475
+ return;
476
+ } else {
477
+ return;
478
+ }
479
+ // Redraw
480
+ clearUp(items.length + hintBoxLines);
481
+ process.stdout.write(render());
482
+ // Re-render hint lines
483
+ if (hintLines) {
484
+ log(sym.end);
485
+ for (var rh = 0; rh < hintLines.length; rh++) {
486
+ log(" " + gradient(hintLines[rh]));
487
+ }
488
+ }
489
+ });
490
+ }
491
+
492
+ /**
493
+ * Multi-select menu: space to toggle, enter to confirm.
494
+ * items: [{ label, value, checked? }]
495
+ * callback(selectedValues[])
496
+ */
497
+ function promptMultiSelect(title, items, callback) {
498
+ var selected = [];
499
+ for (var si = 0; si < items.length; si++) {
500
+ selected.push(items[si].checked !== false);
501
+ }
502
+ var idx = 0;
503
+
504
+ function render() {
505
+ var out = "";
506
+ for (var i = 0; i < items.length; i++) {
507
+ var cursor = i === idx ? a.indigo + ">" + a.reset : " ";
508
+ var check = selected[i]
509
+ ? a.green + a.bold + "■" + a.reset
510
+ : a.dim + "□" + a.reset;
511
+ out += " " + sym.bar + " " + cursor + " " + check + " " + items[i].label + "\n";
512
+ }
513
+ out += " " + sym.bar + " " + a.dim + "space: toggle · enter: confirm" + a.reset + "\n";
514
+ return out;
515
+ }
516
+
517
+ log(sym.pointer + " " + a.bold + title + a.reset);
518
+ process.stdout.write(render());
519
+
520
+ var lineCount = items.length + 2; // title + items + hint
521
+
522
+ process.stdin.setRawMode(true);
523
+ process.stdin.resume();
524
+ process.stdin.setEncoding("utf8");
525
+
526
+ process.stdin.on("data", function onMulti(ch) {
527
+ if (ch === "\x1b[A") { // up
528
+ if (idx > 0) idx--;
529
+ } else if (ch === "\x1b[B") { // down
530
+ if (idx < items.length - 1) idx++;
531
+ } else if (ch === " ") { // toggle
532
+ selected[idx] = !selected[idx];
533
+ } else if (ch === "a" || ch === "A") { // toggle all
534
+ var allSelected = selected.every(function (s) { return s; });
535
+ for (var ai = 0; ai < selected.length; ai++) selected[ai] = !allSelected;
536
+ } else if (ch === "\r" || ch === "\n") {
537
+ process.stdin.setRawMode(false);
538
+ process.stdin.pause();
539
+ process.stdin.removeListener("data", onMulti);
540
+ clearUp(lineCount);
541
+ var result = [];
542
+ var labels = [];
543
+ for (var ri = 0; ri < items.length; ri++) {
544
+ if (selected[ri]) {
545
+ result.push(items[ri].value);
546
+ labels.push(items[ri].label);
547
+ }
548
+ }
549
+ var summary = result.length === items.length
550
+ ? "All (" + result.length + ")"
551
+ : result.length + " of " + items.length;
552
+ log(sym.done + " " + title + " " + a.dim + "·" + a.reset + " " + summary);
553
+ callback(result);
554
+ return;
555
+ } else if (ch === "\x03") {
556
+ process.stdout.write("\n");
557
+ process.exit(0);
558
+ } else if (ch === "\x1b") {
559
+ // Escape — select none
560
+ process.stdin.setRawMode(false);
561
+ process.stdin.pause();
562
+ process.stdin.removeListener("data", onMulti);
563
+ clearUp(lineCount);
564
+ log(sym.done + " " + title + " " + a.dim + "· Skipped" + a.reset);
565
+ callback([]);
566
+ return;
567
+ } else {
568
+ return;
569
+ }
570
+ // Redraw
571
+ clearUp(items.length + 1); // items + hint (not title)
572
+ process.stdout.write(render());
573
+ });
574
+ }
575
+
576
+ module.exports = {
577
+ isBasicTerm: isBasicTerm,
578
+ a: a,
579
+ gradient: gradient,
580
+ sym: sym,
581
+ log: log,
582
+ clearUp: clearUp,
583
+ printLogo: printLogo,
584
+ promptToggle: promptToggle,
585
+ promptPin: promptPin,
586
+ promptText: promptText,
587
+ promptSelect: promptSelect,
588
+ promptMultiSelect: promptMultiSelect,
589
+ };
package/lib/daemon.js CHANGED
@@ -564,12 +564,21 @@ var relay = createServer({
564
564
  for (var pi = 0; pi < config.projects.length; pi++) {
565
565
  if (config.projects[pi].slug === wtParent) { parentProject = config.projects[pi]; break; }
566
566
  }
567
- if (parentProject) {
568
- var rmResult = removeWorktree(parentProject.path, wtDirName);
569
- if (!rmResult.ok) {
570
- console.log("[daemon] Failed to remove worktree:", slug, rmResult.error);
571
- return { ok: false, error: rmResult.error };
572
- }
567
+ if (!parentProject) {
568
+ // Parent project is gone from config (removed/renamed) — we cannot
569
+ // resolve the worktree's on-disk path, so `git worktree remove` never
570
+ // runs and the checkout stays on disk. Surface this as a failure
571
+ // instead of silently reporting success (lr-fc2818): previously this
572
+ // branch fell through to relay.removeProject/unregisterWorktreeSlug
573
+ // and returned {ok:true}, unregistering the slug while leaving the
574
+ // worktree directory and branch behind with no way to retry from the UI.
575
+ console.log("[daemon] Cannot remove worktree, parent project not found:", slug);
576
+ return { ok: false, error: "Parent project not found; worktree left on disk. Remove it manually with 'git worktree remove'." };
577
+ }
578
+ var rmResult = removeWorktree(parentProject.path, wtDirName);
579
+ if (!rmResult.ok) {
580
+ console.log("[daemon] Failed to remove worktree:", slug, rmResult.error);
581
+ return { ok: false, error: rmResult.error };
573
582
  }
574
583
  relay.removeProject(slug);
575
584
  unregisterWorktreeSlug(wtParent, slug);