fix(coding-agent): buffer early input before prompt loop

This commit is contained in:
Michael Yu
2026-05-29 23:03:03 +08:00
parent 17e9e87576
commit edd1212200
2 changed files with 80 additions and 0 deletions

View File

@@ -277,6 +277,7 @@ export class InteractiveMode {
private version: string;
private isInitialized = false;
private onInputCallback?: (text: string) => void;
private pendingUserInputs: string[] = [];
private loadingAnimation: Loader | undefined = undefined;
private workingMessage: string | undefined = undefined;
private workingVisible = true;
@@ -2660,6 +2661,8 @@ export class InteractiveMode {
if (this.onInputCallback) {
this.onInputCallback(text);
} else {
this.pendingUserInputs.push(text);
}
this.editor.addToHistory?.(text);
};
@@ -3231,6 +3234,11 @@ export class InteractiveMode {
}
async getUserInput(): Promise<string> {
const queuedInput = this.pendingUserInputs.shift();
if (queuedInput !== undefined) {
return queuedInput;
}
return new Promise((resolve) => {
this.onInputCallback = (text: string) => {
this.onInputCallback = undefined;