Skip to content

Conversation

@Shironex
Copy link
Collaborator

@Shironex Shironex commented Jan 21, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Users can now add Git remotes directly through the push dialog
    • Remote names and URLs are validated with length constraints
    • Duplicate remotes are prevented with specific error responses
    • An add-remote form appears when no remotes are configured for a repository
    • New remotes are automatically fetched with timeout handling
  • Tests

    • Comprehensive unit tests added for remote addition workflows

✏️ Tip: You can customize this high-level summary in your review settings.

- Introduced a new route for adding remotes to git worktrees.
- Enhanced the PushToRemoteDialog component to support adding new remotes, including form handling and error management.
- Updated the API client to include an endpoint for adding remotes.
- Modified the worktree state management to track the presence of remotes.
- Improved the list branches handler to check for configured remotes.

This update allows users to easily add remotes through the UI, enhancing the overall git workflow experience.
@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Warning

Rate limit exceeded

@Shironex has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 13 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

This PR introduces a complete add-remote feature for Git repositories within worktrees. It adds a backend POST endpoint to add Git remotes with validation and optional fetching, extends the list-branches response with a hasAnyRemotes flag, updates the frontend API client and type definitions, and refactors the push-to-remote dialog to support adding remotes with a new form-based UI flow.

Changes

Cohort / File(s) Summary
Backend Route Implementation
apps/server/src/routes/worktree/index.ts, apps/server/src/routes/worktree/routes/add-remote.ts
New POST /add-remote endpoint handler with request validation (worktreePath, remoteName, remoteUrl), duplicate remote detection, git command execution via promisified execFile, optional git fetch with 30-second timeout, and comprehensive error handling (400 for invalid input, 400 with REMOTE_EXISTS code for duplicates, 500 for failures).
Backend Testing & Enhancements
apps/server/tests/unit/routes/worktree/add-remote.test.ts, apps/server/src/routes/worktree/routes/list-branches.ts
Comprehensive unit test suite (565 lines) covering validation, remote existence checks, success/failure scenarios, and error handling; list-branches endpoint extended with hasAnyRemotes field derived from git remote output.
Type Definitions
libs/types/src/worktree.ts, libs/types/src/index.ts, apps/ui/src/types/electron.d.ts
New exported types for add-remote workflow: AddRemoteRequest, AddRemoteResult, AddRemoteResponse, AddRemoteErrorResponse; WorktreeAPI type enriched with addRemote method and hasAnyRemotes on listBranches result.
Frontend API Integration
apps/ui/src/lib/http-api-client.ts, apps/ui/src/lib/electron.ts
New addRemote method in HttpApiClient.worktree for POST /api/worktree/add-remote; mock WorktreeAPI updated with hasAnyRemotes field in listBranches response.
Frontend State & Hooks
apps/ui/src/hooks/queries/use-worktrees.ts
BranchInfo.isRemote made required (was optional); BranchesResult enriched with hasAnyRemotes boolean field, propagated across all code paths (NOT_GIT_REPO, NO_COMMITS, success).
Frontend UI Components
apps/ui/src/components/views/board-view/dialogs/push-to-remote-dialog.tsx, apps/ui/src/components/views/board-view/worktree-panel/components/worktree-actions-dropdown.tsx
push-to-remote-dialog refactored with add-remote form state (showAddRemoteForm, newRemoteName, newRemoteUrl, isAddingRemote, addRemoteError), new render paths (renderAddRemoteForm, renderRemoteSelector, renderFooter), error handling helpers, and remote data transformation; actions-dropdown badge changed from "new" to "local only" with amber styling and CloudOff icon.

Sequence Diagram

