Skip to content

Add recurring /loop command with auto-removal#23714

Open
cruzlauroiii wants to merge 4 commits intogoogle-gemini:mainfrom
cruzlauroiii:cruzlauroiii/gemini-loop-command
Open

Add recurring /loop command with auto-removal#23714
cruzlauroiii wants to merge 4 commits intogoogle-gemini:mainfrom
cruzlauroiii:cruzlauroiii/gemini-loop-command

Conversation

@cruzlauroiii
Copy link

Summary

  • add a built-in /loop <Xm> <message> command for interactive recurring prompts
  • keep the loop session-local, replacing any previous schedule and queueing at most one pending loop prompt while Gemini CLI is busy
  • auto-remove the loop when the scheduled turn signals that the work is already complete, and strip the stop marker from visible assistant output
  • cover the parser/command behavior plus the stream-level stop-marker handling with tests

Validation

  • npm run typecheck --workspace @google/gemini-cli
  • npm test --workspace @google/gemini-cli -- src/ui/utils/loopCommand.test.ts src/ui/commands/loopCommand.test.ts src/ui/hooks/slashCommandProcessor.test.tsx src/ui/hooks/useGeminiStream.test.tsx src/ui/AppContainer.test.tsx
  • npm run build --workspace @google/gemini-cli

Fixes #23713
Related duplicate request: #22653

@cruzlauroiii cruzlauroiii requested a review from a team as a code owner March 24, 2026 21:00
@google-cla
Copy link

google-cla bot commented Mar 24, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 Gemini CLI's interactive capabilities by introducing a new /loop command. This feature allows users to automate recurring prompts, which is particularly useful for iterative tasks or continuous monitoring. The implementation includes robust state management to handle loop scheduling, ensures that the CLI remains responsive, and provides a mechanism for the assistant to signal task completion, thereby automatically terminating the loop and streamlining user workflows.

Highlights

  • New /loop command: Introduced a built-in /loop <Xm> <message> command, allowing users to schedule recurring prompts at specified minute intervals.
  • Session-local loop management: The loop functionality is session-local, meaning a new /loop command will replace any previously scheduled one. It also intelligently queues at most one pending loop prompt when the Gemini CLI is busy, preventing message overload.
  • Automatic loop removal: The system now automatically removes a scheduled loop when the assistant's response includes a specific stop marker, indicating task completion. This stop marker is stripped from the visible output to maintain a clean user experience.
  • Comprehensive testing: The new command's parser, behavior, and the stream-level handling of the stop marker are thoroughly covered by new and updated test cases.
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.

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 a new /loop command, allowing users to schedule recurring messages to the LLM at specified intervals. The implementation includes UI state management for scheduling, modifications to the Gemini stream processing to handle a special loop stop marker, and new utility functions for command argument parsing and submission text generation. Feedback indicates a potential Denial of Service vulnerability if large interval values are not properly validated for setInterval, and a style guide violation regarding the copyright year in license headers, which should be updated from 2026 to 2024.

@gemini-cli gemini-cli bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Mar 24, 2026
@cruzlauroiii cruzlauroiii force-pushed the cruzlauroiii/gemini-loop-command branch from e850c29 to 5ba6a92 Compare March 24, 2026 21:30
@cruzlauroiii
Copy link
Author

cruzlauroiii commented Mar 24, 2026

Rebased this branch onto the latest main and the current PR head is 153a023.

This branch addresses the outstanding Gemini Code Assist review feedback:

  • capped /loop intervals to the maximum delay supported by setInterval
  • added a parser test for oversized intervals
  • updated the new file license headers from 2026 to 2024
  • kept the earlier rebase fallout fix where the new useGeminiStream loop-marker test now awaits renderTestHook(...)

Validation rerun on the rebased branch:

  • npm run typecheck --workspace @google/gemini-cli
  • npm test --workspace @google/gemini-cli -- src/ui/utils/loopCommand.test.ts src/ui/commands/loopCommand.test.ts src/ui/hooks/slashCommandProcessor.test.tsx src/ui/hooks/useGeminiStream.test.tsx src/ui/AppContainer.test.tsx

Checks are currently green, and the branch now contains the current upstream main. The remaining gate is maintainer review.

@cruzlauroiii cruzlauroiii force-pushed the cruzlauroiii/gemini-loop-command branch from 5ba6a92 to 19321a0 Compare March 24, 2026 21:34
@cruzlauroiii cruzlauroiii force-pushed the cruzlauroiii/gemini-loop-command branch from 19321a0 to 153a023 Compare March 24, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add /loop <Xm> <message> with auto-removal when work is done

1 participant