Show pending bash executions in pending area, move to chat on user submit
This commit is contained in:
@@ -142,11 +142,6 @@ export class AgentSession {
|
|||||||
await this.checkAutoCompaction();
|
await this.checkAutoCompaction();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flush pending bash messages after agent turn completes
|
|
||||||
if (event.type === "agent_end") {
|
|
||||||
this._flushPendingBashMessages();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -266,6 +261,9 @@ export class AgentSession {
|
|||||||
* @throws Error if no model selected or no API key available
|
* @throws Error if no model selected or no API key available
|
||||||
*/
|
*/
|
||||||
async prompt(text: string, options?: PromptOptions): Promise<void> {
|
async prompt(text: string, options?: PromptOptions): Promise<void> {
|
||||||
|
// Flush any pending bash messages before the new prompt
|
||||||
|
this._flushPendingBashMessages();
|
||||||
|
|
||||||
const expandCommands = options?.expandSlashCommands ?? true;
|
const expandCommands = options?.expandSlashCommands ?? true;
|
||||||
|
|
||||||
// Validate model
|
// Validate model
|
||||||
@@ -699,6 +697,11 @@ export class AgentSession {
|
|||||||
return this._bashAbortController !== null;
|
return this._bashAbortController !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether there are pending bash messages waiting to be flushed */
|
||||||
|
get hasPendingBashMessages(): boolean {
|
||||||
|
return this._pendingBashMessages.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flush pending bash messages to agent state and session.
|
* Flush pending bash messages to agent state and session.
|
||||||
* Called after agent turn completes to maintain proper message ordering.
|
* Called after agent turn completes to maintain proper message ordering.
|
||||||
|
|||||||
@@ -91,6 +91,9 @@ export class InteractiveMode {
|
|||||||
// Track current bash execution component
|
// Track current bash execution component
|
||||||
private bashComponent: BashExecutionComponent | null = null;
|
private bashComponent: BashExecutionComponent | null = null;
|
||||||
|
|
||||||
|
// Track pending bash components (shown in pending area, moved to chat on submit)
|
||||||
|
private pendingBashComponents: BashExecutionComponent[] = [];
|
||||||
|
|
||||||
// Convenience accessors
|
// Convenience accessors
|
||||||
private get agent() {
|
private get agent() {
|
||||||
return this.session.agent;
|
return this.session.agent;
|
||||||
@@ -411,6 +414,9 @@ export class InteractiveMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Normal message submission
|
// Normal message submission
|
||||||
|
// First, move any pending bash components to chat
|
||||||
|
this.flushPendingBashComponents();
|
||||||
|
|
||||||
if (this.onInputCallback) {
|
if (this.onInputCallback) {
|
||||||
this.onInputCallback(text);
|
this.onInputCallback(text);
|
||||||
}
|
}
|
||||||
@@ -826,6 +832,15 @@ export class InteractiveMode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Move pending bash components from pending area to chat */
|
||||||
|
private flushPendingBashComponents(): void {
|
||||||
|
for (const component of this.pendingBashComponents) {
|
||||||
|
this.pendingMessagesContainer.removeChild(component);
|
||||||
|
this.chatContainer.addChild(component);
|
||||||
|
}
|
||||||
|
this.pendingBashComponents = [];
|
||||||
|
}
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// Selectors
|
// Selectors
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
@@ -1242,8 +1257,17 @@ export class InteractiveMode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async handleBashCommand(command: string): Promise<void> {
|
private async handleBashCommand(command: string): Promise<void> {
|
||||||
|
const isDeferred = this.session.isStreaming;
|
||||||
this.bashComponent = new BashExecutionComponent(command, this.ui);
|
this.bashComponent = new BashExecutionComponent(command, this.ui);
|
||||||
this.chatContainer.addChild(this.bashComponent);
|
|
||||||
|
if (isDeferred) {
|
||||||
|
// Show in pending area when agent is streaming
|
||||||
|
this.pendingMessagesContainer.addChild(this.bashComponent);
|
||||||
|
this.pendingBashComponents.push(this.bashComponent);
|
||||||
|
} else {
|
||||||
|
// Show in chat immediately when agent is idle
|
||||||
|
this.chatContainer.addChild(this.bashComponent);
|
||||||
|
}
|
||||||
this.ui.requestRender();
|
this.ui.requestRender();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user