Skip to content

feat(server): use the selected GitHub login in terminals and agent sessions - #20

Merged
donnes merged 3 commits into
mainfrom
t3code/terminal-gh-user
Sep 26, 2026
Merged

donnes merged 3 commits into
mainfrom
t3code/terminal-gh-user

Conversation

@donnes

@donnes donnes commented Sep 26, 2026

Copy link
Copy Markdown
Collaborator

The GitHub CLI account chosen in Settings → Source Control only applied to T3 Code's own gh commands. Terminals and agent sessions used gh's globally active login, so an agent running gh pr create could act as the wrong account. Switching with gh auth switch elsewhere also changed it mid-task, because that rewrites one config file shared by every process.

Fix

  • GitHubCliAccountEnvironment in sourceControl/GitHubCliAccountSelection.ts resolves the checkout's selected login, reads its token with gh auth token --user (cached for 1 minute), and returns it as GH_TOKEN/GITHUB_TOKEN, or the enterprise variables for GHES hosts. The active login is never switched, so multiple terminals, agents and T3 instances can use different accounts at once.
  • Terminals merge it into the shell environment at spawn.
  • Every provider adapter merges it into its per-session process environment: Claude, Codex, Cursor, Grok, OpenCode and Antigravity. An OpenCode server reached by serverUrl keeps its own environment, because T3 doesn't start it.
  • If the selected login can't be read, the process starts with gh's active login and a warning is logged. T3's own GitHub actions still fail closed.
  • User docs updated. They previously said terminals were unaffected.

Changing the selection applies to terminals and sessions started afterwards.

Tests

  • New: token-lookup behavior (github.com vs enterprise hosts, signed-out fallback, caching).
  • New: terminal spawn env.
  • Existing adapter, terminal and source-control suites pass.
  • AntigravityAdapter.test.ts › serves client file reads and writes only inside the session roots fails identically on main on macOS (a /var vs /private/var temp-path mismatch) and is unrelated.

Done with Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Sep 26, 2026
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.6 KiB 13.5 KiB −58 B (−0.4%) 15.1 KiB ✅
Codex Thread snapshot wire 7.1 KiB 7.1 KiB −10 B (−0.1%) 7.3 KiB ✅
Codex Live turn WebSocket wire 6.5 KiB 6.4 KiB −48 B (−0.7%) 7.8 KiB ✅
Codex Live turn WebSocket decoded 56.3 KiB 56.2 KiB −44 B (−0.1%) 66.4 KiB ✅
Codex Live turn messages 10 9 −1 (−10.0%) 21 ✅
Claude Total thread wire 13.5 KiB 13.5 KiB +17 B (+0.1%) 15.1 KiB ✅
Claude Thread snapshot wire 7.1 KiB 7.1 KiB +9 B (+0.1%) 7.3 KiB ✅
Claude Live turn WebSocket wire 6.4 KiB 6.4 KiB +8 B (+0.1%) 7.8 KiB ✅
Claude Live turn WebSocket decoded 57.0 KiB 57.0 KiB 0 B (0.0%) 66.4 KiB ✅
Claude Live turn messages 9 9 0 (0.0%) 21 ✅

Baseline: 1c70739 · PR result: 9ffba12 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 114.0 KiB
  • Claude decoded thread snapshot: 114.7 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@donnes donnes left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewed all 15 changed files at 6b350b7. No verified correctness bugs or blocking findings. Two nonblocking test suggestions are attached inline.

Validation: 512 tests passed across nine focused suites covering account selection, terminal management, all six provider adapters, and GitHub CLI behavior. Server typecheck and diff whitespace checks passed.

Reviewed with GPT-6-Astra through the Codex harness in T3 Code.

Comment thread apps/server/src/provider/Layers/CodexAdapter.ts
Comment thread apps/server/src/sourceControl/GitHubCliAccountSelection.test.ts
donnes and others added 2 commits September 26, 2026 15:50
…ransitions

Each provider adapter now has a test proving the selected login's token
reaches its process over an ambient token, including Codex's MCP merge
and the Antigravity driver handoff. The account environment test covers
selection changes, the one-minute token expiry on the test clock, and
retrying after a failed lookup.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
# Conflicts:
#	apps/server/src/provider/Layers/AntigravityAdapter.ts
@donnes
donnes merged commit 65c1716 into main Sep 26, 2026
18 checks passed
@donnes
donnes deleted the t3code/terminal-gh-user branch September 26, 2026 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant