fix: panel focus before approval
This commit is contained in:
@@ -403,72 +403,42 @@ async function processResponseFile(filePath) {
|
||||
catch { }
|
||||
}
|
||||
if (resp.approved) {
|
||||
// STRATEGY: Try SDK rawRPC first (has CSRF auth), then VS Code commands
|
||||
// Phase 1: SDK rawRPC (requires active SDK connection with CSRF)
|
||||
if (sdk && sessionId) {
|
||||
const rpcMethods = [
|
||||
{ method: 'HandleCascadeUserInteraction', params: { cascadeId: sessionId, approved: true } },
|
||||
{ method: 'ResolveOutstandingSteps', params: { cascadeId: sessionId } },
|
||||
];
|
||||
for (const { method, params } of rpcMethods) {
|
||||
try {
|
||||
const result = await sdk.ls.rawRPC(method, params);
|
||||
const log = `[RESPONSE] RPC OK ${method}: ${JSON.stringify(result).substring(0, 100)}`;
|
||||
logToFile(log);
|
||||
}
|
||||
catch (e) {
|
||||
const log = `[RESPONSE] RPC FAIL ${method}: ${e.message}`;
|
||||
logToFile(log);
|
||||
}
|
||||
}
|
||||
// Step 1: Focus Antigravity panel — webview MUST be active for commands to work
|
||||
// acceptAgentStep dispatches via postMessage to Chat Client webview
|
||||
try {
|
||||
await vscode.commands.executeCommand('antigravity.agentPanel.focus');
|
||||
logToFile('[RESPONSE] panel focused');
|
||||
}
|
||||
else {
|
||||
logToFile(`[RESPONSE] SDK unavailable (sdk=${!!sdk}, session=${sessionId})`);
|
||||
catch (e) {
|
||||
logToFile(`[RESPONSE] panel focus failed: ${e.message}`);
|
||||
}
|
||||
// Phase 2: VS Code commands (may or may not work depending on UI focus)
|
||||
const cmds = [
|
||||
'antigravity.terminalCommand.run',
|
||||
'antigravity.terminalCommand.accept',
|
||||
'antigravity.command.accept',
|
||||
'antigravity.agent.acceptAgentStep',
|
||||
];
|
||||
for (const cmd of cmds) {
|
||||
try {
|
||||
await vscode.commands.executeCommand(cmd);
|
||||
logToFile(`[RESPONSE] CMD OK ${cmd}`);
|
||||
}
|
||||
catch (e) {
|
||||
logToFile(`[RESPONSE] CMD FAIL ${cmd}: ${e.message}`);
|
||||
}
|
||||
// Wait for webview to initialize
|
||||
await new Promise(r => setTimeout(r, 500));
|
||||
// Step 2: Accept — only acceptAgentStep (the universal approval command)
|
||||
try {
|
||||
await vscode.commands.executeCommand('antigravity.agent.acceptAgentStep');
|
||||
logToFile('[RESPONSE] acceptAgentStep sent');
|
||||
}
|
||||
logToFile('[RESPONSE] all approve attempts done');
|
||||
catch (e) {
|
||||
logToFile(`[RESPONSE] acceptAgentStep failed: ${e.message}`);
|
||||
}
|
||||
logToFile('[RESPONSE] approve done');
|
||||
}
|
||||
else {
|
||||
// REJECT
|
||||
if (sdk && sessionId) {
|
||||
try {
|
||||
await sdk.ls.rawRPC('HandleCascadeUserInteraction', { cascadeId: sessionId, approved: false });
|
||||
logToFile('[RESPONSE] RPC reject OK');
|
||||
}
|
||||
catch (e) {
|
||||
logToFile(`[RESPONSE] RPC reject FAIL: ${e.message}`);
|
||||
}
|
||||
// REJECT — same pattern: focus first, then reject
|
||||
try {
|
||||
await vscode.commands.executeCommand('antigravity.agentPanel.focus');
|
||||
}
|
||||
const cmds = [
|
||||
'antigravity.terminalCommand.reject',
|
||||
'antigravity.command.reject',
|
||||
'antigravity.agent.rejectAgentStep',
|
||||
];
|
||||
for (const cmd of cmds) {
|
||||
try {
|
||||
await vscode.commands.executeCommand(cmd);
|
||||
logToFile(`[RESPONSE] CMD OK ${cmd}`);
|
||||
}
|
||||
catch (e) {
|
||||
logToFile(`[RESPONSE] CMD FAIL ${cmd}: ${e.message}`);
|
||||
}
|
||||
catch { }
|
||||
await new Promise(r => setTimeout(r, 500));
|
||||
try {
|
||||
await vscode.commands.executeCommand('antigravity.agent.rejectAgentStep');
|
||||
logToFile('[RESPONSE] rejectAgentStep sent');
|
||||
}
|
||||
logToFile('[RESPONSE] all reject attempts done');
|
||||
catch (e) {
|
||||
logToFile(`[RESPONSE] rejectAgentStep failed: ${e.message}`);
|
||||
}
|
||||
logToFile('[RESPONSE] reject done');
|
||||
}
|
||||
try {
|
||||
fs.unlinkSync(filePath);
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user