fix: try multiple chat open commands for Antigravity compatibility + always consume commands

This commit is contained in:
2026-03-07 15:07:45 +09:00
parent c8c9920dd0
commit 7f15e98e85
2 changed files with 30 additions and 12 deletions

View File

@@ -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": {

View File

@@ -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',
];
const oldClipboard = await vscode.env.clipboard.readText(); let chatOpened = false;
await vscode.env.clipboard.writeText(command.text); for (const cmd of chatCommands) {
await vscode.commands.executeCommand('editor.action.clipboardPasteAction'); try {
await vscode.env.clipboard.writeText(oldClipboard); await vscode.commands.executeCommand(cmd);
chatOpened = true;
console.log(`Gravity Bridge: chat opened with "${cmd}"`);
break;
} catch { /* try next */ }
}
// Mark as consumed if (chatOpened) {
await new Promise(resolve => setTimeout(resolve, 500));
const oldClipboard = await vscode.env.clipboard.readText();
await vscode.env.clipboard.writeText(command.text);
await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
await vscode.env.clipboard.writeText(oldClipboard);
}
// 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);
} }