fix(agent): Properly handle ESC interrupt in TUI with centralized event emission
Fixed the interrupt mechanism to show "[Interrupted by user]" message when ESC is pressed: - Removed duplicate UI cleanup from ESC key handler that interfered with event processing - Added centralized interrupted event emission in exception handler when abort signal is detected - Removed duplicate event emissions from API call methods to prevent multiple messages - Added abort signal support to preflight reasoning check for proper cancellation - Simplified abort detection to only check signal state, not error messages
This commit is contained in:
@@ -113,19 +113,8 @@ export class TuiRenderer implements AgentEventReceiver {
|
||||
this.onInterruptCallback();
|
||||
}
|
||||
|
||||
// Stop the loading animation immediately
|
||||
if (this.currentLoadingAnimation) {
|
||||
this.currentLoadingAnimation.stop();
|
||||
this.statusContainer.clear();
|
||||
this.currentLoadingAnimation = null;
|
||||
}
|
||||
|
||||
// Don't show message here - the interrupted event will handle it
|
||||
|
||||
// Re-enable editor submission
|
||||
this.editor.disableSubmit = false;
|
||||
|
||||
this.ui.requestRender();
|
||||
// Don't do any UI cleanup here - let the interrupted event handle it
|
||||
// This avoids race conditions and ensures the interrupted message is shown
|
||||
|
||||
// Don't forward to editor
|
||||
return false;
|
||||
@@ -280,6 +269,8 @@ export class TuiRenderer implements AgentEventReceiver {
|
||||
this.chatContainer.addChild(new TextComponent(chalk.red("[Interrupted by user]"), { bottom: 1 }));
|
||||
// Re-enable editor submission
|
||||
this.editor.disableSubmit = false;
|
||||
// Explicitly request render to ensure message is displayed
|
||||
this.ui.requestRender();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user