Skip to content

fix: hydrate devcontainer ssh agent socket#3068

Open
boblangley wants to merge 2 commits into
pingdotgg:mainfrom
boblangley:fix/devcontainer-ssh-auth-sock
Open

fix: hydrate devcontainer ssh agent socket#3068
boblangley wants to merge 2 commits into
pingdotgg:mainfrom
boblangley:fix/devcontainer-ssh-auth-sock

Conversation

@boblangley

@boblangley boblangley commented Jun 13, 2026

Copy link
Copy Markdown

What Changed

Fix terminal PTY environment hydration for devcontainers by resolving a usable SSH_AUTH_SOCK when spawning terminal sessions.

The change:

  • Keeps a valid inherited SSH_AUTH_SOCK
  • Falls back to the newest same-user VS Code forwarded socket at /tmp/vscode-ssh-auth-*.sock
  • Preserves explicit runtime env overrides
  • Adds focused tests for resolver behavior and terminal spawn env behavior

Why

Fixes #3067.

When the T3 Code server starts before VS Code attaches to a devcontainer, the server process does not inherit VS Code’s later-injected forwarded SSH agent environment. Terminals spawned by that server therefore miss SSH_AUTH_SOCK, even though the forwarded socket exists and works in normal VS Code terminals.

Resolving the socket at terminal spawn time makes server-started terminals match the attached devcontainer environment without requiring a server restart.

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

Low Risk
Scoped to terminal spawn env and SSH agent socket discovery; behavior change is intentional (stale sockets dropped) with solid unit coverage.

Overview
Fixes devcontainer terminals missing SSH agent forwarding when the server starts before VS Code injects SSH_AUTH_SOCK.

Adds resolveSshAuthSock in shared (@t3tools/shared/sshAgent): on POSIX, reuse a valid same-user inherited socket or pick the newest matching VS Code forwarded socket under temp//tmp; on Windows, only accept OpenSSH named pipes. createTerminalSpawnEnv no longer copies SSH_AUTH_SOCK from the server process—it sets it via the resolver (defaulting to resolveSshAuthSock), and runtime open env can still override. TerminalManager wires an injectable sshAuthSockResolver for tests.

Reviewed by Cursor Bugbot for commit 6042f22. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix SSH agent socket resolution in devcontainer terminals

  • Adds resolveSshAuthSock in packages/shared/src/sshAgent.ts to compute a valid SSH_AUTH_SOCK path: on POSIX it validates the inherited socket by type/uid or falls back to scanning temp directories for VS Code forwarded sockets; on Windows it only accepts named pipe values.
  • createTerminalSpawnEnv in apps/server/src/terminal/Manager.ts now strips the inherited SSH_AUTH_SOCK and replaces it using the resolver, preventing stale or inaccessible socket paths from propagating into terminal processes.
  • runtimeEnv values still override the resolved socket, preserving existing override behavior.
  • Behavioral Change: SSH_AUTH_SOCK is no longer passed through from the base environment; it is always re-resolved unless explicitly set via runtimeEnv.

Macroscope summarized 6042f22.

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

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: 36f5d162-05ea-4070-b0e1-59cd6219a98f

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

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 13, 2026
Comment thread packages/shared/src/sshAgent.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

1 blocking correctness issue found. This PR introduces new SSH agent socket discovery and hydration functionality that changes terminal spawn behavior. Combined with an open high-severity review comment about potential Windows compatibility issues, these changes warrant human review.

You can customize Macroscope's approvability policy. Learn more.

@boblangley boblangley force-pushed the fix/devcontainer-ssh-auth-sock branch from ac1daf4 to 70ce9c4 Compare June 14, 2026 21:14
@boblangley boblangley force-pushed the fix/devcontainer-ssh-auth-sock branch from 70ce9c4 to 8a655cb Compare June 27, 2026 04:22

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8a655cb. Configure here.

Comment thread apps/server/src/terminal/Manager.ts
@boblangley

Copy link
Copy Markdown
Author

Rebased the PR.

@boblangley boblangley force-pushed the fix/devcontainer-ssh-auth-sock branch from 8a655cb to c28dfed Compare June 27, 2026 04:35
Comment thread packages/shared/src/sshAgent.ts Outdated
@boblangley boblangley force-pushed the fix/devcontainer-ssh-auth-sock branch from 330c94f to d59d65b Compare June 27, 2026 22:46
Comment thread apps/server/src/terminal/Manager.ts
@boblangley boblangley force-pushed the fix/devcontainer-ssh-auth-sock branch from d59d65b to 6042f22 Compare June 27, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: server-started terminals in devcontainers can miss forwarded SSH_AUTH_SOCK`

1 participant