Skip to content

fix(desktop): use execWithShellEnv for gh CLI in import from PR#1577

Merged
Kitenite merged 1 commit into
mainfrom
kitenite/fix-import-pr-user-path
Feb 19, 2026
Merged

fix(desktop): use execWithShellEnv for gh CLI in import from PR#1577
Kitenite merged 1 commit into
mainfrom
kitenite/fix-import-pr-user-path

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Feb 19, 2026

Summary

  • Fix gh CLI not being found when importing a PR on macOS (app launched from Finder/Dock)
  • getPrInfo() was the only gh call using raw execFileAsync + getGitEnv(), which lacks the ENOENT retry logic that resolves the user's shell PATH
  • Switch to execWithShellEnv, matching the pattern used by all other gh calls in the codebase

Changes

  • apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts: Replace execFileAsync("gh", ...) with execWithShellEnv("gh", ...) in getPrInfo(), removing the now-unnecessary getGitEnv() call

Test Plan

  • Launch the desktop app from Finder (not terminal) on macOS
  • Import a PR via URL — verify it resolves the gh CLI and fetches PR info successfully
  • Verify existing worktree creation and PR import flows still work end-to-end

Summary by CodeRabbit

  • Refactor
    • Improved internal handling of Git operations for pull request information retrieval through enhanced environment variable management and simplified execution flow.

getPrInfo was using execFileAsync with getGitEnv() to call `gh pr view`,
which doesn't have the ENOENT retry logic needed on macOS when the app
is launched from Finder/Dock (minimal PATH). Switch to execWithShellEnv
which lazily derives the user's shell PATH on command-not-found, matching
the pattern used by other gh CLI calls in github.ts and git-operations.ts.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 19, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The change replaces direct execFile calls with execWithShellEnv wrapper for PR info fetching in the Git utility module. The explicit environment construction via getGitEnv is removed, and environment parameter passing is eliminated from the getPrInfo call, relying on the wrapper to handle shell-environment configuration.

Changes

Cohort / File(s) Summary
Git Environment Wrapper Migration
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts
Replaced direct execFileAsync usage with execWithShellEnv wrapper for PR info fetching; removed getGitEnv call and env parameter passing; updated imports/exports to reflect wrapper dependency. Timeout behavior preserved.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through wrapper's grace,
Environment flows without a trace,
No need to build what's done before,
Shell awareness at the core! ✨

✨ 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 kitenite/fix-import-pr-user-path

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.

@Kitenite Kitenite merged commit 78f0f52 into main Feb 19, 2026
5 of 6 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

@Kitenite Kitenite deleted the kitenite/fix-import-pr-user-path branch February 19, 2026 21:42
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