@bastani/atomic 0.9.57-alpha.1 → 0.9.58-alpha.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 (117) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  5. package/dist/builtin/subagents/package.json +1 -1
  6. package/dist/builtin/subagents/src/extension/index.bundle.mjs +39 -5
  7. package/dist/builtin/web-access/CHANGELOG.md +12 -0
  8. package/dist/builtin/web-access/index.bundle.mjs +2 -2
  9. package/dist/builtin/web-access/package.json +1 -1
  10. package/dist/builtin/workflows/CHANGELOG.md +42 -0
  11. package/dist/builtin/workflows/package.json +1 -1
  12. package/dist/builtin/workflows/src/extension/index.bundle.mjs +885 -228
  13. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +933 -175
  14. package/dist/builtin/workflows/src/index.js +630 -162
  15. package/dist/builtin/workflows/src/local-worker-entry.mjs +933 -175
  16. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +1 -1
  17. package/dist/builtin/workflows/src/shared/workflow-infrastructure-error.d.ts +13 -0
  18. package/dist/builtin/workflows/src/workers/public-options.d.ts +10 -0
  19. package/dist/core/agent-session-persistent-custom-messages.d.ts +5 -0
  20. package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
  21. package/dist/core/agent-session-persistent-custom-messages.js +16 -0
  22. package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
  23. package/dist/core/agent-session-tasks.d.ts.map +1 -1
  24. package/dist/core/agent-session-tasks.js +20 -0
  25. package/dist/core/agent-session-tasks.js.map +1 -1
  26. package/dist/core/settings-defaults.d.ts +4 -0
  27. package/dist/core/settings-defaults.d.ts.map +1 -1
  28. package/dist/core/settings-defaults.js +4 -0
  29. package/dist/core/settings-defaults.js.map +1 -1
  30. package/dist/core/settings-manager-resource-accessors.d.ts +2 -0
  31. package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
  32. package/dist/core/settings-manager-resource-accessors.js +6 -0
  33. package/dist/core/settings-manager-resource-accessors.js.map +1 -1
  34. package/dist/core/settings-schema.d.ts +9 -0
  35. package/dist/core/settings-schema.d.ts.map +1 -1
  36. package/dist/core/settings-schema.js +11 -0
  37. package/dist/core/settings-schema.js.map +1 -1
  38. package/dist/core/settings-types.d.ts +1 -1
  39. package/dist/core/settings-types.d.ts.map +1 -1
  40. package/dist/core/settings-types.js.map +1 -1
  41. package/dist/core/tasks/agent-adapter.d.ts +10 -1
  42. package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
  43. package/dist/core/tasks/agent-adapter.js +20 -0
  44. package/dist/core/tasks/agent-adapter.js.map +1 -1
  45. package/dist/core/tasks/contracts.d.ts +6 -0
  46. package/dist/core/tasks/contracts.d.ts.map +1 -1
  47. package/dist/core/tasks/contracts.js.map +1 -1
  48. package/dist/core/tasks/heartbeat-notice.d.ts +64 -0
  49. package/dist/core/tasks/heartbeat-notice.d.ts.map +1 -0
  50. package/dist/core/tasks/heartbeat-notice.js +98 -0
  51. package/dist/core/tasks/heartbeat-notice.js.map +1 -0
  52. package/dist/core/tasks/heartbeat.d.ts +75 -0
  53. package/dist/core/tasks/heartbeat.d.ts.map +1 -0
  54. package/dist/core/tasks/heartbeat.js +440 -0
  55. package/dist/core/tasks/heartbeat.js.map +1 -0
  56. package/dist/core/tasks/supervisor.d.ts +2 -0
  57. package/dist/core/tasks/supervisor.d.ts.map +1 -1
  58. package/dist/core/tasks/supervisor.js +32 -4
  59. package/dist/core/tasks/supervisor.js.map +1 -1
  60. package/dist/core/tasks/task-view-source.d.ts +72 -0
  61. package/dist/core/tasks/task-view-source.d.ts.map +1 -0
  62. package/dist/core/tasks/task-view-source.js +155 -0
  63. package/dist/core/tasks/task-view-source.js.map +1 -0
  64. package/dist/core/tools/bash-pty-native.d.ts +2 -0
  65. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  66. package/dist/core/tools/bash-pty-native.js +1 -0
  67. package/dist/core/tools/bash-pty-native.js.map +1 -1
  68. package/dist/core/tools/bash.d.ts +3 -0
  69. package/dist/core/tools/bash.d.ts.map +1 -1
  70. package/dist/core/tools/bash.js +20 -2
  71. package/dist/core/tools/bash.js.map +1 -1
  72. package/dist/core/tools/powershell.d.ts +16 -8
  73. package/dist/core/tools/powershell.d.ts.map +1 -1
  74. package/dist/index.d.ts +5 -3
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +4 -2
  77. package/dist/index.js.map +1 -1
  78. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  79. package/dist/modes/interactive/components/chat-session-host-events.js +7 -0
  80. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  81. package/dist/modes/interactive/components/chat-session-host-state.d.ts +3 -0
  82. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  83. package/dist/modes/interactive/components/chat-session-host-state.js +4 -0
  84. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  85. package/dist/modes/interactive/components/chat-session-host-types.d.ts +11 -0
  86. package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
  87. package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
  88. package/dist/modes/interactive/components/chat-session-host.d.ts +2 -0
  89. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  90. package/dist/modes/interactive/components/chat-session-host.js +15 -8
  91. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  92. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  93. package/dist/modes/interactive/components/custom-message.js +12 -0
  94. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  95. package/dist/modes/interactive/components/task-detail.d.ts.map +1 -1
  96. package/dist/modes/interactive/components/task-detail.js +5 -0
  97. package/dist/modes/interactive/components/task-detail.js.map +1 -1
  98. package/dist/modes/interactive/components/task-heartbeat-message.d.ts +14 -0
  99. package/dist/modes/interactive/components/task-heartbeat-message.d.ts.map +1 -0
  100. package/dist/modes/interactive/components/task-heartbeat-message.js +76 -0
  101. package/dist/modes/interactive/components/task-heartbeat-message.js.map +1 -0
  102. package/dist/modes/interactive/components/task-inspector.d.ts +6 -3
  103. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  104. package/dist/modes/interactive/components/task-inspector.js +53 -100
  105. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  106. package/dist/modes/interactive/skill-command-autocomplete.d.ts +22 -2
  107. package/dist/modes/interactive/skill-command-autocomplete.d.ts.map +1 -1
  108. package/dist/modes/interactive/skill-command-autocomplete.js +28 -9
  109. package/dist/modes/interactive/skill-command-autocomplete.js.map +1 -1
  110. package/docs/background-tasks.md +65 -1
  111. package/docs/settings.md +12 -0
  112. package/docs/subagents.md +2 -0
  113. package/docs/tools.md +2 -1
  114. package/docs/workflows/operations.md +5 -3
  115. package/npm-shrinkwrap.json +32 -32
  116. package/package.json +3 -3
  117. package/schemas/settings.schema.json +24 -0
@@ -1,9 +1,7 @@
1
- import { randomUUID } from "node:crypto";
2
1
  import { stripVTControlCharacters } from "node:util";
3
2
  import { getKeybindings, Input, matchesKey, Text, truncateToWidth, visibleWidth, } from "@earendil-works/pi-tui";
4
- import { taskOutputText } from "../../../core/tasks/command-output.js";
5
- import { taskExtensionStatuses, taskOwnTranscriptEntries, taskTranscriptSource, watchTaskExtensionStatuses, } from "../../../core/tasks/supervisor.js";
6
- import { readTaskTranscriptSnapshot } from "../../../core/tasks/transcript.js";
3
+ import { OwnerTaskStore } from "../../../core/tasks/owner-store.js";
4
+ import { ownerTaskViewSource } from "../../../core/tasks/task-view-source.js";
7
5
  import { theme } from "../theme/theme.js";
8
6
  import { chatEntriesFromAgentMessages, renderChatMessageEntry } from "./chat-message-renderer.js";
9
7
  import { mouseWheelDeltaRows } from "./chat-transcript.js";
@@ -14,7 +12,7 @@ import { taskListSections } from "./task-list.js";
14
12
  import { TaskLiveTranscript } from "./task-live-transcript.js";
15
13
  import { TaskNavigation } from "./task-navigation.js";
16
14
  import { taskDisplayText, taskLabel, taskMetricsText, taskModelText, taskStatusAppearance } from "./task-row.js";
