@yanzc/claude-pro 0.7.6 → 0.7.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yanzc/claude-pro",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "description": "claude-pro: a command line coding agent for the codex-gateway. Full access with no permission prompts; file edits are checkpointed and can be rewound.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -27,8 +27,7 @@
27
27
  ],
28
28
  "scripts": {
29
29
  "start": "node bin/claude-pro.js",
30
- "check": "node bin/claude-pro.js --self-check",
31
- "test": "node --test --test-force-exit --test-timeout=60000 --test-reporter=dot \"test/**/*.test.js\""
30
+ "check": "node bin/claude-pro.js --self-check"
32
31
  },
33
32
  "engines": {
34
33
  "node": ">=22"
@@ -39,8 +38,5 @@
39
38
  },
40
39
  "dependencies": {
41
40
  "@anthropic-ai/sdk": "^0.128.0"
42
- },
43
- "devDependencies": {
44
- "@xterm/headless": "^6.0.0"
45
41
  }
46
42
  }
package/src/agent.js CHANGED
@@ -152,6 +152,96 @@ export function normalizeMessages(messages) {
152
152
  return out;
153
153
  }
154
154
 
155
+ const recoveredToolResult = (id) => ({
156
+ type: 'tool_result',
157
+ tool_use_id: id,
158
+ is_error: true,
159
+ content: '[Tool call did not complete before the session was interrupted.]',
160
+ });
161
+
162
+ // Repair a transcript before it reaches an API adapter. A process can die after the assistant
163
+ // tool_use was persisted but before the user tool_result was appended; gateway adapters reject
164
+ // that sequence as "No tool output found for function call". The repair is deterministic and
165
+ // only adds an explicit interrupted result (or drops an orphan result), never a successful one.
166
+ export function repairToolResults(messages) {
167
+ const out = [];
168
+ let pending = null;
169
+ let changed = false;
170
+ let recoveryIndex = 0;
171
+ const usedIds = new Set();
172
+ const freshId = () => {
173
+ let id;
174
+ do { id = `toolu_recovered_${recoveryIndex++}`; } while (usedIds.has(id));
175
+ usedIds.add(id);
176
+ return id;
177
+ };
178
+ const flushPending = () => {
179
+ if (!pending?.length) return;
180
+ out.push({ role: 'user', content: pending.map(recoveredToolResult) });
181
+ pending = null;
182
+ changed = true;
183
+ };
184
+
185
+ for (const original of messages) {
186
+ const source = Array.isArray(original.content) ? original.content : toBlocks(original.content);
187
+ const m = { ...original, content: source.map((b) => ({ ...b })) };
188
+ const uses = m.role === 'assistant' ? m.content.filter((b) => b.type === 'tool_use') : [];
189
+
190
+ if (uses.length) {
191
+ flushPending();
192
+ const ids = [];
193
+ for (const block of uses) {
194
+ let id = typeof block.id === 'string' && block.id ? block.id : null;
195
+ if (!id || usedIds.has(id)) {
196
+ id = freshId();
197
+ block.id = id;
198
+ changed = true;
199
+ } else usedIds.add(id);
200
+ ids.push(id);
201
+ }
202
+ pending = ids;
203
+ out.push(m);
204
+ continue;
205
+ }
206
+
207
+ if (m.role === 'user' && pending?.length) {
208
+ const expected = new Set(pending);
209
+ const seen = new Set();
210
+ const results = [];
211
+ const rest = [];
212
+ for (const block of m.content) {
213
+ if (block.type !== 'tool_result') { rest.push(block); continue; }
214
+ const id = typeof block.tool_use_id === 'string' ? block.tool_use_id : '';
215
+ if (!expected.has(id) || seen.has(id)) { changed = true; continue; }
216
+ seen.add(id);
217
+ if (block.content === undefined || block.content === null) {
218
+ block.content = '(no output)';
219
+ changed = true;
220
+ }
221
+ results.push(block);
222
+ }
223
+ for (const id of pending) if (!seen.has(id)) { results.push(recoveredToolResult(id)); changed = true; }
224
+ const content = [...results, ...rest];
225
+ if (content.length !== m.content.length || content.some((b, i) => b !== m.content[i])) changed = true;
226
+ out.push({ ...m, content });
227
+ pending = null;
228
+ continue;
229
+ }
230
+
231
+ // A tool_result without a directly preceding assistant tool_use is invalid too.
232
+ if (m.role === 'user' && m.content.some((b) => b.type === 'tool_result')) {
233
+ const content = m.content.filter((b) => b.type !== 'tool_result');
234
+ if (content.length !== m.content.length) { changed = true; out.push({ ...m, content }); }
235
+ else out.push(m);
236
+ } else {
237
+ if (pending) flushPending();
238
+ out.push(m);
239
+ }
240
+ }
241
+ flushPending();
242
+ return { messages: out, changed };
243
+ }
244
+
155
245
  // Minimal JSON-schema check for required fields and primitive types.