sequenceDiagram
    participant UI as UI (Dialog)
    participant Client as HTTP Client
    participant Server as Server Handler
    participant Git as Git Process

    UI->>Client: handleAddRemote(worktreePath, remoteName, remoteUrl)
    Client->>Server: POST /api/worktree/add-remote
    
    Server->>Server: Validate request payload
    Server->>Git: git remote (check existing)
    Git-->>Server: List of existing remotes
    Server->>Server: Check if remoteName already exists
    
    alt Remote already exists
        Server-->>Client: 400 error (REMOTE_EXISTS)
        Client-->>UI: Display error "Remote already exists"
    else Remote does not exist
        Server->>Git: git remote add <remoteName> <remoteUrl>
        Git-->>Server: Success
        
        Server->>Git: git fetch <remoteName> (timeout: 30s)
        
        alt Fetch succeeds
            Git-->>Server: Fetch successful
            Server-->>Client: 200 success (fetched: true)
        else Fetch fails
            Git-->>Server: Fetch error
            Server-->>Client: 200 success (fetched: false, message: error)
        end
        
        Client->>UI: Update remotes list, select new remote, clear form
        UI-->>UI: Re-render with new remote available
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Enhancement, Testers-Requested

Poem

🐰 A remote so new, we add with care,
With validation checks beyond compare,
The fetch arrives, the dialog grows bright,
Form fields dancing left and right,
Git remotes at your fingertips tonight! 🌙

🚥 Pre-merge checks | ✅ 2 | ❌ 3
❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title 'fix: detect no remote branch' does not match the actual changeset, which primarily implements a new 'add remote' feature rather than just detecting no remote branches. Update the title to reflect the main feature: 'feat: add ability to add git remotes via UI' or similar to accurately describe the add-remote functionality.
Linked Issues check ⚠️ Warning The linked issue #505 concerns fixing the 'Remove Project' button on right-click, but the PR primarily implements add-remote functionality with no changes addressing project removal. Verify that the linked issue is correct, or ensure the PR changes actually address the 'Remove Project' button functionality described in issue #505.
Out of Scope Changes check ⚠️ Warning The PR implements a comprehensive add-remote feature (new API routes, UI dialogs, type definitions) that appears unrelated to the linked issue #505 about fixing the 'Remove Project' button. Link the correct issue(s) that this add-remote feature addresses, or clarify how these changes relate to fixing the 'Remove Project' button functionality.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Shironex, 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 introduces the ability for users to add Git remotes directly within the application, enhancing the workflow for managing repositories without pre-configured remotes. It also refines the display of local-only branches and improves the overall user experience in the 'Push to Remote' dialog by integrating remote addition seamlessly.

Highlights

  • New Feature: Add Remote: Introduced a new API endpoint and corresponding UI functionality to allow users to add new Git remotes directly from the application. This includes robust input validation for remote names and URLs, and an optional immediate fetch from the newly added remote.
  • Enhanced Remote Branch Detection: The backend now detects and reports whether a Git repository has any configured remotes. This information is propagated to the frontend to improve the user experience, especially when dealing with local-only branches.
  • Improved 'Push to Remote' Dialog: The 'Push New Branch to Remote' dialog has been significantly enhanced. If no remotes are found, it automatically presents an 'Add Remote' form. Users can now add a remote, and then proceed to push, all within the same dialog. The dialog also provides better error handling and visual feedback.
  • Clearer Local-Only Branch Indication: The UI now uses a 'local only' badge with a CloudOff icon to clearly indicate branches that do not have a corresponding remote branch, replacing the previous 'new' badge.
  • Comprehensive Unit Tests: New unit tests have been added for the add-remote API endpoint, covering various scenarios including input validation, remote existence checks, successful additions, and error handling, ensuring the reliability of the new feature.

🧠 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 a new API endpoint and corresponding UI functionality to allow users to add new Git remotes to a worktree. The server-side changes include a new /add-remote POST route with input validation for remote name and URL, checks for existing remotes, and execution of git remote add and an optional git fetch. Unit tests for this new endpoint cover various validation and success/failure scenarios. On the UI side, the 'Push to Remote' dialog is enhanced to include an 'Add Remote' form, allowing users to input a new remote's name and URL. This form appears automatically if no remotes are found, and includes client-side validation, API integration, and dynamic UI updates. Additionally, the list-branches endpoint now reports if a repository has any remotes, and the UI's worktree actions dropdown has been updated to visually indicate local-only branches with a 'local only' tag and a CloudOff icon. Review comments suggested consolidating repetitive validation checks in the server-side handler, logging errors in an empty catch block for debugging, and moving a utility function to a shared location for reusability, as well as fixing a UI bug where an error message was hidden by the 'Add Remote' form.

