strands-darwin 0.0.41 → 0.0.43

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.
@@ -11,8 +11,8 @@ import { peerNotice, peerPrompt } from '../collaboration/protocol.js';
11
11
  * Ctrl+C is handled here rather than by Ink (`exitOnCtrlC: false` at the render
12
12
  * call): during a turn the first press cancels that turn but keeps the session,
13
13
  * because losing a long conversation to a stray interrupt is worse than an
14
- * unfinished answer; a second press within a short window, or any press while
15
- * idle, exits. Ctrl+D always exits.
14
+ * unfinished answer; while idle the first press only arms. A second press within a
15
+ * short window exits, busy or idle. Ctrl+D always exits.
16
16
  */
17
17
  import os from 'node:os';
18
18
  import path from 'node:path';
@@ -961,7 +961,8 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
961
961
  // Cleared with the status, so a cancelled or failed turn stops the busy
962
962
  // readout in the same breath as the tick that was redrawing it.
963
963
  turnStartedAt.current = undefined;
964
- interruptedAt.current = undefined;
964
+ // `interruptedAt` is deliberately kept: a Ctrl+C that cancelled this turn still arms
965
+ // the exit window, so the promised "press ctrl+c again to exit" holds once idle.
965
966
  // The turn's own `userInput` line reaches the record when the turn closes (one
966
967
  // append per turn), so this is the moment the reading in memory is one prompt
967
968
  // short. Marked, never re-read here: the next `Up` pays for it, and a session
@@ -1543,7 +1544,6 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
1543
1544
  // be killed, but it cannot wedge the session.
1544
1545
  shellRun.current = undefined;
1545
1546
  setStatus('idle');
1546
- interruptedAt.current = undefined;
1547
1547
  }
1548
1548
  // A user-cancelled `!` never silently sends the queue, exactly like a
1549
1549
  // cancelled turn (SER-027): what was queued behind it comes back to the
@@ -2260,15 +2260,18 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
2260
2260
  const handleInterrupt = useCallback(() => {
2261
2261
  const now = Date.now();
2262
2262
  const previous = interruptedAt.current;
2263
- if (status === 'idle' && pendingPermission === undefined) {
2264
- exit();
2265
- return;
2266
- }
2263
+ // Any Ctrl+C within the window of the previous one exits — idle or busy, and also right
2264
+ // after a cancel ended the turn, which is what "press ctrl+c again to exit" promises.
2267
2265
  if (previous !== undefined && now - previous < DOUBLE_INTERRUPT_MS) {
2268
2266
  exit();
2269
2267
  return;
2270
2268
  }
2271
2269
  interruptedAt.current = now;
2270
+ if (status === 'idle' && pendingPermission === undefined) {
2271
+ // One stray press never ends the session: it only arms the second one.
2272
+ dispatch({ type: 'notice', text: 'press ctrl+c again to exit' });
2273
+ return;
2274
+ }
2272
2275
  if (status === 'shell') {
2273
2276
  // The user's own `!` command: TERM its group now, KILL after the grace. The
2274
2277
  // completion path in submit() reports it as killed and frees the prompt —