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",
|
||||
"publisher": "variet",
|
||||
"engines": {
|
||||
"vscode": "^1.109.0"
|
||||
"vscode": "^1.100.0"
|
||||
},
|
||||
"categories": [
|
||||
"Other",
|
||||
@@ -21,7 +21,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.0.0",
|
||||
"@types/vscode": "^1.109.0",
|
||||
"@types/vscode": "^1.100.0",
|
||||
"typescript": "^5.3.0"
|
||||
},
|
||||
"contributes": {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user