fix(coding-agent): properly queue extension messages (#2674)
This commit is contained in:
@@ -112,6 +112,11 @@ export function parseSkillBlock(text: string): ParsedSkillBlock | null {
|
||||
/** Session-specific events that extend the core AgentEvent */
|
||||
export type AgentSessionEvent =
|
||||
| AgentEvent
|
||||
| {
|
||||
type: "queue_update";
|
||||
steering: readonly string[];
|
||||
followUp: readonly string[];
|
||||
}
|
||||
| { type: "compaction_start"; reason: "manual" | "threshold" | "overflow" }
|
||||
| {
|
||||
type: "compaction_end";
|
||||
@@ -414,6 +419,14 @@ export class AgentSession {
|
||||
}
|
||||
}
|
||||
|
||||
private _emitQueueUpdate(): void {
|
||||
this._emit({
|
||||
type: "queue_update",
|
||||
steering: [...this._steeringMessages],
|
||||
followUp: [...this._followUpMessages],
|
||||
});
|
||||
}
|
||||
|
||||
// Track last assistant message for auto-compaction check
|
||||
private _lastAssistantMessage: AssistantMessage | undefined = undefined;
|
||||
|
||||
@@ -476,11 +489,13 @@ export class AgentSession {
|
||||
const steeringIndex = this._steeringMessages.indexOf(messageText);
|
||||
if (steeringIndex !== -1) {
|
||||
this._steeringMessages.splice(steeringIndex, 1);
|
||||
this._emitQueueUpdate();
|
||||
} else {
|
||||
// Check follow-up queue
|
||||
const followUpIndex = this._followUpMessages.indexOf(messageText);
|
||||
if (followUpIndex !== -1) {
|
||||
this._followUpMessages.splice(followUpIndex, 1);
|
||||
this._emitQueueUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1155,6 +1170,7 @@ export class AgentSession {
|
||||
*/
|
||||
private async _queueSteer(text: string, images?: ImageContent[]): Promise<void> {
|
||||
this._steeringMessages.push(text);
|
||||
this._emitQueueUpdate();
|
||||
const content: (TextContent | ImageContent)[] = [{ type: "text", text }];
|
||||
if (images) {
|
||||
content.push(...images);
|
||||
@@ -1171,6 +1187,7 @@ export class AgentSession {
|
||||
*/
|
||||
private async _queueFollowUp(text: string, images?: ImageContent[]): Promise<void> {
|
||||
this._followUpMessages.push(text);
|
||||
this._emitQueueUpdate();
|
||||
const content: (TextContent | ImageContent)[] = [{ type: "text", text }];
|
||||
if (images) {
|
||||
content.push(...images);
|
||||
@@ -1282,7 +1299,7 @@ export class AgentSession {
|
||||
expandPromptTemplates: false,
|
||||
streamingBehavior: options?.deliverAs,
|
||||
images,
|
||||
source: "extension",
|
||||
source: "interactive",
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1297,6 +1314,7 @@ export class AgentSession {
|
||||
this._steeringMessages = [];
|
||||
this._followUpMessages = [];
|
||||
this.agent.clearAllQueues();
|
||||
this._emitQueueUpdate();
|
||||
return { steering, followUp };
|
||||
}
|
||||
|
||||
|
||||
@@ -2244,6 +2244,11 @@ export class InteractiveMode {
|
||||
this.ui.requestRender();
|
||||
break;
|
||||
|
||||
case "queue_update":
|
||||
this.updatePendingMessagesDisplay();
|
||||
this.ui.requestRender();
|
||||
break;
|
||||
|
||||
case "message_start":
|
||||
if (event.message.role === "custom") {
|
||||
this.addMessageToChat(event.message);
|
||||
|
||||
Reference in New Issue
Block a user