Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(desktop): backfill SSH_AUTH_SOCK from login shell on macOS #972

Mergedstickerdaniel(GitHub profile, opens in a new tab)merged 6 commits intomain fromrefs/pull/972/headmerged by juliusmarminge View on GitHub

Closes #971.

What Changed

  • replace the desktop-only fixPath() startup hook with syncShellEnvironment()
  • extend the shared login-shell probe so desktop startup can read multiple environment variables instead of only PATH
  • continue refreshing PATH on macOS startup, but only backfill SSH_AUTH_SOCK when it is missing
  • add desktop tests covering macOS hydration, non-macOS no-op behavior, and the regression case where an inherited SSH_AUTH_SOCK must be preserved

Why

The macOS desktop app currently repairs PATH from the login shell, but Finder and Dock launches can still miss SSH_AUTH_SOCK. That breaks Git-over-SSH flows in the desktop app even when the same repo works correctly from Terminal.

This keeps the fix small and reliability-focused:

  • Finder/Dock launches get the missing SSH agent socket they need
  • Terminal-launched sessions keep their inherited SSH_AUTH_SOCK instead of being overwritten by a different login-shell value
  • the server-side startup path is left unchanged so this PR stays desktop-scoped

UI Changes

None.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Backfill SSH_AUTH_SOCK from login shell on macOS desktop startup

  • Replaces fixPath with a new syncShellEnvironment module that reads both PATH and SSH_AUTH_SOCK from the user's login shell on macOS at startup.
  • SSH_AUTH_SOCK is only written if it is not already set in the inherited environment; PATH is always updated from the shell.
  • Extends readEnvironmentFromLoginShell in packages/shared/src/shell.ts to capture multiple named variables in a single shell invocation using bracketed markers and printenv <NAME> || true.
  • Errors from the shell invocation are swallowed so a failure leaves the inherited environment intact.
Macroscope summarized 90d9c4f.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. 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.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 7b2148d1-de5f-46c6-b7ce-b4f50b78f692

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

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Post copyable unit tests in a comment
      📝 Coding Plan
      • Generate coding plan for human review comments

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Pull request overview

      This PR extends the shared “read env from login shell” utility so the macOS desktop app can hydrate more than just PATH at startup, specifically backfilling SSH_AUTH_SOCK when it’s missing (e.g., Finder/Dock launches) while preserving inherited values when present.

      Changes:

      • Replaced the desktop-only fixPath() hook with syncShellEnvironment() and wired it into desktop startup.
      • Generalized the shared login-shell probe to support reading multiple environment variables (used for PATH + SSH_AUTH_SOCK).
      • Added unit tests for the shared shell helper and for desktop macOS/no-op/regression behavior.

      Reviewed changes

      Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

      Show a summary per file
      FileDescription
      packages/shared/src/shell.tsAdds multi-variable login-shell environment capture/extraction and reimplements readPathFromLoginShell on top of it.
      packages/shared/src/shell.test.tsUpdates PATH probe test markers and adds tests for multi-variable extraction behavior.
      apps/desktop/src/syncShellEnvironment.tsNew macOS-only startup hook to sync PATH and backfill missing SSH_AUTH_SOCK.
      apps/desktop/src/syncShellEnvironment.test.tsAdds tests for macOS hydration, preservation of inherited SSH_AUTH_SOCK, omission behavior, and non-macOS no-op.
      apps/desktop/src/main.tsSwitches startup hook from fixPath() to syncShellEnvironment().
      apps/desktop/src/fixPath.tsRemoves the previous desktop-only PATH fix implementation.

      💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

    4. Can confirm this fixed git over ssh for me cc @juliusmarminge

    5. juliusmarminge reviewed

    6. The Electron app fixes its env first and the bundled backend inherits that via ...process.env when spawned so the desktop path is covered

    7. os-jank.ts and the Linux report in #971 might be follow up scope

    8. juliusmarminge merged this765c1dc

    9. juliusmarminge closed this

Sign in to join this conversation.