strands-darwin 0.0.32 → 0.0.33
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/dist/src/agent/background-delegation.d.ts +69 -11
- package/dist/src/agent/background-delegation.js +156 -28
- package/dist/src/agent/background-delegation.js.map +1 -1
- package/dist/src/agent/runtime.d.ts +55 -1
- package/dist/src/agent/runtime.js +84 -11
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/agent/task-terminal-delivery.d.ts +43 -0
- package/dist/src/agent/task-terminal-delivery.js +115 -0
- package/dist/src/agent/task-terminal-delivery.js.map +1 -0
- package/dist/src/agents/subagent-tool.d.ts +6 -0
- package/dist/src/agents/subagent-tool.js +1 -1
- package/dist/src/agents/subagent-tool.js.map +1 -1
- package/dist/src/agents/workflow-tool.d.ts +2 -0
- package/dist/src/agents/workflow-tool.js +1 -1
- package/dist/src/agents/workflow-tool.js.map +1 -1
- package/dist/src/cli-main.js +5 -0
- package/dist/src/cli-main.js.map +1 -1
- package/dist/src/config.d.ts +14 -1
- package/dist/src/config.js +3 -0
- package/dist/src/config.js.map +1 -1
- package/dist/src/tools/background-bash.d.ts +11 -2
- package/dist/src/tools/background-bash.js +11 -5
- package/dist/src/tools/background-bash.js.map +1 -1
- package/dist/src/tools/background-tail.d.ts +1 -0
- package/dist/src/tools/background-tail.js +2 -1
- package/dist/src/tools/background-tail.js.map +1 -1
- package/dist/src/tools/background-wait-contract.d.ts +7 -0
- package/dist/src/tools/background-wait-contract.js +17 -0
- package/dist/src/tools/background-wait-contract.js.map +1 -1
- package/dist/src/trajectory/record.d.ts +45 -2
- package/dist/src/trajectory/record.js +3 -0
- package/dist/src/trajectory/record.js.map +1 -1
- package/dist/src/trajectory/replay.js +14 -0
- package/dist/src/trajectory/replay.js.map +1 -1
- package/dist/src/trajectory/writer.d.ts +13 -6
- package/dist/src/trajectory/writer.js +31 -7
- package/dist/src/trajectory/writer.js.map +1 -1
- package/dist/src/tui/App.js +154 -23
- package/dist/src/tui/App.js.map +1 -1
- package/dist/src/tui/background-tool-presentation.js +2 -2
- package/dist/src/tui/background-tool-presentation.js.map +1 -1
- package/dist/src/tui/prompt-queue.d.ts +52 -8
- package/dist/src/tui/prompt-queue.js +68 -8
- package/dist/src/tui/prompt-queue.js.map +1 -1
- package/dist/src/tui/subagent-format.d.ts +8 -0
- package/dist/src/tui/subagent-format.js +11 -0
- package/dist/src/tui/subagent-format.js.map +1 -1
- package/dist/src/tui/task-wake.d.ts +75 -0
- package/dist/src/tui/task-wake.js +201 -0
- package/dist/src/tui/task-wake.js.map +1 -0
- package/dist/src/tui/turn-state.d.ts +10 -1
- package/dist/src/tui/turn-state.js +17 -1
- package/dist/src/tui/turn-state.js.map +1 -1
- package/package.json +1 -1
package/dist/src/tui/App.js
CHANGED
|
@@ -19,7 +19,7 @@ import { BUILTIN_COMMAND_NAMES } from '../commands/custom-commands.js';
|
|
|
19
19
|
import { WORKFLOW_COMMAND_USAGE, parseWorkflowCommand } from '../commands/workflow-command.js';
|
|
20
20
|
import { MCP_CONFIG_FILENAME, mcpConfigCandidates } from '../mcp/registry.js';
|
|
21
21
|
import { DARWIN_DIRNAME } from '../paths.js';
|
|
22
|
-
import { readBackgroundTails } from '../tools/background-tail.js';
|
|
22
|
+
import { readBackgroundTail, readBackgroundTails } from '../tools/background-tail.js';
|
|
23
23
|
import { exportTranscript } from '../trajectory/export.js';
|
|
24
24
|
import { readPromptHistory, } from '../trajectory/prompt-history.js';
|
|
25
25
|
import { InputBox, MAX_COMPLETIONS, completionSelection, moveCompletionSelection, } from './InputBox.js';
|
|
@@ -39,10 +39,12 @@ import { openPromptRecall, promptRecallIndicator, stepPromptRecall, } from './pr
|
|
|
39
39
|
import { acceptPromptHistorySearch, appendPromptHistorySearchQuery, backspacePromptHistorySearchQuery, cancelPromptHistorySearch, clearPromptHistorySearchQuery, movePromptHistorySearchSelection, openPromptHistorySearch, promptHistorySearchView, resolvePromptHistorySearch, } from './prompt-history-search.js';
|
|
40
40
|
import { ESCAPE_REWIND_CHORD_MS, acceptRewindSearch, appendRewindSearchQuery, backspaceRewindSearchQuery, cancelRewindSearch, clearRewindSearchQuery, moveRewindSearchSelection, openRewindSearch, rewindSearchView, } from './rewind-search.js';
|
|
41
41
|
import { clipboardImageFact, readClipboardImage } from './clipboard-image.js';
|
|
42
|
-
import { hasQueuedImage, queuedCountHint, refusesToQueue, takeBackDraft } from './prompt-queue.js';
|
|
42
|
+
import { delegationWakeEntries, hasQueuedImage, isTaskWake, partitionQueue, queuedCountHint, refusesToQueue, takeBackDraft, } from './prompt-queue.js';
|
|
43
43
|
import { composeShellReport, parseShellCommand, projectShellOutput, runShellCommand, } from './shell-command.js';
|
|
44
44
|
import { formatTaskCompletion, formatTasksReport } from './task-format.js';
|
|
45
|
+
import { TASK_WAKE_TAIL_LINES, formatTaskNotification, formatTaskWakeUndelivered, taskNotificationFields, } from './task-wake.js';
|
|
45
46
|
import { formatDispatchCancellation, formatDispatchCompletion, formatDispatchesReport, } from './subagent-format.js';
|
|
47
|
+
import { liveBackgroundDelegationRefusal } from '../agent/background-delegation.js';
|
|
46
48
|
import { createContextWarnLatch, formatContextReport } from './context-format.js';
|
|
47
49
|
import { COPY_COMMAND_USAGE, runCopyCommand } from './copy-command.js';
|
|
48
50
|
import { formatHelpReport } from './help-format.js';
|
|
@@ -111,6 +113,10 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
111
113
|
const historyRef = useRef(state.history);
|
|
112
114
|
historyRef.current = state.history;
|
|
113
115
|
const [status, setStatus] = useState('idle');
|
|
116
|
+
// Mirror for subscription callbacks that must read the live status without being
|
|
117
|
+
// rebuilt per status change (the delegation-settlement listener, SER-070).
|
|
118
|
+
const statusRef = useRef(status);
|
|
119
|
+
statusRef.current = status;
|
|
114
120
|
const [workspacePaths, setWorkspacePaths] = useState(NO_WORKSPACE_PATHS);
|
|
115
121
|
const commandNames = useMemo(() => [
|
|
116
122
|
...BUILTIN_COMMAND_NAMES,
|
|
@@ -375,6 +381,14 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
375
381
|
dispatch({ type: 'notice', text: '/rewind is not available in this driver', severity: 'warn' });
|
|
376
382
|
return false;
|
|
377
383
|
}
|
|
384
|
+
// The SDK's `assertCanLoadSnapshot` throws while a background task is tracked, so a
|
|
385
|
+
// live delegation (SER-070) is refused here, before the chooser opens: no partial
|
|
386
|
+
// restore, no model call — the notice names the tasks and the two exits.
|
|
387
|
+
const liveDelegations = runtime.listBackgroundDelegations();
|
|
388
|
+
if (liveDelegations.length > 0) {
|
|
389
|
+
dispatch({ type: 'notice', text: liveBackgroundDelegationRefusal('/rewind', liveDelegations), severity: 'warn' });
|
|
390
|
+
return false;
|
|
391
|
+
}
|
|
378
392
|
const catalogue = await runtime.listRewindCheckpoints();
|
|
379
393
|
if (catalogue.problem !== undefined) {
|
|
380
394
|
dispatch({ type: 'notice', text: `rewind unavailable: ${catalogue.problem}`, severity: 'warn' });
|
|
@@ -469,7 +483,8 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
469
483
|
? Date.now() - turnStartedAt.current
|
|
470
484
|
: undefined;
|
|
471
485
|
const busyRetryWait = busyElapsedMs === undefined ? undefined : liveRetryWait(runtime);
|
|
472
|
-
const
|
|
486
|
+
const queuedCounts = partitionQueue(queued);
|
|
487
|
+
const streamingHint = hintForStatus(effectiveStatus, busyElapsedMs === undefined ? undefined : busySuffix(busyElapsedMs, liveSpend(runtime), busyRetryWait), queuedCounts.user.length, queuedCounts.wakes.length);
|
|
473
488
|
const activeToolClaims = state.activeTools.map((tool) => ({
|
|
474
489
|
detailRows: toolDetailsVisible(tool.name, state.toolDetailsExpanded)
|
|
475
490
|
? toolInputRows(tool.input, columns, tool.name).length
|
|
@@ -558,9 +573,44 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
558
573
|
// Terminal task events are transcript-only observers: they never alter turn
|
|
559
574
|
// status, active tools, permissions, or the agent loop. React dispatch also
|
|
560
575
|
// causes an immediate idle render; cleanup prevents shutdown notices after exit.
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
576
|
+
//
|
|
577
|
+
// With `backgroundTaskWake` on (the default), the same terminal snapshot — and
|
|
578
|
+
// only that snapshot: never output activity, never a turn end — also leaves one
|
|
579
|
+
// wake entry in the prompt queue (SER-069), so the model learns of the completion
|
|
580
|
+
// as one ordinary drained turn instead of by polling `wait`. Exactly once per
|
|
581
|
+
// task: the manager publishes one snapshot, and a task already queued or already
|
|
582
|
+
// delivered to the model through a completed turn's `wait`/`status` result is not
|
|
583
|
+
// queued again. Independent of busy state: mid-turn it waits like any prompt
|
|
584
|
+
// (SER-027, next-turn-only). The tail read is the one async step; a subscription
|
|
585
|
+
// that ended before it resolved (`/clear` replaced the runtime) drops the wake
|
|
586
|
+
// rather than handing a predecessor's job to the successor's queue.
|
|
587
|
+
useEffect(() => {
|
|
588
|
+
let live = true;
|
|
589
|
+
const unsubscribe = runtime.subscribeToBackgroundTasks((task) => {
|
|
590
|
+
dispatch({ type: 'notice', text: formatTaskCompletion(task) });
|
|
591
|
+
if (runtime.config.backgroundTaskWake === false)
|
|
592
|
+
return;
|
|
593
|
+
const fields = taskNotificationFields(task);
|
|
594
|
+
if (fields === undefined)
|
|
595
|
+
return;
|
|
596
|
+
void readBackgroundTail(task.outputPath, { lines: TASK_WAKE_TAIL_LINES }).then((tail) => {
|
|
597
|
+
if (!live || runtime.terminalStateDelivered(task.taskId))
|
|
598
|
+
return;
|
|
599
|
+
if (queuedRef.current.some((entry) => isTaskWake(entry) && entry.taskId === task.taskId))
|
|
600
|
+
return;
|
|
601
|
+
const wake = {
|
|
602
|
+
kind: 'taskNotification',
|
|
603
|
+
...fields,
|
|
604
|
+
text: formatTaskNotification(task, tail),
|
|
605
|
+
};
|
|
606
|
+
setQueued([...queuedRef.current, wake]);
|
|
607
|
+
});
|
|
608
|
+
});
|
|
609
|
+
return () => {
|
|
610
|
+
live = false;
|
|
611
|
+
unsubscribe();
|
|
612
|
+
};
|
|
613
|
+
}, [dispatch, runtime, setQueued]);
|
|
564
614
|
// Same observer-only contract for finished delegations: a notice, never a status
|
|
565
615
|
// change. Concurrent children finish in an order nobody scripted, so a dispatch
|
|
566
616
|
// that ends mid-turn (or while a prompt is up) has to be able to say so without
|
|
@@ -568,25 +618,56 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
568
618
|
useEffect(() => runtime.subscribeToSubagentDispatches((dispatched) => {
|
|
569
619
|
dispatch({ type: 'notice', text: formatDispatchCompletion(dispatched) });
|
|
570
620
|
}), [runtime]);
|
|
621
|
+
// A background delegation's settlement (SER-070) wakes the agent through the same
|
|
622
|
+
// queue as a finished job — but only when nothing else would start a turn. Busy,
|
|
623
|
+
// the SDK itself attaches the result pair before the running turn's next model call
|
|
624
|
+
// (or at its end), so a wake would be a second turn about a delivered report; idle,
|
|
625
|
+
// one wake entry names the delegation (never its report — the SDK attaches that to
|
|
626
|
+
// the wake turn's own request). Exactly once per task: `delegationWakesSent`
|
|
627
|
+
// remembers every id ever queued, and the drain drops a wake whose task the SDK no
|
|
628
|
+
// longer tracks. The idle sweep below closes the one gap the settlement listener
|
|
629
|
+
// cannot see — a run that settled in the last microtasks of a turn, too late for
|
|
630
|
+
// the SDK's end-of-invocation delivery, is still tracked when the turn ends.
|
|
631
|
+
const delegationWakesSent = useRef(new Set());
|
|
632
|
+
const enqueueDelegationWakes = useCallback(() => {
|
|
633
|
+
if (runtime.config.backgroundTaskWake === false)
|
|
634
|
+
return;
|
|
635
|
+
const additions = delegationWakeEntries(runtime.listBackgroundDelegations(), delegationWakesSent.current);
|
|
636
|
+
if (additions.length === 0)
|
|
637
|
+
return;
|
|
638
|
+
for (const entry of additions)
|
|
639
|
+
delegationWakesSent.current.add(entry.taskId);
|
|
640
|
+
setQueued([...queuedRef.current, ...additions]);
|
|
641
|
+
}, [runtime, setQueued]);
|
|
642
|
+
useEffect(() => runtime.subscribeToBackgroundDelegations(() => {
|
|
643
|
+
if (statusRef.current === 'idle')
|
|
644
|
+
enqueueDelegationWakes();
|
|
645
|
+
}), [enqueueDelegationWakes, runtime]);
|
|
646
|
+
useEffect(() => {
|
|
647
|
+
if (status === 'idle')
|
|
648
|
+
enqueueDelegationWakes();
|
|
649
|
+
}, [enqueueDelegationWakes, status]);
|
|
571
650
|
// Safe phase changes and periodic heartbeats update only the existing live tool
|
|
572
651
|
// row. They never append transcript history or enter the model/trajectory.
|
|
573
652
|
useEffect(() => runtime.subscribeToSubagentProgress((progress) => {
|
|
574
653
|
dispatch({ type: 'subagentProgress', progress });
|
|
575
654
|
}), [runtime]);
|
|
576
655
|
/**
|
|
577
|
-
* Puts every queued entry back into the editor, unsent — ahead of any
|
|
578
|
-
* text, one per line, cursor at the end — and says so. The take-back gesture
|
|
656
|
+
* Puts every queued **user** entry back into the editor, unsent — ahead of any
|
|
657
|
+
* typed text, one per line, cursor at the end — and says so. The take-back gesture
|
|
579
658
|
* and the post-abort return share this so "what a cancel does to the queue"
|
|
580
659
|
* and "what `Up` does to the queue" cannot drift apart; `withNotice` is the
|
|
581
|
-
* only difference (the gesture explains itself).
|
|
660
|
+
* only difference (the gesture explains itself). Background-task wakes (SER-069)
|
|
661
|
+
* have nothing to edit and stay in the queue, in order: a cancel re-queues them
|
|
662
|
+
* rather than dropping them, and the drain sends them once the session is idle.
|
|
582
663
|
*/
|
|
583
664
|
const returnQueuedToEditor = useCallback((withNotice) => {
|
|
584
|
-
const entries = queuedRef.current;
|
|
665
|
+
const { user: entries, wakes } = partitionQueue(queuedRef.current);
|
|
585
666
|
if (entries.length === 0)
|
|
586
667
|
return false;
|
|
587
668
|
const text = takeBackDraft(entries, editorRef.current.text);
|
|
588
669
|
const returnedImage = entries.find((entry) => entry.image !== undefined)?.image;
|
|
589
|
-
setQueued(
|
|
670
|
+
setQueued(wakes);
|
|
590
671
|
if (returnedImage !== undefined)
|
|
591
672
|
setAttachedImage(returnedImage);
|
|
592
673
|
// The queue's entries replace the draft wholesale; the drafts destroyed by
|
|
@@ -603,7 +684,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
603
684
|
}
|
|
604
685
|
return true;
|
|
605
686
|
}, [dispatch, setAttachedImage, setEditor, setQueued]);
|
|
606
|
-
const runTurn = useCallback(async (text, userInput = text, image) => {
|
|
687
|
+
const runTurn = useCallback(async (text, userInput = text, image, origin) => {
|
|
607
688
|
turnStartedAt.current = Date.now();
|
|
608
689
|
turnAborted.current = false;
|
|
609
690
|
let lifecycleOutcome = 'success';
|
|
@@ -611,7 +692,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
611
692
|
try {
|
|
612
693
|
await runWithStreamResumption(text, async (turnInput) => {
|
|
613
694
|
let answerTailLive = false;
|
|
614
|
-
for await (const event of runtime.send(turnInput, userInput, turnInput === text ? image : undefined)) {
|
|
695
|
+
for await (const event of runtime.send(turnInput, userInput, turnInput === text ? image : undefined, origin)) {
|
|
615
696
|
if (event.type === 'modelStreamUpdateEvent' &&
|
|
616
697
|
event.event.type === 'modelContentBlockDeltaEvent' &&
|
|
617
698
|
event.event.delta.type === 'textDelta' &&
|
|
@@ -755,6 +836,28 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
755
836
|
// that retain the draft: clearing there only loses undo history — the
|
|
756
837
|
// failure mode this guards against is resurrecting a sent prompt.
|
|
757
838
|
undoStack.current = [];
|
|
839
|
+
// A drained background-task wake (SER-069): one ordinary turn through the
|
|
840
|
+
// same `runTurn` a prompt uses — hooks, permission gate, trajectory barrier
|
|
841
|
+
// and `TurnComplete` all fire — but nothing above the model applies: no
|
|
842
|
+
// slash expansion, no `!`, no local command, and no held `!` reports, so the
|
|
843
|
+
// `taskNotification` record's text is exactly what the model received. The
|
|
844
|
+
// drain only calls this at idle; a busy session re-queues defensively.
|
|
845
|
+
// The wake's own turn is final: cancelled or failed, it is not re-sent
|
|
846
|
+
// (auto-resending into an error is how retry loops start — the SER-027 rule),
|
|
847
|
+
// and one notice says the job's output is still readable.
|
|
848
|
+
if (queuedEntry !== undefined && isTaskWake(queuedEntry)) {
|
|
849
|
+
if (status !== 'idle') {
|
|
850
|
+
setQueued([...queuedRef.current, queuedEntry]);
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
const { kind: _kind, text: _text, image: _image, ...fields } = queuedEntry;
|
|
854
|
+
dispatch({ type: 'taskNotification', ...fields });
|
|
855
|
+
const completed = await runTurn(text, text, undefined, fields);
|
|
856
|
+
if (!completed) {
|
|
857
|
+
dispatch({ type: 'notice', text: formatTaskWakeUndelivered(fields), severity: 'warn' });
|
|
858
|
+
}
|
|
859
|
+
return;
|
|
860
|
+
}
|
|
758
861
|
// A bounded pure projection of canonical commands and fixed input controls.
|
|
759
862
|
// It owns every whitespace-separated /help form before the busy guard, so an
|
|
760
863
|
// argument is rejected locally and a valid report remains available while a
|
|
@@ -1194,6 +1297,14 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1194
1297
|
dispatch({ type: 'notice', text: '/clear is not available in this driver', severity: 'warn' });
|
|
1195
1298
|
return;
|
|
1196
1299
|
}
|
|
1300
|
+
// A tracked background delegation (SER-070) makes `/clear` a local refusal: a
|
|
1301
|
+
// successor would cancel the children unasked and orphan the report the SDK
|
|
1302
|
+
// still owes. The notice names the tasks and the two exits; nothing is released.
|
|
1303
|
+
const liveDelegations = runtime.listBackgroundDelegations();
|
|
1304
|
+
if (liveDelegations.length > 0) {
|
|
1305
|
+
dispatch({ type: 'notice', text: liveBackgroundDelegationRefusal('/clear', liveDelegations), severity: 'warn' });
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1197
1308
|
// The switch awaits an assembly (skills, tools, a new Agent), and `status` stays
|
|
1198
1309
|
// idle throughout — so without this latch a second enter could start a second
|
|
1199
1310
|
// successor and leak the first.
|
|
@@ -1236,7 +1347,9 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1236
1347
|
// successor starts empty, and the old session's record still has them.
|
|
1237
1348
|
pendingShellReports.current = [];
|
|
1238
1349
|
// The queue dies with the conversation it was typed at (SER-027): nothing
|
|
1239
|
-
// was sent, so nothing is recorded — the entries simply never existed.
|
|
1350
|
+
// was sent, so nothing is recorded — the entries simply never existed. A
|
|
1351
|
+
// pending background-task wake (SER-069) dies with it too: the job it
|
|
1352
|
+
// names belongs to the conversation just set aside.
|
|
1240
1353
|
setQueued([]);
|
|
1241
1354
|
clipboardReadGeneration.current += 1;
|
|
1242
1355
|
setAttachedImage(undefined);
|
|
@@ -1366,19 +1479,36 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1366
1479
|
// effect after an entry — a local command, say — that left every other dep
|
|
1367
1480
|
// unchanged. Never while a permission decision is pending (the queue is held
|
|
1368
1481
|
// untouched under a prompt) and never while `/clear` is assembling a successor.
|
|
1482
|
+
//
|
|
1483
|
+
// Background-task wakes (SER-069) are entries of this same queue, so they are a
|
|
1484
|
+
// dependency of this effect through `queued`, never a side effect of a render: a
|
|
1485
|
+
// wake enqueued while a permission prompt is open is held here and sent once the
|
|
1486
|
+
// prompt resolves and the turn ends. Suppression is decided here, at drain time,
|
|
1487
|
+
// because only now is it known whether the turn that was running when the job
|
|
1488
|
+
// finished *completed* after carrying its terminal state to the model through
|
|
1489
|
+
// `wait`/`status`; such a wake is dropped silently — the conversation already
|
|
1490
|
+
// holds the fact — and the next entry drains in its place.
|
|
1369
1491
|
useEffect(() => {
|
|
1370
1492
|
if (draining.current || status !== 'idle' || pendingPermission !== undefined || clearing.current)
|
|
1371
1493
|
return;
|
|
1372
|
-
|
|
1373
|
-
|
|
1494
|
+
// A delegation wake (SER-070) is dropped once the SDK no longer tracks its task:
|
|
1495
|
+
// an intervening turn already carried the result pair, so the report is known.
|
|
1496
|
+
const entries = queuedRef.current.filter((entry) => !(isTaskWake(entry) && (entry.source === 'delegation'
|
|
1497
|
+
? !runtime.listBackgroundDelegations().some((delegation) => delegation.taskId === entry.taskId)
|
|
1498
|
+
: runtime.terminalStateDelivered(entry.taskId))));
|
|
1499
|
+
const next = entries[0];
|
|
1500
|
+
if (next === undefined) {
|
|
1501
|
+
if (entries.length !== queuedRef.current.length)
|
|
1502
|
+
setQueued(entries);
|
|
1374
1503
|
return;
|
|
1504
|
+
}
|
|
1375
1505
|
draining.current = true;
|
|
1376
|
-
setQueued(
|
|
1506
|
+
setQueued(entries.slice(1));
|
|
1377
1507
|
void submit(next.text, next).finally(() => {
|
|
1378
1508
|
draining.current = false;
|
|
1379
1509
|
setDrainCycle((cycle) => cycle + 1);
|
|
1380
1510
|
});
|
|
1381
|
-
}, [drainCycle, pendingPermission, queued, setQueued, status, submit]);
|
|
1511
|
+
}, [drainCycle, pendingPermission, queued, runtime, setQueued, status, submit]);
|
|
1382
1512
|
/**
|
|
1383
1513
|
* Answers the pending confirmation and, when the user picked an "always allow"
|
|
1384
1514
|
* option, remembers the rule.
|
|
@@ -1479,7 +1609,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1479
1609
|
* takes the whole queue back — entries one per line, ahead of any typed text.
|
|
1480
1610
|
*/
|
|
1481
1611
|
const takeBackQueued = useCallback(() => {
|
|
1482
|
-
if (queuedRef.current.length === 0 || recallRef.current !== undefined)
|
|
1612
|
+
if (partitionQueue(queuedRef.current).user.length === 0 || recallRef.current !== undefined)
|
|
1483
1613
|
return false;
|
|
1484
1614
|
const value = editorRef.current;
|
|
1485
1615
|
const shape = layoutEditor(value.text, columns, value.cursor);
|
|
@@ -2077,17 +2207,18 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2077
2207
|
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(Box, { ref: headerRef, flexDirection: "column", children: _jsx(Header, { runtime: runtime, status: effectiveStatus, frame: frame }) }), _jsx(MessageList, { history: state.history, ...(state.staticEpoch === 0 ? { welcome: initialWelcome } : {}), liveText: state.liveText, liveCodeOpen: fenceOpenAfter(state.committedAnswer), columns: columns, maxLiveRows: grants.live, staticEpoch: state.staticEpoch }), _jsxs(Box, { ref: chromeRef, flexDirection: "column", children: [state.thinking && effectiveStatus === 'streaming' && (_jsx(Text, { dimColor: true, wrap: "truncate-end", children: `thinking…${busyElapsedMs === undefined ? '' : busySuffix(busyElapsedMs, undefined, busyRetryWait)}` })), _jsx(ActiveToolCalls, { tools: state.activeTools, frame: frame, toolDetailsExpanded: state.toolDetailsExpanded, columns: columns, maxRows: grants.tools }), _jsx(PlanChecklist, { plan: state.livePlan, maxRows: grants.plan }), _jsx(QueuedMessages, { entries: queued, maxRows: grants.queued }), pendingPermission !== undefined ? (_jsx(PermissionPrompt, { request: pendingPermission, waiting: permissions.waiting, columns: columns, maxRows: grants.prompt })) : (_jsx(InputBox, { layout: layout, completions: completions, completionKind: completionKind, completionNote: completionNote, selectedCompletion: selectedCompletion, editable: effectiveStatus !== 'compacting', offset: { top: chrome.top, left: chrome.left }, maxRows: grants.prompt, hint: streamingHint, attachment: attachedImage === undefined ? undefined : clipboardImageFact(attachedImage), recallIndicator: recallIndicator, historySearch: historySearchProjection, rewindSearch: rewindSearchProjection }))] })] }));
|
|
2078
2208
|
}
|
|
2079
2209
|
/** The hint row under the draft, or nothing when the session is idle. */
|
|
2080
|
-
function hintForStatus(status, busyReadout, queuedCount = 0) {
|
|
2210
|
+
function hintForStatus(status, busyReadout, queuedCount = 0, queuedWakeCount = 0) {
|
|
2081
2211
|
if (status === 'streaming') {
|
|
2082
2212
|
// The live readout rides directly behind `working…`, ahead of the static command
|
|
2083
2213
|
// hints: the row is one truncated <Text>, so on a narrow terminal the tail is what
|
|
2084
2214
|
// goes missing, and the tail should be the part that never changes. The queue
|
|
2085
|
-
// count (SER-027) rides with it: even a listing cut to nothing stays counted here
|
|
2086
|
-
|
|
2215
|
+
// count (SER-027) rides with it: even a listing cut to nothing stays counted here,
|
|
2216
|
+
// typed entries and background-task wakes (SER-069) each under their own word.
|
|
2217
|
+
return `working…${busyReadout ?? ''}${queuedCountHint(queuedCount, queuedWakeCount)} /tasks lists jobs · /agents lists dispatches · /usage reports tokens · ctrl+c cancels this turn`;
|
|
2087
2218
|
}
|
|
2088
2219
|
// Elapsed lives on the command's own panel row, so this row can stay static.
|
|
2089
2220
|
if (status === 'shell')
|
|
2090
|
-
return `running ! command…${queuedCountHint(queuedCount)} ctrl+c cancels it`;
|
|
2221
|
+
return `running ! command…${queuedCountHint(queuedCount, queuedWakeCount)} ctrl+c cancels it`;
|
|
2091
2222
|
return status === 'compacting' ? 'compacting conversation…' : undefined;
|
|
2092
2223
|
}
|
|
2093
2224
|
/**
|