Skip to content

t1224.8: Integrate localdev with worktree workflow for auto branch subdomain routing#1948

Merged
marcusquinn merged 2 commits intomainfrom
feature/t1224.8
Feb 19, 2026
Merged

t1224.8: Integrate localdev with worktree workflow for auto branch subdomain routing#1948
marcusquinn merged 2 commits intomainfrom
feature/t1224.8

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Feb 19, 2026

Summary

  • When worktree-helper.sh add creates a worktree for a project registered with localdev add, it auto-runs localdev branch <project> <branch> to create a subdomain route (e.g., feature-auth.myapp.local) and outputs the URL
  • Worktree removal (remove, clean) auto-cleans the corresponding localdev branch route
  • Detection matches repo basename against ~/.local-dev-proxy/ports.json — non-fatal if localdev is not configured

Changes

  • .agents/scripts/worktree-helper.sh: Added detect_localdev_project(), localdev_auto_branch(), localdev_auto_branch_rm() functions; hooked into cmd_add, cmd_remove, cmd_clean
  • .agents/tools/git/worktrunk.md: Added Localdev Integration section with Worktrunk post-create hook example
  • .agents/workflows/worktree.md: Added Localdev Integration section documenting auto-routing behaviour

Design Decisions

  • Chose to detect project by matching repo basename against ports.json app names (simplest, no config needed)
  • All localdev calls are non-fatal — worktree operations succeed even if localdev is not installed or project is not registered
  • Branch route cleanup happens in both cmd_remove (single) and cmd_clean (batch) paths
  • Reuses localdev-helper.sh existing branch and branch rm commands rather than duplicating logic

Ref #1881

Summary by CodeRabbit

  • New Features

    • Localdev integration: worktree creation now auto-configures branch-specific subdomain routes for projects registered with Localdev.
    • Worktree removal and cleanup now automatically remove the corresponding branch routes.
  • Documentation

    • Updated docs with Localdev integration workflow, examples, and notes on automatic branch route creation and cleanup.

…main routing (t1224.8)

When worktree-helper.sh creates a worktree for a localdev-registered project,
it auto-runs `localdev branch <project> <branch>` to create a subdomain route
(e.g., feature-auth.myapp.local) and outputs the URL. Worktree removal
(remove, clean) auto-cleans the corresponding branch route.

Detection: matches repo basename against ~/.local-dev-proxy/ports.json.
Non-fatal: if localdev is not configured or the project is not registered,
the worktree workflow proceeds normally without error.
@marcusquinn marcusquinn marked this pull request as ready for review February 19, 2026 08:11
@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, 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 integrates the worktree-helper.sh script with localdev to automate the management of branch-specific subdomain routes. This enhancement streamlines the local development workflow by automatically configuring and cleaning up development URLs when git worktree operations are performed, providing a more seamless experience for developers working on multiple branches simultaneously.

Highlights

  • Automated Localdev Branch Routing: Worktree creation for localdev-registered projects now automatically creates a branch-specific subdomain route (e.g., feature-auth.myapp.local).
  • Automated Route Cleanup: Worktree removal or cleanup operations now automatically remove the corresponding localdev branch route.
  • Non-Fatal Integration: The localdev integration is designed to be non-fatal; worktree operations will succeed even if localdev is not installed or the project is not registered.
  • Project Detection: Localdev projects are detected by matching the repository's basename against registered app names in ~/.local-dev-proxy/ports.json.
Changelog
  • .agents/scripts/worktree-helper.sh
    • Added detect_localdev_project function to identify localdev-registered repositories.
    • Implemented localdev_auto_branch function to create subdomain routes upon worktree addition.
    • Introduced localdev_auto_branch_rm function to remove subdomain routes during worktree removal.
    • Integrated these new functions into cmd_add, cmd_remove, and cmd_clean for automated localdev route management.
  • .agents/tools/git/worktrunk.md
    • Added a new section on 'Localdev Integration' detailing the auto-routing feature.
    • Provided an example post-create hook for Worktrunk to demonstrate leveraging the localdev integration.
  • .agents/workflows/worktree.md
    • Added a 'Localdev Integration' section to document the automatic subdomain routing behavior for worktrees.
Activity
  • No activity to report for this pull request yet.
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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2026

Walkthrough

This PR adds Localdev integration to the worktree helper: detects localdev-registered projects via ~/.local-dev-proxy/ports.json, and automatically creates/removes branch-specific subdomain routes by invoking a localdev helper when worktrees are added, removed, or cleaned. Documentation is updated.

Changes

Cohort / File(s) Summary
Core Implementation
.agents/scripts/worktree-helper.sh
Adds Localdev constants (LOCALDEV_PORTS_FILE, LOCALDEV_HELPER), detect_localdev_project(), localdev_auto_branch(), localdev_auto_branch_rm(). Hooks these into cmd_add, cmd_remove, and cmd_clean to auto-create and clean branch subdomain routes (uses jq when available, falls back to grep).
Documentation
.agents/tools/git/worktrunk.md, .agents/workflows/worktree.md
Adds "Localdev Integration (t1224.8)" subsections describing detection method (match against ~/.local-dev-proxy/ports.json), automatic branch route creation on worktree add, and auto-clean on remove/clean; includes usage notes and example hook snippet.

Sequence Diagram

