fix: try multiple chat open commands for Antigravity compatibility + always consume commands
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"publisher": "variet",
|
"publisher": "variet",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.109.0"
|
"vscode": "^1.100.0"
|
||||||
},
|
},
|
||||||
"categories": [
|
"categories": [
|
||||||
"Other",
|
"Other",
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^20.0.0",
|
"@types/node": "^20.0.0",
|
||||||
"@types/vscode": "^1.109.0",
|
"@types/vscode": "^1.100.0",
|
||||||
"typescript": "^5.3.0"
|
"typescript": "^5.3.0"
|
||||||
},
|
},
|
||||||
"contributes": {
|
"contributes": {
|
||||||
|
|||||||
@@ -263,20 +263,38 @@ async function handleCommand(filePath: string) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// General text: type into chat panel
|
// General text: try to open chat panel and paste
|
||||||
await vscode.commands.executeCommand('workbench.action.chat.open');
|
const chatCommands = [
|
||||||
await new Promise(resolve => setTimeout(resolve, 500));
|
'workbench.action.chat.open',
|
||||||
|
'workbench.panel.chat.view.copilot.focus',
|
||||||
|
'workbench.action.chat.openEditSession',
|
||||||
|
'workbench.action.openChat',
|
||||||
|
];
|
||||||
|
|
||||||
|
let chatOpened = false;
|
||||||
|
for (const cmd of chatCommands) {
|
||||||
|
try {
|
||||||
|
await vscode.commands.executeCommand(cmd);
|
||||||
|
chatOpened = true;
|
||||||
|
console.log(`Gravity Bridge: chat opened with "${cmd}"`);
|
||||||
|
break;
|
||||||
|
} catch { /* try next */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
if (chatOpened) {
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 500));
|
||||||
const oldClipboard = await vscode.env.clipboard.readText();
|
const oldClipboard = await vscode.env.clipboard.readText();
|
||||||
await vscode.env.clipboard.writeText(command.text);
|
await vscode.env.clipboard.writeText(command.text);
|
||||||
await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
|
await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
|
||||||
await vscode.env.clipboard.writeText(oldClipboard);
|
await vscode.env.clipboard.writeText(oldClipboard);
|
||||||
|
}
|
||||||
|
|
||||||
// Mark as consumed
|
// Always mark as consumed + show notification
|
||||||
command.consumed = true;
|
command.consumed = true;
|
||||||
fs.writeFileSync(filePath, JSON.stringify(command, null, 2), 'utf-8');
|
fs.writeFileSync(filePath, JSON.stringify(command, null, 2), 'utf-8');
|
||||||
|
|
||||||
vscode.window.showInformationMessage(`📨 [${projectName}] Discord: ${command.text.substring(0, 50)}...`);
|
const prefix = chatOpened ? '📨' : '⚠️ (채팅 패널 못 열음)';
|
||||||
|
vscode.window.showInformationMessage(`${prefix} [${projectName}] Discord: ${command.text.substring(0, 80)}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Gravity Bridge: error handling command', err);
|
console.error('Gravity Bridge: error handling command', err);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user