strands-darwin 0.0.52 → 0.0.53
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -2
- package/README.zh-CN.md +9 -2
- package/dist/patches/{@strands-agents+sdk+1.20.0.patch → @strands-agents+sdk+1.21.0.patch} +9 -9
- package/dist/src/agent/compact.js +1 -1
- package/dist/src/agent/prompt-suggestion.d.ts +22 -0
- package/dist/src/agent/prompt-suggestion.js +120 -0
- package/dist/src/agent/prompt-suggestion.js.map +1 -0
- package/dist/src/agent/runtime.d.ts +8 -0
- package/dist/src/agent/runtime.js +50 -2
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/agent/session-recap.d.ts +30 -0
- package/dist/src/agent/session-recap.js +98 -0
- package/dist/src/agent/session-recap.js.map +1 -0
- package/dist/src/cli-main.js +5 -1
- package/dist/src/cli-main.js.map +1 -1
- package/dist/src/commands/custom-commands.d.ts +1 -1
- package/dist/src/commands/custom-commands.js +2 -1
- package/dist/src/commands/custom-commands.js.map +1 -1
- package/dist/src/commands/recap-command.d.ts +4 -0
- package/dist/src/commands/recap-command.js +10 -0
- package/dist/src/commands/recap-command.js.map +1 -0
- package/dist/src/commands/review-command.d.ts +3 -1
- package/dist/src/commands/review-command.js +21 -2
- package/dist/src/commands/review-command.js.map +1 -1
- package/dist/src/config.d.ts +11 -2
- package/dist/src/config.js +25 -15
- package/dist/src/config.js.map +1 -1
- package/dist/src/dev-repl.js +7 -4
- package/dist/src/dev-repl.js.map +1 -1
- package/dist/src/headless-runner.js +4 -3
- package/dist/src/headless-runner.js.map +1 -1
- package/dist/src/npm-package/patch-package-format.d.ts +5 -5
- package/dist/src/npm-package/patch-package-format.js +4 -4
- package/dist/src/sdk-patch-preflight.js +1 -1
- package/dist/src/tui/App.d.ts +3 -1
- package/dist/src/tui/App.js +211 -14
- package/dist/src/tui/App.js.map +1 -1
- package/dist/src/tui/InputBox.d.ts +4 -2
- package/dist/src/tui/InputBox.js +3 -3
- package/dist/src/tui/InputBox.js.map +1 -1
- package/dist/src/tui/help-format.d.ts +1 -1
- package/dist/src/tui/help-format.js +1 -1
- package/dist/src/tui/prompt-suggestion.d.ts +31 -0
- package/dist/src/tui/prompt-suggestion.js +65 -0
- package/dist/src/tui/prompt-suggestion.js.map +1 -0
- package/dist/src/tui/session-recap.d.ts +36 -0
- package/dist/src/tui/session-recap.js +109 -0
- package/dist/src/tui/session-recap.js.map +1 -0
- package/dist/src/tui/terminal-focus.d.ts +29 -0
- package/dist/src/tui/terminal-focus.js +128 -0
- package/dist/src/tui/terminal-focus.js.map +1 -0
- package/package.json +3 -3
package/dist/src/tui/App.js
CHANGED
|
@@ -38,7 +38,7 @@ import { isThinkingEffort, THINKING_EFFORTS, } from '../agent/thinking.js';
|
|
|
38
38
|
import { CONFIG_FILENAME } from '../config.js';
|
|
39
39
|
import { BUILTIN_COMMAND_NAMES } from '../commands/custom-commands.js';
|
|
40
40
|
import { WORKFLOW_COMMAND_USAGE, parseWorkflowCommand } from '../commands/workflow-command.js';
|
|
41
|
-
import { parseReviewCommand
|
|
41
|
+
import { parseReviewCommand } from '../commands/review-command.js';
|
|
42
42
|
import { MCP_CONFIG_FILENAME, mcpConfigCandidates } from '../mcp/registry.js';
|
|
43
43
|
import { mcpPromptLoadedNotice, mcpPromptOmittedAnything } from '../mcp/prompts.js';
|
|
44
44
|
import { searchPreview } from './search-preview.js';
|
|
@@ -68,6 +68,11 @@ import { acceptPromptHistorySearch, appendPromptHistorySearchQuery, backspacePro
|
|
|
68
68
|
import { ESCAPE_REWIND_CHORD_MS, acceptRewindSearch, appendRewindSearchQuery, backspaceRewindSearchQuery, cancelRewindSearch, clearRewindSearchQuery, moveRewindSearchSelection, openRewindSearch, rewindSearchView, } from './rewind-search.js';
|
|
69
69
|
import { TANGENT_COMMAND_USAGE, armTangent, captureReturnPoint, discardedPromptCount, parseTangentCommand, rewindDraftAfterBranch, tangentCommandOutcome, tangentEndedByNotice, tangentHeaderSuffix, tangentReturnNotice, tangentStatusFact, } from './tangent.js';
|
|
70
70
|
import { clipboardImageFact, readClipboardImage } from './clipboard-image.js';
|
|
71
|
+
import { PromptSuggestionState, suggestionRow, suggestionUnowned } from './prompt-suggestion.js';
|
|
72
|
+
import { SessionRecapState } from './session-recap.js';
|
|
73
|
+
import { recapNotice, recapTail, recapUsageNotice } from '../agent/session-recap.js';
|
|
74
|
+
import { parseRecapCommand, RECAP_USAGE, RECAP_UNSUPPORTED } from '../commands/recap-command.js';
|
|
75
|
+
import { suggestionTail, suggestionUsageNotice, SUGGESTION_ANSWER_CODE_POINTS } from '../agent/prompt-suggestion.js';
|
|
71
76
|
import { DRAFT_STASH_DROP_NOTICE, stashHint, toggleDraftStash } from './draft-stash.js';
|
|
72
77
|
import { delegationWakeEntries, hasQueuedImage, isTaskWake, partitionQueue, queuedCountHint, refusesToQueue, takeBackDraft, } from './prompt-queue.js';
|
|
73
78
|
import { GOAL_CONDITION_MAX_CODE_POINTS, parseGoalCommand } from '../commands/goal-command.js';
|
|
@@ -123,7 +128,7 @@ const ASSUMED_HEADER_ROWS = 14;
|
|
|
123
128
|
* different thing from one per text delta.
|
|
124
129
|
*/
|
|
125
130
|
const CLEAR_TERMINAL = '\u001B[2J\u001B[3J\u001B[H';
|
|
126
|
-
export function App({ runtime: initialRuntime, permissions, initialHistory = [], startNewSession, startRewind, }) {
|
|
131
|
+
export function App({ runtime: initialRuntime, permissions, initialHistory = [], focusInput, startNewSession, startRewind, }) {
|
|
127
132
|
const { exit: inkExit, waitUntilRenderFlush, suspendTerminal } = useApp();
|
|
128
133
|
const { stdin } = useStdin();
|
|
129
134
|
const { columns, rows } = useWindowSize();
|
|
@@ -133,6 +138,29 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
133
138
|
// meter, trajectory recorder, context estimate — moves to the new session together,
|
|
134
139
|
// and the old session's numbers cannot leak into the new transcript.
|
|
135
140
|
const [runtime, setRuntime] = useState(initialRuntime);
|
|
141
|
+
const suggestions = useRef(new PromptSuggestionState());
|
|
142
|
+
const recaps = useRef(new SessionRecapState());
|
|
143
|
+
const recapTimer = useRef(undefined);
|
|
144
|
+
const recapReady = useRef(() => false);
|
|
145
|
+
const [, redrawRecap] = useReducer((n) => n + 1, 0);
|
|
146
|
+
const dismissRecap = useCallback(() => {
|
|
147
|
+
clearTimeout(recapTimer.current);
|
|
148
|
+
recapTimer.current = undefined;
|
|
149
|
+
recaps.current.invalidate();
|
|
150
|
+
}, []);
|
|
151
|
+
useEffect(() => () => { dismissRecap(); recaps.current.resetSession(); }, [runtime, dismissRecap]);
|
|
152
|
+
const [, redrawSuggestion] = useReducer((n) => n + 1, 0);
|
|
153
|
+
const suggestionReady = useRef(() => false);
|
|
154
|
+
const shownSuggestion = useRef(undefined);
|
|
155
|
+
const dismissSuggestion = useCallback(() => {
|
|
156
|
+
dismissRecap();
|
|
157
|
+
const visible = suggestions.current.candidate !== undefined;
|
|
158
|
+
suggestions.current.invalidate();
|
|
159
|
+
shownSuggestion.current = undefined;
|
|
160
|
+
if (visible)
|
|
161
|
+
redrawSuggestion();
|
|
162
|
+
}, []);
|
|
163
|
+
useEffect(() => () => dismissSuggestion(), [runtime, dismissSuggestion]);
|
|
136
164
|
const [state, recordAction] = useReducer(turnReducer, initialHistory, (history) => ({ ...initialTurnState, history: [...history] }));
|
|
137
165
|
// The ready welcome is process/App-scoped, not session-scoped. Capture its
|
|
138
166
|
// complete responsive variant once so a later resize cannot mutate an item
|
|
@@ -158,6 +186,8 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
158
186
|
const setStatus = useCallback((next) => {
|
|
159
187
|
editorPrefix.current = false;
|
|
160
188
|
statusRef.current = next;
|
|
189
|
+
if (next !== 'idle')
|
|
190
|
+
dismissSuggestion();
|
|
161
191
|
setStatusState(next);
|
|
162
192
|
}, []);
|
|
163
193
|
const [workspacePaths, setWorkspacePaths] = useState(NO_WORKSPACE_PATHS);
|
|
@@ -197,6 +227,8 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
197
227
|
const current = editorRef.current;
|
|
198
228
|
const value = typeof next === 'function' ? next(current) : next;
|
|
199
229
|
editorRef.current = value;
|
|
230
|
+
if (value.text !== current.text)
|
|
231
|
+
dismissSuggestion();
|
|
200
232
|
if (dismissedCompletionRef.current !== undefined && (value.text !== current.text || value.cursor.offset !== current.cursor.offset ||
|
|
201
233
|
value.cursor.affinity !== current.cursor.affinity)) {
|
|
202
234
|
const changedCompletion = promptCompletionState(value, commandNames, workspacePaths);
|
|
@@ -210,6 +242,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
210
242
|
const [attachedImage, setAttachedImageState] = useState(undefined);
|
|
211
243
|
const attachedImageRef = useRef(attachedImage);
|
|
212
244
|
const setAttachedImage = useCallback((next) => {
|
|
245
|
+
dismissSuggestion();
|
|
213
246
|
attachedImageRef.current = next;
|
|
214
247
|
setAttachedImageState(next);
|
|
215
248
|
}, []);
|
|
@@ -229,6 +262,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
229
262
|
// A session replacement/unmount invalidates the result before killing its process.
|
|
230
263
|
useEffect(() => () => discardDiff(), [runtime, discardDiff]);
|
|
231
264
|
const exit = useCallback(() => {
|
|
265
|
+
dismissSuggestion();
|
|
232
266
|
discardDiff();
|
|
233
267
|
if (draftStashRef.current === undefined) {
|
|
234
268
|
inkExit();
|
|
@@ -328,6 +362,8 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
328
362
|
const queuedRef = useRef(queued);
|
|
329
363
|
const setQueued = useCallback((next) => {
|
|
330
364
|
editorPrefix.current = false;
|
|
365
|
+
if (next.length > 0)
|
|
366
|
+
dismissSuggestion();
|
|
331
367
|
queuedRef.current = next;
|
|
332
368
|
setQueuedState(next);
|
|
333
369
|
}, []);
|
|
@@ -411,6 +447,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
411
447
|
}, [dispatch]);
|
|
412
448
|
const pendingPermission = useSyncExternalStore((onChange) => permissions.subscribe(() => {
|
|
413
449
|
editorPrefix.current = false;
|
|
450
|
+
dismissSuggestion();
|
|
414
451
|
onChange();
|
|
415
452
|
}), permissions.getSnapshot, permissions.getSnapshot);
|
|
416
453
|
const [ruleReview, setRuleReview] = useState();
|
|
@@ -419,7 +456,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
419
456
|
? ruleReview : undefined;
|
|
420
457
|
// Background activity is independent of the foreground turn.
|
|
421
458
|
// The manager publishes starts and terminal transitions, never output or ticks.
|
|
422
|
-
const subscribeTaskActivity = useCallback((onChange) => runtime.subscribeToBackgroundTaskActivity(onChange), [runtime]);
|
|
459
|
+
const subscribeTaskActivity = useCallback((onChange) => runtime.subscribeToBackgroundTaskActivity(() => { dismissSuggestion(); onChange(); }), [runtime, dismissSuggestion]);
|
|
423
460
|
const readRunningTaskCount = useCallback(() => runtime.runningBackgroundTaskCount, [runtime]);
|
|
424
461
|
const runningTaskCount = useSyncExternalStore(subscribeTaskActivity, readRunningTaskCount, readRunningTaskCount);
|
|
425
462
|
// A pending confirmation outranks streaming: the loop is blocked on it.
|
|
@@ -724,6 +761,72 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
724
761
|
// guaranteed to reach `<Static>` history in full.
|
|
725
762
|
live: { wanted: liveTextRows === 0 ? 0 : liveTextRows + LIVE_BLOCK_CHROME_ROWS, floor: 0 },
|
|
726
763
|
});
|
|
764
|
+
// Advisory text never competes for ownership or adds a frame row. Read mirrors on
|
|
765
|
+
// acceptance as well as render, so batched keys cannot accept yesterday's draft.
|
|
766
|
+
recapReady.current = () => suggestionUnowned({
|
|
767
|
+
idle: statusRef.current === 'idle', draft: editorRef.current.text,
|
|
768
|
+
permission: permissions.current !== undefined,
|
|
769
|
+
search: historySearchRef.current !== undefined || rewindSearchRef.current !== undefined || recallRef.current !== undefined,
|
|
770
|
+
completion: promptCompletionState(editorRef.current, commandNames, workspacePaths).candidates.length > 0,
|
|
771
|
+
image: attachedImageRef.current !== undefined || imageTurnInFlight.current,
|
|
772
|
+
editor: editorActive.current || diffRun.current !== undefined,
|
|
773
|
+
queue: queuedRef.current.length > 0 || draining.current,
|
|
774
|
+
peer: (runtime.collaboration?.pending ?? 0) > 0,
|
|
775
|
+
goal: goalRef.current !== undefined,
|
|
776
|
+
task: runtime.runningBackgroundTaskCount > 0 || runtime.listBackgroundDelegations().length > 0,
|
|
777
|
+
replacing: clearing.current || !presentationMounted.current,
|
|
778
|
+
});
|
|
779
|
+
suggestionReady.current = () => runtime.config.promptSuggestions !== false && recapReady.current();
|
|
780
|
+
const recapModelKey = JSON.stringify([runtime.config.provider, runtime.config.model, runtime.config.openaiApi, runtime.config.baseUrl, runtime.config.region, runtime.config.apiKeyEnv, runtime.config.bedrockMantle, runtime.config.bedrockRuntime, runtime.thinking.effective, runtime.config.sessionRecap]);
|
|
781
|
+
useLayoutEffect(() => { recaps.current.configure(recapModelKey); }, [recapModelKey]);
|
|
782
|
+
const generateRecap = useCallback(async (manual) => {
|
|
783
|
+
const model = `${runtime.config.provider}/${runtime.config.model}`;
|
|
784
|
+
await recaps.current.generate(manual, runtime.config.sessionRecap !== false, recapReady.current(), (evidence, signal) => runtime.sessionRecap(evidence, signal), (result, evidence, publish, suspension) => {
|
|
785
|
+
if (!presentationMounted.current)
|
|
786
|
+
return;
|
|
787
|
+
recordAction({ type: 'notice', text: recapUsageNotice(result, model, manual) });
|
|
788
|
+
if (suspension)
|
|
789
|
+
recordAction({ type: 'notice', text: suspension });
|
|
790
|
+
if (publish && result.text !== undefined && recapReady.current())
|
|
791
|
+
recordAction({ type: 'notice', text: recapNotice(result, evidence) });
|
|
792
|
+
});
|
|
793
|
+
}, [runtime]);
|
|
794
|
+
useEffect(() => {
|
|
795
|
+
if (runtime.config.sessionRecap === false || focusInput === undefined)
|
|
796
|
+
return;
|
|
797
|
+
return focusInput.watch(focused => {
|
|
798
|
+
clearTimeout(recapTimer.current);
|
|
799
|
+
recapTimer.current = undefined;
|
|
800
|
+
const prepared = recaps.current.focus(focused, recapReady.current());
|
|
801
|
+
if (prepared)
|
|
802
|
+
recordAction({ type: 'notice', text: recapNotice(prepared.result, prepared.evidence) });
|
|
803
|
+
redrawRecap();
|
|
804
|
+
});
|
|
805
|
+
}, [runtime, focusInput]);
|
|
806
|
+
// One eligibility deadline, only after an actual blur. No idle polling or turn scheduler.
|
|
807
|
+
useEffect(() => {
|
|
808
|
+
const unowned = recapReady.current();
|
|
809
|
+
if (!unowned)
|
|
810
|
+
dismissRecap();
|
|
811
|
+
const delay = recaps.current.delay(runtime.config.sessionRecap !== false, unowned);
|
|
812
|
+
if (delay === undefined)
|
|
813
|
+
return;
|
|
814
|
+
recapTimer.current = setTimeout(() => { recapTimer.current = undefined; void generateRecap(false); }, delay);
|
|
815
|
+
return () => { clearTimeout(recapTimer.current); recapTimer.current = undefined; };
|
|
816
|
+
});
|
|
817
|
+
const candidate = suggestionReady.current() ? suggestions.current.candidate : undefined;
|
|
818
|
+
const candidateRow = suggestionRow(candidate, columns, grants.prompt);
|
|
819
|
+
useLayoutEffect(() => {
|
|
820
|
+
shownSuggestion.current = undefined;
|
|
821
|
+
let live = true;
|
|
822
|
+
const revision = suggestions.current.revision;
|
|
823
|
+
if (candidateRow !== undefined)
|
|
824
|
+
void waitUntilRenderFlush().then(() => {
|
|
825
|
+
if (live && revision === suggestions.current.revision && suggestionReady.current())
|
|
826
|
+
shownSuggestion.current = candidate;
|
|
827
|
+
});
|
|
828
|
+
return () => { live = false; shownSuggestion.current = undefined; };
|
|
829
|
+
}, [candidate, candidateRow, columns, grants.prompt, runtime, waitUntilRenderFlush]);
|
|
727
830
|
// A changed viewport starts review over. An Enter may acknowledge only a page
|
|
728
831
|
// flushed by Ink, never a newly selected rule or an unrendered next page.
|
|
729
832
|
const activeRuleReview = useMemo(() => reviewing === undefined ? undefined : {
|
|
@@ -947,6 +1050,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
947
1050
|
}
|
|
948
1051
|
}, [dispatch, setGoal]);
|
|
949
1052
|
const runTurn = useCallback(async (text, userInput = text, image, origin) => {
|
|
1053
|
+
recaps.current.workStarted();
|
|
950
1054
|
turnStartedAt.current = Date.now();
|
|
951
1055
|
turnAborted.current = false;
|
|
952
1056
|
// Who started this turn, decided once at its start (SER-108): the goal's own
|
|
@@ -959,10 +1063,29 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
959
1063
|
setGoal(goalBeforeTurn(goalRef.current, goalKind));
|
|
960
1064
|
let lifecycleOutcome = 'success';
|
|
961
1065
|
setStatus('streaming');
|
|
1066
|
+
const suggestionRevision = suggestions.current.revision;
|
|
1067
|
+
let suggestionAnswer = '';
|
|
1068
|
+
let suggestionCompleted = false;
|
|
1069
|
+
let recapAnswer = { text: '', truncated: false };
|
|
1070
|
+
let recapCompleted = false;
|
|
962
1071
|
try {
|
|
963
1072
|
await runWithStreamResumption(text, async (turnInput) => {
|
|
964
1073
|
let answerTailLive = false;
|
|
965
1074
|
for await (const event of runtime.send(turnInput, userInput, turnInput === text ? image : undefined, origin)) {
|
|
1075
|
+
if (goalKind === 'user') {
|
|
1076
|
+
if (event.type === 'modelMessageEvent')
|
|
1077
|
+
recapAnswer = recapTail(event.message.content.map(block => block.type === 'textBlock' ? block.text : '').join(''), 1600);
|
|
1078
|
+
else if (event.type === 'agentResultEvent')
|
|
1079
|
+
recapCompleted = event.result.stopReason === 'endTurn';
|
|
1080
|
+
}
|
|
1081
|
+
if (runtime.config.promptSuggestions !== false && goalKind === 'user') {
|
|
1082
|
+
if (event.type === 'modelMessageEvent') {
|
|
1083
|
+
// Post-redaction, parent text only; no tool results or reasoning.
|
|
1084
|
+
suggestionAnswer = suggestionTail(event.message.content.map(block => block.type === 'textBlock' ? block.text : '').join(''), SUGGESTION_ANSWER_CODE_POINTS);
|
|
1085
|
+
}
|
|
1086
|
+
else if (event.type === 'agentResultEvent')
|
|
1087
|
+
suggestionCompleted = event.result.stopReason === 'endTurn';
|
|
1088
|
+
}
|
|
966
1089
|
// The bounded record a `/goal` check may read: observed, never re-read.
|
|
967
1090
|
if (goalRef.current !== undefined) {
|
|
968
1091
|
if (event.type === 'contentBlockEvent' && event.contentBlock.type === 'textBlock') {
|
|
@@ -1154,12 +1277,55 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1154
1277
|
if (goalNow !== undefined) {
|
|
1155
1278
|
applyGoalTransition(goalAfterTurn(goalNow, goalKind, !failed ? 'completed' : lifecycleOutcome === 'cancelled' ? 'cancelled' : 'failed'));
|
|
1156
1279
|
}
|
|
1280
|
+
if (!failed && recapCompleted && goalKind === 'user' && image === undefined && !/^[!/]/u.test(userInput.trim()) && recapAnswer.text !== '') {
|
|
1281
|
+
recaps.current.complete(userInput, recapAnswer.text, recapAnswer.truncated);
|
|
1282
|
+
redrawRecap();
|
|
1283
|
+
}
|
|
1284
|
+
if (!failed && suggestionCompleted && goalKind === 'user' && image === undefined &&
|
|
1285
|
+
!/^[!/]/u.test(userInput.trim()) && suggestionAnswer !== '' && suggestionReady.current()) {
|
|
1286
|
+
const config = runtime.config;
|
|
1287
|
+
const key = JSON.stringify([config.provider, config.model, config.region, config.openaiApi,
|
|
1288
|
+
config.baseUrl, config.apiKeyEnv, config.bedrockMantle, config.bedrockRuntime, runtime.thinking.effective]);
|
|
1289
|
+
void suggestions.current.offer(suggestionRevision, key, signal => runtime.suggestPrompt(userInput, suggestionAnswer, signal), (result, suspension) => {
|
|
1290
|
+
if (!presentationMounted.current)
|
|
1291
|
+
return;
|
|
1292
|
+
dispatch({ type: 'notice', text: suggestionUsageNotice(result, `${config.provider}/${config.model}`) });
|
|
1293
|
+
if (suspension !== undefined)
|
|
1294
|
+
dispatch({ type: 'notice', text: suspension, severity: 'warn' });
|
|
1295
|
+
redrawSuggestion();
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1157
1298
|
return !failed;
|
|
1158
1299
|
}, [applyGoalTransition, prepareAnswerClose, returnQueuedToEditor, runtime, setGoal, setTangent, waitUntilRenderFlush]);
|
|
1159
1300
|
const submit = useCallback(async (raw, queuedEntry) => {
|
|
1301
|
+
dismissSuggestion();
|
|
1160
1302
|
editorPrefix.current = false;
|
|
1161
1303
|
const text = raw.trim();
|
|
1162
1304
|
const diff = parseDiffCommand(text);
|
|
1305
|
+
const recap = parseRecapCommand(text);
|
|
1306
|
+
if (recap !== undefined) {
|
|
1307
|
+
if (queuedEntry !== undefined) {
|
|
1308
|
+
recordAction({ type: 'notice', text: RECAP_UNSUPPORTED });
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
setEditor({ text: '', cursor: { offset: 0, affinity: 'downstream' } });
|
|
1312
|
+
setSelectedCompletion(0);
|
|
1313
|
+
if (recap === 'usage') {
|
|
1314
|
+
recordAction({ type: 'notice', text: RECAP_USAGE });
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
if (!recapReady.current()) {
|
|
1318
|
+
recordAction({ type: 'notice', text: '/recap does not queue — wait for current work and composer owners to finish' });
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
if (recaps.current.evidence.exchanges.length === 0) {
|
|
1322
|
+
recordAction({ type: 'notice', text: 'No completed human text exchanges in this interactive visit; restored history, tools and images are not recap evidence' });
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
recordAction({ type: 'notice', text: 'Preparing manual session recap; typing or Escape cancels it' });
|
|
1326
|
+
await generateRecap(true);
|
|
1327
|
+
return;
|
|
1328
|
+
}
|
|
1163
1329
|
if (clearing.current) {
|
|
1164
1330
|
if (diff !== undefined)
|
|
1165
1331
|
recordAction({ type: 'notice', text: diff === 'usage' ? DIFF_USAGE : '/diff does not queue — run it after current work finishes' });
|
|
@@ -1676,10 +1842,11 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
1676
1842
|
});
|
|
1677
1843
|
return;
|
|
1678
1844
|
}
|
|
1679
|
-
// Invalid explicit
|
|
1845
|
+
// Invalid explicit review scopes are local usage errors even while busy.
|
|
1680
1846
|
// Retain the draft and any image rather than queueing or consuming either.
|
|
1681
|
-
|
|
1682
|
-
|
|
1847
|
+
const review = parseReviewCommand(text);
|
|
1848
|
+
if (review?.invalid) {
|
|
1849
|
+
dispatch({ type: 'notice', text: review.usage });
|
|
1683
1850
|
return;
|
|
1684
1851
|
}
|
|
1685
1852
|
// Everything below needs the agent, and the SDK runs one turn at a time.
|
|
@@ -2085,7 +2252,9 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2085
2252
|
: expanded.kind === 'review'
|
|
2086
2253
|
? expanded.message.startsWith('Review commit ')
|
|
2087
2254
|
? 'reviewing commit with /review'
|
|
2088
|
-
: '
|
|
2255
|
+
: expanded.message.startsWith('Review committed changes ')
|
|
2256
|
+
? 'reviewing merge-base changes with /review'
|
|
2257
|
+
: 'reviewing current changes with /review'
|
|
2089
2258
|
: expanded.kind === 'mcp-prompt'
|
|
2090
2259
|
? mcpPromptLoadedNotice(expanded)
|
|
2091
2260
|
: `loaded command "/${expanded.command.name}"`,
|
|
@@ -2137,7 +2306,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2137
2306
|
severity: 'warn',
|
|
2138
2307
|
});
|
|
2139
2308
|
}
|
|
2140
|
-
}, [adoptBranchSuccessor, dispatch, exit, openRewindChooser, recordAction, returnQueuedToEditor, runtime, runTurn, setAttachedImage, setDraftStash, setEditor, setGoal, setQueued, setTangent, startNewSession, startRewind, status, writeToTerminal]);
|
|
2309
|
+
}, [adoptBranchSuccessor, dispatch, exit, generateRecap, openRewindChooser, recordAction, returnQueuedToEditor, runtime, runTurn, setAttachedImage, setDraftStash, setEditor, setGoal, setQueued, setTangent, startNewSession, startRewind, status, writeToTerminal]);
|
|
2141
2310
|
// The drain (SER-027): when the session is idle and nothing owns the keyboard,
|
|
2142
2311
|
// the oldest queued entry goes back through the ordinary submit path — its own
|
|
2143
2312
|
// turn for a prompt, its own run for a `!`, its own `userInput` recorded at
|
|
@@ -2186,6 +2355,8 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2186
2355
|
return;
|
|
2187
2356
|
let previous = 0;
|
|
2188
2357
|
const changed = () => {
|
|
2358
|
+
if (local.pending > 0)
|
|
2359
|
+
dismissSuggestion();
|
|
2189
2360
|
editorPrefix.current = false;
|
|
2190
2361
|
for (const text of local.takeNotices())
|
|
2191
2362
|
dispatch({ type: 'notice', text });
|
|
@@ -2206,6 +2377,12 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2206
2377
|
return;
|
|
2207
2378
|
draining.current = true;
|
|
2208
2379
|
dispatch({ type: 'notice', text: peerNotice(peer) });
|
|
2380
|
+
if (parseRecapCommand(peer.envelope.text) !== undefined) {
|
|
2381
|
+
recordAction({ type: 'notice', text: RECAP_UNSUPPORTED });
|
|
2382
|
+
draining.current = false;
|
|
2383
|
+
setDrainCycle(cycle => cycle + 1);
|
|
2384
|
+
return;
|
|
2385
|
+
}
|
|
2209
2386
|
void runTurn(peerPrompt(peer), peerPrompt(peer), undefined, peer).then(completed => {
|
|
2210
2387
|
if (!completed)
|
|
2211
2388
|
dispatch({ type: 'notice', severity: 'warn', text: `peer message ${peer.envelope.id} failed/cancelled; not re-sent` });
|
|
@@ -2630,7 +2807,8 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2630
2807
|
dispatch({ type: 'notice', text: `${command.source} not used: it ${command.reason} — draft unchanged`, severity: 'warn' });
|
|
2631
2808
|
return;
|
|
2632
2809
|
}
|
|
2633
|
-
|
|
2810
|
+
const terminalInput = focusInput?.source ?? stdin;
|
|
2811
|
+
if (!terminalInput.isTTY || !canQuiesceTerminalInput(terminalInput)) {
|
|
2634
2812
|
dispatch({ type: 'notice', text: 'Ctrl+G needs an interactive terminal darwin can hand over safely — draft unchanged', severity: 'warn' });
|
|
2635
2813
|
return;
|
|
2636
2814
|
}
|
|
@@ -2656,7 +2834,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2656
2834
|
const terminal = await openFile('/dev/tty', 'r+').catch(() => undefined);
|
|
2657
2835
|
try {
|
|
2658
2836
|
await suspendTerminal(async () => {
|
|
2659
|
-
restartInput = await quiesceTerminalInput(
|
|
2837
|
+
restartInput = await quiesceTerminalInput(terminalInput);
|
|
2660
2838
|
const run = runExternalEditor(original.text, {
|
|
2661
2839
|
argv: command.argv,
|
|
2662
2840
|
cwd,
|
|
@@ -2717,7 +2895,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2717
2895
|
dispatch({ type: 'notice', text: `external editor storage: ${outcome.cleanupProblem}`, severity: 'warn' });
|
|
2718
2896
|
}
|
|
2719
2897
|
})();
|
|
2720
|
-
}, [dispatch, pendingPermission, runtime, setDismissedCompletion, setEditor, setRecall, setSelectedCompletion, status, stdin, suspendTerminal, waitUntilRenderFlush]);
|
|
2898
|
+
}, [dispatch, focusInput, pendingPermission, runtime, setDismissedCompletion, setEditor, setRecall, setSelectedCompletion, status, stdin, suspendTerminal, waitUntilRenderFlush]);
|
|
2721
2899
|
const handleInterrupt = useCallback(() => {
|
|
2722
2900
|
const now = Date.now();
|
|
2723
2901
|
const previous = interruptedAt.current;
|
|
@@ -2769,6 +2947,10 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2769
2947
|
dispatch({ type: 'notice', text: 'interrupted — press ctrl+c again to exit' });
|
|
2770
2948
|
}, [exit, pendingPermission, permissions, runtime, status]);
|
|
2771
2949
|
useInput((typed, key) => {
|
|
2950
|
+
const hadSuggestion = suggestions.current.candidate !== undefined;
|
|
2951
|
+
const plainRight = key.rightArrow && !key.ctrl && !key.meta && !key.shift;
|
|
2952
|
+
if (!plainRight)
|
|
2953
|
+
dismissSuggestion();
|
|
2772
2954
|
const armedEditorPrefix = editorPrefix.current;
|
|
2773
2955
|
editorPrefix.current = false;
|
|
2774
2956
|
// Esc Esc chord (SER-059) bookkeeping: every key disarms it, and only the
|
|
@@ -2931,6 +3113,8 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
2931
3113
|
// editor, submits, dispatches, or changes the queue/runtime. The dismissed query
|
|
2932
3114
|
// is read from the immediate editor mirror so batched Escape/text is coherent.
|
|
2933
3115
|
if (key.escape) {
|
|
3116
|
+
if (hadSuggestion)
|
|
3117
|
+
return;
|
|
2934
3118
|
const { completion: currentCompletion, candidates: visible } = currentPromptCompletions();
|
|
2935
3119
|
if (visible.length > 0 && currentCompletion.identity !== undefined) {
|
|
2936
3120
|
setDismissedCompletion(currentCompletion.identity);
|
|
@@ -3128,6 +3312,15 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
3128
3312
|
preferredColumn.current = undefined;
|
|
3129
3313
|
return;
|
|
3130
3314
|
}
|
|
3315
|
+
if (plainRight && suggestionReady.current() && shownSuggestion.current !== undefined &&
|
|
3316
|
+
shownSuggestion.current === suggestions.current.candidate &&
|
|
3317
|
+
suggestionRow(shownSuggestion.current, columns, grants.prompt) !== undefined) {
|
|
3318
|
+
const text = shownSuggestion.current;
|
|
3319
|
+
dismissSuggestion();
|
|
3320
|
+
setEditor({ text, cursor: { offset: text.length, affinity: 'upstream' } });
|
|
3321
|
+
preferredColumn.current = undefined;
|
|
3322
|
+
return;
|
|
3323
|
+
}
|
|
3131
3324
|
if (key.leftArrow || key.rightArrow) {
|
|
3132
3325
|
setEditor((current) => ({
|
|
3133
3326
|
...current,
|
|
@@ -3155,8 +3348,11 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
3155
3348
|
return;
|
|
3156
3349
|
if (stepRecall(key.upArrow ? 'older' : 'newer'))
|
|
3157
3350
|
return;
|
|
3158
|
-
|
|
3159
|
-
|
|
3351
|
+
// Earlier keys in this stdin batch may have changed the draft or cursor
|
|
3352
|
+
// without a render. Use the same immediate geometry as queue/recall above.
|
|
3353
|
+
const current = editorRef.current;
|
|
3354
|
+
const moved = moveVertical(layoutEditor(current.text, columns, current.cursor), key.upArrow ? -1 : 1, preferredColumn.current);
|
|
3355
|
+
setEditor({ ...current, cursor: moved.cursor });
|
|
3160
3356
|
preferredColumn.current = moved.preferredColumn;
|
|
3161
3357
|
return;
|
|
3162
3358
|
}
|
|
@@ -3192,6 +3388,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
3192
3388
|
endRecall();
|
|
3193
3389
|
});
|
|
3194
3390
|
usePaste((pasted) => {
|
|
3391
|
+
dismissSuggestion();
|
|
3195
3392
|
editorPrefix.current = false;
|
|
3196
3393
|
// Permission and compaction own all input while visible/busy, including paste.
|
|
3197
3394
|
if (pendingPermission !== undefined || status === 'compacting')
|
|
@@ -3214,7 +3411,7 @@ export function App({ runtime: initialRuntime, permissions, initialHistory = [],
|
|
|
3214
3411
|
setSelectedCompletion(0);
|
|
3215
3412
|
endRecall();
|
|
3216
3413
|
});
|
|
3217
|
-
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(MessageList, { history: heldHistory ?? state.history, ...(state.staticEpoch === 0 ? { welcome: initialWelcome } : {}), liveText: state.liveText, liveCodeOpen: fenceOpenAfter(state.committedAnswer), columns: columns, maxLiveRows: grants.live, staticEpoch: state.staticEpoch }), _jsx(Box, { ref: headerRef, flexDirection: "column", children: _jsx(Header, { runtime: runtime, status: effectiveStatus, frame: frame, tangent: tangent, goal: goal, runningTaskCount: runningTaskCount, draftStashed: statusHint === undefined && draftStash !== undefined }) }), _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 }), activeRuleReview !== undefined ? _jsx(PermissionRulePreview, { review: activeRuleReview }) : pendingPermission !== undefined ? (_jsx(PermissionPrompt, { request: pendingPermission, waiting: permissions.waiting, columns: columns, maxRows: grants.prompt })) : (_jsx(InputBox, { layout: layout, completions: completions, completionKind: completionKind, completionNote: completionNote, commandDescriptions: commandDescriptions, selectedCompletion: selectedCompletion, editable: effectiveStatus !== 'compacting', shellMode: parseShellCommand(draft) !== undefined, offset: { top: chrome.top, left: chrome.left }, maxRows: grants.prompt, hint: streamingHint, attachment: attachedImage === undefined ? undefined : clipboardImageFact(attachedImage), recallIndicator: recallIndicator, historySearch: historySearchProjection, rewindSearch: rewindSearchProjection }))] })] }));
|
|
3414
|
+
return (_jsxs(Box, { flexDirection: "column", children: [_jsx(MessageList, { history: heldHistory ?? state.history, ...(state.staticEpoch === 0 ? { welcome: initialWelcome } : {}), liveText: state.liveText, liveCodeOpen: fenceOpenAfter(state.committedAnswer), columns: columns, maxLiveRows: grants.live, staticEpoch: state.staticEpoch }), _jsx(Box, { ref: headerRef, flexDirection: "column", children: _jsx(Header, { runtime: runtime, status: effectiveStatus, frame: frame, tangent: tangent, goal: goal, runningTaskCount: runningTaskCount, draftStashed: statusHint === undefined && draftStash !== undefined }) }), _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 }), activeRuleReview !== undefined ? _jsx(PermissionRulePreview, { review: activeRuleReview }) : pendingPermission !== undefined ? (_jsx(PermissionPrompt, { request: pendingPermission, waiting: permissions.waiting, columns: columns, maxRows: grants.prompt })) : (_jsx(InputBox, { layout: layout, suggestion: candidateRow, completions: completions, completionKind: completionKind, completionNote: completionNote, commandDescriptions: commandDescriptions, selectedCompletion: selectedCompletion, editable: effectiveStatus !== 'compacting', shellMode: parseShellCommand(draft) !== undefined, offset: { top: chrome.top, left: chrome.left }, maxRows: grants.prompt, hint: streamingHint, attachment: attachedImage === undefined ? undefined : clipboardImageFact(attachedImage), recallIndicator: recallIndicator, historySearch: historySearchProjection, rewindSearch: rewindSearchProjection }))] })] }));
|
|
3218
3415
|
}
|
|
3219
3416
|
/** The hint row under the draft, or nothing when the session is idle. */
|
|
3220
3417
|
function hintForStatus(status, busyReadout, queuedCount = 0, queuedWakeCount = 0, goalSuffix = '') {
|