Skip to content

Conversation

@stefandevo
Copy link
Collaborator

@stefandevo stefandevo commented Jan 17, 2026

Problem

When opening a git repository that has no GitHub remote configured, the server logs are spammed with warnings every 5 seconds:

WARN [Worktree] Failed to fetch GitHub PRs: Command failed: gh pr list ... no git remotes found

This happens because the worktree list endpoint (called every 5 seconds for polling) attempts to fetch GitHub PRs using gh pr list without first checking if the project has a GitHub remote configured.

Root Cause

In apps/server/src/routes/worktree/routes/list.ts, the fetchGitHubPRs() function:

  • Checks if gh CLI is available
  • Runs gh pr list command directly without first checking if there's a GitHub remote
  • Fails with "no git remotes found" for projects without GitHub remotes
  • This happens on every worktree list request (including the 5-second polling interval)

The dedicated /api/github/prs endpoint doesn't have this issue because it uses checkGitHubRemote() first to verify a GitHub remote exists.

Solution

Added per-project caching for GitHub remote status with a 5-minute TTL:

  1. Cache Structure: A Map keyed by project path storing the GitHubRemoteStatus and timestamp
  2. Check Before Fetch: Before calling gh pr list, check the cache for GitHub remote status
  3. Silent Skip: If no GitHub remote is detected (cached), skip the PR fetch silently (no warning)
  4. Manual Refresh: Added forceRefreshGitHub parameter that clears the cache when the user clicks the "Refresh worktrees" button

Changes

  • apps/server/src/routes/worktree/routes/list.ts - Added caching logic and forceRefreshGitHub parameter
  • apps/ui/src/lib/http-api-client.ts - Added forceRefreshGitHub parameter to listAll()
  • apps/ui/src/types/electron.d.ts - Updated type definition
  • apps/ui/src/lib/electron.ts - Updated mock API
  • apps/ui/src/components/views/board-view/worktree-panel/hooks/use-worktrees.ts - Pass forceRefreshGitHub: true on manual refresh

Testing

  1. Git project WITHOUT GitHub remote

    • Open the project in Automaker
    • Should see NO "Failed to fetch GitHub PRs" warnings in server logs
    • Subsequent polling (every 5 seconds) should not trigger warnings
  2. Git project WITH GitHub remote

    • Should fetch PRs normally with no changes to behavior
  3. Add GitHub remote after opening project

    • Click the "Refresh worktrees" button
    • Should immediately detect the new remote and fetch PRs

Test Results

  • All 1226 server unit tests pass
  • Server and UI build successfully

Summary by CodeRabbit

  • New Features

    • Added cache for GitHub remote status detection with configurable refresh capability for detecting newly added remotes.
  • Improvements

    • Reduced redundant checks for GitHub remote configuration through status caching.
    • Enhanced handling when GitHub CLI is unavailable—PR fetching now gracefully returns empty results without warnings.

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

When opening a git repository without a GitHub remote, the server logs
were spammed with warnings every 5 seconds during worktree polling:

  WARN [Worktree] Failed to fetch GitHub PRs: Command failed: gh pr list
  ... no git remotes found

This happened because fetchGitHubPRs() ran `gh pr list` without first
checking if the project has a GitHub remote configured.

Changes:
- Add per-project cache for GitHub remote status with 5-minute TTL
- Check cache before attempting to fetch PRs, skip silently if no remote
- Add forceRefreshGitHub parameter to clear cache on manual refresh
- Pass forceRefreshGitHub when user clicks the refresh worktrees button

This allows users to add a GitHub remote and immediately detect it by
clicking the refresh button, while preventing log spam during normal
polling for projects without GitHub remotes.
@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

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 implements a GitHub remote status caching mechanism with a 5-minute TTL to reduce repeated remote detection attempts. It introduces a forceRefreshGitHub flag throughout the API layers to allow clients to invalidate the cache when needed, and updates the server-side PR fetching logic to use this cached status silently without warnings.

Changes

Cohort / File(s) Summary
Server-side GitHub remote caching
apps/server/src/routes/worktree/routes/list.ts
Added in-memory cache with TTL for GitHub remote status, new getGitHubRemoteStatus() helper that checks cache validity before querying. Reworked PR fetching to use cached status. Extended request payload to accept forceRefreshGitHub flag for cache invalidation.
UI hook integration
apps/ui/src/components/views/board-view/worktree-panel/hooks/use-worktrees.ts
Updated worktree listing call to pass forceRefreshGitHub flag computed as !silent, enabling force-refresh on explicit user actions versus silent polling.
API client layer
apps/ui/src/lib/http-api-client.ts
Extended listAll method signature to accept optional forceRefreshGitHub parameter and include it in POST payload.
Type definitions & mocks
apps/ui/src/types/electron.d.ts, apps/ui/src/lib/electron.ts
Updated WorktreeAPI.listAll type signature and mock implementation to accept optional forceRefreshGitHub parameter.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

Bug, Enhancement, Ready-To-Merge

Poem

🐰 A cache to remember,
Five minutes of peace—
No more GitHub whispers,
Just force when released!
Hop swiftly through worktrees! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% 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 clearly and accurately summarizes the main change: adding caching to prevent repeated GitHub PR fetch warnings for non-GitHub repositories.

✏️ 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 @stefandevo, 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 addresses a persistent issue where the server logs were being flooded with warnings related to GitHub PR fetching for non-GitHub repositories. The core problem stemmed from an endpoint attempting to fetch GitHub PRs without first verifying the existence of a GitHub remote. The solution introduces a caching mechanism for GitHub remote status, allowing the system to intelligently skip PR fetching for irrelevant projects and providing a way to manually refresh this status when needed, significantly reducing log noise and improving efficiency.

Highlights

  • Eliminated Repeated Warnings: The system will no longer spam server logs with 'Failed to fetch GitHub PRs' warnings every 5 seconds for repositories that do not have a GitHub remote configured.
  • Introduced GitHub Remote Status Caching: A per-project cache with a 5-minute TTL has been implemented to store the GitHub remote status. This cache is checked before attempting to fetch GitHub PRs, preventing unnecessary gh pr list calls.
  • Silent PR Fetch Skipping: If the cached status indicates no GitHub remote is present, the pull request fetching process is now silently skipped, avoiding both the command execution and the associated warning.
  • Manual Cache Refresh Mechanism: A forceRefreshGitHub parameter has been added to the API, allowing the GitHub remote status cache to be explicitly cleared when a user manually triggers a 'Refresh worktrees' action in the UI. This ensures that newly added GitHub remotes are detected promptly.

🧠 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.

@stefandevo
Copy link
Collaborator Author

@coderabbitai pls review

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 is a solid pull request that effectively addresses the issue of log spam from repeated GitHub PR fetches for non-GitHub repositories. The caching strategy is a good solution, and the implementation is clean and well-documented. Adding the forceRefreshGitHub parameter for manual refreshes is a thoughtful addition that improves user experience. I've included one suggestion to improve the accuracy of the cache's time-to-live (TTL).

@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

@stefandevo: I'll review the changes in this pull request.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Use Date.now() after checkGitHubRemote() completes instead of the
pre-captured timestamp to ensure accurate 5-minute TTL.
@Shironex Shironex merged commit c2cf8ae into AutoMaker-Org:v0.12.0rc Jan 17, 2026
7 of 8 checks passed
@stefandevo stefandevo deleted the fix/gh-not-in-git-folder branch January 18, 2026 22:30
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.

2 participants