mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
feat(vscode-ide-companion): add cancel streaming functionality
- Add handleCancel callback to App component - Implement cancelStreaming message posting to VS Code - Add onCancel prop to InputForm component - Replace send button with stop button during streaming
This commit is contained in:
@@ -25,6 +25,7 @@ export class SessionMessageHandler extends BaseMessageHandler {
|
||||
'getQwenSessions',
|
||||
'saveSession',
|
||||
'resumeSession',
|
||||
'cancelStreaming',
|
||||
// UI action: open a new chat tab (new WebviewPanel)
|
||||
'openNewChatTab',
|
||||
].includes(messageType);
|
||||
@@ -102,6 +103,11 @@ export class SessionMessageHandler extends BaseMessageHandler {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'cancelStreaming':
|
||||
// Handle cancel streaming request from webview
|
||||
await this.handleCancelStreaming();
|
||||
break;
|
||||
|
||||
default:
|
||||
console.warn(
|
||||
'[SessionMessageHandler] Unknown message type:',
|
||||
@@ -910,6 +916,34 @@ export class SessionMessageHandler extends BaseMessageHandler {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle cancel streaming request
|
||||
*/
|
||||
private async handleCancelStreaming(): Promise<void> {
|
||||
try {
|
||||
console.log('[SessionMessageHandler] Canceling streaming...');
|
||||
|
||||
// Cancel the current streaming operation in the agent manager
|
||||
await this.agentManager.cancelCurrentPrompt();
|
||||
|
||||
// Send streamEnd message to WebView to update UI
|
||||
this.sendToWebView({
|
||||
type: 'streamEnd',
|
||||
data: { timestamp: Date.now(), reason: 'user_cancelled' },
|
||||
});
|
||||
|
||||
console.log('[SessionMessageHandler] Streaming cancelled successfully');
|
||||
} catch (_error) {
|
||||
console.log('[SessionMessageHandler] Streaming cancelled (interrupted)');
|
||||
|
||||
// Always send streamEnd to update UI, regardless of errors
|
||||
this.sendToWebView({
|
||||
type: 'streamEnd',
|
||||
data: { timestamp: Date.now(), reason: 'user_cancelled' },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle resume session request
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user