Skip to content

Interactive follow-up loop and worktree improvements#2

Merged
axeldelafosse merged 3 commits intomainfrom
feat/interactive-followup-and-worktree-improvements
Feb 22, 2026
Merged

Interactive follow-up loop and worktree improvements#2
axeldelafosse merged 3 commits intomainfrom
feat/interactive-followup-and-worktree-improvements

Conversation

@axeldelafosse
Copy link
Copy Markdown
Owner

@axeldelafosse axeldelafosse commented Feb 22, 2026

Summary

  • Interactive follow-up loop: After iterations complete, users at a TTY (or inside tmux) are prompted for follow-up tasks instead of the process exiting. Extracted iteration logic into runIterations helper to keep runLoop focused on the interactive prompt shell.
  • Worktree nesting detection: Before creating a worktree, checks rev-parse --show-superproject-working-tree and --git-dir to avoid nesting worktrees inside worktrees.
  • PLAN.md portability: Moves PLAN.md from the original cwd into the new worktree so the task context follows the user.
  • Removed redundant pathExists guard in tryCreateWorktree — git's own conflict detection is more reliable.
  • Fixed tmux test: Added missing env: {} to the runInTmux test mock.

Test plan

  • bun test tests/loop/main.test.ts — all 5 existing tests pass (readline mock prevents hangs)
  • bun test tests/loop/worktree.test.ts — 3 new worktree detection tests + 2 PLAN.md move tests pass
  • bun run check — lint, types, and style pass
  • Manual: run loop in a TTY and verify follow-up prompt appears after iteration completes

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @axeldelafosse, 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 loop command's user experience and robustness. It introduces an interactive follow-up mechanism, allowing for continuous task refinement without restarting the process. Additionally, it improves the handling of Git worktrees by preventing nested worktree creation and ensuring that the task plan remains accessible within the new worktree environment, making the overall workflow more seamless and error-resistant.

Highlights

  • Interactive Follow-up Loop: Implemented an interactive prompt after iterations complete, allowing users in TTY or tmux environments to provide follow-up tasks instead of the process exiting. The core iteration logic was extracted into a runIterations helper.
  • Worktree Nesting Detection: Added checks using git rev-parse --show-superproject-working-tree and --git-dir to prevent creating new worktrees inside existing Git worktrees.
  • PLAN.md Portability: Ensured that the PLAN.md file is moved from the original current working directory into the newly created worktree, maintaining task context.
  • Redundant Path Check Removal: Removed an unnecessary pathExists guard in tryCreateWorktree, relying on Git's native conflict detection.
  • Tmux Test Fix: Corrected the runInTmux test mock by adding a missing env: {} property.
Changelog
  • src/loop/main.ts
    • Extracted the main iteration logic into a new runIterations function.
    • Implemented an interactive loop in runLoop using node:readline/promises to prompt for follow-up tasks after iterations, if running in a TTY or tmux.
    • Modified runIterations to return a boolean indicating if the 'done' signal was detected.
  • src/loop/worktree.ts
    • Added rmSync to imports for file removal operations.
    • Introduced moveFile to the WorktreeDeps interface and defaultDeps for moving files.
    • Defined PLAN_FILE and WORKTREE_GIT_DIR_MARKER constants.
    • Implemented logic to detect if already inside a Git worktree using git rev-parse --show-superproject-working-tree and --git-dir, skipping worktree setup if true.
    • Removed the deps.pathExists(candidatePath) check before attempting to create a worktree.
    • Added functionality to move PLAN_FILE (PLAN.md) from the current working directory to the new worktree's directory.
  • tests/loop/main.test.ts
    • Added a mock for node:readline/promises to prevent tests from hanging when createInterface is called.
  • tests/loop/tmux.test.ts
    • Updated the runInTmux test mock to include an empty env object.
  • tests/loop/worktree.test.ts
    • Added three new tests to verify that maybeEnterWorktree correctly identifies and skips setup when already in a Git worktree (superproject or linked git-dir).
    • Added two new tests to confirm that maybeEnterWorktree successfully moves PLAN.md into the worktree root or subpath.
    • Updated existing worktree creation tests to reflect the new git rev-parse calls for worktree detection.
Activity
  • The author provided a detailed summary of changes, including an interactive follow-up loop, worktree nesting detection, and PLAN.md portability.
  • A comprehensive test plan was outlined, covering existing and new unit tests, linting, type checks, and manual verification.
  • The pull request description indicates that the changes were generated with Claude Code.
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
Copy Markdown

@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 follow-up loop and enhances worktree creation by adding nesting detection and ensuring PLAN.md portability. The changes are well-implemented and include corresponding tests. My review focuses on a few opportunities to improve code clarity and reduce duplication, which will enhance the long-term maintainability of the new features.

Comment thread src/loop/main.ts Outdated
Comment thread src/loop/worktree.ts
Comment thread tests/loop/worktree.test.ts
@axeldelafosse axeldelafosse changed the title feat: interactive follow-up loop and worktree improvements Interactive follow-up loop and worktree improvements Feb 22, 2026
Extract iteration logic into runIterations helper to keep runLoop
focused on the interactive prompt shell. After iterations complete,
users at a TTY (or inside tmux) are prompted for follow-up tasks
instead of the process exiting immediately.

Worktree improvements:
- Detect when already inside a worktree to avoid nesting
- Move PLAN.md from the original cwd into the new worktree
- Remove redundant pathExists guard (git handles conflicts)
@axeldelafosse axeldelafosse force-pushed the feat/interactive-followup-and-worktree-improvements branch from 2acd941 to 3cc2865 Compare February 22, 2026 05:36
@axeldelafosse axeldelafosse marked this pull request as ready for review February 22, 2026 05:42
…etection, extract test helper

- Differentiate interactive vs non-interactive log when hitting max iterations
- Consolidate two separate worktree detection blocks into a single boolean check
- Extract makeWorktreeRunGit() helper to reduce duplication in PLAN.md tests
@axeldelafosse axeldelafosse merged commit 521c74b into main Feb 22, 2026
2 checks passed
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.

1 participant