156
246
  function validateInput(schema, input) {
157
247
  if (!schema || typeof input !== 'object' || input === null) return 'Input must be an object';
@@ -681,10 +771,16 @@ export class Agent {
681
771
  this.recordedSystem = system;
682
772
  this.io.systemPrompt?.(system, this);
683
773
  }
774
+ const normalized = normalizeMessages(this.messages);
775
+ const repaired = repairToolResults(normalized);
776
+ if (repaired.changed) {
777
+ this.replaceMessages(repaired.messages);
778
+ this.io.notice?.('Recovered an unfinished tool call in the conversation; continuing with an interrupted result.', 'warn');
779
+ }
684
780
  const request = {
685
781
  model: this.model,
686
782
  system,
687
- messages: normalizeMessages(this.messages),
783
+ messages: repaired.messages,
688
784
  tools: this.toolSchemas(),
689
785
  cacheBucket: this.isSubagent ? 'other' : 'main',
690
786
  ...(this.effort ? { effort: this.effort } : {}),
@@ -739,14 +835,16 @@ export class Agent {
739
835
  const run = async (tu) => {
740
836
  try {
741
837
  const r = await this.runOne(tu, signal, map, { parallel: batch.parallel });
742
- results.set(tu.id, r.block);
838
+ // Key by the tool-use object, not its provider id. A malformed provider response
839
+ // can repeat an id; one duplicate must not overwrite the other result.
840
+ results.set(tu, r.block);
743
841
  if (r.stop) stop = true;
744
842
  } catch (err) {
745
843
  if (isAbort(err) || signal?.aborted) {
746
844
  interrupted = true;
747
- results.set(tu.id, { type: 'tool_result', tool_use_id: tu.id, is_error: true, content: 'Interrupted by user' });
845
+ results.set(tu, { type: 'tool_result', tool_use_id: tu.id, is_error: true, content: 'Interrupted by user' });
748
846
  } else {
749
- results.set(tu.id, { type: 'tool_result', tool_use_id: tu.id, is_error: true, content: `Error: ${err.message}` });
847
+ results.set(tu, { type: 'tool_result', tool_use_id: tu.id, is_error: true, content: `Error: ${err.message}` });
750
848
  }
751
849
  }
752
850
  };
@@ -755,11 +853,11 @@ export class Agent {
755
853
  if (signal?.aborted) interrupted = true;
756
854
  }
757
855
  for (const tu of toolUses) {
758
- if (results.has(tu.id)) continue;
856
+ if (results.has(tu)) continue;
759
857
  const skipped = this.trace?.toolStart({ turnId: this.traceTurnId, agent: this.name, depth: this.depth, name: tu.name, input: tu.input, parallel: false, toolUseId: tu.id });
760
858
  this.trace?.toolEnd(skipped, { skipped: true, aborted: interrupted, error: true, error_type: interrupted ? 'aborted' : 'skipped' });
761
859
  }
762
- const blocks = toolUses.map((tu) => results.get(tu.id) || {
860
+ const blocks = toolUses.map((tu) => results.get(tu) || {
763
861
  type: 'tool_result', tool_use_id: tu.id, is_error: true,
764
862
  content: interrupted ? 'Interrupted by user' : 'Skipped: the user rejected an earlier tool call in this batch.',
765
863
  });
@@ -828,6 +926,7 @@ export class Agent {
828
926
  if (Array.isArray(result.content)) await fitImagesIn(result.content);
829
927
  handle.done?.(result);
830
928
  let content = typeof result.content === 'string' ? (result.content || '(no output)') : result.content;
929
+ if (content === undefined || content === null || (Array.isArray(content) && !content.length)) content = '(no output)';
831
930
  if (this.hooks?.has('PostToolUse')) {
832
931
  const h = await this.hooks.run('PostToolUse', { tool_name: tool.name, tool_input: input, tool_response: typeof content === 'string' ? content.slice(0, 20_000) : '[non-text result]' }, { cwd: this.cwd, signal });
833
932
  for (const w of h.warnings) this.io.notice?.(w, 'warn');
@@ -933,7 +1032,7 @@ export class Agent {
933
1032
  const beforeContextTokens = this.contextEstimate;
934
1033
  this.io.compactStart?.(false, this);
935
1034
  await this.lightenImages(); // in place: `before` and `after` hold the same blocks
936
- const messages = normalizeMessages([...this.messages, { role: 'user', content: [{ type: 'text', text: partialCompactPrompt(part, label, instructions) }] }]);
1035
+ const messages = repairToolResults(normalizeMessages([...this.messages, { role: 'user', content: [{ type: 'text', text: partialCompactPrompt(part, label, instructions) }] }])).messages;
937
1036
  let res;
938
1037
  try {
939
1038
  res = await this.requestSummary(messages, { signal, compactionId, onEvent: (ev) => this.io.compactProgress?.(ev, this) });
@@ -970,8 +1069,9 @@ export class Agent {
970
1069
  const beforeContextTokens = this.contextEstimate;
971
1070
  this.io.compactStart?.(auto, this);
972
1071
  await this.lightenImages();
973
- const messages = normalizeMessages([...this.messages, { role: 'user', content: [{ type: 'text', text: compactPrompt(instructions) }] }]);
974
- // If the last assistant turn has unanswered tool calls, the sequence is invalid; drop it.
1072
+ // A crash or forced restart can leave the last assistant tool_use without its result.
1073
+ // Send an explicit interrupted result in the summary request so compaction itself can recover.
1074
+ const messages = repairToolResults(normalizeMessages([...this.messages, { role: 'user', content: [{ type: 'text', text: compactPrompt(instructions) }] }])).messages;
975
1075
  let res;
976
1076
  try {
977
1077
  res = await this.requestSummary(messages, { signal, compactionId, onEvent: (ev) => this.io.compactProgress?.(ev, this) });
package/src/ui/repl.js CHANGED
@@ -184,6 +184,9 @@ export class App {
184
184
  this.driven = noProcessExit;
185
185
  this.screen = new Screen(stdout);
186
186
  this.busy = false;
187
+ // Attachment expansion is asynchronous. Claim the turn before the first await so two
188
+ // rapid submits cannot start two Agent.run() calls against the same message array.
189
+ this.turnStarting = false;
187
190
  this.controller = null;
188
191
  this.queue = [];
189
192
  this.dialogs = [];
@@ -257,6 +260,7 @@ export class App {
257
260
  get agent() { return this.runtime.agent; }
258
261
  get config() { return this.runtime.config; }
259
262
  get width() { return this.screen.width; }
263
+ isTurnRunning() { return this.busy || this.turnStarting; }
260
264
 
261
265
  // ---------------------------------------------------------------- lifecycle
262
266
 
@@ -315,7 +319,7 @@ export class App {
315
319
  this.screen.setLive((w) => this.renderLive(w));
316
320
  this.spinnerTimer = setInterval(() => {
317
321
  const clock = this.cacheClock(); // the footer's clock counts down while nothing else is drawn
318
- if (this.busy || this.active.length || clock !== this.shownClock) this.screen.schedule();
322
+ if (this.isTurnRunning() || this.active.length || clock !== this.shownClock) this.screen.schedule();
319
323
  this.shownClock = clock;
320
324
  }, 120);
321
325
  if (restart) this.continueAfterRestart(restart);
@@ -392,7 +396,7 @@ export class App {
392
396
  terminalTitle() {
393
397
  const dir = path.basename(this.cwd) || this.cwd;
394
398
  const { model, effort } = modelInfo(this.config);
395
- const state = this.rateWait ? '⏸' : this.busy ? (Math.floor(Date.now() / 1000) % 2 ? '⠐' : '⠂') : '✳';
399
+ const state = this.rateWait ? '⏸' : this.isTurnRunning() ? (Math.floor(Date.now() / 1000) % 2 ? '⠐' : '⠂') : '✳';
396
400
  const session = this.sessionLabel();
397
401
  const where = [dir, model, effort].filter(Boolean).join(' · ');
398
402
  return `${state} ${session ? `${truncate(session, 40).replace(/\x1b\[0m$/, '')} | ` : ''}${where}`;
@@ -614,7 +618,7 @@ export class App {
614
618
  }
615
619
  const display = `✉ ${msg.kind === 'reply' ? 'answer from' : 'task from'} &${msg.from.name}: ${msg.text}`;
616
620
  const item = { text: peerMessagePrompt(msg), images: [], display, peer: msg.kind === 'task' ? msg : null };
617
- if (this.busy) { this.queue.push(item); this.screen.schedule(); return; }
621
+ if (this.isTurnRunning()) { this.queue.push(item); this.screen.schedule(); return; }
618
622
  this.startTurn(item.text, { display, peers: item.peer ? [item.peer] : [] });
619
623
  }
620
624
 
@@ -813,9 +817,9 @@ export class App {
813
817
  };
814
818
  }
815
819
  return {
816
- busy: this.busy,
820
+ busy: this.isTurnRunning(),
817
821
  verb: this.status || (this.thinking ? 'Thinking' : this.verb),
818
- elapsed: this.busy ? Date.now() - this.turnStart : 0,
822
+ elapsed: this.isTurnRunning() ? Date.now() - this.turnStart : 0,
819
823
  tokens: this.turnTokens,
820
824
  aborting: Boolean(this.controller?.signal.aborted),
821
825
  rateWait,
@@ -908,9 +912,9 @@ export class App {
908
912
  if (!value.trim() && pictures.length) value = pictures.map((_, i) => `[Image #${i + 1}]`).join(' ');
909
913
  if (!value.trim()) throw new Error('The message is empty.');
910
914
  if (this.exiting) throw new Error('The session is ending.');
911
- if (this.busy && value.trim().startsWith('/')) throw new Error('Commands wait until the current task is done (or stopped).');
912
- if (this.dialogs.length && !this.busy) throw new Error('A question is open: answer it first.');
913
- const queued = this.busy;
915
+ if (this.isTurnRunning() && value.trim().startsWith('/')) throw new Error('Commands wait until the current task is done (or stopped).');
916
+ if (this.dialogs.length && !this.isTurnRunning()) throw new Error('A question is open: answer it first.');
917
+ const queued = this.isTurnRunning();
914
918
  this.onSubmit(value, value, pictures);
915
919
  this.screen.schedule();
916
920
  return { queued };
@@ -996,7 +1000,7 @@ export class App {
996
1000
  // Something is going on that an update must not cut into: a turn, a question waiting for an answer, messages
997
1001
  // waiting to be sent, background agents and shells.
998
1002
  working() {
999
- return Boolean(this.busy || this.dialogs.length || this.queue.length || this.restartBlockers().length);
1003
+ return Boolean(this.isTurnRunning() || this.dialogs.length || this.queue.length || this.restartBlockers().length);
1000
1004
  }
1001
1005
 
1002
1006
  restartBlockers() {
@@ -1021,7 +1025,7 @@ export class App {
1021
1025
  if (blockers.length && !force) return { ok: false, message: `${cwd ? 'Changing the directory restarts the session, which would stop' : 'A restart would kill'}: ${blockers.join('; ')}.` };
1022
1026
  this.restartRequest = { reason, then, continueTurn, cwd };
1023
1027
  this.screen.schedule();
1024
- if (!this.busy) this.restartNow();
1028
+ if (!this.isTurnRunning()) this.restartNow();
1025
1029
  return { ok: true };
1026
1030
  }
1027
1031
 
@@ -1077,7 +1081,7 @@ export class App {
1077
1081
  // state, the @ file index, the input history and where the conversation is kept. The conversation, the remote
1078
1082
  // page's id and a name given with /rename stay. Returns {ok, message}.
1079
1083
  changeDirectory(dir) {
1080
- if (this.busy) return { ok: false, message: 'Wait for the current task to finish (or press Esc) before changing the directory.' };
1084
+ if (this.isTurnRunning()) return { ok: false, message: 'Wait for the current task to finish (or press Esc) before changing the directory.' };
1081
1085
  if (!canRestart()) return { ok: false, message: 'This session cannot change its directory: that restarts it, and it was not started by the claude-pro launcher. Start claude-pro in that directory instead.' };
1082
1086
  return this.requestRestart({ reason: `working directory ${dir}`, cwd: dir });
1083
1087
  }
@@ -1134,12 +1138,12 @@ export class App {
1134
1138
  this.pendingUpdate = null;
1135
1139
  this.notice(`${APP_NAME} ${disk} was installed (by another window or npm); this one restarts to load it ${this.working() ? 'once its work is done' : 'now'}.`);
1136
1140
  }
1137
- if (!this.busy) this.maybeAutoReload();
1141
+ if (!this.isTurnRunning()) this.maybeAutoReload();
1138
1142
  });
1139
1143
  }
1140
1144
 
1141
1145
  async maybeAutoReload() {
1142
- if (!this.sourceChanged || this.updating || this.reloading || this.busy || this.exiting || this.restartRequest || this.dialogs.length || this.queue.length) return;
1146
+ if (!this.sourceChanged || this.updating || this.reloading || this.isTurnRunning() || this.exiting || this.restartRequest || this.dialogs.length || this.queue.length) return;
1143
1147
  if (this.skipAutoReload) { this.skipAutoReload = false; return; } // the user just interrupted: not now
1144
1148
  if (this.restartBlockers().length) return; // looked at again whenever the program is next idle
1145
1149
  const changed = this.sourceChanged;
@@ -1153,7 +1157,7 @@ export class App {
1153
1157
  this.notice(`The program's source changed but the new code does not start, so it was not restarted:\n${check.output.split('\n').slice(0, 12).join('\n')}\nFix it; the restart follows by itself (or run /restart).`, 'warn');
1154
1158
  return;
1155
1159
  }
1156
- if (this.busy || this.dialogs.length) { this.sourceChanged = changed; return; } // something started meanwhile: later
1160
+ if (this.isTurnRunning() || this.dialogs.length) { this.sourceChanged = changed; return; } // something started meanwhile: later
1157
1161
  this.requestRestart({ reason: this.updateRestart ? `updated to ${APP_NAME} ${this.updateRestart}` : 'source changed', force: true });
1158
1162
  }
1159
1163
 
@@ -1181,7 +1185,7 @@ export class App {
1181
1185
  } else if (r.status === 'installed') {
1182
1186
  if (force || this.updateRestart !== r.version) this.notice(`${APP_NAME} ${r.version} is installed already; this session restarts to load it ${this.working() ? 'once its work is done' : 'now'}.`);
1183
1187
  this.updateRestart = r.version;
1184
- if (canRestart()) { this.sourceChanged ||= true; if (!this.busy) this.maybeAutoReload(); }
1188
+ if (canRestart()) { this.sourceChanged ||= true; if (!this.isTurnRunning()) this.maybeAutoReload(); }
1185
1189
  } else if (r.status === 'failed') {
1186
1190
  if (force || (r.version && !quiet)) this.notice(`Could not update ${APP_NAME}${r.version ? ` to ${r.version}` : ''}: ${r.error}`, 'warn');
1187
1191
  } else if (force) {
@@ -1375,7 +1379,7 @@ export class App {
1375
1379
  if (key.ctrl && key.name === 't') { this.showTodos = !this.showTodos; this.screen.schedule(); return; }
1376
1380
  if (key.ctrl && key.name === 'l') { if (this.screen.full) this.screen.repaint(); else this.screen.clearScreen(); return; }
1377
1381
  if (key.ctrl && key.name === 'd' && !this.editor.text) { this.keyboardExit(); return; }
1378
- if (key.name === 'escape' && this.busy) { this.interrupt(); return; }
1382
+ if (key.name === 'escape' && this.isTurnRunning()) { this.interrupt(); return; }
1379
1383
  this.exitArmed = 0;
1380
1384
  this.editor.handleKey(str, key);
1381
1385
  this.screen.schedule();
@@ -1396,7 +1400,7 @@ export class App {
1396
1400
  this.interrupt();
1397
1401
  return;
1398
1402
  }
1399
- if (this.busy) { this.interrupt(); return; }
1403
+ if (this.isTurnRunning()) { this.interrupt(); return; }
1400
1404
  if (this.editor.text) { this.editor.discard(); this.screen.schedule(); return; }
1401
1405
  if (Date.now() - this.exitArmed < 1500) { this.keyboardExit(); return; }
1402
1406
  this.exitArmed = Date.now();
@@ -1474,7 +1478,7 @@ export class App {
1474
1478
  if (this.screen.scrolledUp) this.screen.scrollBy('bottom'); // what was sent, and what comes of it, is in view
1475
1479
  appendHistory(this.cwd, raw);
1476
1480
  if (this.sendTypedToPeer(text)) return;
1477
- if (this.busy) {
1481
+ if (this.isTurnRunning()) {
1478
1482
  if (text.startsWith('/')) { this.notice('Wait for the current task to finish (or press Esc) before running commands.', 'warn'); return; }
1479
1483
  this.queue.push({ text: value, images });
1480
1484
  this.screen.schedule();
@@ -1691,6 +1695,16 @@ export class App {
1691
1695
  // `topic`: what to name the conversation's topic after (default: the message as shown).
1692
1696
  // `peers`: tasks of other sessions that this turn answers.
1693
1697
  async startTurn(prompt, { echo = true, display, images = [], topic, peers = [] } = {}) {
1698
+ // Claim the turn synchronously. attachments() below awaits filesystem work, and a second
1699
+ // submit can otherwise enter here before runAgent() has a chance to set busy=true.
1700
+ if (this.isTurnRunning()) {
1701
+ this.queue.push({ text: prompt, images, display: display ?? prompt, peer: peers.length === 1 ? peers[0] : null });
1702
+ this.screen.schedule();
1703
+ return;
1704
+ }
1705
+ this.turnStarting = true;
1706
+ this.turnStart = Date.now();
1707
+ this.verb = VERBS[Math.floor(Math.random() * VERBS.length)];
1694
1708
  if (echo) this.echoUser(display ?? prompt, images.length);
1695
1709
  this.refreshTopic(topic ?? display ?? prompt);
1696
1710
  let content;
@@ -1705,7 +1719,10 @@ export class App {
1705
1719
  ];
1706
1720
  await fitImagesIn(content); // a dropped or attached image file at full size would be refused later
1707
1721
  } catch (e) {
1722
+ this.turnStarting = false;
1708
1723
  this.logError(e); // nobody awaits this method: an error left to escape would end the program
1724
+ this.screen.schedule();
1725
+ this.sendWhatWaited();
1709
1726
  return;
1710
1727
  }
1711
1728
  await this.runAgent(content, { peers });
@@ -1759,6 +1776,7 @@ export class App {
1759
1776
  }
1760
1777
 
1761
1778
  async runAgent(content, { peers = [] } = {}) {
1779
+ this.turnStarting = false;
1762
1780
  this.busy = true;
1763
1781
  this.turnPeers.push(...peers);
1764
1782
  let result = null;
@@ -1801,7 +1819,7 @@ export class App {
1801
1819
  // meantime as the next turn, or else tell the model about background agents that finished after the
1802
1820
  // last check. Everything that makes the app busy has to end with this, or what waited stays queued.
1803
1821
  sendWhatWaited() {
1804
- if (this.busy || this.exiting) return;
1822
+ if (this.isTurnRunning() || this.exiting) return;
1805
1823
  // A restart that was asked for goes first; what waited is carried over and sent by the new process.
1806
1824
  if (this.restartRequest) { this.restartNow(); return; }
1807
1825
  if (this.queue.length) {
@@ -1825,7 +1843,7 @@ export class App {
1825
1843
  const secs = Math.round((task.ended - task.started) / 1000);
1826
1844
  const color = task.status === 'completed' ? c.green : c.red;
1827
1845
  this.screen.log(`${color(DOT)} ${c.bold('Background agent')} ${task.id} ${c.dim(`"${task.description}"`)} ${task.status} ${c.dim(`(${formatDuration(secs * 1000)})`)}`, '');
1828
- if (!this.busy && !this.exiting && this.agent.notifications.length) this.runAgent(this.agent.drainNotifications());
1846
+ if (!this.isTurnRunning() && !this.exiting && this.agent.notifications.length) this.runAgent(this.agent.drainNotifications());
1829
1847
  else this.screen.schedule();
1830
1848
  }
1831
1849
 
@@ -2248,7 +2266,7 @@ export class App {
2248
2266
 
2249
2267
  // esc esc on an empty prompt: the rewind menu, as in Claude Code (/rewind). Not while a turn runs (esc stops it).
2250
2268
  openRewind() {
2251
- if (this.busy || this.dialogs.length || this.exiting) return;
2269
+ if (this.isTurnRunning() || this.dialogs.length || this.exiting) return;
2252
2270
  if (!this.runtime.checkpoints.list().length && !this.previousSession) { this.flash('Nothing to rewind yet: every prompt you send makes a point to go back to'); return; }
2253
2271
  Promise.resolve(this.commands.get('rewind').run('')).catch((e) => this.logError(e)).finally(() => this.screen.schedule());
2254
2272
  }
@@ -2313,7 +2331,7 @@ export class App {
2313
2331
  const w = width - 1;
2314
2332
  const lines = [];
2315
2333
  let cursor = null;
2316
- if (this.busy) {
2334
+ if (this.isTurnRunning()) {
2317
2335
  // In-progress assistant text.
2318
2336
  if (this.md) {
2319
2337
  const partial = this.md.partial();
@@ -2352,7 +2370,7 @@ export class App {
2352
2370
  for (const q of this.queue) lines.push(c.dim(' ⎿ queued: ') + c.gray(truncate((q.display ?? q.text).replace(/\s+/g, ' '), w - 14)));
2353
2371
  }
2354
2372
  if (lines.length) lines.push('');
2355
- const placeholder = this.busy ? 'Type a message to queue it for the agent…' : (this.agent.messages.length ? '' : 'Try "explain this codebase" or "fix the failing test"');
2373
+ const placeholder = this.isTurnRunning() ? 'Type a message to queue it for the agent…' : (this.agent.messages.length ? '' : 'Try "explain this codebase" or "fix the failing test"');
2356
2374
  const r = this.finder ? this.renderFind(width) : this.editor.render(width, { placeholder, title: this.boxTitle() });
2357
2375
  const top = lines.length;
2358
2376
  lines.push(...r.lines);
@@ -2413,7 +2431,7 @@ export class App {
2413
2431
  const { model, effort } = modelInfo(cfg);
2414
2432
  // An effort that is not set is not sent: the API then uses the model's default, which is shown instead.
2415
2433
  const level = effort || defaultEffort(cfg.model.id, cfg);
2416
- const info = c.dim(level ? `${model} · effort ${level}` : model);
2434
+ const info = c.dim(level ? `${model} · ${level}` : model);
2417
2435
  const version = c.dim(`v${VERSION}`);
2418
2436
  const compactTokens = (n) => formatTokens(n).replace(/\.0([kM])$/, '$1');
2419
2437
  const context = c.dim(`ctx ${compactTokens(used)}/${compactTokens(cfg.model.contextWindow)}`);