mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 17:27:54 +00:00
feat(vscode-ide-companion): improve message handling and diff auto-opening
- Ignore messages during checkpoint saves in WebViewProvider - Move diff auto-opening logic from useEffect to useWebViewMessages hook - Remove unused imports and variables in EditToolCall component - Enhance tool call handling for edit operations with diff content
This commit is contained in:
@@ -386,7 +386,7 @@ export const useWebViewMessages = ({
|
||||
|
||||
if (permToolCall?.toolCallId) {
|
||||
// Infer kind more robustly for permission preview:
|
||||
// - If content contains a diff entry, force 'edit' so the EditToolCall auto-opens VS Code diff
|
||||
// - If content contains a diff entry, force 'edit' so the EditToolCall can handle it properly
|
||||
// - Else try title-based hints; fall back to provided kind or 'execute'
|
||||
let kind = permToolCall.kind || 'execute';
|
||||
const contentArr = (permToolCall.content as unknown[]) || [];
|
||||
@@ -400,6 +400,32 @@ export const useWebViewMessages = ({
|
||||
: false;
|
||||
if (hasDiff) {
|
||||
kind = 'edit';
|
||||
|
||||
// Auto-open diff view for edit operations with diff content
|
||||
// This replaces the useEffect auto-trigger in EditToolCall component
|
||||
const diffContent = contentArr.find(
|
||||
(c: unknown) =>
|
||||
!!c &&
|
||||
typeof c === 'object' &&
|
||||
(c as { type?: string }).type === 'diff',
|
||||
) as
|
||||
| { path?: string; oldText?: string; newText?: string }
|
||||
| undefined;
|
||||
|
||||
if (
|
||||
diffContent?.path &&
|
||||
diffContent?.oldText !== undefined &&
|
||||
diffContent?.newText !== undefined
|
||||
) {
|
||||
vscode.postMessage({
|
||||
type: 'openDiff',
|
||||
data: {
|
||||
path: diffContent.path,
|
||||
oldText: diffContent.oldText,
|
||||
newText: diffContent.newText,
|
||||
},
|
||||
});
|
||||
}
|
||||
} else if (permToolCall.title) {
|
||||
const title = permToolCall.title.toLowerCase();
|
||||
if (title.includes('touch') || title.includes('echo')) {
|
||||
|
||||
Reference in New Issue
Block a user