Skip to content

Conversation

@AbdulTawabJuly
Copy link

Summary

This PR implements an interactive GUI wizard for configuring hooks, replacing the need for manual JSON editing. Users can now add hooks through a guided multi-step interface accessible via /hooks add.

Changes

  • HookConfigurationWizard: Main wizard component orchestrating a 4-step flow (event selection → matcher → details → review)
  • EventSelector: Interactive picker for selecting hook events with descriptions
  • MatcherInput: Input component with validation for tool name patterns (exact match, regex, or wildcard)
  • HookDetailsForm: Form for entering command, name, description, and timeout with real-time validation
  • HookReview: Review screen allowing users to edit any step before saving
  • Validation utilities: Functions to validate commands, matchers (regex), timeouts, and hook names
  • Integration: Added add subcommand to /hooks command that launches the wizard

Implementation Details

The wizard uses Ink components and follows the existing CLI UI patterns. State management is handled via React hooks, with validation performed at each step. The wizard saves hooks directly to .gemini/settings.json using the existing settings API.

Related Issues

Fixes 15268

How to Validate

/hooks add => Then just follow the steps shown on the UI

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@AbdulTawabJuly AbdulTawabJuly requested a review from a team as a code owner December 26, 2025 07:24
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @AbdulTawabJuly, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the user experience for configuring hooks in the Gemini CLI by introducing an interactive wizard. This new feature allows users to easily define and add hooks through a guided, step-by-step process directly within the command line, eliminating the previous requirement of manually editing JSON configuration files. The wizard ensures proper configuration through built-in validation and provides a clear summary before saving.

Highlights

  • Interactive Hook Configuration Wizard: Introduces a new interactive GUI wizard for configuring hooks, replacing the need for manual JSON editing.
  • Simplified Hook Addition: Users can now add hooks through a guided multi-step interface accessible via the /hooks add command.
  • Four-Step Guided Process: The wizard orchestrates a clear four-step flow: event selection, matcher configuration, hook details input, and a final review screen.
  • Input Validation: Includes real-time validation for all inputs, such as command paths, hook names, matchers (regex), and timeouts, providing clear error messages.
  • Enhanced User Experience: Leverages Ink components and React hooks for state management, following existing CLI UI patterns to provide a smooth and intuitive experience.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces an interactive wizard for configuring hooks, which is a great usability improvement. The implementation is well-structured, using Ink for the UI and breaking down the wizard into logical components and steps. My review focuses on a few areas to improve correctness and user experience: ensuring proper user feedback in the standalone CLI command, correcting the configuration update logic to avoid duplicate entries, and fixing a minor UI inconsistency in the wizard's step numbering. Addressing these points will make the new feature more robust and polished.

Comment on lines +91 to +115
const newHookDef: HookDefinition = {
matcher: state.matcher || undefined,
hooks: [
{
type: HookType.Command,
command: state.command,
name: state.name || undefined,
description: state.description || undefined,
timeout: state.timeout || undefined,
},
],
};

const hooksConfig =
(settings.merged.hooks as Record<string, unknown>) || {};
const existingHooks =
(hooksConfig[state.event] as HookDefinition[]) || [];

const updatedHooks = [...existingHooks, newHookDef];

settings.setValue(
SettingScope.Workspace,
`hooks.${state.event}`,
updatedHooks,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current implementation always creates a new HookDefinition object, even if one with the same matcher already exists for the given event. This leads to duplicate entries in the settings.json file, making it bloated and harder to manage. The logic should be updated to find an existing HookDefinition for the same matcher and add the new hook to its hooks array. A new HookDefinition should only be created if no matching one is found.

You will also need to import HookConfig from @google/gemini-cli-core.

      const hooksConfig =
        (settings.merged.hooks as Record<string, HookDefinition[]>) || {};
      const existingHookDefs = hooksConfig[state.event]?.slice() || [];

      const newHook: HookConfig = {
        type: HookType.Command,
        command: state.command!,
        name: state.name || undefined,
        description: state.description || undefined,
        timeout: state.timeout || undefined,
      };

      // Use empty string for wildcard matcher for consistent comparison.
      const matcher = state.matcher || '';
      const existingDefIndex = existingHookDefs.findIndex(
        (def) => (def.matcher || '') === matcher,
      );

      if (existingDefIndex > -1) {
        // Add to existing hook definition.
        const existingDef = existingHookDefs[existingDefIndex];
        existingDef.hooks.push(newHook);
      } else {
        // Create a new hook definition.
        const newHookDef: HookDefinition = {
          matcher: state.matcher || undefined,
          hooks: [newHook],
        };
        existingHookDefs.push(newHookDef);
      }

      settings.setValue(
        SettingScope.Workspace,
        `hooks.${state.event}`,
        existingHookDefs,
      );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UX: Interactive Hook Configuration GUI

2 participants