Repository navigation
Conversation
added 11 commits
October 30, 2026 09:14
Projects that provide their toolchain through direnv (Nix dev shells, devenv, mise) only worked in integrated terminals: agents never go through a shell, so they ran without the project's tools. Before a provider process starts, ProviderSessionManagerV2 loads the `.envrc` governing the session's cwd, as a shell with the direnv hook would, and the Codex, Claude, OpenCode, Pi, Grok, ACP registry and Antigravity adapters apply it to their launch environment. Trust stays with direnv: only `.envrc` files approved with `direnv allow` are loaded. A blocked or failing one becomes a system notice on the run and the agent starts without it. Cursor runs in-process through its SDK, which takes no environment, and OpenCode 2 shares one server across all of an instance's projects, so both are left out. Every turn reopens its session, so that is where the shell hook's staleness check runs: direnv compares the files it watches against the environment the process started with, and when the user allowed or edited the `.envrc`, or `flake.lock` changed, an idle session the thread owns alone is released and reopened with the new environment. The native thread resumes as it does after an idle release. A busy or shared session keeps its environment until it idles. A blocked `.envrc` notice offers "Allow .envrc" on web and mobile, backed by a `projectEnvironment.allowDirenv` RPC that resolves the directory from the thread. The behavior is on by default and can be turned off per environment or project with "Load direnv environment".
Allowing a project's .envrc is guarded by the orchestration operate grant, but the web and mobile buttons showed for every client, so a read-only session only learned it couldn't act after clicking. The buttons now read the command's permission for the thread's environment and stay hidden without the grant; the warning itself still shows.
A direnv environment can remove variables, such as a toolchain path an .envrc replaces, so a terminal launch needs a way to drop inherited keys, and a change to them counts as a new launch.
The registry resolved the agent binary before the direnv environment was applied, so tools the project provides through its .envrc were not found. Apply it first, and keep the process environment's own variables on top.
One provider process carries one environment, so sharing a Codex app-server across projects would give every project the first one's direnv environment. Derive the shared session per project; threads with a stored session id keep it.
Loading only .envrc files allowed from a shell left every new worktree blocked until a setup script ran direnv allow, which competes with the project's own setup script. T3 Code now asks once per project and per .envrc content, records the approval, and writes direnv's allow record for the exact content reviewed in each checkout it loads. A change asks again with a diff unless the project trusts changes, a direnv deny is never overridden, and an .envrc too large to show cannot be approved in the app. Agent sessions pick up an approved change by restarting, but only while the whole session is idle, so turns and background work in threads sharing the process are never cut off.
A new Load direnv environment setup stage evaluates the worktree's approved .envrc before the setup script, so projects no longer need a direnv allow setup script. A failure is shown on the stage and setup continues.
…is on A banner above the composer shows the .envrc, or the diff of a change, to approve, turn off, or put off. The thread details panel shows On, Off or Needs approval when the project has one, and Settings > Worktrees holds the project's direnv and trust-changes settings.
The new task and thread screens show the same approval banner as the web, and the worktrees settings page gains the project's direnv and trust-changes settings.
Muse launches its own process but was the one process-based provider still started without the thread's direnv environment, so tools a project provides through its .envrc were missing.
Collaborator
|
Note Written by the prior-approval rule applies to this new project environment workflow. the draft adds in-app .envrc approval and trust, automatic loading, idle restart behavior and project-scoped Codex sessions. its scope section says maintainer approval is still pending. the maintainer note in #6715 preserves automatic activation as a requirement; it does not approve this implementation's trust and lifecycle choices. draft status does not postpone triage. see prior approval. obtain and link explicit approval for direction and scope, including those choices, before resubmitting. the underlying missing project toolchain remains recorded in #6715. |
|
Seriously ??? How should we actually use t3-code without this ? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Projects that provide their toolchain through direnv (
use flake, devenv,use mise) only work in T3 terminals, where the shell hook runs. Providers are never launched through a shell, so agents start without the project'sPATH, compilers and pinned runtimes, and worktree setup scripts can't see the project environment either. Today the workaround is adirenv allowsetup script in every worktree, which competes with the project's ownrunOnWorktreeCreate.Change
T3 asks once per project to approve its
.envrc, then loads it automatically on the server host:.envrcand asks. An approval is bound to the file's path and content; T3 writes direnv's own allow record, so new worktrees with matching content are allowed without asking. A changed.envrcasks again with a diff.direnv denyis never overridden, files over 64 KiB are refused, and agents can't approve. Approving needs the operate grant.@cursor/sdk) and Windows are not supported. Codex runs one shared process per project, since one process can carry only one environment..envrcstarts the session with the normal environment and shows one notice with a "Review .envrc" action.Out of scope: static per-project variables, git commands the server runs itself (commit hooks), terminals and previews, and environment managers without direnv.
Scope and approval
Proposed in #6715 (October 7 proposal, revised design). Maintainer approval of direction and scope is still pending; this is a draft so the full change can be reviewed alongside the discussion. The open questions for maintainers are listed in the revised design comment.
Verification
.envrcvariables.First
.envrcin a projectApproving it (MP4)
A changed
.envrcshows a diffA new worktree's setup script sees the environment
Settings → Worktrees
Not yet captured: mobile and desktop.
Done with Claude Opus 5.5 in T3 Code (Claude Code harness).