feat: use sendPromptToAgentPanel + add 171 command reference doc
This commit is contained in:
@@ -279,46 +279,30 @@ async function handleCommand(filePath: string) {
|
||||
return;
|
||||
}
|
||||
|
||||
// General text: send to Antigravity chat
|
||||
// Step 1: Ensure agent panel is open
|
||||
const openCmds = [
|
||||
'antigravity.prioritized.chat.openNewConversation',
|
||||
'workbench.panel.chat.view.copilot.focus',
|
||||
];
|
||||
for (const cmd of openCmds) {
|
||||
// General text: send directly to Antigravity agent panel
|
||||
try {
|
||||
await vscode.commands.executeCommand('antigravity.sendPromptToAgentPanel', command.text);
|
||||
console.log(`Gravity Bridge: ✅ sent via sendPromptToAgentPanel`);
|
||||
} catch (e1) {
|
||||
console.log(`Gravity Bridge: sendPromptToAgentPanel failed: ${e1}`);
|
||||
// Fallback: try sendChatActionMessage
|
||||
try {
|
||||
await vscode.commands.executeCommand(cmd);
|
||||
console.log(`Gravity Bridge: panel opened with "${cmd}"`);
|
||||
break;
|
||||
} catch { /* try next */ }
|
||||
}
|
||||
|
||||
// Step 2: Wait for panel to be ready
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
// Step 3: Try sending text via native API
|
||||
let sent = false;
|
||||
for (const flag of [true, false]) {
|
||||
try {
|
||||
await vscode.commands.executeCommand('antigravity.sendTextToChat', flag, command.text);
|
||||
console.log(`Gravity Bridge: ✅ sendTextToChat(${flag}) executed`);
|
||||
sent = true;
|
||||
break;
|
||||
} catch (e) {
|
||||
console.log(`Gravity Bridge: sendTextToChat(${flag}) error: ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: If native API didn't work, clipboard paste
|
||||
if (!sent) {
|
||||
try {
|
||||
const oldClip = await vscode.env.clipboard.readText();
|
||||
await vscode.env.clipboard.writeText(command.text);
|
||||
await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
|
||||
await vscode.env.clipboard.writeText(oldClip);
|
||||
console.log('Gravity Bridge: clipboard paste fallback');
|
||||
} catch (e) {
|
||||
console.error('Gravity Bridge: all methods failed', e);
|
||||
await vscode.commands.executeCommand('antigravity.sendChatActionMessage', command.text);
|
||||
console.log(`Gravity Bridge: ✅ sent via sendChatActionMessage`);
|
||||
} catch (e2) {
|
||||
console.log(`Gravity Bridge: sendChatActionMessage failed: ${e2}`);
|
||||
// Last resort: focus panel + clipboard paste
|
||||
try {
|
||||
await vscode.commands.executeCommand('antigravity.agentPanel.focus');
|
||||
await new Promise(resolve => setTimeout(resolve, 300));
|
||||
const oldClip = await vscode.env.clipboard.readText();
|
||||
await vscode.env.clipboard.writeText(command.text);
|
||||
await vscode.commands.executeCommand('editor.action.clipboardPasteAction');
|
||||
await vscode.env.clipboard.writeText(oldClip);
|
||||
console.log('Gravity Bridge: clipboard paste fallback');
|
||||
} catch (e3) {
|
||||
console.error('Gravity Bridge: all methods failed', e3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user