17
- /** Focused view only. The store and original session remain the authorities. */
15
+ /** Focused view only. The task source and original session remain the authorities. */
18
16
  export class TaskInspector {
19
17
  navigation;
20
18
  actionIndex = 0;
@@ -28,6 +26,8 @@ export class TaskInspector {
28
26
  transcriptPageRows = 5;
29
27
  cursor;
30
28
  status = "";
29
+ /** Why the last stop did not reach its task; shown under the list until the next key. */
30
+ stopFailure = "";
31
31
  scroll = 0;
32
32
  detailContent = {};
33
33
  detailTaskId;
@@ -37,7 +37,7 @@ export class TaskInspector {
37
37
  input = new Input();
38
38
  unsubscribe;
39
39
  constructor(privateStore, privateRender, privateClose, openQuestion) {
40
- this.store = privateStore;
40
+ this.store = privateStore instanceof OwnerTaskStore ? ownerTaskViewSource(privateStore) : privateStore;
41
41
  this.requestRender = privateRender;
42
42
  this.close = privateClose;
43
43
  this.navigation = new TaskNavigation(getKeybindings(), {
@@ -57,26 +57,23 @@ export class TaskInspector {
57
57
  void this.loadTranscript();
58
58
  },
59
59
  foreground: (task) => {
60
- const lease = this.store.resolveTask(task.ref.taskId);
61
- if (lease.ok)
62
- void this.store.supervisor.foregroundTask(lease.value).then((result) => {
63
- this.status = result.ok ? result.value.kind : result.error.message;
64
- this.requestRender();
65
- });
60
+ void this.store.foregroundTask(task.ref.taskId).then((result) => {
61
+ this.status = result.ok ? result.value.kind : result.error.message;
62
+ this.requestRender();
63
+ });
66
64
  },
67
65
  confirmCancel: () => new Promise((resolve) => {
68
66
  this.confirmation = resolve;
69
67
  this.requestRender();
70
68
  }),
71
69
  cancel: (task) => {
72
- const lease = this.store.resolveTask(task.ref.taskId);
73
- if (lease.ok)
74
- void this.store.supervisor.cancelTask(lease.value, "user").then(() => this.requestRender());
75
- },
76
- stdinAvailable: (task) => {
77
- const lease = this.store.resolveTask(task.ref.taskId);
78
- return lease.ok && this.store.supervisor.taskStdin(lease.value).ok;
70
+ void this.store.cancelTask(task.ref.taskId).then((result) => {
71
+ // A stop that did not reach the task says so, instead of leaving it looking untouched.
72
+ this.stopFailure = result.ok ? "" : `Could not stop the task: ${result.error.message}`;
73
+ this.requestRender();
74
+ });
79
75
  },
76
+ stdinAvailable: (task) => this.store.stdinAvailable(task.ref.taskId),
80
77
  input: () => {
81
78
  this.input.setValue("");
82
79
  },
@@ -131,25 +128,13 @@ export class TaskInspector {
131
128
  const task = this.selected();
132
129
  if (!task || task.execution.kind === "settled")
133
130
  return false;
134
- const lease = this.store.resolveTask(task.ref.taskId);
135
- return lease.ok && this.store.supervisor.taskStdin(lease.value).ok;
131
+ return this.store.stdinAvailable(task.ref.taskId);
136
132
  }
137
133
  async sendInput(text) {
138
134
  const task = this.selected();
139
135
  if (!task)
140
136
  return;
141
- const lease = this.store.resolveTask(task.ref.taskId);
142
- if (!lease.ok)
143
- return;
144
- const stdin = this.store.supervisor.taskStdin(lease.value);
145
- if (!stdin.ok) {
146
- this.status = stdin.error.message;
147
- return;
148
- }
149
- const result = await this.store.supervisor.writeTaskInput(stdin.value, randomUUID(), {
150
- kind: "bytes",
151
- bytes: Buffer.from(`${text}\n`),
152
- });
137
+ const result = await this.store.writeTaskInput(task.ref.taskId, text);
153
138
  this.status = result.ok ? `Sent ${result.value.acceptedBytes} bytes` : result.error.message;
154
139
  this.input.setValue("");
155
140
  this.requestRender();
@@ -164,8 +149,7 @@ export class TaskInspector {
164
149
  */
165
150
  taskStatusRows(width) {
166
151
  const task = this.navigation.focus.kind === "detail" && !this.confirmation ? this.selected() : undefined;
167
- const lease = task?.kind === "agent" ? this.store.resolveTask(task.ref.taskId) : undefined;
168
- if (!task || !lease?.ok) {
152
+ if (task?.kind !== "agent") {
169
153
  this.releaseStatusWatch();
170
154
  return [];
171
155
  }
@@ -173,10 +157,10 @@ export class TaskInspector {
173
157
  this.releaseStatusWatch();
174
158
  this.statusWatch = {
175
159
  taskId: task.ref.taskId,
176
- release: watchTaskExtensionStatuses(lease.value, () => this.requestRender()),
160
+ release: this.store.watchExtensionStatuses(task.ref.taskId, () => this.requestRender()),
177
161
  };
178
162
  }
179
- const row = renderExtensionStatusRow(taskExtensionStatuses(lease.value), width);
163
+ const row = renderExtensionStatusRow(this.store.extensionStatuses(task.ref.taskId), width);
180
164
  return row === undefined ? [] : [row];
181
165
  }
182
166
  releaseLiveTranscript() {
@@ -188,12 +172,11 @@ export class TaskInspector {
188
172
  if (this.disposed || !this.transcriptRequested)
189
173
  return;
190
174
  const task = this.selected();
191
- const lease = task && this.store.resolveTask(task.ref.taskId);
192
- const bound = lease?.ok ? taskTranscriptSource(lease.value) : undefined;
193
- if (bound?.ok && this.liveTranscript?.source === bound.value.session)
175
+ const follow = task && this.store.followTaskTranscript(task.ref.taskId);
176
+ if (follow?.session !== undefined && this.liveTranscript?.source === follow.session)
194
177
  return;
195
- // Legacy history-only sources have no live tail; keep their retained page anchored.
196
- if (bound?.ok && !bound.value.session.subscribe && this.transcriptHistorical)
178
+ // History-only sources have no live tail; keep their retained page anchored.
179
+ if (follow?.historyOnly === true && this.transcriptHistorical)
197
180
  return;
198
181
  if (this.transcriptLoading)
199
182
  this.transcriptRefreshPending = true;
@@ -212,14 +195,9 @@ export class TaskInspector {
212
195
  this.transcriptHistorical = true;
213
196
  this.requestRender();
214
197
  try {
215
- const lease = this.store.resolveTask(task.ref.taskId);
216
- if (!lease.ok) {
217
- this.status = lease.error.message;
218
- return;
219
- }
220
198
  if (task.kind === "command") {
221
199
  const count = BigInt(task.output.byteCount);
222
- const page = await this.store.supervisor.readTaskOutput(lease.value, {
200
+ const page = await this.store.readTaskOutput(task.ref.taskId, {
223
201
  start: String(count > 8192n ? count - 8192n : 0n),
224
202
  maximumBytes: 8192,
225
203
  });
@@ -228,7 +206,7 @@ export class TaskInspector {
228
206
  focus !== this.navigation.focus ||
229
207
  task.ref.taskId !== this.navigation.selectedTaskId)
230
208
  return;
231
- const text = page.ok ? taskOutputText(page.value) : page.error.message;
209
+ const text = page.ok ? page.value.text : page.error.message;
232
210
  this.transcript = [
233
211
  new Text(text.split("\n").map(taskDisplayText).join("\n") || "No output available", 0, 0),
234
212
  ];
@@ -238,34 +216,20 @@ export class TaskInspector {
238
216
  this.requestRender();
239
217
  return;
240
218
  }
241
- const page = readTaskTranscriptSnapshot(lease.value, earlier ? this.cursor : undefined);
219
+ const read = this.store.readTaskTranscript(task.ref.taskId, earlier ? this.cursor : undefined);
220
+ const page = read instanceof Promise ? await read : read;
242
221
  if (this.disposed ||
243
222
  generation !== this.detailGeneration ||
244
223
  focus !== this.navigation.focus ||
245
224
  task.ref.taskId !== this.navigation.selectedTaskId)
246
225
  return;
247
- const bound = taskTranscriptSource(lease.value);
248
- if (!bound.ok || (!page.ok && !bound.value.session.subscribe)) {
249
- this.status = "Transcript unavailable";
226
+ if (!page.ok) {
227
+ this.status = page.error.message;
250
228
  this.requestRender();
251
229
  return;
252
230
  }
253
- const ids = new Set(page.ok ? page.value.items.map((item) => item.source.entryId) : []);
254
- const messages = bound.value.session.getEntries().flatMap((entry) => {
255
- if (entry.type !== "message" || !ids.has(entry.id))
256
- return [];
257
- const message = entry.message;
258
- if (message.role === "assistant")
259
- return [
260
- {
261
- ...message,
262
- content: message.content.filter((block, index) => block.type !== "thinking" &&
263
- page.ok &&
264
- page.value.items.some((item) => item.source.entryId === entry.id && item.source.contentIndex === index)),
265
- },
266
- ];
267
- return message.role === "user" || message.role === "toolResult" ? [message] : [];
268
- });
231
+ const messages = [...page.value.messages];
232
+ const follow = this.store.followTaskTranscript(task.ref.taskId);
269
233
  const components = chatEntriesFromAgentMessages(messages).map((entry) => renderChatMessageEntry(entry, {
270
234
  ui: { requestRender: this.requestRender },
271
235
  cwd: process.cwd(),
@@ -273,14 +237,14 @@ export class TaskInspector {
273
237
  toolOutputExpanded: true,
274
238
  showImages: false,
275
239
  }));
276
- if (!earlier && bound.value.session.subscribe) {
240
+ if (!earlier && follow?.session?.subscribe) {
277
241
  this.releaseLiveTranscript();
278
- this.liveTranscript = new TaskLiveTranscript(bound.value.session, messages, this.requestRender);
242
+ this.liveTranscript = new TaskLiveTranscript(follow.session, messages, this.requestRender);
279
243
  this.transcript = [this.liveTranscript];
280
244
  }
281
245
  else
282
246
  this.transcript = earlier ? [...components, ...(this.transcript ?? [])] : components;
283
- this.cursor = page.ok ? page.value.nextCursor : undefined;
247
+ this.cursor = page.value.nextCursor;
284
248
  this.status = this.cursor ? "PageUp: earlier retained messages" : "";
285
249
  this.requestRender();
286
250
  }
@@ -318,42 +282,26 @@ export class TaskInspector {
318
282
  this.navigation.focus === focus &&
319
283
  focus.kind === "detail" &&
320
284
  this.navigation.selectedTaskId === task.ref.taskId;
321
- const lease = this.store.resolveTask(task.ref.taskId);
322
- if (!lease.ok)
285
+ const read = this.store.taskDetailText(task.ref.taskId);
286
+ const own = read instanceof Promise ? await read : read;
287
+ if (!current())
323
288
  return;
324
- const ownEntries = taskOwnTranscriptEntries(lease.value);
325
- if (ownEntries) {
326
- const prompt = ownEntries.find((entry) => entry.type === "message" && entry.message.role === "user");
327
- if (prompt?.type === "message" && prompt.message.role === "user")
328
- this.detailContent.prompt =
329
- typeof prompt.message.content === "string"
330
- ? prompt.message.content
331
- : prompt.message.content
332
- .filter((block) => block.type === "text")
333
- .map((block) => block.text)
334
- .join("");
335
- const response = ownEntries
336
- .slice()
337
- .reverse()
338
- .find((entry) => entry.type === "message" && entry.message.role === "assistant");
339
- if (response?.type === "message" && response.message.role === "assistant")
340
- this.detailContent.output = response.message.content
341
- .filter((block) => block.type === "text")
342
- .map((block) => block.text)
343
- .join("");
344
- }
289
+ if (own.prompt !== undefined)
290
+ this.detailContent.prompt = own.prompt;
291
+ if (own.output !== undefined)
292
+ this.detailContent.output = own.output;
345
293
  if (task.kind === "command") {
346
294
  try {
347
295
  const count = BigInt(task.output.byteCount);
348
- const output = await this.store.supervisor.readTaskOutput(lease.value, {
296
+ const output = await this.store.readTaskOutput(task.ref.taskId, {
349
297
  start: String(count > 8192n ? count - 8192n : 0n),
350
298
  maximumBytes: 8192,
351
299
  });
352
300
  if (!current())
353
301
  return;
354
302
  if (output.ok) {
355
- this.detailContent.output = taskOutputText(output.value);
356
- this.detailContent.outputOmitted = count > 8192n || output.value.omittedRanges.length > 0;
303
+ this.detailContent.output = output.value.text;
304
+ this.detailContent.outputOmitted = count > 8192n || output.value.omitted;
357
305
  }
358
306
  else
359
307
  this.status = output.error.message;
@@ -368,6 +316,7 @@ export class TaskInspector {
368
316
  this.requestRender();
369
317
  }
370
318
  handleInput(data) {
319
+ this.stopFailure = "";
371
320
  if (this.confirmation) {
372
321
  if (data === "y" || data === "n" || matchesKey(data, "escape")) {
373
322
  const answer = this.confirmation;
@@ -492,7 +441,8 @@ export class TaskInspector {
492
441
  renderTranscriptViewport(width, budget) {
493
442
  const task = this.selected();
494
443
  const statusRows = this.taskStatusRows(width);
495
- const room = Math.max(1, budget - 5 - statusRows.length);
444
+ const failure = this.stopFailure ? [theme.fg("warning", this.stopFailure)] : [];
445
+ const room = Math.max(1, budget - 5 - statusRows.length - failure.length);
496
446
  this.transcriptPageRows = room;
497
447
  const rows = this.transcript?.flatMap((component) => component.render(width)) ?? [
498
448
  this.transcriptLoading ? "Loading transcript…" : this.status,
@@ -514,6 +464,7 @@ export class TaskInspector {
514
464
  ...Array.from({ length: Math.max(0, room - visible.length) }, () => ""),
515
465
  theme.fg("dim", `Lines ${rows.length ? this.scroll + 1 : 0}–${Math.min(rows.length, this.scroll + room)} of ${rows.length}${this.cursor ? " · PgUp at top: earlier history" : ""}${this.status ? ` · ${this.status}` : ""}`),
516
466
  theme.fg("dim", "↑↓ scroll · PgUp/PgDn page · Home/End · ←/Esc back"),
467
+ ...failure,
517
468
  ...statusRows,
518
469
  ]
519
470
  .map(fit)
@@ -560,8 +511,9 @@ export class TaskInspector {
560
511
  .filter(Boolean)
561
512
  .join(" · ");
562
513
  const footer = theme.fg("dim", truncateToWidth(`/tasks · ${hints}`, width));
514
+ const failure = this.stopFailure ? [theme.fg("warning", truncateToWidth(this.stopFailure, width))] : [];
563
515
  if (!framed)
564
- return [...compactSummary, ...view, ...actionRow, footer, ...statusRows]
516
+ return [...compactSummary, ...view, ...actionRow, footer, ...failure, ...statusRows]
565
517
  .map((line) => truncateToWidth(line, width))
566
518
  .slice(-Math.max(1, budget));
567
519
  const live = this.store.backgroundTasks.filter((task) => task.execution.kind !== "settled").length;
@@ -583,6 +535,7 @@ export class TaskInspector {
583
535
  ...actionRow.map(frameRow),
584
536
  border(`╰${"─".repeat(Math.max(0, width - 2))}╯`),
585
537
  footer,
538
+ ...failure,
586
539
  ...statusRows,
587
540
  ].map((line) => truncateToWidth(line, width));
588
541
  }
@@ -1 +1 @@
1
- {"version":3,"file":"task-inspector.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/task-inspector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAEN,cAAc,EACd,KAAK,EACL,UAAU,EACV,IAAI,EACJ,eAAe,EACf,YAAY,GACZ,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAGvE,OAAO,EACN,qBAAqB,EACrB,wBAAwB,EACxB,oBAAoB,EACpB,0BAA0B,GAC1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,O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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iBAChG,CAAC;YACH,CAAC,CAAC;SACF,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport { stripVTControlCharacters } from \"node:util\";\nimport type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport {\n\ttype Component,\n\tgetKeybindings,\n\tInput,\n\tmatchesKey,\n\tText,\n\ttruncateToWidth,\n\tvisibleWidth,\n} from \"@earendil-works/pi-tui\";\nimport type { KeybindingsManager } from \"../../../core/keybindings.ts\";\nimport { taskOutputText } from \"../../../core/tasks/command-output.js\";\nimport type { OperationId, PromptRoute, TaskId } from \"../../../core/tasks/contracts.js\";\nimport type { OwnerTaskStore } from \"../../../core/tasks/owner-store.js\";\nimport {\n\ttaskExtensionStatuses,\n\ttaskOwnTranscriptEntries,\n\ttaskTranscriptSource,\n\twatchTaskExtensionStatuses,\n} from \"../../../core/tasks/supervisor.js\";\nimport { readTaskTranscriptSnapshot } from \"../../../core/tasks/transcript.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { chatEntriesFromAgentMessages, renderChatMessageEntry } from \"./chat-message-renderer.ts\";\nimport { mouseWheelDeltaRows } from \"./chat-transcript.js\";\nimport { renderExtensionStatusRow } from \"./footer.ts\";\nimport { keyHintIfBound } from \"./keybinding-hints.js\";\nimport {\n\tTaskDetail,\n\ttype TaskDetailContent,\n\ttaskDetailActions,\n\ttaskDetailLabels,\n\ttaskDetailSummary,\n} from \"./task-detail.js\";\nimport { type TaskListSection, taskListSections } from \"./task-list.js\";\nimport { TaskLiveTranscript } from \"./task-live-transcript.js\";\nimport { TaskNavigation } from \"./task-navigation.js\";\nimport { taskDisplayText, taskLabel, taskMetricsText, taskModelText, taskStatusAppearance } from \"./task-row.js\";\n\n/** Focused view only. The store and original session remain the authorities. */\nexport class TaskInspector implements Component {\n\treadonly navigation: TaskNavigation;\n\tprivate actionIndex = 0;\n\tprivate confirmation?: (answer: boolean) => void;\n\tprivate transcript?: Component[];\n\tprivate liveTranscript?: TaskLiveTranscript;\n\tprivate transcriptRefreshPending = false;\n\tprivate transcriptRequested = false;\n\tprivate transcriptLoading = false;\n\tprivate transcriptHistorical = false;\n\tprivate transcriptPageRows = 5;\n\tprivate cursor?: string;\n\tprivate status = \"\";\n\tprivate scroll = 0;\n\tprivate detailContent: Omit<TaskDetailContent, \"stdinAvailable\"> = {};\n\tprivate detailTaskId?: TaskId;\n\tprivate detailGeneration = 0;\n\tprivate disposed = false;\n\tprivate statusWatch?: { taskId: TaskId; release: () => void };\n\tprivate readonly input = new Input();\n\tprivate readonly unsubscribe: () => void;\n\tconstructor(\n\t\tprivateStore: OwnerTaskStore,\n\t\tprivateRender: () => void,\n\t\tprivateClose: () => void,\n\t\topenQuestion?: (route: PromptRoute) => void,\n\t) {\n\t\tthis.store = privateStore;\n\t\tthis.requestRender = privateRender;\n\t\tthis.close = privateClose;\n\t\tthis.navigation = new TaskNavigation(getKeybindings() as KeybindingsManager, {\n\t\t\tinspect: () => {\n\t\t\t\tthis.releaseLiveTranscript();\n\t\t\t\tthis.actionIndex = 0;\n\t\t\t\tthis.scroll = 0;\n\t\t\t\tthis.transcript = undefined;\n\t\t\t\tthis.transcriptRequested = false;\n\t\t\t\tthis.transcriptLoading = false;\n\t\t\t\tthis.transcriptHistorical = false;\n\t\t\t\tvoid this.loadDetail();\n\t\t\t},\n\t\t\ttranscript: () => {\n\t\t\t\tthis.detailGeneration++;\n\t\t\t\tthis.scroll = 0;\n\t\t\t\tvoid this.loadTranscript();\n\t\t\t},\n\t\t\tforeground: (task) => {\n\t\t\t\tconst lease = this.store.resolveTask(task.ref.taskId);\n\t\t\t\tif (lease.ok)\n\t\t\t\t\tvoid this.store.supervisor.foregroundTask(lease.value).then((result) => {\n\t\t\t\t\t\tthis.status = result.ok ? result.value.kind : result.error.message;\n\t\t\t\t\t\tthis.requestRender();\n\t\t\t\t\t});\n\t\t\t},\n\t\t\tconfirmCancel: () =>\n\t\t\t\tnew Promise<boolean>((resolve) => {\n\t\t\t\t\tthis.confirmation = resolve;\n\t\t\t\t\tthis.requestRender();\n\t\t\t\t}),\n\t\t\tcancel: (task) => {\n\t\t\t\tconst lease = this.store.resolveTask(task.ref.taskId);\n\t\t\t\tif (lease.ok) void this.store.supervisor.cancelTask(lease.value, \"user\").then(() => this.requestRender());\n\t\t\t},\n\t\t\tstdinAvailable: (task) => {\n\t\t\t\tconst lease = this.store.resolveTask(task.ref.taskId);\n\t\t\t\treturn lease.ok && this.store.supervisor.taskStdin(lease.value).ok;\n\t\t\t},\n\t\t\tinput: () => {\n\t\t\t\tthis.input.setValue(\"\");\n\t\t\t},\n\t\t\topenQuestion: (route) => {\n\t\t\t\tif (openQuestion) {\n\t\t\t\t\tthis.close();\n\t\t\t\t\topenQuestion(route);\n\t\t\t\t} else this.status = \"Question is available in its owning session.\";\n\t\t\t},\n\t\t});\n\t\tthis.unsubscribe = this.store.subscribe(() => {\n\t\t\tthis.navigation.update(this.orderedSections().flatMap((section) => section.tasks));\n\t\t\tif (this.transcriptRequested) {\n\t\t\t\tthis.refreshTranscript();\n\t\t\t} else if (this.navigation.focus.kind === \"detail\") void this.loadDetail();\n\t\t\tthis.requestRender();\n\t\t});\n\t\tthis.navigation.update(this.orderedSections().flatMap((section) => section.tasks));\n\t\tthis.navigation.open();\n\t\tthis.input.onSubmit = (text) => {\n\t\t\tvoid this.sendInput(text);\n\t\t};\n\t}\n\tprivate readonly store: OwnerTaskStore;\n\tprivate readonly requestRender: () => void;\n\tprivate readonly close: () => void;\n\topen(id?: TaskId): void {\n\t\tthis.navigation.open(id);\n\t}\n\tprivate orderedSections(): TaskListSection[] {\n\t\treturn taskListSections(this.store.backgroundTasks, this.store.settlementOrder);\n\t}\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.releaseStatusWatch();\n\t\tthis.releaseLiveTranscript();\n\t\tthis.confirmation?.(false);\n\t\tthis.unsubscribe();\n\t}\n\tinvalidate(): void {\n\t\tfor (const component of this.transcript ?? []) component.invalidate();\n\t}\n\tprivate selected() {\n\t\treturn this.store.backgroundTasks.find((task) => task.ref.taskId === this.navigation.selectedTaskId);\n\t}\n\tprivate stdinAvailable(): boolean {\n\t\tconst task = this.selected();\n\t\tif (!task || task.execution.kind === \"settled\") return false;\n\t\tconst lease = this.store.resolveTask(task.ref.taskId);\n\t\treturn lease.ok && this.store.supervisor.taskStdin(lease.value).ok;\n\t}\n\tprivate async sendInput(text: string): Promise<void> {\n\t\tconst task = this.selected();\n\t\tif (!task) return;\n\t\tconst lease = this.store.resolveTask(task.ref.taskId);\n\t\tif (!lease.ok) return;\n\t\tconst stdin = this.store.supervisor.taskStdin(lease.value);\n\t\tif (!stdin.ok) {\n\t\t\tthis.status = stdin.error.message;\n\t\t\treturn;\n\t\t}\n\t\tconst result = await this.store.supervisor.writeTaskInput(stdin.value, randomUUID() as OperationId, {\n\t\t\tkind: \"bytes\",\n\t\t\tbytes: Buffer.from(`${text}\\n`),\n\t\t});\n\t\tthis.status = result.ok ? `Sent ${result.value.acceptedBytes} bytes` : result.error.message;\n\t\tthis.input.setValue(\"\");\n\t\tthis.requestRender();\n\t}\n\tprivate releaseStatusWatch(): void {\n\t\tthis.statusWatch?.release();\n\t\tthis.statusWatch = undefined;\n\t}\n\t/**\n\t * The selected task's own extension statuses, as the row under its fullscreen page's footer. The\n\t * compact picker and confirmation page show none. A write repaints the page while it is shown.\n\t */\n\tprivate taskStatusRows(width: number): string[] {\n\t\tconst task = this.navigation.focus.kind === \"detail\" && !this.confirmation ? this.selected() : undefined;\n\t\tconst lease = task?.kind === \"agent\" ? this.store.resolveTask(task.ref.taskId) : undefined;\n\t\tif (!task || !lease?.ok) {\n\t\t\tthis.releaseStatusWatch();\n\t\t\treturn [];\n\t\t}\n\t\tif (this.statusWatch?.taskId !== task.ref.taskId) {\n\t\t\tthis.releaseStatusWatch();\n\t\t\tthis.statusWatch = {\n\t\t\t\ttaskId: task.ref.taskId,\n\t\t\t\trelease: watchTaskExtensionStatuses(lease.value, () => this.requestRender()),\n\t\t\t};\n\t\t}\n\t\tconst row = renderExtensionStatusRow(taskExtensionStatuses(lease.value), width);\n\t\treturn row === undefined ? [] : [row];\n\t}\n\tprivate releaseLiveTranscript(): void {\n\t\tthis.liveTranscript?.dispose();\n\t\tthis.liveTranscript = undefined;\n\t\tthis.transcriptRefreshPending = false;\n\t}\n\tprivate refreshTranscript(): void {\n\t\tif (this.disposed || !this.transcriptRequested) return;\n\t\tconst task = this.selected();\n\t\tconst lease = task && this.store.resolveTask(task.ref.taskId);\n\t\tconst bound = lease?.ok ? taskTranscriptSource(lease.value) : undefined;\n\t\tif (bound?.ok && this.liveTranscript?.source === bound.value.session) return;\n\t\t// Legacy history-only sources have no live tail; keep their retained page anchored.\n\t\tif (bound?.ok && !bound.value.session.subscribe && this.transcriptHistorical) return;\n\t\tif (this.transcriptLoading) this.transcriptRefreshPending = true;\n\t\telse void this.loadTranscript();\n\t}\n\tprivate async loadTranscript(earlier = false): Promise<void> {\n\t\tconst task = this.selected();\n\t\tif (!task) return;\n\t\tconst generation = ++this.detailGeneration;\n\t\tconst focus = this.navigation.focus;\n\t\tthis.transcriptRequested = true;\n\t\tthis.transcriptLoading = true;\n\t\tif (earlier) this.transcriptHistorical = true;\n\t\tthis.requestRender();\n\t\ttry {\n\t\t\tconst lease = this.store.resolveTask(task.ref.taskId);\n\t\t\tif (!lease.ok) {\n\t\t\t\tthis.status = lease.error.message;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (task.kind === \"command\") {\n\t\t\t\tconst count = BigInt(task.output.byteCount);\n\t\t\t\tconst page = await this.store.supervisor.readTaskOutput(lease.value, {\n\t\t\t\t\tstart: String(count > 8192n ? count - 8192n : 0n),\n\t\t\t\t\tmaximumBytes: 8192,\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tthis.disposed ||\n\t\t\t\t\tgeneration !== this.detailGeneration ||\n\t\t\t\t\tfocus !== this.navigation.focus ||\n\t\t\t\t\ttask.ref.taskId !== this.navigation.selectedTaskId\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tconst text = page.ok ? taskOutputText(page.value) : page.error.message;\n\t\t\t\tthis.transcript = [\n\t\t\t\t\tnew Text(text.split(\"\\n\").map(taskDisplayText).join(\"\\n\") || \"No output available\", 0, 0),\n\t\t\t\t];\n\t\t\t\tthis.cursor = undefined;\n\t\t\t\tthis.status =\n\t\t\t\t\tcount > 8192n ? \"Earlier output omitted · showing retained 8 KiB tail\" : \"Retained shell output\";\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst page = readTaskTranscriptSnapshot(lease.value, earlier ? this.cursor : undefined);\n\t\t\tif (\n\t\t\t\tthis.disposed ||\n\t\t\t\tgeneration !== this.detailGeneration ||\n\t\t\t\tfocus !== this.navigation.focus ||\n\t\t\t\ttask.ref.taskId !== this.navigation.selectedTaskId\n\t\t\t)\n\t\t\t\treturn;\n\t\t\tconst bound = taskTranscriptSource(lease.value);\n\t\t\tif (!bound.ok || (!page.ok && !bound.value.session.subscribe)) {\n\t\t\t\tthis.status = \"Transcript unavailable\";\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst ids = new Set(page.ok ? page.value.items.map((item) => item.source.entryId) : []);\n\t\t\tconst messages = bound.value.session.getEntries().flatMap<AgentMessage>((entry) => {\n\t\t\t\tif (entry.type !== \"message\" || !ids.has(entry.id)) return [];\n\t\t\t\tconst message = entry.message;\n\t\t\t\tif (message.role === \"assistant\")\n\t\t\t\t\treturn [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t...message,\n\t\t\t\t\t\t\tcontent: message.content.filter(\n\t\t\t\t\t\t\t\t(block, index) =>\n\t\t\t\t\t\t\t\t\tblock.type !== \"thinking\" &&\n\t\t\t\t\t\t\t\t\tpage.ok &&\n\t\t\t\t\t\t\t\t\tpage.value.items.some(\n\t\t\t\t\t\t\t\t\t\t(item) => item.source.entryId === entry.id && item.source.contentIndex === index,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\t\t\t\treturn message.role === \"user\" || message.role === \"toolResult\" ? [message] : [];\n\t\t\t});\n\t\t\tconst components = chatEntriesFromAgentMessages(messages).map((entry) =>\n\t\t\t\trenderChatMessageEntry(entry, {\n\t\t\t\t\tui: { requestRender: this.requestRender },\n\t\t\t\t\tcwd: process.cwd(),\n\t\t\t\t\thideThinkingBlock: true,\n\t\t\t\t\ttoolOutputExpanded: true,\n\t\t\t\t\tshowImages: false,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (!earlier && bound.value.session.subscribe) {\n\t\t\t\tthis.releaseLiveTranscript();\n\t\t\t\tthis.liveTranscript = new TaskLiveTranscript(bound.value.session, messages, this.requestRender);\n\t\t\t\tthis.transcript = [this.liveTranscript];\n\t\t\t} else this.transcript = earlier ? [...components, ...(this.transcript ?? [])] : components;\n\t\t\tthis.cursor = page.ok ? page.value.nextCursor : undefined;\n\t\t\tthis.status = this.cursor ? \"PageUp: earlier retained messages\" : \"\";\n\t\t\tthis.requestRender();\n\t\t} catch {\n\t\t\tif (!this.disposed && generation === this.detailGeneration && focus === this.navigation.focus) {\n\t\t\t\tthis.transcript = [];\n\t\t\t\tthis.status = \"Task output unavailable\";\n\t\t\t\tthis.requestRender();\n\t\t\t}\n\t\t} finally {\n\t\t\tif (generation === this.detailGeneration) {\n\t\t\t\tthis.transcriptLoading = false;\n\t\t\t\tif (this.transcriptRefreshPending) {\n\t\t\t\t\tthis.transcriptRefreshPending = false;\n\t\t\t\t\tthis.refreshTranscript();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprivate async loadDetail(): Promise<void> {\n\t\tconst selectedId = this.selected()?.ref.taskId;\n\t\tif (selectedId !== this.detailTaskId) {\n\t\t\tthis.detailContent = {};\n\t\t\tthis.detailTaskId = selectedId;\n\t\t}\n\t\tthis.status = \"\";\n\t\tconst generation = ++this.detailGeneration;\n\t\tconst focus = this.navigation.focus;\n\t\tconst task = this.selected();\n\t\tif (!task) return;\n\t\tconst current = () =>\n\t\t\t!this.disposed &&\n\t\t\tgeneration === this.detailGeneration &&\n\t\t\tthis.navigation.focus === focus &&\n\t\t\tfocus.kind === \"detail\" &&\n\t\t\tthis.navigation.selectedTaskId === task.ref.taskId;\n\t\tconst lease = this.store.resolveTask(task.ref.taskId);\n\t\tif (!lease.ok) return;\n\t\tconst ownEntries = taskOwnTranscriptEntries(lease.value);\n\t\tif (ownEntries) {\n\t\t\tconst prompt = ownEntries.find((entry) => entry.type === \"message\" && entry.message.role === \"user\");\n\t\t\tif (prompt?.type === \"message\" && prompt.message.role === \"user\")\n\t\t\t\tthis.detailContent.prompt =\n\t\t\t\t\ttypeof prompt.message.content === \"string\"\n\t\t\t\t\t\t? prompt.message.content\n\t\t\t\t\t\t: prompt.message.content\n\t\t\t\t\t\t\t\t.filter((block) => block.type === \"text\")\n\t\t\t\t\t\t\t\t.map((block) => block.text)\n\t\t\t\t\t\t\t\t.join(\"\");\n\t\t\tconst response = ownEntries\n\t\t\t\t.slice()\n\t\t\t\t.reverse()\n\t\t\t\t.find((entry) => entry.type === \"message\" && entry.message.role === \"assistant\");\n\t\t\tif (response?.type === \"message\" && response.message.role === \"assistant\")\n\t\t\t\tthis.detailContent.output = response.message.content\n\t\t\t\t\t.filter((block) => block.type === \"text\")\n\t\t\t\t\t.map((block) => block.text)\n\t\t\t\t\t.join(\"\");\n\t\t}\n\t\tif (task.kind === \"command\") {\n\t\t\ttry {\n\t\t\t\tconst count = BigInt(task.output.byteCount);\n\t\t\t\tconst output = await this.store.supervisor.readTaskOutput(lease.value, {\n\t\t\t\t\tstart: String(count > 8192n ? count - 8192n : 0n),\n\t\t\t\t\tmaximumBytes: 8192,\n\t\t\t\t});\n\t\t\t\tif (!current()) return;\n\t\t\t\tif (output.ok) {\n\t\t\t\t\tthis.detailContent.output = taskOutputText(output.value);\n\t\t\t\t\tthis.detailContent.outputOmitted = count > 8192n || output.value.omittedRanges.length > 0;\n\t\t\t\t} else this.status = output.error.message;\n\t\t\t} catch {\n\t\t\t\tif (!current()) return;\n\t\t\t\tthis.status = \"Command output unavailable\";\n\t\t\t}\n\t\t}\n\t\tif (current()) this.requestRender();\n\t}\n\thandleInput(data: string): boolean {\n\t\tif (this.confirmation) {\n\t\t\tif (data === \"y\" || data === \"n\" || matchesKey(data, \"escape\")) {\n\t\t\t\tconst answer = this.confirmation;\n\t\t\t\tthis.confirmation = undefined;\n\t\t\t\tanswer(data === \"y\");\n\t\t\t}\n\t\t\tthis.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\tconst wheel = mouseWheelDeltaRows(data);\n\t\tif (wheel !== 0) {\n\t\t\tif (this.navigation.focus.kind === \"tasks\") this.navigation.moveSelection(Math.sign(wheel));\n\t\t\telse if (this.navigation.focus.kind === \"detail\") {\n\t\t\t\tif (this.transcriptRequested && wheel < 0 && this.scroll === 0 && this.cursor && !this.transcriptLoading)\n\t\t\t\t\tvoid this.loadTranscript(true);\n\t\t\t\telse this.scroll = Math.max(0, this.scroll + wheel);\n\t\t\t}\n\t\t\tthis.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\t// Mouse reports are never text input, including horizontal wheel/release.\n\t\tif (/^\\x1b\\[<\\d+;\\d+;\\d+[mM]$/.test(data) || data.startsWith(\"\\x1b[M\")) return true;\n\t\tif (\n\t\t\tmatchesKey(data, \"escape\") ||\n\t\t\t(matchesKey(data, \"left\") && this.navigation.focus.kind !== \"stdin\" && !this.configuredTaskKey(data))\n\t\t) {\n\t\t\tif (this.transcriptRequested) {\n\t\t\t\tthis.releaseLiveTranscript();\n\t\t\t\tthis.detailGeneration++;\n\t\t\t\tthis.transcript = undefined;\n\t\t\t\tthis.transcriptRequested = false;\n\t\t\t\tthis.transcriptLoading = false;\n\t\t\t\tthis.transcriptHistorical = false;\n\t\t\t\tthis.scroll = 0;\n\t\t\t\tvoid this.loadDetail();\n\t\t\t} else {\n\t\t\t\tthis.navigation.handleInput(\"\\x1b\", \"tasks\");\n\t\t\t\tif (this.navigation.focus.kind === \"composer\") this.close();\n\t\t\t}\n\t\t\tthis.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\tif (this.navigation.focus.kind === \"stdin\") {\n\t\t\tthis.input.handleInput(data);\n\t\t\tthis.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"x\" && !this.configuredTaskKey(data)) {\n\t\t\tvoid this.navigation.activate(\"cancel\");\n\t\t\treturn true;\n\t\t}\n\t\tif (this.transcriptRequested) {\n\t\t\tif (this.configuredTaskKey(data)) this.navigation.handleInput(data, \"tasks\");\n\t\t\telse if (matchesKey(data, \"up\")) this.scroll = Math.max(0, this.scroll - 1);\n\t\t\telse if (matchesKey(data, \"down\")) this.scroll++;\n\t\t\telse if (matchesKey(data, \"pageUp\")) {\n\t\t\t\tif (this.scroll === 0 && this.cursor && !this.transcriptLoading) void this.loadTranscript(true);\n\t\t\t\telse this.scroll = Math.max(0, this.scroll - this.transcriptPageRows);\n\t\t\t} else if (matchesKey(data, \"pageDown\")) this.scroll += this.transcriptPageRows;\n\t\t\telse if (matchesKey(data, \"home\")) this.scroll = 0;\n\t\t\telse if (matchesKey(data, \"end\")) this.scroll = Number.MAX_SAFE_INTEGER;\n\t\t\tthis.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\tconst task = this.selected();\n\t\tif (task && this.navigation.focus.kind === \"detail\") {\n\t\t\tconst actions = taskDetailActions(task.execution, task.attention, this.stdinAvailable());\n\t\t\tif (this.configuredTaskKey(data)) {\n\t\t\t\tif (getKeybindings().matches(data, \"app.tasks.inspect\"))\n\t\t\t\t\tvoid this.navigation.activate(actions[Math.min(this.actionIndex, actions.length - 1)]);\n\t\t\t\telse this.navigation.handleInput(data, \"tasks\");\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (matchesKey(data, \"pageUp\") || matchesKey(data, \"pageDown\")) {\n\t\t\t\tthis.scroll = Math.max(0, this.scroll + (matchesKey(data, \"pageUp\") ? -5 : 5));\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (matchesKey(data, \"up\")) this.actionIndex = Math.max(0, this.actionIndex - 1);\n\t\t\telse if (matchesKey(data, \"down\")) this.actionIndex = Math.min(actions.length - 1, this.actionIndex + 1);\n\t\t\telse if (getKeybindings().matches(data, \"app.tasks.inspect\"))\n\t\t\t\tvoid this.navigation.activate(actions[Math.min(this.actionIndex, actions.length - 1)]);\n\t\t\telse if (!this.navigation.handleInput(data, \"tasks\")) return false;\n\t\t} else if (!this.navigation.handleInput(data, \"tasks\")) return false;\n\t\tthis.requestRender();\n\t\treturn true;\n\t}\n\tprivate configuredTaskKey(data: string): boolean {\n\t\treturn ([\"app.tasks.inspect\", \"app.tasks.foreground\", \"app.tasks.cancel\", \"app.tasks.input\"] as const).some(\n\t\t\t(key) => getKeybindings().matches(data, key),\n\t\t);\n\t}\n\t/** Only the task picker stays inline; drill-down and confirmation own the screen. */\n\tget fullscreen(): boolean {\n\t\treturn (\n\t\t\tthis.confirmation !== undefined ||\n\t\t\tthis.navigation.focus.kind === \"detail\" ||\n\t\t\tthis.navigation.focus.kind === \"stdin\"\n\t\t);\n\t}\n\trenderPicker(width: number, availableRows: number): string[] {\n\t\treturn this.renderViewport(width, Math.max(1, Math.min(12, availableRows)));\n\t}\n\trender(width: number): string[] {\n\t\treturn this.renderViewport(width, Math.max(3, (process.stdout.rows || 24) - 5));\n\t}\n\tprivate renderTranscriptViewport(width: number, budget: number): string[] {\n\t\tconst task = this.selected();\n\t\tconst statusRows = this.taskStatusRows(width);\n\t\tconst room = Math.max(1, budget - 5 - statusRows.length);\n\t\tthis.transcriptPageRows = room;\n\t\tconst rows = this.transcript?.flatMap((component) => component.render(width)) ?? [\n\t\t\tthis.transcriptLoading ? \"Loading transcript…\" : this.status,\n\t\t];\n\t\tthis.scroll = Math.min(this.scroll, Math.max(0, rows.length - room));\n\t\tconst visible = rows.slice(this.scroll, this.scroll + room);\n\t\t// Transcript tools own their backgrounds. Keep them out of a nested box,\n\t\t// strip terminal movement, and reset styles at every viewport row boundary.\n\t\tconst safeLine = (line: string) =>\n\t\t\tline\n\t\t\t\t.split(/(\\x1b\\[[0-9;:]*m)/g)\n\t\t\t\t.map((part, index) =>\n\t\t\t\t\tindex % 2 ? part : stripVTControlCharacters(part).replace(/[\\x00-\\x1f\\x7f-\\x9f]/g, \" \"),\n\t\t\t\t)\n\t\t\t\t.join(\"\");\n\t\tconst fit = (line: string) => truncateToWidth(safeLine(line), Math.max(1, width)) + \"\\x1b[0m\";\n\t\treturn [\n\t\t\ttheme.bold(`Transcript · ${task ? taskDisplayText(taskLabel(task)) : \"Task\"}`),\n\t\t\ttask ? taskDetailSummary(task) : \"\",\n\t\t\ttheme.fg(\"borderMuted\", \"─\".repeat(Math.max(0, width))),\n\t\t\t...visible,\n\t\t\t...Array.from({ length: Math.max(0, room - visible.length) }, () => \"\"),\n\t\t\ttheme.fg(\n\t\t\t\t\"dim\",\n\t\t\t\t`Lines ${rows.length ? this.scroll + 1 : 0}–${Math.min(rows.length, this.scroll + room)} of ${rows.length}${this.cursor ? \" · PgUp at top: earlier history\" : \"\"}${this.status ? ` · ${this.status}` : \"\"}`,\n\t\t\t),\n\t\t\ttheme.fg(\"dim\", \"↑↓ scroll · PgUp/PgDn page · Home/End · ←/Esc back\"),\n\t\t\t...statusRows,\n\t\t]\n\t\t\t.map(fit)\n\t\t\t.slice(0, Math.max(1, budget));\n\t}\n\trenderViewport(width: number, budget: number): string[] {\n\t\tif (this.transcriptRequested && !this.confirmation && this.navigation.focus.kind === \"detail\")\n\t\t\treturn this.renderTranscriptViewport(width, budget);\n\t\tconst framed = width >= 20 && budget >= 7;\n\t\tconst inner = Math.max(1, width - (framed ? 4 : 0));\n\t\tconst current = this.selected();\n\t\tconst detail = this.navigation.focus.kind === \"detail\";\n\t\tconst selectingAction = current && detail && !this.transcriptRequested && !this.confirmation;\n\t\tconst actions = selectingAction\n\t\t\t? taskDetailActions(current.execution, current.attention, this.stdinAvailable())\n\t\t\t: [];\n\t\tthis.actionIndex = Math.max(0, Math.min(this.actionIndex, actions.length - 1));\n\t\tconst action = actions[this.actionIndex];\n\t\tconst actionRow = action ? [theme.fg(\"accent\", `› ${taskDetailLabels[action]}`)] : [];\n\t\tconst rows = this.renderAll(inner);\n\t\tconst compactSummary = !framed && detail && current && budget >= 4 ? [taskDetailSummary(current)] : [];\n\t\tconst statusRows = this.taskStatusRows(width);\n\t\tconst height = Math.max(\n\t\t\t0,\n\t\t\tbudget - (framed ? 4 : 1) - actionRow.length - compactSummary.length - statusRows.length,\n\t\t);\n\t\tconst selected = detail ? -1 : rows.findIndex((row) => stripVTControlCharacters(row).startsWith(\"›\"));\n\t\tthis.scroll = Math.min(this.scroll, Math.max(0, rows.length - height));\n\t\tconst selectionRows = Math.min(height, current?.kind === \"agent\" ? 3 : 2);\n\t\tconst offset = detail ? this.scroll : Math.max(0, selected + selectionRows - height);\n\t\tconst view = rows.slice(offset, offset + height);\n\t\tconst inspect = keyHintIfBound(\"app.tasks.inspect\", detail ? \"select\" : \"view\");\n\t\tconst hints = this.confirmation\n\t\t\t? \"y confirm · n/Esc keep running\"\n\t\t\t: this.navigation.focus.kind === \"stdin\"\n\t\t\t\t? \"Enter send · Esc back\"\n\t\t\t\t: this.transcriptRequested\n\t\t\t\t\t? \"↑↓ scroll · PgUp/PgDn page · ←/Esc back\"\n\t\t\t\t\t: [\n\t\t\t\t\t\t\tdetail ? \"PgUp/PgDn scroll · ↑↓ actions\" : \"↑↓ select\",\n\t\t\t\t\t\t\tinspect,\n\t\t\t\t\t\t\tcurrent && current.execution.kind !== \"settled\"\n\t\t\t\t\t\t\t\t? keyHintIfBound(\"app.tasks.cancel\", \"stop\") || (!this.configuredTaskKey(\"x\") ? \"x stop\" : \"\")\n\t\t\t\t\t\t\t\t: \"\",\n\t\t\t\t\t\t\t\"Esc back\",\n\t\t\t\t\t\t]\n\t\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t\t.join(\" · \");\n\t\tconst footer = theme.fg(\"dim\", truncateToWidth(`/tasks · ${hints}`, width));\n\t\tif (!framed)\n\t\t\treturn [...compactSummary, ...view, ...actionRow, footer, ...statusRows]\n\t\t\t\t.map((line) => truncateToWidth(line, width))\n\t\t\t\t.slice(-Math.max(1, budget));\n\t\tconst live = this.store.backgroundTasks.filter((task) => task.execution.kind !== \"settled\").length;\n\t\tconst title =\n\t\t\tdetail && current\n\t\t\t\t? `${taskDisplayText(taskLabel(current))} › ${taskDisplayText(current.title)}`\n\t\t\t\t: \"Background tasks\";\n\t\tconst heading = ` ${truncateToWidth(title, Math.max(1, width - 5))} `;\n\t\tconst border = (text: string) => theme.fg(\"borderMuted\", text);\n\t\tconst frameRow = (line: string) => {\n\t\t\tconst text = truncateToWidth(line, inner);\n\t\t\treturn border(\"│ \") + text + \" \".repeat(Math.max(0, inner - visibleWidth(text))) + border(\" │\");\n\t\t};\n\t\treturn [\n\t\t\tborder(\"╭─\") + theme.bold(heading) + border(`${\"─\".repeat(Math.max(0, width - visibleWidth(heading) - 3))}╮`),\n\t\t\tframeRow(\n\t\t\t\tdetail && current\n\t\t\t\t\t? taskDetailSummary(current)\n\t\t\t\t\t: theme.fg(\"muted\", `${live} active · ${this.store.backgroundTasks.length} total`),\n\t\t\t),\n\t\t\t...view.map(frameRow),\n\t\t\t...actionRow.map(frameRow),\n\t\t\tborder(`╰${\"─\".repeat(Math.max(0, width - 2))}╯`),\n\t\t\tfooter,\n\t\t\t...statusRows,\n\t\t].map((line) => truncateToWidth(line, width));\n\t}\n\tprivate renderAll(width: number): string[] {\n\t\tconst task = this.selected();\n\t\tif (this.confirmation)\n\t\t\treturn new Text(\n\t\t\t\t`Cancel ${task?.title}\\nTask ${task?.ref.taskId}\\ny: confirm · n/Escape: keep running`,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t).render(width);\n\t\tif (this.navigation.focus.kind === \"stdin\")\n\t\t\treturn [`Input to ${task?.title} · Escape: tasks`, ...this.input.render(width), this.status];\n\t\tif (this.transcript) return [...this.transcript.flatMap((component) => component.render(width)), this.status];\n\t\tif (this.transcriptRequested)\n\t\t\treturn [this.transcriptLoading ? \"Loading transcript…\" : this.status || \"Transcript unavailable\"];\n\t\tif (task && this.navigation.focus.kind === \"detail\") {\n\t\t\treturn [\n\t\t\t\t...new TaskDetail(task, {\n\t\t\t\t\t...this.detailContent,\n\t\t\t\t\tstdinAvailable: this.stdinAvailable(),\n\t\t\t\t\tactivity: this.store.recentActivity(task.ref.taskId),\n\t\t\t\t\tactivityOmitted: this.store.activityOmitted(task.ref.taskId),\n\t\t\t\t}).renderContent(width),\n\t\t\t\tthis.status,\n\t\t\t];\n\t\t}\n\t\tconst sections = this.orderedSections();\n\t\tif (!sections.length)\n\t\t\treturn new Text(\"No background tasks.\\nBackground agents and shells will appear here.\", 0, 0).render(width);\n\t\treturn sections.flatMap((section) => [\n\t\t\t\"\",\n\t\t\ttheme.fg(\"muted\", theme.bold(`${section.title} (${section.tasks.length})`)),\n\t\t\t...section.tasks.flatMap((item) => {\n\t\t\t\tconst selected = item.ref.taskId === this.navigation.selectedTaskId;\n\t\t\t\tconst { label: state, color, icon } = taskStatusAppearance(item);\n\t\t\t\tconst status = width < 32 ? ` ${icon}` : ` ${icon} ${state}`;\n\t\t\t\tconst name = taskDisplayText(item.title || taskLabel(item));\n\t\t\t\tconst marker = selected ? \"› \" : \" \";\n\t\t\t\tconst title = marker + truncateToWidth(name, Math.max(1, width - visibleWidth(status) - 3));\n\t\t\t\tconst row = `${selected ? theme.fg(\"accent\", theme.bold(title)) : title}${\" \".repeat(Math.max(1, width - visibleWidth(title) - visibleWidth(status)))}${theme.fg(color, status)}`;\n\t\t\t\tconst metadata = [\n\t\t\t\t\t...(width < 32 ? [state] : []),\n\t\t\t\t\ttaskLabel(item),\n\t\t\t\t\ttaskMetricsText(item),\n\t\t\t\t\titem.currentAction ? `${item.currentAction.tool} ${item.currentAction.text}` : \"\",\n\t\t\t\t]\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.join(\" · \");\n\t\t\t\treturn [\n\t\t\t\t\ttruncateToWidth(row, width),\n\t\t\t\t\t...(item.kind === \"agent\" ? [theme.fg(\"dim\", truncateToWidth(` ${taskModelText(item)}`, width))] : []),\n\t\t\t\t\t...(selected ? [theme.fg(\"dim\", truncateToWidth(` ${taskDisplayText(metadata)}`, width))] : []),\n\t\t\t\t];\n\t\t\t}),\n\t\t]);\n\t}\n}\n"]}
1
+ {"version":3,"file":"task-inspector.js","sourceRoot":"","sources":["../../../../src/modes/interactive/components/task-inspector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAEN,cAAc,EACd,KAAK,EACL,UAAU,EACV,IAAI,EACJ,eAAe,EACf,YAAY,GACZ,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAuB,MAAM,yCAAyC,CAAC;AACnG,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACN,UAAU,EAEV,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAwB,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,cAA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AAa,CAAC,IAAI,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;iBACjF;qBACC,MAAM,CAAC,OAAO,CAAC;qBACf,IAAI,CAAC,KAAK,CAAC,CAAC;gBACd,OAAO;oBACN,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC;oBAC3B,GAAG,CAAC,IAAI,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,KAAK,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBACvG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,CAAC,KAAK,eAAe,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iBAChG,CAAC;YACH,CAAC,CAAC;SACF,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import { stripVTControlCharacters } from \"node:util\";\nimport {\n\ttype Component,\n\tgetKeybindings,\n\tInput,\n\tmatchesKey,\n\tText,\n\ttruncateToWidth,\n\tvisibleWidth,\n} from \"@earendil-works/pi-tui\";\nimport type { KeybindingsManager } from \"../../../core/keybindings.ts\";\nimport type { PromptRoute, TaskId } from \"../../../core/tasks/contracts.js\";\nimport { OwnerTaskStore } from \"../../../core/tasks/owner-store.js\";\nimport { ownerTaskViewSource, type TaskViewSource } from \"../../../core/tasks/task-view-source.js\";\nimport { theme } from \"../theme/theme.js\";\nimport { chatEntriesFromAgentMessages, renderChatMessageEntry } from \"./chat-message-renderer.ts\";\nimport { mouseWheelDeltaRows } from \"./chat-transcript.js\";\nimport { renderExtensionStatusRow } from \"./footer.ts\";\nimport { keyHintIfBound } from \"./keybinding-hints.js\";\nimport {\n\tTaskDetail,\n\ttype TaskDetailContent,\n\ttaskDetailActions,\n\ttaskDetailLabels,\n\ttaskDetailSummary,\n} from \"./task-detail.js\";\nimport { type TaskListSection, taskListSections } from \"./task-list.js\";\nimport { TaskLiveTranscript } from \"./task-live-transcript.js\";\nimport { TaskNavigation } from \"./task-navigation.js\";\nimport { taskDisplayText, taskLabel, taskMetricsText, taskModelText, taskStatusAppearance } from \"./task-row.js\";\n\n/** Focused view only. The task source and original session remain the authorities. */\nexport class TaskInspector implements Component {\n\treadonly navigation: TaskNavigation;\n\tprivate actionIndex = 0;\n\tprivate confirmation?: (answer: boolean) => void;\n\tprivate transcript?: Component[];\n\tprivate liveTranscript?: TaskLiveTranscript;\n\tprivate transcriptRefreshPending = false;\n\tprivate transcriptRequested = false;\n\tprivate transcriptLoading = false;\n\tprivate transcriptHistorical = false;\n\tprivate transcriptPageRows = 5;\n\tprivate cursor?: string;\n\tprivate status = \"\";\n\t/** Why the last stop did not reach its task; shown under the list until the next key. */\n\tprivate stopFailure = \"\";\n\tprivate scroll = 0;\n\tprivate detailContent: Omit<TaskDetailContent, \"stdinAvailable\"> = {};\n\tprivate detailTaskId?: TaskId;\n\tprivate detailGeneration = 0;\n\tprivate disposed = false;\n\tprivate statusWatch?: { taskId: TaskId; release: () => void };\n\tprivate readonly input = new Input();\n\tprivate readonly unsubscribe: () => void;\n\tconstructor(\n\t\tprivateStore: OwnerTaskStore | TaskViewSource,\n\t\tprivateRender: () => void,\n\t\tprivateClose: () => void,\n\t\topenQuestion?: (route: PromptRoute) => void,\n\t) {\n\t\tthis.store = privateStore instanceof OwnerTaskStore ? ownerTaskViewSource(privateStore) : privateStore;\n\t\tthis.requestRender = privateRender;\n\t\tthis.close = privateClose;\n\t\tthis.navigation = new TaskNavigation(getKeybindings() as KeybindingsManager, {\n\t\t\tinspect: () => {\n\t\t\t\tthis.releaseLiveTranscript();\n\t\t\t\tthis.actionIndex = 0;\n\t\t\t\tthis.scroll = 0;\n\t\t\t\tthis.transcript = undefined;\n\t\t\t\tthis.transcriptRequested = false;\n\t\t\t\tthis.transcriptLoading = false;\n\t\t\t\tthis.transcriptHistorical = false;\n\t\t\t\tvoid this.loadDetail();\n\t\t\t},\n\t\t\ttranscript: () => {\n\t\t\t\tthis.detailGeneration++;\n\t\t\t\tthis.scroll = 0;\n\t\t\t\tvoid this.loadTranscript();\n\t\t\t},\n\t\t\tforeground: (task) => {\n\t\t\t\tvoid this.store.foregroundTask(task.ref.taskId).then((result) => {\n\t\t\t\t\tthis.status = result.ok ? result.value.kind : result.error.message;\n\t\t\t\t\tthis.requestRender();\n\t\t\t\t});\n\t\t\t},\n\t\t\tconfirmCancel: () =>\n\t\t\t\tnew Promise<boolean>((resolve) => {\n\t\t\t\t\tthis.confirmation = resolve;\n\t\t\t\t\tthis.requestRender();\n\t\t\t\t}),\n\t\t\tcancel: (task) => {\n\t\t\t\tvoid this.store.cancelTask(task.ref.taskId).then((result) => {\n\t\t\t\t\t// A stop that did not reach the task says so, instead of leaving it looking untouched.\n\t\t\t\t\tthis.stopFailure = result.ok ? \"\" : `Could not stop the task: ${result.error.message}`;\n\t\t\t\t\tthis.requestRender();\n\t\t\t\t});\n\t\t\t},\n\t\t\tstdinAvailable: (task) => this.store.stdinAvailable(task.ref.taskId),\n\t\t\tinput: () => {\n\t\t\t\tthis.input.setValue(\"\");\n\t\t\t},\n\t\t\topenQuestion: (route) => {\n\t\t\t\tif (openQuestion) {\n\t\t\t\t\tthis.close();\n\t\t\t\t\topenQuestion(route);\n\t\t\t\t} else this.status = \"Question is available in its owning session.\";\n\t\t\t},\n\t\t});\n\t\tthis.unsubscribe = this.store.subscribe(() => {\n\t\t\tthis.navigation.update(this.orderedSections().flatMap((section) => section.tasks));\n\t\t\tif (this.transcriptRequested) {\n\t\t\t\tthis.refreshTranscript();\n\t\t\t} else if (this.navigation.focus.kind === \"detail\") void this.loadDetail();\n\t\t\tthis.requestRender();\n\t\t});\n\t\tthis.navigation.update(this.orderedSections().flatMap((section) => section.tasks));\n\t\tthis.navigation.open();\n\t\tthis.input.onSubmit = (text) => {\n\t\t\tvoid this.sendInput(text);\n\t\t};\n\t}\n\tprivate readonly store: TaskViewSource;\n\tprivate readonly requestRender: () => void;\n\tprivate readonly close: () => void;\n\topen(id?: TaskId): void {\n\t\tthis.navigation.open(id);\n\t}\n\tprivate orderedSections(): TaskListSection[] {\n\t\treturn taskListSections(this.store.backgroundTasks, this.store.settlementOrder);\n\t}\n\tdispose(): void {\n\t\tthis.disposed = true;\n\t\tthis.releaseStatusWatch();\n\t\tthis.releaseLiveTranscript();\n\t\tthis.confirmation?.(false);\n\t\tthis.unsubscribe();\n\t}\n\tinvalidate(): void {\n\t\tfor (const component of this.transcript ?? []) component.invalidate();\n\t}\n\tprivate selected() {\n\t\treturn this.store.backgroundTasks.find((task) => task.ref.taskId === this.navigation.selectedTaskId);\n\t}\n\tprivate stdinAvailable(): boolean {\n\t\tconst task = this.selected();\n\t\tif (!task || task.execution.kind === \"settled\") return false;\n\t\treturn this.store.stdinAvailable(task.ref.taskId);\n\t}\n\tprivate async sendInput(text: string): Promise<void> {\n\t\tconst task = this.selected();\n\t\tif (!task) return;\n\t\tconst result = await this.store.writeTaskInput(task.ref.taskId, text);\n\t\tthis.status = result.ok ? `Sent ${result.value.acceptedBytes} bytes` : result.error.message;\n\t\tthis.input.setValue(\"\");\n\t\tthis.requestRender();\n\t}\n\tprivate releaseStatusWatch(): void {\n\t\tthis.statusWatch?.release();\n\t\tthis.statusWatch = undefined;\n\t}\n\t/**\n\t * The selected task's own extension statuses, as the row under its fullscreen page's footer. The\n\t * compact picker and confirmation page show none. A write repaints the page while it is shown.\n\t */\n\tprivate taskStatusRows(width: number): string[] {\n\t\tconst task = this.navigation.focus.kind === \"detail\" && !this.confirmation ? this.selected() : undefined;\n\t\tif (task?.kind !== \"agent\") {\n\t\t\tthis.releaseStatusWatch();\n\t\t\treturn [];\n\t\t}\n\t\tif (this.statusWatch?.taskId !== task.ref.taskId) {\n\t\t\tthis.releaseStatusWatch();\n\t\t\tthis.statusWatch = {\n\t\t\t\ttaskId: task.ref.taskId,\n\t\t\t\trelease: this.store.watchExtensionStatuses(task.ref.taskId, () => this.requestRender()),\n\t\t\t};\n\t\t}\n\t\tconst row = renderExtensionStatusRow(this.store.extensionStatuses(task.ref.taskId), width);\n\t\treturn row === undefined ? [] : [row];\n\t}\n\tprivate releaseLiveTranscript(): void {\n\t\tthis.liveTranscript?.dispose();\n\t\tthis.liveTranscript = undefined;\n\t\tthis.transcriptRefreshPending = false;\n\t}\n\tprivate refreshTranscript(): void {\n\t\tif (this.disposed || !this.transcriptRequested) return;\n\t\tconst task = this.selected();\n\t\tconst follow = task && this.store.followTaskTranscript(task.ref.taskId);\n\t\tif (follow?.session !== undefined && this.liveTranscript?.source === follow.session) return;\n\t\t// History-only sources have no live tail; keep their retained page anchored.\n\t\tif (follow?.historyOnly === true && this.transcriptHistorical) return;\n\t\tif (this.transcriptLoading) this.transcriptRefreshPending = true;\n\t\telse void this.loadTranscript();\n\t}\n\tprivate async loadTranscript(earlier = false): Promise<void> {\n\t\tconst task = this.selected();\n\t\tif (!task) return;\n\t\tconst generation = ++this.detailGeneration;\n\t\tconst focus = this.navigation.focus;\n\t\tthis.transcriptRequested = true;\n\t\tthis.transcriptLoading = true;\n\t\tif (earlier) this.transcriptHistorical = true;\n\t\tthis.requestRender();\n\t\ttry {\n\t\t\tif (task.kind === \"command\") {\n\t\t\t\tconst count = BigInt(task.output.byteCount);\n\t\t\t\tconst page = await this.store.readTaskOutput(task.ref.taskId, {\n\t\t\t\t\tstart: String(count > 8192n ? count - 8192n : 0n),\n\t\t\t\t\tmaximumBytes: 8192,\n\t\t\t\t});\n\t\t\t\tif (\n\t\t\t\t\tthis.disposed ||\n\t\t\t\t\tgeneration !== this.detailGeneration ||\n\t\t\t\t\tfocus !== this.navigation.focus ||\n\t\t\t\t\ttask.ref.taskId !== this.navigation.selectedTaskId\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tconst text = page.ok ? page.value.text : page.error.message;\n\t\t\t\tthis.transcript = [\n\t\t\t\t\tnew Text(text.split(\"\\n\").map(taskDisplayText).join(\"\\n\") || \"No output available\", 0, 0),\n\t\t\t\t];\n\t\t\t\tthis.cursor = undefined;\n\t\t\t\tthis.status =\n\t\t\t\t\tcount > 8192n ? \"Earlier output omitted · showing retained 8 KiB tail\" : \"Retained shell output\";\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst read = this.store.readTaskTranscript(task.ref.taskId, earlier ? this.cursor : undefined);\n\t\t\tconst page = read instanceof Promise ? await read : read;\n\t\t\tif (\n\t\t\t\tthis.disposed ||\n\t\t\t\tgeneration !== this.detailGeneration ||\n\t\t\t\tfocus !== this.navigation.focus ||\n\t\t\t\ttask.ref.taskId !== this.navigation.selectedTaskId\n\t\t\t)\n\t\t\t\treturn;\n\t\t\tif (!page.ok) {\n\t\t\t\tthis.status = page.error.message;\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst messages = [...page.value.messages];\n\t\t\tconst follow = this.store.followTaskTranscript(task.ref.taskId);\n\t\t\tconst components = chatEntriesFromAgentMessages(messages).map((entry) =>\n\t\t\t\trenderChatMessageEntry(entry, {\n\t\t\t\t\tui: { requestRender: this.requestRender },\n\t\t\t\t\tcwd: process.cwd(),\n\t\t\t\t\thideThinkingBlock: true,\n\t\t\t\t\ttoolOutputExpanded: true,\n\t\t\t\t\tshowImages: false,\n\t\t\t\t}),\n\t\t\t);\n\t\t\tif (!earlier && follow?.session?.subscribe) {\n\t\t\t\tthis.releaseLiveTranscript();\n\t\t\t\tthis.liveTranscript = new TaskLiveTranscript(follow.session, messages, this.requestRender);\n\t\t\t\tthis.transcript = [this.liveTranscript];\n\t\t\t} else this.transcript = earlier ? [...components, ...(this.transcript ?? [])] : components;\n\t\t\tthis.cursor = page.value.nextCursor;\n\t\t\tthis.status = this.cursor ? \"PageUp: earlier retained messages\" : \"\";\n\t\t\tthis.requestRender();\n\t\t} catch {\n\t\t\tif (!this.disposed && generation === this.detailGeneration && focus === this.navigation.focus) {\n\t\t\t\tthis.transcript = [];\n\t\t\t\tthis.status = \"Task output unavailable\";\n\t\t\t\tthis.requestRender();\n\t\t\t}\n\t\t} finally {\n\t\t\tif (generation === this.detailGeneration) {\n\t\t\t\tthis.transcriptLoading = false;\n\t\t\t\tif (this.transcriptRefreshPending) {\n\t\t\t\t\tthis.transcriptRefreshPending = false;\n\t\t\t\t\tthis.refreshTranscript();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tprivate async loadDetail(): Promise<void> {\n\t\tconst selectedId = this.selected()?.ref.taskId;\n\t\tif (selectedId !== this.detailTaskId) {\n\t\t\tthis.detailContent = {};\n\t\t\tthis.detailTaskId = selectedId;\n\t\t}\n\t\tthis.status = \"\";\n\t\tconst generation = ++this.detailGeneration;\n\t\tconst focus = this.navigation.focus;\n\t\tconst task = this.selected();\n\t\tif (!task) return;\n\t\tconst current = () =>\n\t\t\t!this.disposed &&\n\t\t\tgeneration === this.detailGeneration &&\n\t\t\tthis.navigation.focus === focus &&\n\t\t\tfocus.kind === \"detail\" &&\n\t\t\tthis.navigation.selectedTaskId === task.ref.taskId;\n\t\tconst read = this.store.taskDetailText(task.ref.taskId);\n\t\tconst own = read instanceof Promise ? await read : read;\n\t\tif (!current()) return;\n\t\tif (own.prompt !== undefined) this.detailContent.prompt = own.prompt;\n\t\tif (own.output !== undefined) this.detailContent.output = own.output;\n\t\tif (task.kind === \"command\") {\n\t\t\ttry {\n\t\t\t\tconst count = BigInt(task.output.byteCount);\n\t\t\t\tconst output = await this.store.readTaskOutput(task.ref.taskId, {\n\t\t\t\t\tstart: String(count > 8192n ? count - 8192n : 0n),\n\t\t\t\t\tmaximumBytes: 8192,\n\t\t\t\t});\n\t\t\t\tif (!current()) return;\n\t\t\t\tif (output.ok) {\n\t\t\t\t\tthis.detailContent.output = output.value.text;\n\t\t\t\t\tthis.detailContent.outputOmitted = count > 8192n || output.value.omitted;\n\t\t\t\t} else this.status = output.error.message;\n\t\t\t} catch {\n\t\t\t\tif (!current()) return;\n\t\t\t\tthis.status = \"Command output unavailable\";\n\t\t\t}\n\t\t}\n\t\tif (current()) this.requestRender();\n\t}\n\thandleInput(data: string): boolean {\n\t\tthis.stopFailure = \"\";\n\t\tif (this.confirmation) {\n\t\t\tif (data === \"y\" || data === \"n\" || matchesKey(data, \"escape\")) {\n\t\t\t\tconst answer = this.confirmation;\n\t\t\t\tthis.confirmation = undefined;\n\t\t\t\tanswer(data === \"y\");\n\t\t\t}\n\t\t\tthis.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\tconst wheel = mouseWheelDeltaRows(data);\n\t\tif (wheel !== 0) {\n\t\t\tif (this.navigation.focus.kind === \"tasks\") this.navigation.moveSelection(Math.sign(wheel));\n\t\t\telse if (this.navigation.focus.kind === \"detail\") {\n\t\t\t\tif (this.transcriptRequested && wheel < 0 && this.scroll === 0 && this.cursor && !this.transcriptLoading)\n\t\t\t\t\tvoid this.loadTranscript(true);\n\t\t\t\telse this.scroll = Math.max(0, this.scroll + wheel);\n\t\t\t}\n\t\t\tthis.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\t// Mouse reports are never text input, including horizontal wheel/release.\n\t\tif (/^\\x1b\\[<\\d+;\\d+;\\d+[mM]$/.test(data) || data.startsWith(\"\\x1b[M\")) return true;\n\t\tif (\n\t\t\tmatchesKey(data, \"escape\") ||\n\t\t\t(matchesKey(data, \"left\") && this.navigation.focus.kind !== \"stdin\" && !this.configuredTaskKey(data))\n\t\t) {\n\t\t\tif (this.transcriptRequested) {\n\t\t\t\tthis.releaseLiveTranscript();\n\t\t\t\tthis.detailGeneration++;\n\t\t\t\tthis.transcript = undefined;\n\t\t\t\tthis.transcriptRequested = false;\n\t\t\t\tthis.transcriptLoading = false;\n\t\t\t\tthis.transcriptHistorical = false;\n\t\t\t\tthis.scroll = 0;\n\t\t\t\tvoid this.loadDetail();\n\t\t\t} else {\n\t\t\t\tthis.navigation.handleInput(\"\\x1b\", \"tasks\");\n\t\t\t\tif (this.navigation.focus.kind === \"composer\") this.close();\n\t\t\t}\n\t\t\tthis.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\tif (this.navigation.focus.kind === \"stdin\") {\n\t\t\tthis.input.handleInput(data);\n\t\t\tthis.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\tif (data === \"x\" && !this.configuredTaskKey(data)) {\n\t\t\tvoid this.navigation.activate(\"cancel\");\n\t\t\treturn true;\n\t\t}\n\t\tif (this.transcriptRequested) {\n\t\t\tif (this.configuredTaskKey(data)) this.navigation.handleInput(data, \"tasks\");\n\t\t\telse if (matchesKey(data, \"up\")) this.scroll = Math.max(0, this.scroll - 1);\n\t\t\telse if (matchesKey(data, \"down\")) this.scroll++;\n\t\t\telse if (matchesKey(data, \"pageUp\")) {\n\t\t\t\tif (this.scroll === 0 && this.cursor && !this.transcriptLoading) void this.loadTranscript(true);\n\t\t\t\telse this.scroll = Math.max(0, this.scroll - this.transcriptPageRows);\n\t\t\t} else if (matchesKey(data, \"pageDown\")) this.scroll += this.transcriptPageRows;\n\t\t\telse if (matchesKey(data, \"home\")) this.scroll = 0;\n\t\t\telse if (matchesKey(data, \"end\")) this.scroll = Number.MAX_SAFE_INTEGER;\n\t\t\tthis.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\tconst task = this.selected();\n\t\tif (task && this.navigation.focus.kind === \"detail\") {\n\t\t\tconst actions = taskDetailActions(task.execution, task.attention, this.stdinAvailable());\n\t\t\tif (this.configuredTaskKey(data)) {\n\t\t\t\tif (getKeybindings().matches(data, \"app.tasks.inspect\"))\n\t\t\t\t\tvoid this.navigation.activate(actions[Math.min(this.actionIndex, actions.length - 1)]);\n\t\t\t\telse this.navigation.handleInput(data, \"tasks\");\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (matchesKey(data, \"pageUp\") || matchesKey(data, \"pageDown\")) {\n\t\t\t\tthis.scroll = Math.max(0, this.scroll + (matchesKey(data, \"pageUp\") ? -5 : 5));\n\t\t\t\tthis.requestRender();\n\t\t\t\treturn true;\n\t\t\t}\n\t\t\tif (matchesKey(data, \"up\")) this.actionIndex = Math.max(0, this.actionIndex - 1);\n\t\t\telse if (matchesKey(data, \"down\")) this.actionIndex = Math.min(actions.length - 1, this.actionIndex + 1);\n\t\t\telse if (getKeybindings().matches(data, \"app.tasks.inspect\"))\n\t\t\t\tvoid this.navigation.activate(actions[Math.min(this.actionIndex, actions.length - 1)]);\n\t\t\telse if (!this.navigation.handleInput(data, \"tasks\")) return false;\n\t\t} else if (!this.navigation.handleInput(data, \"tasks\")) return false;\n\t\tthis.requestRender();\n\t\treturn true;\n\t}\n\tprivate configuredTaskKey(data: string): boolean {\n\t\treturn ([\"app.tasks.inspect\", \"app.tasks.foreground\", \"app.tasks.cancel\", \"app.tasks.input\"] as const).some(\n\t\t\t(key) => getKeybindings().matches(data, key),\n\t\t);\n\t}\n\t/** Only the task picker stays inline; drill-down and confirmation own the screen. */\n\tget fullscreen(): boolean {\n\t\treturn (\n\t\t\tthis.confirmation !== undefined ||\n\t\t\tthis.navigation.focus.kind === \"detail\" ||\n\t\t\tthis.navigation.focus.kind === \"stdin\"\n\t\t);\n\t}\n\trenderPicker(width: number, availableRows: number): string[] {\n\t\treturn this.renderViewport(width, Math.max(1, Math.min(12, availableRows)));\n\t}\n\trender(width: number): string[] {\n\t\treturn this.renderViewport(width, Math.max(3, (process.stdout.rows || 24) - 5));\n\t}\n\tprivate renderTranscriptViewport(width: number, budget: number): string[] {\n\t\tconst task = this.selected();\n\t\tconst statusRows = this.taskStatusRows(width);\n\t\tconst failure = this.stopFailure ? [theme.fg(\"warning\", this.stopFailure)] : [];\n\t\tconst room = Math.max(1, budget - 5 - statusRows.length - failure.length);\n\t\tthis.transcriptPageRows = room;\n\t\tconst rows = this.transcript?.flatMap((component) => component.render(width)) ?? [\n\t\t\tthis.transcriptLoading ? \"Loading transcript…\" : this.status,\n\t\t];\n\t\tthis.scroll = Math.min(this.scroll, Math.max(0, rows.length - room));\n\t\tconst visible = rows.slice(this.scroll, this.scroll + room);\n\t\t// Transcript tools own their backgrounds. Keep them out of a nested box,\n\t\t// strip terminal movement, and reset styles at every viewport row boundary.\n\t\tconst safeLine = (line: string) =>\n\t\t\tline\n\t\t\t\t.split(/(\\x1b\\[[0-9;:]*m)/g)\n\t\t\t\t.map((part, index) =>\n\t\t\t\t\tindex % 2 ? part : stripVTControlCharacters(part).replace(/[\\x00-\\x1f\\x7f-\\x9f]/g, \" \"),\n\t\t\t\t)\n\t\t\t\t.join(\"\");\n\t\tconst fit = (line: string) => truncateToWidth(safeLine(line), Math.max(1, width)) + \"\\x1b[0m\";\n\t\treturn [\n\t\t\ttheme.bold(`Transcript · ${task ? taskDisplayText(taskLabel(task)) : \"Task\"}`),\n\t\t\ttask ? taskDetailSummary(task) : \"\",\n\t\t\ttheme.fg(\"borderMuted\", \"─\".repeat(Math.max(0, width))),\n\t\t\t...visible,\n\t\t\t...Array.from({ length: Math.max(0, room - visible.length) }, () => \"\"),\n\t\t\ttheme.fg(\n\t\t\t\t\"dim\",\n\t\t\t\t`Lines ${rows.length ? this.scroll + 1 : 0}–${Math.min(rows.length, this.scroll + room)} of ${rows.length}${this.cursor ? \" · PgUp at top: earlier history\" : \"\"}${this.status ? ` · ${this.status}` : \"\"}`,\n\t\t\t),\n\t\t\ttheme.fg(\"dim\", \"↑↓ scroll · PgUp/PgDn page · Home/End · ←/Esc back\"),\n\t\t\t...failure,\n\t\t\t...statusRows,\n\t\t]\n\t\t\t.map(fit)\n\t\t\t.slice(0, Math.max(1, budget));\n\t}\n\trenderViewport(width: number, budget: number): string[] {\n\t\tif (this.transcriptRequested && !this.confirmation && this.navigation.focus.kind === \"detail\")\n\t\t\treturn this.renderTranscriptViewport(width, budget);\n\t\tconst framed = width >= 20 && budget >= 7;\n\t\tconst inner = Math.max(1, width - (framed ? 4 : 0));\n\t\tconst current = this.selected();\n\t\tconst detail = this.navigation.focus.kind === \"detail\";\n\t\tconst selectingAction = current && detail && !this.transcriptRequested && !this.confirmation;\n\t\tconst actions = selectingAction\n\t\t\t? taskDetailActions(current.execution, current.attention, this.stdinAvailable())\n\t\t\t: [];\n\t\tthis.actionIndex = Math.max(0, Math.min(this.actionIndex, actions.length - 1));\n\t\tconst action = actions[this.actionIndex];\n\t\tconst actionRow = action ? [theme.fg(\"accent\", `› ${taskDetailLabels[action]}`)] : [];\n\t\tconst rows = this.renderAll(inner);\n\t\tconst compactSummary = !framed && detail && current && budget >= 4 ? [taskDetailSummary(current)] : [];\n\t\tconst statusRows = this.taskStatusRows(width);\n\t\tconst height = Math.max(\n\t\t\t0,\n\t\t\tbudget - (framed ? 4 : 1) - actionRow.length - compactSummary.length - statusRows.length,\n\t\t);\n\t\tconst selected = detail ? -1 : rows.findIndex((row) => stripVTControlCharacters(row).startsWith(\"›\"));\n\t\tthis.scroll = Math.min(this.scroll, Math.max(0, rows.length - height));\n\t\tconst selectionRows = Math.min(height, current?.kind === \"agent\" ? 3 : 2);\n\t\tconst offset = detail ? this.scroll : Math.max(0, selected + selectionRows - height);\n\t\tconst view = rows.slice(offset, offset + height);\n\t\tconst inspect = keyHintIfBound(\"app.tasks.inspect\", detail ? \"select\" : \"view\");\n\t\tconst hints = this.confirmation\n\t\t\t? \"y confirm · n/Esc keep running\"\n\t\t\t: this.navigation.focus.kind === \"stdin\"\n\t\t\t\t? \"Enter send · Esc back\"\n\t\t\t\t: this.transcriptRequested\n\t\t\t\t\t? \"↑↓ scroll · PgUp/PgDn page · ←/Esc back\"\n\t\t\t\t\t: [\n\t\t\t\t\t\t\tdetail ? \"PgUp/PgDn scroll · ↑↓ actions\" : \"↑↓ select\",\n\t\t\t\t\t\t\tinspect,\n\t\t\t\t\t\t\tcurrent && current.execution.kind !== \"settled\"\n\t\t\t\t\t\t\t\t? keyHintIfBound(\"app.tasks.cancel\", \"stop\") || (!this.configuredTaskKey(\"x\") ? \"x stop\" : \"\")\n\t\t\t\t\t\t\t\t: \"\",\n\t\t\t\t\t\t\t\"Esc back\",\n\t\t\t\t\t\t]\n\t\t\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t\t\t.join(\" · \");\n\t\tconst footer = theme.fg(\"dim\", truncateToWidth(`/tasks · ${hints}`, width));\n\t\tconst failure = this.stopFailure ? [theme.fg(\"warning\", truncateToWidth(this.stopFailure, width))] : [];\n\t\tif (!framed)\n\t\t\treturn [...compactSummary, ...view, ...actionRow, footer, ...failure, ...statusRows]\n\t\t\t\t.map((line) => truncateToWidth(line, width))\n\t\t\t\t.slice(-Math.max(1, budget));\n\t\tconst live = this.store.backgroundTasks.filter((task) => task.execution.kind !== \"settled\").length;\n\t\tconst title =\n\t\t\tdetail && current\n\t\t\t\t? `${taskDisplayText(taskLabel(current))} › ${taskDisplayText(current.title)}`\n\t\t\t\t: \"Background tasks\";\n\t\tconst heading = ` ${truncateToWidth(title, Math.max(1, width - 5))} `;\n\t\tconst border = (text: string) => theme.fg(\"borderMuted\", text);\n\t\tconst frameRow = (line: string) => {\n\t\t\tconst text = truncateToWidth(line, inner);\n\t\t\treturn border(\"│ \") + text + \" \".repeat(Math.max(0, inner - visibleWidth(text))) + border(\" │\");\n\t\t};\n\t\treturn [\n\t\t\tborder(\"╭─\") + theme.bold(heading) + border(`${\"─\".repeat(Math.max(0, width - visibleWidth(heading) - 3))}╮`),\n\t\t\tframeRow(\n\t\t\t\tdetail && current\n\t\t\t\t\t? taskDetailSummary(current)\n\t\t\t\t\t: theme.fg(\"muted\", `${live} active · ${this.store.backgroundTasks.length} total`),\n\t\t\t),\n\t\t\t...view.map(frameRow),\n\t\t\t...actionRow.map(frameRow),\n\t\t\tborder(`╰${\"─\".repeat(Math.max(0, width - 2))}╯`),\n\t\t\tfooter,\n\t\t\t...failure,\n\t\t\t...statusRows,\n\t\t].map((line) => truncateToWidth(line, width));\n\t}\n\tprivate renderAll(width: number): string[] {\n\t\tconst task = this.selected();\n\t\tif (this.confirmation)\n\t\t\treturn new Text(\n\t\t\t\t`Cancel ${task?.title}\\nTask ${task?.ref.taskId}\\ny: confirm · n/Escape: keep running`,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t).render(width);\n\t\tif (this.navigation.focus.kind === \"stdin\")\n\t\t\treturn [`Input to ${task?.title} · Escape: tasks`, ...this.input.render(width), this.status];\n\t\tif (this.transcript) return [...this.transcript.flatMap((component) => component.render(width)), this.status];\n\t\tif (this.transcriptRequested)\n\t\t\treturn [this.transcriptLoading ? \"Loading transcript…\" : this.status || \"Transcript unavailable\"];\n\t\tif (task && this.navigation.focus.kind === \"detail\") {\n\t\t\treturn [\n\t\t\t\t...new TaskDetail(task, {\n\t\t\t\t\t...this.detailContent,\n\t\t\t\t\tstdinAvailable: this.stdinAvailable(),\n\t\t\t\t\tactivity: this.store.recentActivity(task.ref.taskId),\n\t\t\t\t\tactivityOmitted: this.store.activityOmitted(task.ref.taskId),\n\t\t\t\t}).renderContent(width),\n\t\t\t\tthis.status,\n\t\t\t];\n\t\t}\n\t\tconst sections = this.orderedSections();\n\t\tif (!sections.length)\n\t\t\treturn new Text(\"No background tasks.\\nBackground agents and shells will appear here.\", 0, 0).render(width);\n\t\treturn sections.flatMap((section) => [\n\t\t\t\"\",\n\t\t\ttheme.fg(\"muted\", theme.bold(`${section.title} (${section.tasks.length})`)),\n\t\t\t...section.tasks.flatMap((item) => {\n\t\t\t\tconst selected = item.ref.taskId === this.navigation.selectedTaskId;\n\t\t\t\tconst { label: state, color, icon } = taskStatusAppearance(item);\n\t\t\t\tconst status = width < 32 ? ` ${icon}` : ` ${icon} ${state}`;\n\t\t\t\tconst name = taskDisplayText(item.title || taskLabel(item));\n\t\t\t\tconst marker = selected ? \"› \" : \" \";\n\t\t\t\tconst title = marker + truncateToWidth(name, Math.max(1, width - visibleWidth(status) - 3));\n\t\t\t\tconst row = `${selected ? theme.fg(\"accent\", theme.bold(title)) : title}${\" \".repeat(Math.max(1, width - visibleWidth(title) - visibleWidth(status)))}${theme.fg(color, status)}`;\n\t\t\t\tconst metadata = [\n\t\t\t\t\t...(width < 32 ? [state] : []),\n\t\t\t\t\ttaskLabel(item),\n\t\t\t\t\ttaskMetricsText(item),\n\t\t\t\t\titem.currentAction ? `${item.currentAction.tool} ${item.currentAction.text}` : \"\",\n\t\t\t\t]\n\t\t\t\t\t.filter(Boolean)\n\t\t\t\t\t.join(\" · \");\n\t\t\t\treturn [\n\t\t\t\t\ttruncateToWidth(row, width),\n\t\t\t\t\t...(item.kind === \"agent\" ? [theme.fg(\"dim\", truncateToWidth(` ${taskModelText(item)}`, width))] : []),\n\t\t\t\t\t...(selected ? [theme.fg(\"dim\", truncateToWidth(` ${taskDisplayText(metadata)}`, width))] : []),\n\t\t\t\t];\n\t\t\t}),\n\t\t]);\n\t}\n}\n"]}