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

@@ -263,20 +263,38 @@ async function handleCommand(filePath: string) {
return;
}
// General text: type into chat panel
await vscode.commands.executeCommand('workbench.action.chat.open');
await new Promise(resolve => setTimeout(resolve, 500));
// General text: try to open chat panel and paste
const chatCommands = [
'workbench.action.chat.open',
'workbench.panel.chat.view.copilot.focus',
'workbench.action.chat.openEditSession',
'workbench.action.openChat',
];
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);
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 */ }
}
// 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;
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) {
console.error('Gravity Bridge: error handling command', err);
}