@Shironex Shironex self-assigned this Jan 21, 2026
@Shironex Shironex changed the title feat: detect no remote branch fix: detect no remote branch Jan 21, 2026
@Shironex Shironex added Bug Something isn't working Enhancement Improvements to existing functionality or UI. Do Not Merge Use this label if something should not be merged. labels Jan 21, 2026
Copy link

@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

🤖 Fix all issues with AI agents
In `@apps/server/src/routes/worktree/routes/add-remote.ts`:
- Around line 1-6: Update the header comment in the POST /add-remote file to
reference the actual middleware used: change the mention of requireValidWorktree
to requireGitRepoOnly so the comment matches the route registration; locate the
top-of-file comment in add-remote.ts and replace the middleware name accordingly
(keep the rest of the note intact).

In `@apps/ui/src/components/views/board-view/dialogs/push-to-remote-dialog.tsx`:
- Around line 98-103: The effect that auto-opens the add-remote form currently
runs whenever isLoading is false and remotes.length === 0, which hides the error
view when listRemotes fails; update the useEffect (the effect that calls
setShowAddRemoteForm) to also require that there is no error (e.g., add a check
for !error) and include error in the dependency array so the auto-open only
triggers on an empty remotes list when no error is present, leaving the error
view visible for retries.
🧹 Nitpick comments (3)
apps/ui/src/types/electron.d.ts (1)

992-1007: Consider reusing shared AddRemote response types.
This avoids type drift between UI and @automaker/types and keeps the API surface centralized.

♻️ Suggested type reuse
-import type { ClaudeUsageResponse, CodexUsageResponse } from '@/store/app-store';
+import type { ClaudeUsageResponse, CodexUsageResponse } from '@/store/app-store';
+import type { AddRemoteResponse, AddRemoteErrorResponse } from '@automaker/types';

@@
   addRemote: (
     worktreePath: string,
     remoteName: string,
     remoteUrl: string
-  ) => Promise<{
-    success: boolean;
-    result?: {
-      remoteName: string;
-      remoteUrl: string;
-      fetched: boolean;
-      message: string;
-    };
-    error?: string;
-    code?: 'REMOTE_EXISTS';
-  }>;
+  ) => Promise<AddRemoteResponse | AddRemoteErrorResponse>;
apps/ui/src/hooks/queries/use-worktrees.ts (1)

213-219: Consider normalizing isRemote in branch results

Since isRemote is now non-optional, a defensive boolean cast here prevents accidental undefined if an older backend omits it.

Suggested change
-        branches: result.result?.branches ?? [],
+        branches: (result.result?.branches ?? []).map((branch) => ({
+          ...branch,
+          isRemote: !!branch.isRemote,
+        })),
apps/server/src/routes/worktree/index.ts (1)

182-188: Verify middleware scope for /add-remote

/list-remotes uses requireValidWorktree, but /add-remote only uses requireGitRepoOnly. If this should be restricted to registered worktrees, align the middleware for consistency.

Possible alignment
   router.post(
     '/add-remote',
     validatePathParams('worktreePath'),
-    requireGitRepoOnly,
+    requireValidWorktree,
     createAddRemoteHandler()
   );

@Shironex Shironex merged commit 3f05735 into v0.14.0rc Jan 21, 2026
6 checks passed
@Shironex Shironex deleted the feat/detect-no-remote-branch branch January 21, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working Do Not Merge Use this label if something should not be merged. Enhancement Improvements to existing functionality or UI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants