From a480e6b795d995524b6813230e950e383089e876 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Thu, 21 May 2026 00:22:57 -0700 Subject: [PATCH] Fix Antigravity tool calls blocked by Orca hook Fixes #2426 --- .../remote-hook-service-installers.test.ts | 52 ++++++++++++++++++- src/main/antigravity/hook-service.test.ts | 7 +-- src/main/antigravity/hook-service.ts | 3 +- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/src/main/agent-hooks/remote-hook-service-installers.test.ts b/src/main/agent-hooks/remote-hook-service-installers.test.ts index 23ed458411e..b4cc662b407 100644 --- a/src/main/agent-hooks/remote-hook-service-installers.test.ts +++ b/src/main/agent-hooks/remote-hook-service-installers.test.ts @@ -236,7 +236,8 @@ describe('remote hook service installers', () => { expect(command).toContain('/home/dev/.orca/agent-hooks/antigravity-hook.sh') expect(command).toContain(`ORCA_ANTIGRAVITY_EVENT='${eventName}'`) } - for (const eventName of ['PreToolUse', 'PostToolUse']) { + expect(antigravityConfig['orca-status'].PreToolUse).toBeUndefined() + for (const eventName of ['PostToolUse']) { const definition = antigravityConfig['orca-status'][eventName]?.[0] const command = definition?.hooks?.[0]?.command expect(definition?.matcher).toBe('*') @@ -285,6 +286,55 @@ describe('remote hook service installers', () => { expect(grokConfig.hooks.PreToolUse?.[0]?.matcher).toBe('*') }) + it('removes stale remote Antigravity PreToolUse hooks while installing SSH hooks', async () => { + const { sftp, fs } = createFakeSftp() + fs.files.set( + '/home/dev/.gemini/config/hooks.json', + `${JSON.stringify( + { + 'orca-status': { + PreToolUse: [ + { + matcher: '*', + hooks: [ + { + type: 'command', + command: '/tmp/old/agent-hooks/antigravity-hook.sh' + } + ] + } + ], + PostToolUse: [ + { + matcher: '*', + hooks: [ + { + type: 'command', + command: 'echo user-authored' + } + ] + } + ] + } + }, + null, + 2 + )}\n` + ) + + await new AntigravityHookService().installRemote(sftp, '/home/dev') + + const config = JSON.parse(fs.files.get('/home/dev/.gemini/config/hooks.json')!) as { + 'orca-status': Record + } + expect(config['orca-status'].PreToolUse).toBeUndefined() + const postToolCommands = config['orca-status'].PostToolUse.flatMap((definition) => + (definition.hooks ?? []).map((hook) => hook.command) + ) + expect(postToolCommands).toContain('echo user-authored') + expect(postToolCommands.some((command) => command.includes('antigravity-hook.sh'))).toBe(true) + }) + it('installs remote Copilot hooks under the user-level hooks directory', async () => { const { sftp, fs } = createFakeSftp() fs.dirs.add('/home/dev/.copilot') diff --git a/src/main/antigravity/hook-service.test.ts b/src/main/antigravity/hook-service.test.ts index 4a565f3a1ec..93327ccf041 100644 --- a/src/main/antigravity/hook-service.test.ts +++ b/src/main/antigravity/hook-service.test.ts @@ -46,9 +46,9 @@ describe('AntigravityHookService', () => { > } expect(Object.keys(config['orca-status']).sort()).toEqual( - ['PostInvocation', 'PostToolUse', 'PreInvocation', 'PreToolUse', 'Stop'].sort() + ['PostInvocation', 'PostToolUse', 'PreInvocation', 'Stop'].sort() ) - expect(config['orca-status'].PreToolUse[0].matcher).toBe('*') + expect(config['orca-status'].PreToolUse).toBeUndefined() expect(config['orca-status'].PostToolUse[0].matcher).toBe('*') expect(config['orca-status'].PreInvocation[0].command).toContain('antigravity-hook') expect(config['orca-status'].PreInvocation[0].command).toContain( @@ -130,7 +130,8 @@ describe('AntigravityHookService', () => { 'orca-status': Record } expect(config['orca-status'].OldEvent).toBeUndefined() - const commands = config['orca-status'].PreToolUse.flatMap((definition) => + expect(config['orca-status'].PreToolUse).toBeUndefined() + const commands = config['orca-status'].PostToolUse.flatMap((definition) => (definition.hooks ?? []).map((hook) => hook.command) ) expect(commands).toHaveLength(1) diff --git a/src/main/antigravity/hook-service.ts b/src/main/antigravity/hook-service.ts index 259b3631920..018304a968a 100644 --- a/src/main/antigravity/hook-service.ts +++ b/src/main/antigravity/hook-service.ts @@ -25,7 +25,8 @@ const ANTIGRAVITY_EVENTS = [ { eventName: 'PreInvocation', schema: 'direct' }, { eventName: 'PostInvocation', schema: 'direct' }, { eventName: 'Stop', schema: 'direct' }, - { eventName: 'PreToolUse', schema: 'tool' }, + // Why: Antigravity requires PreToolUse hooks to make permission decisions. + // Orca's hook is observational, so installing there can block user tools. { eventName: 'PostToolUse', schema: 'tool' } ] as const