sequenceDiagram
    actor User
    participant WorktreeHelper as worktree-helper.sh
    participant LocaldevHelper as localdev-helper.sh
    participant PortsFile as ~/.local-dev-proxy/ports.json

    rect rgba(100, 200, 150, 0.5)
    Note over User,PortsFile: Add Worktree with Localdev
    User->>WorktreeHelper: cmd_add <branch>
    WorktreeHelper->>WorktreeHelper: create worktree
    WorktreeHelper->>WorktreeHelper: detect_localdev_project()
    WorktreeHelper->>PortsFile: check for repo entry
    alt Project registered
        WorktreeHelper->>LocaldevHelper: localdev_auto_branch(branch)
        LocaldevHelper->>PortsFile: create branch route
        LocaldevHelper-->>WorktreeHelper: branch URL
        WorktreeHelper-->>User: output branch URL
    else Not registered
        WorktreeHelper-->>User: no route created
    end
    end

    rect rgba(200, 150, 100, 0.5)
    Note over User,PortsFile: Remove/Clean Worktree with Cleanup
    User->>WorktreeHelper: cmd_remove|cmd_clean <branch>
    WorktreeHelper->>WorktreeHelper: remove/clean worktree(s)
    WorktreeHelper->>WorktreeHelper: localdev_auto_branch_rm(branch)
    alt Route exists
        WorktreeHelper->>LocaldevHelper: request remove route
        LocaldevHelper->>PortsFile: remove branch route
    end
    WorktreeHelper-->>User: cleanup complete
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

Possibly related issues

Possibly related PRs

Poem

🌱 A branch is born, a route is spun,
worktree and localdev now dance as one.
Add, remove, clean — the helper sings,
Subdomains bloom on automated wings. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 62.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: integrating localdev with worktree workflow for automatic branch subdomain routing, which is the core functionality added across worktree-helper.sh and documentation files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/t1224.8

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 29 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Feb 19 08:11:40 UTC 2026: Code review monitoring started
Thu Feb 19 08:11:41 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 29

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 29
  • VULNERABILITIES: 0

Generated on: Thu Feb 19 08:11:43 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link

@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

The integration of localdev with the worktree workflow is well-implemented and follows the project's non-fatal design philosophy. The detection logic for projects is robust, and the hooks into add, remove, and clean cover the necessary lifecycle events. I have one recommendation regarding the removal of redundant logic in the branch cleanup function to improve maintainability, aligning with the repository's rules on avoiding logic duplication. This review was informed by the Repository Style Guide's emphasis on reusing existing helpers and preventing maintenance drift.

coderabbitai[bot]
coderabbitai bot previously requested changes Feb 19, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.agents/scripts/worktree-helper.sh:
- Around line 90-95: The grep fallback treats $base_name as a regex which breaks
on metacharacters; update the grep call that currently reads grep -q
"\"$base_name\"" "$LOCALDEV_PORTS_FILE" to use fixed-string matching and safe
argument handling (e.g., grep -F -q -- "\"$base_name\"" "$LOCALDEV_PORTS_FILE"
2>/dev/null) so repo names with characters like . or [ ] are matched literally;
keep the surrounding quoted-string match so you still look for the JSON key
form.

In @.agents/tools/git/worktrunk.md:
- Around line 220-226: The post-create hook in .worktrunk/hooks/post-create
hardcodes the helper path ~/.aidevops/agents/scripts/localdev-helper.sh and
masks failures with "2>/dev/null || true", which hides command-not-found when
aidevops is installed elsewhere; update the hook or docs to either (a) document
the default-install assumption so users know to adjust the path, or (b) change
the hook to resolve the helper dynamically (e.g., respect an AIDEVOPS_HOME env
var, search PATH or use command -v to locate localdev-helper.sh) and remove the
silent suppression so a clear error or fallback message appears instead of
swallowing failures.

@marcusquinn marcusquinn dismissed coderabbitai[bot]’s stale review February 19, 2026 08:29

Auto-dismissed: bot review does not block autonomous pipeline

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 29 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Thu Feb 19 08:43:13 UTC 2026: Code review monitoring started
Thu Feb 19 08:43:13 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 29

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 29
  • VULNERABILITIES: 0

Generated on: Thu Feb 19 08:43:16 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link

coderabbitai[bot]
coderabbitai bot previously requested changes Feb 19, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.agents/scripts/worktree-helper.sh:
- Around line 120-129: The function localdev_auto_branch_rm currently swallows
failures from the "$LOCALDEV_HELPER" branch rm call with "|| true"; change it to
capture the command's exit status and, on non-zero exit, print a warning similar
to localdev_auto_branch (use the ${YELLOW}Localdev branch route removal failed
(non-fatal)${NC} style message) so failures are logged for observability;
reference the localdev_auto_branch_rm function and the "$LOCALDEV_HELPER" branch
rm invocation when making the change.

In @.agents/tools/git/worktrunk.md:
- Around line 208-228: The docs claim cleanup happens with Worktrunk's
post-create hook but omit the corresponding pre-remove hook so users using wt
remove will not trigger localdev_auto_branch_rm; add either (A) a pre-remove
hook example that calls the same LOCALDEV_HELPER and invokes
localdev_auto_branch_rm (mirror the post-create snippet but run the cleanup for
the current worktree/branch), or (B) a clear note stating that automatic route
removal only occurs when using worktree-helper.sh (and not just the post-create
hook), referencing worktree-helper.sh, localdev_auto_branch_rm, post-create and
pre-remove so maintainers can find the right spots; also change the example URL
scheme from https://feature-xyz.myapp.local to http:// or append “(https if
mkcert/local CA configured)” to avoid implying TLS by default.

@marcusquinn marcusquinn dismissed coderabbitai[bot]’s stale review February 19, 2026 09:05

Auto-dismissed: bot review does not block autonomous pipeline

@marcusquinn marcusquinn merged commit 8aada2b into main Feb 19, 2026
31 checks passed
@marcusquinn marcusquinn deleted the feature/t1224.8 branch February 19, 2026 09:18
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