happier-tui 0.2.2 → 0.4.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 CHANGED
@@ -6,7 +6,7 @@ Pick a session running on any of your machines, read it live, send prompts, answ
6
6
  requests, start new sessions — and get a bell or a notification from your terminal, tmux or cmux
7
7
  when an agent needs you.
8
8
 
9
- ![happier-tui start screen](https://raw.githubusercontent.com/CyrilPeponnet/happier-tui/main/assets/main.png)
9
+ ![A tour of happier-tui: the start screen, a conversation, an agent at work, a permission request and a question](https://raw.githubusercontent.com/CyrilPeponnet/happier-tui/main/assets/demo.gif)
10
10
 
11
11
  happier-tui is an independent, unofficial client. It talks to the Happier relay directly (HTTP and
12
12
  Socket.IO, end-to-end encrypted) and is built on
@@ -48,7 +48,7 @@ To update: `git pull && npm install && npm run build` in the same folder. Withou
48
48
 
49
49
  ```
50
50
  happier-tui start screen: pick or start a session
51
- happier-tui <session-id-or-prefix> open a session directly
51
+ happier-tui <session-id-or-prefix> open a session directly (or --session <id>)
52
52
  happier-tui <directory> start a new session on this machine in that directory
53
53
  happier-tui --list [--all] print active (or all) sessions and exit
54
54
 
@@ -62,7 +62,11 @@ happier-tui --list [--all] print active (or all) sessions and exit
62
62
 
63
63
  ### Start screen
64
64
 
65
- Active sessions grouped by machine. Type to search by title, host, agent or path.
65
+ Active sessions grouped by machine, each with its agent, folder and last activity, or what it
66
+ is doing: `working`, `needs you` (a permission request or a question) or `new reply` (not seen
67
+ yet). Type to search by title, host, agent or path.
68
+
69
+ ![The start screen: sessions on several machines, with what each one is doing](https://raw.githubusercontent.com/CyrilPeponnet/happier-tui/main/assets/home.png)
66
70
 
67
71
  | Key | Action |
68
72
  | --- | --- |
@@ -100,9 +104,11 @@ Type `@` to mention a file: completion lists the files of the session's folder o
100
104
  | `/rename` | rename the session |
101
105
  | `/sessions`, `/new-session`, `/abort`, `/stop-session`, `/archive`, `/reload`, `/keys`, `/quit` | |
102
106
 
103
- When the agent ends its turn offering choices, a picker opens: press the number or use the
104
- arrows to send one as your reply, or `esc` to write your own (`ctrl+r` brings it back). You can
105
- also click a choice in the transcript. Permission requests open the same way.
107
+ When the agent ends its turn offering choices, the first one is highlighted in the transcript:
108
+ `↑` `↓` move the highlight and `enter` sends it as your reply. Typing writes your own reply
109
+ instead; `esc` puts the highlight away (`ctrl+r` brings it back). You can also click a choice.
110
+ Permission requests and questions open a picker above the editor, which closes by itself once
111
+ the request is answered elsewhere.
106
112
 
107
113
  Anything else starting with `/` goes to the agent, whose own commands are offered in
108
114
  autocomplete. The agent publishes them once it has handled a first message, so a new session
@@ -120,8 +126,10 @@ output; `ctrl+o` unfolds everything.
120
126
 
121
127
  ## Knowing when an agent needs you
122
128
 
123
- When a session you are not looking at finishes its turn, fails, or asks for a permission or an
124
- answer, happier-tui signals it through the terminal:
129
+ ![A permission request from an agent on another machine, answered from the TUI](https://raw.githubusercontent.com/CyrilPeponnet/happier-tui/main/assets/permission.png)
130
+
131
+ When the open session finishes its turn, fails, or asks for a permission or an answer while you
132
+ are not looking at it, happier-tui signals it through the terminal:
125
133
 
126
134
  - **Bell.** Works everywhere. tmux flags the window in its status line, cmux and most terminals
127
135
  mark the tab.
@@ -129,7 +137,10 @@ answer, happier-tui signals it through the terminal:
129
137
  sidebar badge, banner), Ghostty, WezTerm and others; ignored by terminals that do not know it.
130
138
  Inside tmux this part needs `set -g allow-passthrough on`.
131
139
 
132
- Nothing is raised for the session on screen while the terminal has focus.
140
+ Nothing is raised while you are at the terminal looking at that session. Other sessions never
141
+ ring: they are listed in the footer, marked as on the start screen (`!` needs you, `●` new
142
+ reply), until you open them, answer their request or they start working again. So with one
143
+ happier-tui per session, as cmux or tmux tabs, each event rings only the tab showing that session.
133
144
 
134
145
  **Phone pushes.** While you are at the terminal (it has focus and you used it in the last three
135
146
  minutes), happier-tui reports a focused computer to the relay, as the Happier desktop app does.
@@ -141,6 +152,14 @@ session is also marked read, so the unread badge clears on your other devices.
141
152
  If a signal does not show up, run with `HAPPIER_TUI_DEBUG=/tmp/happier-tui.log`. The log records
142
153
  focus changes and, for each turn or request change, whether a signal was sent.
143
154
 
155
+ ## cmux tab restore
156
+
157
+ Inside [cmux](https://cmux.com), happier-tui registers the open session as the tab's restore
158
+ command (`happier-tui --session <id>`), so the tab comes back on that session after cmux restarts.
159
+ cmux only restores tabs registered by its agent hooks, so happier-tui uses pi's: the tab shows as Pi.
160
+ Quitting normally clears the entry. The restore runs with your default server: cmux does not keep
161
+ other options such as `--server`.
162
+
144
163
  ## How it works
145
164
 
146
165
  ```
@@ -180,10 +199,16 @@ of CLI 0.2.20, so a relay or CLI upgrade may require changes here.
180
199
 
181
200
  ```bash
182
201
  npm run dev # run from source
202
+ npm run demo # the TUI on made-up sessions, no account needed
183
203
  npm test # unit tests
184
204
  npm run typecheck
185
205
  ```
186
206
 
207
+ The README's animation and screenshots come from the demo: `npm run screenshots` (needs
208
+ [VHS](https://github.com/charmbracelet/vhs), `brew install vhs`) plays the tour in
209
+ [`scripts/screenshots.tape`](scripts/screenshots.tape) and rewrites `assets/demo.gif` and the PNGs.
210
+ Change the made-up sessions and the agent's scripted replies in [`scripts/demo.ts`](scripts/demo.ts).
211
+
187
212
  ### Releasing
188
213
 
189
214
  Releases are made by GitHub Actions. Pushing a version tag runs `.github/workflows/release.yml`,
package/dist/app.js CHANGED
@@ -6,6 +6,7 @@ import { latestOptions, Transcript } from "./happier/transcript.js";
6
6
  import { attentionChange, FOCUS_IN, FOCUS_OUT, notificationSequence, } from "./ui/notify.js";
7
7
  import { NewSessionFlow } from "./new-session.js";
8
8
  import { errorText, justify, machineName, questionsOf, requestSummary, shortHost, untilText } from "./ui/format.js";
9
+ import { cmuxBind, cmuxUnbind } from "./cmux.js";
9
10
  import { SessionAutocomplete } from "./ui/autocomplete.js";
10
11
  import { PromptEditor } from "./ui/prompt-editor.js";
11
12
  import { Picker } from "./ui/picker.js";
@@ -86,6 +87,8 @@ export class App {
86
87
  prompted = new Set();
87
88
  /** Last observed attention-relevant state per session, to notify on changes only. */
88
89
  attention = new Map();
90
+ /** Other sessions that signalled and still wait for the user, shown in the footer (latest last). */
91
+ rang = new Map();
89
92
  /** Whether this terminal has focus. Only meaningful once `focusKnown` is set. */
90
93
  focused = true;
91
94
  /** The terminal has reported focus at least once, i.e. it supports focus reporting. */
@@ -98,7 +101,12 @@ export class App {
98
101
  loadError = "";
99
102
  frame = 0;
100
103
  notice = null;
104
+ /** The open picker, floating or docked; hide() closes it. */
101
105
  overlay = null;
106
+ /** A picker answering a request, shown above the editor so the conversation stays visible. */
107
+ docked = null;
108
+ /** Offered choices picked from the keyboard, highlighted in the transcript (`key` as in `prompted`). */
109
+ optionPick = null;
102
110
  lastCtrlC = 0;
103
111
  everConnected = false;
104
112
  connection = "connecting";
@@ -137,7 +145,7 @@ export class App {
137
145
  scrollToEndIndicator: () => c.accent(" ↓ jump to latest "),
138
146
  });
139
147
  this.scroll = new ScrollView(this.view, { follow: "end", primary: true, scrollbar: "auto" });
140
- this.editor = new PromptEditor(this.tui, editorTheme, { paddingX: 1 });
148
+ this.editor = new PromptEditor(this.tui, editorTheme, { paddingX: 2 });
141
149
  this.editor.onSubmit = (text) => void this.submit(text);
142
150
  this.home = new Home(() => {
143
151
  const machines = [...this.client.machines.values()];
@@ -153,10 +161,14 @@ export class App {
153
161
  unread: this.unread,
154
162
  currentId: this.currentId,
155
163
  frame: this.frame,
164
+ connecting: !this.loaded || this.connection !== "connected",
156
165
  rows: this.tui.terminal.rows - this.renderRequests(this.tui.terminal.columns).length,
157
166
  status: this.loaded
158
- ? `${this.client.config.serverName} ${link}${c.dim(` · ${active} active session${active === 1 ? "" : "s"} · ${online} machine${online === 1 ? "" : "s"} online`)}`
159
- : c.dim(this.loadError || `Connecting to ${this.client.config.serverName}…`),
167
+ ? [
168
+ `${this.client.config.serverName} ${link}`,
169
+ c.dim(`${active} active session${active === 1 ? "" : "s"} · ${online} machine${online === 1 ? "" : "s"} online`),
170
+ ]
171
+ : [c.dim(this.loadError || `Connecting to ${this.client.config.serverName}…`)],
160
172
  };
161
173
  });
162
174
  this.home.onOpen = (id) => void this.openSession(id);
@@ -175,9 +187,10 @@ export class App {
175
187
  void this.openSession(this.currentId);
176
188
  };
177
189
  this.chatRoot = new VStack([
178
- { component: new Lines((w) => this.renderHeader(w)), basis: 1, shrink: 0 },
190
+ { component: new Lines((w) => this.renderHeader(w)), basis: 2, shrink: 0 },
179
191
  { component: this.scroll, basis: 0, grow: 1, minSize: 3 },
180
192
  { component: new Lines((w) => this.renderRequests(w)), basis: "auto", shrink: 0 },
193
+ { component: new Lines((w) => this.docked?.picker.render(w) ?? []), basis: "auto", shrink: 0 },
181
194
  { component: this.editor, basis: "auto", shrink: 1, minSize: 3 },
182
195
  { component: new Lines((w) => this.renderFooter(w)), basis: 1, shrink: 0 },
183
196
  ]);
@@ -186,6 +199,7 @@ export class App {
186
199
  { component: new Lines((w) => this.renderRequests(w)), basis: "auto", shrink: 0 },
187
200
  ]);
188
201
  this.showHome();
202
+ this.view.selectedOption = () => this.choosing();
189
203
  this.view.isBusy = () => {
190
204
  const s = this.current();
191
205
  return !!s && this.busy(s);
@@ -253,6 +267,7 @@ export class App {
253
267
  if (this.timer)
254
268
  clearInterval(this.timer);
255
269
  this.client.close();
270
+ cmuxUnbind();
256
271
  // The alt-screen renderer prints its document to the main screen on stop; leave nothing behind.
257
272
  this.tui.setLayoutRoot(new Lines(() => []));
258
273
  this.tui.stop();
@@ -276,7 +291,7 @@ export class App {
276
291
  const anyBusy = [...this.client.sessions.values()].some((s) => this.busy(s));
277
292
  if (anyBusy)
278
293
  dirty = true;
279
- // The start screen's logo is animated.
294
+ // The start screen shows each session's age.
280
295
  if (this.mode === "home" && !this.overlay)
281
296
  dirty = true;
282
297
  this.maybeLoadEarlier();
@@ -312,6 +327,7 @@ export class App {
312
327
  });
313
328
  cl.on("session-removed", (id) => {
314
329
  this.attention.delete(id);
330
+ this.rang.delete(id);
315
331
  this.entries.delete(id);
316
332
  this.unread.delete(id);
317
333
  if (id === this.currentId) {
@@ -415,6 +431,8 @@ export class App {
415
431
  if (!s)
416
432
  return;
417
433
  this.currentId = id;
434
+ cmuxBind(id);
435
+ this.rang.delete(id);
418
436
  this.unread.delete(id);
419
437
  if (this.mode !== "chat") {
420
438
  this.mode = "chat";
@@ -603,6 +621,8 @@ export class App {
603
621
  this.quit();
604
622
  return true;
605
623
  }
624
+ if (this.onChoosingKey(data))
625
+ return true;
606
626
  if (matchesKey(data, Key.escape)) {
607
627
  const s = this.current();
608
628
  if (this.editor.isShowingAutocomplete())
@@ -1059,7 +1079,11 @@ export class App {
1059
1079
  this.flash(`Usage limit: ${String(res.status ?? "done").replace(/_/g, " ")}`, "info");
1060
1080
  }
1061
1081
  // --- overlays ---
1062
- pick(opts) {
1082
+ /**
1083
+ * Shows a picker over the screen or, answering `forRequest` in a session, above the editor; that
1084
+ * one closes by itself once the request is no longer pending.
1085
+ */
1086
+ pick(opts, forRequest) {
1063
1087
  return new Promise((resolve) => {
1064
1088
  const close = (value) => {
1065
1089
  this.overlay?.hide();
@@ -1070,6 +1094,13 @@ export class App {
1070
1094
  };
1071
1095
  const picker = new Picker({ ...opts, onSelect: (item) => close(item.value), onCancel: () => close(null) });
1072
1096
  this.overlay?.hide();
1097
+ if (forRequest && this.mode === "chat") {
1098
+ this.docked = { picker, requestId: forRequest, cancel: () => close(null) };
1099
+ this.overlay = { hide: () => (this.docked = null) };
1100
+ this.tui.setFocus(picker);
1101
+ this.tui.requestRender();
1102
+ return;
1103
+ }
1073
1104
  this.overlay = this.tui.showOverlay(picker, { width: "70%", minWidth: 44, maxHeight: "80%", anchor: "center" });
1074
1105
  });
1075
1106
  }
@@ -1086,9 +1117,11 @@ export class App {
1086
1117
  }
1087
1118
  /**
1088
1119
  * Opens the answer picker for what the open session waits on: each permission request once,
1089
- * and choices the agent offered once its turn ends, unless you have started typing.
1120
+ * and highlights the choices the agent offered once its turn ends, unless you have started typing.
1090
1121
  */
1091
1122
  promptForRequests(s) {
1123
+ if (this.docked && !pendingRequests(s).some((r) => r.id === this.docked?.requestId))
1124
+ this.docked.cancel();
1092
1125
  if (this.overlay || this.mode !== "chat" || s.id !== this.currentId)
1093
1126
  return;
1094
1127
  const next = pendingRequests(s).find((r) => !this.prompted.has(`${s.id}:${r.id}`));
@@ -1097,12 +1130,13 @@ export class App {
1097
1130
  this.run(() => this.answer(s, next));
1098
1131
  return;
1099
1132
  }
1100
- const options = this.offeredOptions(s);
1101
- const key = `${s.id}:options:${this.entries.get(s.id)?.transcript.maxSeq}`;
1102
- if (options.length === 0 || this.prompted.has(key) || this.editor.getText().trim())
1133
+ const offer = this.offeredOptions(s);
1134
+ // Keyed on the message that offers them, so a dismissed popup stays dismissed.
1135
+ const key = offer && `${s.id}:options:${offer.key}`;
1136
+ if (!offer || !key || this.prompted.has(key) || this.editor.getText().trim())
1103
1137
  return;
1104
1138
  this.prompted.add(key);
1105
- this.run(() => this.chooseOption(options));
1139
+ this.optionPick = { key, index: 0 };
1106
1140
  }
1107
1141
  /** ctrl+r: answer what the agent is waiting for: a permission request, else its offered choices. */
1108
1142
  async answerRequest() {
@@ -1110,27 +1144,49 @@ export class App {
1110
1144
  const req = s && pendingRequests(s)[0];
1111
1145
  if (s && req)
1112
1146
  return this.answer(s, req);
1113
- const options = s ? this.offeredOptions(s) : [];
1114
- if (!s || options.length === 0) {
1147
+ const offer = s && this.offeredOptions(s);
1148
+ if (!s || !offer) {
1115
1149
  this.flash("Nothing to answer in this session.", "info");
1116
1150
  return;
1117
1151
  }
1118
- await this.chooseOption(options);
1152
+ this.optionPick = { key: `${s.id}:options:${offer.key}`, index: 0 };
1153
+ if (this.editor.getText())
1154
+ this.flash("Clear the editor to choose one of the offered replies.", "info");
1119
1155
  }
1120
- async chooseOption(options) {
1121
- const choice = await this.pick({
1122
- title: "Reply with",
1123
- noFilter: true,
1124
- hint: `1–${options.length} or ↑↓ enter · esc to write your own reply (ctrl+r brings this back)`,
1125
- items: options.map((o, i) => ({ value: o, label: `${i + 1}. ${oneLine(o)}` })),
1126
- });
1127
- if (choice)
1128
- await this.submit(choice);
1156
+ /** The offered choices being picked from the keyboard: highlighted, and the editor is empty. */
1157
+ choosing() {
1158
+ const pick = this.optionPick;
1159
+ const s = pick && this.mode === "chat" ? this.current() : undefined;
1160
+ const offer = s && this.offeredOptions(s);
1161
+ if (!s || !offer || !pick || pick.key !== `${s.id}:options:${offer.key}` || this.editor.getText())
1162
+ return null;
1163
+ return { key: offer.key, index: Math.min(pick.index, offer.options.length - 1), options: offer.options };
1164
+ }
1165
+ /** ↑↓ move the highlight over the offered choices, enter sends it, esc puts it away. */
1166
+ onChoosingKey(data) {
1167
+ const choosing = this.choosing();
1168
+ if (!choosing || !this.optionPick)
1169
+ return false;
1170
+ if (matchesKey(data, Key.up) || matchesKey(data, Key.down)) {
1171
+ const index = choosing.index + (matchesKey(data, Key.up) ? -1 : 1);
1172
+ this.optionPick.index = Math.max(0, Math.min(choosing.options.length - 1, index));
1173
+ }
1174
+ else if (matchesKey(data, Key.enter)) {
1175
+ this.optionPick = null;
1176
+ void this.submit(choosing.options[choosing.index] ?? "");
1177
+ }
1178
+ else if (matchesKey(data, Key.escape)) {
1179
+ this.optionPick = null;
1180
+ }
1181
+ else
1182
+ return false;
1183
+ this.tui.requestRender();
1184
+ return true;
1129
1185
  }
1130
1186
  /** Choices the agent offered at the end of its last turn, while it waits for the reply. */
1131
1187
  offeredOptions(s) {
1132
1188
  const entry = this.entries.get(s.id);
1133
- return entry && !this.busy(s) ? latestOptions(entry.transcript) : [];
1189
+ return entry && !this.busy(s) ? latestOptions(entry.transcript) : undefined;
1134
1190
  }
1135
1191
  async answer(s, req) {
1136
1192
  const questions = questionsOf(req);
@@ -1142,7 +1198,7 @@ export class App {
1142
1198
  noFilter: true,
1143
1199
  items: q.options,
1144
1200
  hint: "esc to answer later (ctrl+r)",
1145
- });
1201
+ }, req.id);
1146
1202
  if (choice === null)
1147
1203
  return;
1148
1204
  answers[q.question] = [choice];
@@ -1161,7 +1217,7 @@ export class App {
1161
1217
  { value: "denied", label: "Deny" },
1162
1218
  { value: "abort", label: "Deny and stop the turn" },
1163
1219
  ],
1164
- });
1220
+ }, req.id);
1165
1221
  if (!choice)
1166
1222
  return;
1167
1223
  await this.client.respondPermission(s, req, choice);
@@ -1205,18 +1261,33 @@ export class App {
1205
1261
  return this.focusKnown && this.present() && this.mode === "chat" && sessionId === this.currentId;
1206
1262
  }
1207
1263
  /**
1208
- * Raises a terminal notification when a session starts needing the user (permission request,
1209
- * question) or finishes its turn, unless they are already looking at it.
1264
+ * Only the open session rings, and only when the user is not already looking at it: with
1265
+ * several happier-tui open, an event rings once, in the tab showing that session.
1266
+ */
1267
+ rings(sessionId) {
1268
+ return (this.notify.osc || this.notify.bell) && sessionId === this.currentId && !this.watching(sessionId);
1269
+ }
1270
+ /**
1271
+ * Raises a terminal notification when the open session starts needing the user (permission
1272
+ * request, question) or finishes its turn, unless they are already looking at it. Other
1273
+ * sessions are listed in the footer.
1210
1274
  */
1211
1275
  noteAttention(s) {
1212
1276
  const next = attentionOf(s);
1213
1277
  const prev = this.attention.get(s.id);
1214
1278
  const change = attentionChange(prev, next);
1215
1279
  this.attention.set(s.id, next);
1280
+ const rung = this.rang.get(s.id);
1281
+ if (rung && (rung.kind === "request" ? !next.requestIds.includes(rung.requestId) : next.busy))
1282
+ this.rang.delete(s.id);
1283
+ if (change && s.id !== this.currentId) {
1284
+ this.rang.delete(s.id);
1285
+ this.rang.set(s.id, change);
1286
+ }
1216
1287
  if (prev && (prev.busy !== next.busy || prev.turnStatus !== next.turnStatus || prev.requestIds.length !== next.requestIds.length)) {
1217
- debug(`session ${s.id.slice(0, 8)} busy ${prev.busy}->${next.busy} turn ${prev.turnStatus}->${next.turnStatus} requests ${prev.requestIds.length}->${next.requestIds.length} => ${change ? change.kind : "no change"}; focused=${this.focused} present=${this.present()} current=${s.id === this.currentId} notify=${Boolean(change && (this.notify.osc || this.notify.bell) && !this.watching(s.id))}`);
1288
+ debug(`session ${s.id.slice(0, 8)} busy ${prev.busy}->${next.busy} turn ${prev.turnStatus}->${next.turnStatus} requests ${prev.requestIds.length}->${next.requestIds.length} => ${change ? change.kind : "no change"}; focused=${this.focused} present=${this.present()} current=${s.id === this.currentId} notify=${Boolean(change && this.rings(s.id))}`);
1218
1289
  }
1219
- if (!change || !(this.notify.osc || this.notify.bell) || this.watching(s.id))
1290
+ if (!change || !this.rings(s.id))
1220
1291
  return;
1221
1292
  let body;
1222
1293
  if (change.kind === "request") {
@@ -1241,7 +1312,7 @@ export class App {
1241
1312
  : this.connection === "connecting"
1242
1313
  ? c.warn("◌ connecting")
1243
1314
  : c.err("○ offline — retrying");
1244
- let left = ` ${c.accent.bold("happier")}`;
1315
+ let left = ` ${c.accent.bold("happier-tui")}`;
1245
1316
  if (s) {
1246
1317
  left += ` ${statusGlyph(s, this.frame)} ${c.bold.whiteBright(clean(sessionTitle(s)).replace(/\s+/g, " "))}`;
1247
1318
  left += c.faint(` ${s.metadata.flavor ?? "?"} · ${this.hostOf(s)} · ${shortPath(s.metadata.path, s.metadata.homeDir)}`);
@@ -1249,7 +1320,8 @@ export class App {
1249
1320
  else {
1250
1321
  left += c.dim(` ${this.client.config.serverName}`);
1251
1322
  }
1252
- return [c.headerBg(justify(left, `${conn} `, width))];
1323
+ // A blank line keeps the conversation off the header when scrolled.
1324
+ return [c.headerBg(justify(left, `${conn} `, width)), ""];
1253
1325
  }
1254
1326
  renderRequests(width) {
1255
1327
  const lines = [];
@@ -1283,11 +1355,13 @@ export class App {
1283
1355
  lines.push(c.faint(` ${more}/queue to edit or cancel`));
1284
1356
  }
1285
1357
  const reqs = pendingRequests(s);
1286
- const offered = reqs.length === 0 ? this.offeredOptions(s).length : 0;
1287
- if (offered > 0)
1288
- lines.push(` ${c.accent("❯")} ${c.dim(`${offered} choices above · click one, or ctrl+r`)}`);
1358
+ const offered = reqs.length === 0 ? (this.offeredOptions(s)?.options.length ?? 0) : 0;
1359
+ if (offered > 0) {
1360
+ const how = this.choosing() ? "↑↓ choose · enter send · esc dismiss · or type your own reply" : `${offered} choices above · click one, or ctrl+r`;
1361
+ lines.push(` ${c.accent("❯")} ${c.dim(how)}`);
1362
+ }
1289
1363
  const first = reqs[0];
1290
- if (first) {
1364
+ if (first && !this.docked) {
1291
1365
  const more = reqs.length > 1 ? c.dim(` (+${reqs.length - 1} more)`) : "";
1292
1366
  const what = questionsOf(first).length ? "Question from the agent" : `Permission: ${first.tool} ${c.dim(requestSummary(first))}`;
1293
1367
  lines.push(` ${c.warn("⚠")} ${what}${more}`);
@@ -1334,7 +1408,25 @@ export class App {
1334
1408
  else
1335
1409
  state = c.ok("ready");
1336
1410
  const right = `${this.busy(s) ? "" : `last activity ${agoText(s.activityAt)} · `}ctrl+s sessions · /keys `;
1337
- return [justify(` ${state}${c.dim(" · ")}${parts.join(c.dim(" · "))}`, c.faint(right), width)];
1411
+ return [justify(` ${state}${c.dim(" · ")}${parts.join(c.dim(" · "))}`, this.waiting() + c.faint(right), width)];
1412
+ }
1413
+ /**
1414
+ * The other sessions waiting for the user, most recent first, marked as on the start screen:
1415
+ * "! train ● flaky · ".
1416
+ */
1417
+ waiting() {
1418
+ const items = [];
1419
+ for (const [id, why] of [...this.rang].reverse()) {
1420
+ const s = this.client.sessions.get(id);
1421
+ if (!s)
1422
+ continue;
1423
+ const mark = why.kind === "request" || why.failed ? c.err("!") : c.accent("●");
1424
+ items.push(`${mark} ${truncateToWidth(sessionTitle(s), 20)}`);
1425
+ }
1426
+ if (items.length === 0)
1427
+ return "";
1428
+ const shown = items.length > 3 ? [...items.slice(0, 3), c.dim(`+${items.length - 3}`)] : items;
1429
+ return `${shown.join(" ")}${c.faint(" · ")}`;
1338
1430
  }
1339
1431
  }
1340
1432
  const isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);