Skip to content

Comments

fix: hide Create PR when PR exists and toast when pull fails#969

Open
naaa760 wants to merge 6 commits intogeneralaction:mainfrom
naaa760:fix/fail-pull-repo-still-pr
Open

fix: hide Create PR when PR exists and toast when pull fails#969
naaa760 wants to merge 6 commits intogeneralaction:mainfrom
naaa760:fix/fail-pull-repo-still-pr

Conversation

@naaa760
Copy link
Contributor

@naaa760 naaa760 commented Feb 19, 2026

fix: #912

description:

  • When the remote was unreachable (e.g. SSH agent off), the app still showed "Create PR" for branches that already had a PR and didn’t tell the user that the pull failed.

Changes:

  • Create PR: Only update PR state when the GitHub/gh request succeeds; on failure keep last known PR (memory + localStorage) so we show "View PR" instead of "Create PR" when a PR exists.
  • Pull failed: If git fetch fails while listing branches, show a toast: "Could not pull from repository" with the error.

Result: No "Create PR" when a PR already exists and the repo is unreachable; users see a clear message when pull fails.

@vercel
Copy link

vercel bot commented Feb 19, 2026

@naaa760 is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link

greptile-apps bot commented Feb 19, 2026

Greptile Summary

Prevents incorrect "Create PR" button display and adds user feedback when git operations fail due to unreachable remotes.

  • PR state persistence: When GitHub/gh requests fail, prStatusStore.ts now preserves the last known PR state in both memory and localStorage (using emdash:pr:{taskPath} keys), ensuring "View PR" appears instead of "Create PR" when a PR already exists
  • Fetch failure notifications: When git fetch fails in listRemoteBranches, the failure is captured and returned to the caller, triggering a toast notification: "Could not pull from repository"
  • Success-only updates: The store only updates cached PR state on successful requests; on failure, it falls back to in-memory cache or localStorage to maintain last known state

This ensures users get accurate UI state and clear feedback when working offline or with unreachable remotes.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Changes are well-contained error handling improvements with graceful fallbacks. The localStorage persistence is properly guarded with try-catch, fetch failures don't break normal flow, and the existing cache/pending deduplication logic is preserved.
  • No files require special attention

Important Files Changed

Filename Overview
src/main/ipc/gitIpc.ts Captures fetch failure state and returns it to caller without breaking normal flow
src/renderer/hooks/useProjectManagement.tsx Displays toast notification when git fetch fails, informing user of connection issue
src/renderer/lib/prStatusStore.ts Implements localStorage persistence and success-only cache updates to preserve PR state when GitHub is unreachable

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User opens project] --> B[listRemoteBranches called]
    B --> C{Remote exists?}
    C -->|Yes| D[git fetch --prune]
    C -->|No| E[List local branches only]
    D --> F{Fetch succeeded?}
    F -->|Yes| G[List remote branches]
    F -->|No| H[Set fetchFailed=true<br/>Capture error]
    H --> G
    G --> I[Return success=true<br/>branches + fetchFailed]
    E --> I
    I --> J[useProjectManagement]
    J --> K{fetchFailed?}
    K -->|Yes| L[Show toast:<br/>'Could not pull from repository']
    K -->|No| M[Continue normally]
    L --> M
    M --> N[Update branch list]
    
    P[Component mounts] --> Q[subscribeToPrStatus]
    Q --> R{Cached PR?}
    R -->|Yes| S[Show cached PR state]
    R -->|No| T{localStorage PR?}
    T -->|Yes| U[Load from localStorage<br/>Update cache]
    T -->|No| V[Show loading]
    U --> W[refreshPrStatus]
    V --> W
    S --> W
    W --> X[Fetch PR from GitHub]
    X --> Y{Request succeeded?}
    Y -->|Yes| Z[Update cache + localStorage<br/>Show current state]
    Y -->|No| AA[Keep cached/localStorage PR<br/>Maintain 'View PR' button]
Loading

Last reviewed commit: 03552f5

@arnestrickmann
Copy link
Contributor

Thank you! @naaa760
Could you run pnpm run format?

@naaa760 naaa760 force-pushed the fix/fail-pull-repo-still-pr branch from a992572 to 4c0307c Compare February 21, 2026 13:53
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.

[bug]: failing to pull from repo still shows 'create PR' command

2 participants