fix(server): recover the login shell SSH agent #10312
main fromrefs/pull/10312/head·opened View on GitHubProblem#
The Windows desktop WSL backend can start without SSH_AUTH_SOCK even when its login shell exports a working agent. With SSH commit signing enabled, Commit, Commit & push, and Commit, push & PR then fail at the commit step.
Change#
Recover a missing SSH_AUTH_SOCK alongside PATH from the accepted login-shell probe during unprepared Linux/macOS server startup. Preserve an inherited socket, the prepared-environment early return, and PATH/mise hydration.
Scope and approval#
Fixes #5740 GitCafe: https://git.cafe/pingdotgg/t3code/issues/5740 Triaged bug via the automated issue flow. Existing contributor implementation and maintainer takeover retained. Limited to agent sockets exported by the login shell; it does not address #10179.
Verification#
Rechecked during issue triage on October 22:
vp test run apps/server/src/os-jank.test.ts packages/shared/src/shell.test.ts: 63 passed, 1 skipped at the PR head.- Production
fixPathplus real Git SSH signing, using an isolated agent, disposable key and a wrapper shell: current main 3b95e7831b leaves the socket absent and commit exits 128; PR head recovers the socket, commit exits 0, and the commit contains an SSH signature. This is a direct server-startup behavior check, not a Windows/WSL desktop reproduction. - No visible render paths changed; visual fixture matrix is empty. Windows/WSL desktop remains
cannot-verify desktop-wslbecausewsl.exeis unavailable here.
5740-runtime.mjs 5740-runtime-current-main.log 5740-runtime-pr.log
Previously recorded verification follows:
Verification on d189ceac58:
- Replaced the six original hydrator-level cases with a five-row extension of main’s startup test: Linux/macOS recovery, forwarded socket precedence, accepted shell without an agent, and no accepted PATH. Existing HOME/prepared/Windows checks remain; mise also asserts its associated PATH. os-jank cases: 15→13.
- Both recovery cases fail behaviorally against main; focused os-jank/shared-shell suites pass 63 tests with one existing skip. Scoped server typecheck, targeted lint, formatting, and whitespace checks pass.
- Headless Linux proof ran production
fixPaththrough a real login-shell wrapper and two temporary empty SSH agents:
recovery: ssh-add -l exit 2 (no agent) → exit 1 (agent has no identities)
forwarded: inherited second-agent socket preserved
prepared: shell calls=0; existing PATH preserved
PATH and __MISE_DIFF propagation: passed
owned agents stopped; temporary HOME/sockets/wrapper removed
The wrapper avoids user profiles; mise’s record was synthetic. Empty-agent connectivity does not establish key signing, remote Git authentication, or a provider CLI flow. macOS, Windows, iOS, Android, Electron desktop, OrbStack, and WSL were not verified live. No visual UI change; screenshots do not apply.
One independent review round (Claude Opus 5.5 and GPT-6-Sol) found no code blockers. Historical GitHub findings were rechecked against this revision. Windows desktop/WSL remains unverified (cannot-verify desktop-wsl); this Linux VM has no wsl.exe.
Tests: GPT-6-Astra; implementation: GPT-6.1-Sol; adversarial reviews: Claude Opus 5.5 and GPT-6-Sol. T3 Code using the Codex and Claude harnesses.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
- apps/server/src/os-jank.ts lines 31 to 31OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -17,8 +18,14 @@1718 );1819 }192020-function hydratePosixPath(env: NodeJS.ProcessEnv, platform: NodeJS.Platform): void {21+export function hydratePosixEnvironment(22+ env: NodeJS.ProcessEnv,23+ platform: NodeJS.Platform,24+ readShellEnvironment: ShellEnvironmentReader = readEnvironmentFromLoginShell,25+): void {2126 let shellPath: string | undefined;2227 for (const shell of listLoginShellCandidates(platform, env.SHELL)) {2328 try {24- shellPath = readPathFromLoginShell(shell);29+ const shellEnvironment = readShellEnvironment(shell, ["PATH", "SSH_AUTH_SOCK"]);30+ shellPath = shellEnvironment.PATH;31+ if (!env.SSH_AUTH_SOCK && shellEnvironment.SSH_AUTH_SOCK) {
🟠 High
src/os-jank.ts:31A fallback shell's
SSH_AUTH_SOCKis committed even when that shell provides noPATH, so a later shell's selectedPATHcan be paired with the earlier shell's stale agent socket. Only copySSH_AUTH_SOCKwhen the candidate also provides thePATHthat causes it to be accepted.No longer relevant as of 863f077c23fdd9a838e6bf46b9145035e864af4c
Fixed in 863f077c2: the agent socket now comes from the accepted shell, with coverage for a preceding candidate that has no PATH.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.
Approvability#
Verdict: Approved at
5c319d9Macroscope's review found this PR approvable — Restores the login shell’s SSH agent when the server starts without one, while preserving inherited sockets and prepared environments. The change reuses the existing startup probe and does not modify keys or persistent configuration.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Note
This comment is posted by Julius' dot
The reporter in #10179 returned “absent” when the login shell started without SSH_AUTH_SOCK, and this patch reads that same login-shell environment. Can you remove the “Fixes #10179” claim and limit the stated coverage to agents available from the login shell, or provide evidence showing how this path recovers that reporter's socket? The verification requirement calls for evidence matching the claimed fix; #5740 remains a useful, distinct case.
juliusmarminge added labelsmacroscope-review
juliusmarminge assignedjuliusmarminge
Taking over this one. I’m retaining @yashranaway’s login-shell agent recovery, resolving main’s PATH/mise and prepared-environment conflicts, and replacing the test-only hydrator seam with startup behavior coverage. Headless Linux proof uses two isolated SSH agents. Leaving it unmerged for credential-propagation review.
No actionable comments were generated in the recent review.
Walkthrough
-
The login-shell environment probe now requests
SSH_AUTH_SOCK. When a shellPATHis found,hydratePosixPathcopies the socket value only if the existing environment does not have one. A test covers the accepted probe value and preservation of an existing value.Changes: SSH agent environment hydration
Layer / File(s) Summary Probe and copy SSH_AUTH_SOCK
apps/server/src/os-jank.ts,apps/server/src/os-jank.test.tsThe login-shell lookup now requests SSH_AUTH_SOCK. When a shellPATHis found andenv.SSH_AUTH_SOCKis unset,hydratePosixPathcopies the shell value. The test checks that the accepted probe value is used, the rejected shell value is ignored, and an existing forwarded value is preserved.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
t3dotgg,juliusmarminge
Merge Risk:
Minimal · up to5c319-
The change recovers the login-shell SSH agent socket when the server environment lacks one, and it keeps any inherited socket. No concrete merge-blocking risk was found. Windows/WSL desktop behavior was not verified at runtime.
Pre-merge checks:
3 · 1-
Failed checks: 1 inconclusiveCheck name Status Explanation Resolution Linked Issues check For #5740,hydratePosixPathnow requestsSSH_AUTH_SOCKfrom the accepted login-shell probe and sets it only when the server environment lacks a socket. The added test verifies accepted-shell recov…Provide reviewable evidence for the #5740unavailable-agent error behavior, such as the existing implementation and a focused automated test or an explicit requirement decision that excludes this behavior. Passed checks: 3 passed-
Check name Status Explanation Title check The title clearly and concisely describes the main change: recovering the SSH agent from the login shell during server startup. Description check The description covers the required Problem, Change, Scope and approval, and Verification sections. It explains the affected behavior, implementation scope, linked issue, test results, production veri… Out of Scope Changes check The pull request changes only POSIX startup environment hydration and its test. The changes support #5740by recovering a login-shellSSH_AUTH_SOCKand preserving an inherited socket. No unrelated p…Full details: Description check
-
Explanation
The description covers the required Problem, Change, Scope and approval, and Verification sections. It explains the affected behavior, implementation scope, linked issue, test results, production verification, and remaining Windows/WSL verification limits.
Full details: Out of Scope Changes check
-
Explanation
The pull request changes only POSIX startup environment hydration and its test. The changes support
#5740by recovering a login-shellSSH_AUTH_SOCKand preserving an inherited socket. No unrelated product behavior is present. The stated exclusion of#10179remains within scope.
-
Full details: Linked Issues check
-
Explanation
For
#5740,hydratePosixPathnow requestsSSH_AUTH_SOCKfrom the accepted login-shell probe and sets it only when the server environment lacks a socket. The added test verifies accepted-shell recovery and inherited-socket precedence. The issue also requires actionable Git stderr when the signing agent is unavailable. The reviewed diff adds no error-reporting code or test for that behavior, and the available evidence does not establish whether existing Git error handling already satisfies it.Resolution
Provide reviewable evidence for the
#5740unavailable-agent error behavior, such as the existing implementation and a focused automated test or an explicit requirement decision that excludes this behavior.
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: 362ef9a
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
19feb4ac-2b6a-4939-a46d-287b2871d15e
Commits-
Reviewing files that changed from the base of the PR and between 362ef9a88a18b7f692864409c35c15cc28d7a09e and 5c319d94fce0ff8cf44d85802dbc2ed50d3fe0c4.
Files selected for processing: 2-
apps/server/src/os-jank.test.tsapps/server/src/os-jank.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
-
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:S
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
Takeover complete at d189ceac58. Current-head build, lint, and test jobs pass; skipped jobs remain skipped. No unresolved inline findings. One full independent review round with Claude Opus 5.5 and GPT-6-Sol found no code blockers. The PR body contains the current focused tests, headless proof, original-author credit, and platform limits.
Macroscope correctness passed. Its neutral approvability result explicitly requires human review of login-shell credential propagation. Leaving unmerged.
juliusmarminge added labelsbugfix
juliusmarminge added labelspr:needs-julius
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XS
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Evidence#
The shared POSIX startup/signing behavior reproduces on Linux. Windows desktop launching WSL was not exercised.
On both commits: launch the real server without SSH_AUTH_SOCK, expose a loaded signing agent through its login shell, enable SSH commit signing, modify README.md, and submit the same explicit message through Git action options > Commit.
Before After 
362ef9a88a
5c319d94fcContinuous recording: 29.5 seconds, 885 frames Continuous recording: 18.1 seconds, 543 frames Base creates no commit. Its actual toast exposes a generic Git failure; the subsequent terminal diagnostic shows
Couldn't get agent socket?,failed to write commit object, and exit 128. Head creates synthetic commit646bf98; its terminal shows a good SSH signature andgit verify-commitexit 0.Both recordings are continuous 30 fps captures without splicing, reordering, or speed changes. Stills were extracted from the processed recordings. Only the repository path is masked in the base toast; the terminal error remains visible and untouched.
The inherited-socket guard also passed: the login-shell agent has no identities, the inherited agent contains the signing identity, and the app creates distinct synthetic commit
4626be5, whose signature verifies with exit 0.
Inherited-agent continuous recording · Driver and seed scripts · Supplementary verification transcript
AI-assisted; verified with the tests and tools listed above.
Not shown:
- Windows desktop launching a fresh WSL backend was unavailable on this Linux VM; the captures prove the shared POSIX server path under Linux.
- Commit & push and Commit, push & PR were not exercised; the captured app action is Commit.
- The final paired captures use key:: public-key configuration to require the agent; the file-valued user.signingkey variant was not captured.
tanstack-source added labelsbug
yashranaway(GitHub profile, opens in a new tab) linked this to fix #5740
Note
🤖 Claude Opus 5.5 responding on behalf of Theo
Closing. This PR has been open for more than 3 weeks, and
mainhas moved a long way since then. If the change still matters, open a fresh PR from currentmain.t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed