fix(cli): keep --base-dir in the sudo command browser setup prints #23646
main fromrefs/pull/23646/head·merged by maria-rcks View on GitHubProblem#
On Linux, t3 browser setup without root checks T3's browser and prints a sudo command to finish the job. With --base-dir <dir>, it checks the browser under <dir>, but the command it prints drops the flag:
This needs root. Run:
sudo t3 browser setup
The root run then looks for the browser in the default ~/.t3 instead. T3CODE_HOME has the same gap, because sudo resets the environment by default. If no browser is there, setup finds no missing libraries and skips installing them, so the browser under <dir> still fails to start.
Change#
resolveRootCliCommandtakes an optional argument list and passes it toresolveHostCliCommand, which already quotes arguments for the host's shell. Thesudo env "PATH=$PATH"and absolute-launcher forms are unchanged.browser setupresolves its home once, uses it for the browser check, and passes--base-dir <home>to the printed command when the user chose a home with--base-dirorT3CODE_HOME. Without either, the command is the same as before.
DatabaseStorage already passes --base-dir <home> to resolveHostCliCommand for its t3 doctor command, so this follows that pattern.
Scope and approval#
No issue. This is a very small, focused fix of an obvious bug: the command setup tells the user to run checks a different directory from the one it just checked. It changes no package choices, privilege checks or setup steps. No open PR changes resolveRootCliCommand or cli/browser.ts.
Verification#
New test in invocation.test.ts: resolveRootCliCommand keeps its arguments, quoted, for a user-installed Node (sudo env "PATH=$PATH" t3 ...) and for an absolute launcher, using a home with a space.
vp test run apps/server/src/cli/invocation.test.ts
It fails on main, where the arguments are dropped, and passes on this branch:

I also ran the real CLI on Linux, built with vp pack from main and from this branch. Fonts were hidden in a mount namespace (bwrap --tmpfs /etc/fonts --tmpfs /usr/share/fonts), so setup had something to fix and printed its root command. Nothing ran as root. On main, all three runs print sudo t3 browser setup. On this branch, the --base-dir and T3CODE_HOME runs keep the home, and the run with neither prints the same command as before.

Other checks on this branch: tsc --noEmit in apps/server, vp lint and vp fmt --check on the changed files all pass.
Not checked:
- Running the printed command as root. It would install packages, so I did not run it. Given
--base-dir, setup uses that directory and skips its fallback to the sudo user's home. - The setup command shown by the server when its browser fails to start (
ServerBrowser.ts,HtmlRender.ts). Those messages also callresolveRootCliCommandwithout a home. This PR leaves them alone.
Prior PRs#
No earlier PR makes this change. adrilasar's #17570 added the font check and install to this command, and mxdhavgautam's #19846 added its warning for a root account. Both are merged; this builds on them and reuses no code from other PRs.
Production fix, tests, PR description and images written with Claude Opus 5.5 in T3 Code Nightly.
🤖 Generated with Claude Opus 5.5 in T3 Code Nightly
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
b208108Macroscope's review found this PR approvable — This focused CLI fix preserves the existing default command while carrying an explicitly selected base directory through sudo setup. The argument propagation is small, isolated, and covered by quoting tests for both launcher forms.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: f054d1b
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
467768aa-1aee-40e9-b43b-285df89e425c
📥 Commits
-
Reviewing files that changed from the base of the PR and between f054d1b8018721bd997d99cbb918a7b17bf098a4 and b20810863221ed3fbd14d48a29639ede49c0c8a1.
📒 Files selected for processing: 3
-
apps/server/src/cli/browser.tsapps/server/src/cli/invocation.test.tsapps/server/src/cli/invocation.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
-
📝 Walkthrough
-
The browser setup handler passes the resolved base directory to the root setup command when a base directory is specified or
T3CODE_HOMEis set. The root CLI resolver now forwards optional arguments, and tests verify argument preservation and quoting.Changes: Browser setup command
Layer / File(s) Summary Forward base-directory arguments
apps/server/src/cli/invocation.ts,apps/server/src/cli/browser.ts,apps/server/src/cli/invocation.test.tsThe root CLI resolver accepts and forwards optional arguments. The browser setup handler adds --base-dirwhen a base directory is specified orT3CODE_HOMEis set. Tests check argument preservation and quoting for both launcher types.Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related issues
- Issue 22626 describes the Linux AppArmor browser setup flow and privileged setup command. This change preserves an explicitly selected
--base-dirfor that command.
Suggested reviewers:
mxdhavgautam,juliusmarminge - Issue 22626 describes the Linux AppArmor browser setup flow and privileged setup command. This change preserves an explicitly selected
Merge Risk: ⚪ Minimal · up to
b2081-
The selected base directory is preserved in the privileged browser setup command, with no identified merge-blocking risk.
Pre-merge checks:
4-
Check name Status Explanation Title check The title clearly and concisely describes the main fix: preserving --base-dir in the sudo command printed by browser setup. Description check The description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the bug, implementation, focused scope, test results, manual checks, limitations, and … Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Description check
-
Explanation
The description includes the required Problem, Change, Scope and approval, and Verification sections. It explains the bug, implementation, focused scope, test results, manual checks, limitations, and agent usage.
-
✨ Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
Note
Written by
gpt-6.1-solon behalf of MariaVerified in a real dev environment#
verified unchanged head
b20810863221ed3fbd14d48a29639ede49c0c8a1on this Linux Boat VM. no code changes were needed.- reproduced on
github/main(32ecd71726) in a separate worktree aftervp i: an explicit home with spaces was dropped from the sudo command. - installed the exact PR head and ran
vp run dev --home-dir '/home/user/browser verification'in the background. only one task dev server ran at a time. - used repo Playwright and
/usr/bin/google-chrometo pair, create the realpr23646-browser-checkgit project, and send real Codexgpt-6.1-solturns. the provider checked the project, opened example.com through T3's browser tools, returnedExample Domain, and closed its background tab. checked the actual browser tool output in the client. - ran the setup comparison in the app's terminal. fonts were hidden only inside a read-only
bwrapmount namespace to trigger the real setup path. no mocked commands, fixtures, or demo data. --base-dirandT3CODE_HOMEboth preserve the resolved home. an explicit flag overrides a conflicting environment value, relative paths become absolute, and the command without either home selection remains unchanged.- ran the printed sudo command using a temporary
t3launcher pointing at this checkout's realsrc/bin.ts. it returnedThis host is ready for T3's browser.separately confirmed withstracethat root executed the real browser installed under/home/user/browser verification/tools/chrome-headless-shell/..., rather than root's default home. - blacksmith:
vp run check:changedpassed format, lint, knip, GraphQL, affected typechecks, and all eight CLI tests. existing CI has 21 successful and seven skipped checks, with no failures.
short command transcript (same home and font namespace):
$ timeout 60 bwrap --ro-bind / / --tmpfs /etc/fonts --tmpfs /usr/share/fonts \ node <checkout>/apps/server/src/bin.ts browser setup \ --base-dir '/home/user/browser verification' main prints: sudo env "PATH=$PATH" t3 browser setup PR prints: sudo env "PATH=$PATH" t3 browser setup --base-dir '/home/user/browser verification' PR with T3CODE_HOME only prints the same explicit --base-dir. PR with neither setting prints the original command without --base-dir.

Not verified#
- installing genuinely absent system packages or changing AppArmor policy: this VM already has the browser's libraries, fonts, and sandbox support. the root directory selection and healthy-browser path were exercised; package installation was not.
- native desktop, iOS/Android, macOS/Windows, and relay/tunnel connections were not exercised. this change is Linux CLI behavior; the web client and real Codex provider path were exercised.
- distribution through a newly packaged npm or standalone executable was not exercised; runtime verification used the checked-out source entrypoint.
- reproduced on
maria-rcks merged thiscf93019
maria-rcks closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes