Skip to content

fix(cli): t3 connect and t3 service hints keep --base-dir - #31906

Open
spoukyii wants to merge 2 commits into
pingdotgg:mainfrom
spoukyii:users/spoukyii/connect-service-hints-base-dir
Open

spoukyii wants to merge 2 commits into
pingdotgg:mainfrom
spoukyii:users/spoukyii/connect-service-hints-base-dir

Conversation

@spoukyii

@spoukyii spoukyii commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Problem

t3 connect status|link|publish --base-dir <dir> and t3 service status|install --base-dir <dir> print next steps without --base-dir, such as "Run t3 connect link to authorize and enable T3 Connect.", "Next: Run t3 service install." and "Run t3 up to choose how your other devices reach it." Copied as printed, each one acts on the default ~/.t3 home instead of <dir>: the first links the wrong environment, and the second installs a service that serves ~/.t3.

Change

apps/server/src/cli/invocation.ts gets resolveHostCliHint(subcommand, baseDir, args) next to resolveHostCliCommand. It puts --base-dir <dir> first when the caller passed one, then any other arguments, which is the order t3 up uses (#29684, #30480) and #31878 keeps. Both commands build their hints through it:

  • t3 connect status: its three "Run t3 connect link" next steps, and the "t3 service status" line shown when no server answers the reachability check. formatCloudStatus takes the two resolved commands instead of hard-coding them.
  • t3 connect link: "Start the server with t3 serve", which used resolveCliCommand("serve") and so never carried arguments.
  • t3 connect publish: "Run t3 connect login first".
  • t3 service status: the "not installed" and "repair it" next steps, and the "newer than this CLI" next step (t3 update --base-dir <dir> <version>, plus the t3 service install it names for --allow-downgrade). formatServiceStatus takes the resolved commands and stays a pure formatter.
  • t3 service install: "Run t3 up to choose how your other devices reach it." after a first install.

Like the t3 up and t3 pair hints, these now also print the runner form (npx t3@… connect link) or this install's launcher when that is how the CLI ran. Run as plain t3 with no --base-dir, the text is unchanged. Every command named takes --base-dir, and t3 update accepts it ahead of its version argument.

Scope and approval

This is the follow-up #29684 ("t3 up's pairing hint keeps --base-dir") named and left out: "the hints in t3 service/t3 connect are not changed". It is the same defect with the same fix, in printed hints only, with no contract, setting or other behaviour change. That makes it a small, focused fix for an obvious bug. #31878 does the same for the rest of t3 up and t3 status. The two PRs touch different lines of invocation.ts and merge cleanly.

Not changed here:

  • "Memory protection: off … Run t3 service protect". t3 service protect acts on the unit path the service manager reports, which does not depend on --base-dir, so the bare command is correct.
  • t3 service protect's own messages and the deprecated t3 service update message. These describe follow-ups, not the next step to run.
  • t3 connect unlink and t3 connect logout still print a bare "Run t3 connect unlink again" or "run t3 connect login and retry" from disconnectCloud, and waitForReachability prints "run t3 service status, then t3 connect status". The first two print only when the relay can't be reached or you are signed out. Fixing them needs a baseDir option on disconnectCloud and waitForReachability, plus new arguments at their up.ts call sites, so they are left for a follow-up. No open PR covers them.

Open PRs on these files:

Verification

apps/server/src/cli/connect.test.ts gets one it.effect.each table with two rows. They run the real CLI (makeCli) as t3 connect status --base-dir <tmp> and t3 connect publish --base-dir <tmp> against an empty temp home. That home is unauthorized, so status prints the "Run t3 connect link" next step and publish prints the "Run t3 connect login first" hint.

apps/server/src/cli/service.test.ts extends the existing install table ("install keeps $label off the local network only when it is new") to also check the t3 up hint. Its two rows that install a new service expect the hint with --base-dir, and the older-service row expects none. A new two-row table runs t3 service status --base-dir <tmp> against the stub BootService the other rows use, once for a missing service and once for a newer one (999.0.0).

Each expected command is resolveHostCliCommand(<hint>, ["--base-dir", <tmp>, ...args]), as pair.test.ts does for its hints. The expected text therefore follows the platform's quoting, and the rows behave the same on Windows and on CI's Ubuntu.

On main with only the test commit, vp test run src/cli/connect.test.ts src/cli/service.test.ts from apps/server:

× install keeps a new service off the local network only when it is new
× install keeps a set host off the local network only when it is new
× status of a missing service names its next step with --base-dir
× status of a newer service names its next step with --base-dir
× t3 connect status names `t3 connect link` with --base-dir
× t3 connect publish names `t3 connect login` with --base-dir
AssertionError: expected 'T3 Code service\n  Status: not instal…' to contain 'Next: Run `t3 service install "--base…'
AssertionError: expected 'T3 Code service\n  Status: installed …' to contain 'Next: Run `t3 update "--base-dir" "C:…'
AssertionError: expected '[16:00:00.000] INFO (#51):\nMigration…' to include '`t3 connect link "--base-dir" "C:\Use…'
Tests  6 failed | 14 passed (20)

With the fix: Tests 20 passed (20).

I ran these rows again the way CI does, with two uncommitted test edits: HostProcess.Platform set to linux and the temp baseDir written with forward slashes. On main all six failed, expecting POSIX-quoted hints such as `t3 connect link --base-dir C:/Users/…` and `t3 update --base-dir C:/Us…`. With the fix all seven filtered rows passed, including the older-service row.

Runtime transcript, from apps/server, with an empty temp home. Placeholder T3CODE_RELAY_URL, T3CODE_CLERK_PUBLISHABLE_KEY and T3CODE_CLERK_CLI_OAUTH_CLIENT_ID are set so that the connect command is registered. Both commands read only the temp home's state, and nothing reaches the network:

$ node src/bin.ts connect status --base-dir C:/Users/…/Temp/t3-connect-demo-YYnM
main:   Next: Run `t3 connect link` to authorize and enable T3 Connect.
branch: Next: Run `t3 connect link "--base-dir" "C:/Users/…/Temp/t3-connect-demo-YYnM"` to authorize and enable T3 Connect.

$ node src/bin.ts connect publish --base-dir C:/Users/…/Temp/t3-connect-demo-YYnM
main:   Run `t3 connect login` first so this environment can be authorized to publish.
branch: Run `t3 connect login "--base-dir" "C:/Users/…/Temp/t3-connect-demo-YYnM"` first so this environment can be authorized to publish.

The quoting is PowerShell's because this ran on Windows.

vp run check:changed: format, lint, knip, graphql and typecheck pass. The test step passes for every changed file except invocation.test.ts, where two cases fail ("requires the npm prefix's bin to point to the running package" and "proves the downloaded executable was started by a global npm launcher"). They fail the same way on main on Windows: realPath returns backslashes that the npm-global pattern doesn't match, so runner detection sees the test's bunx-tools folder. Both cases use Linux paths, and CI runs on Ubuntu.

Not checked:

  • No runtime transcript for the t3 service hints. The background service exists only on Linux with systemd and macOS with launchd, and on Windows t3 service status prints "unavailable on this machine" before any hint. The rows above run the real command handlers with only BootService stubbed.
  • The t3 connect link serve hint and the status "t3 service status" line were not seen at runtime. The first needs a real T3 Connect sign-in in a browser, and the second a linked environment whose server is down.
  • The "repair it" hint has no row of its own.

All of these go through the same resolveHostCliHint call as the tested hints.

Bug: t3 connect's next-step hints drop --base-dir
Bug: t3 service's next-step hints drop --base-dir

This was written with Claude Opus 5.5 in Claude Code, driven from T3 Code.

`t3 connect status`, `link` and `publish` printed their next steps as
bare `t3 connect link`, `t3 service status`, `t3 serve` and
`t3 connect login`, and `t3 service status` and `install` printed bare
`t3 service install`, `t3 update <version>` and `t3 up`. Run with
`--base-dir <dir>`, each printed command then acted on the default home
instead of <dir>, so following "Run `t3 service install`" installed a
service for ~/.t3.

A new `resolveHostCliHint` next to `resolveHostCliCommand` puts the
caller's `--base-dir` first, as `t3 up` already does, and both commands
build their hints through it. They also print the runner or launcher
form when that is how the CLI ran. Without `--base-dir` and run as plain
`t3`, the text is unchanged.

Bug: t3 connect's next-step hints drop --base-dir
Bug: t3 service's next-step hints drop --base-dir
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 6, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at d637d2b

Macroscope's review found this PR approvable — Connect and service command hints now preserve explicit --base-dir values and use the appropriate host launcher. The changes affect printed guidance only, reusing existing shell quoting without changing operational behavior or defaults.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Connect and service CLI guidance now resolves host-aware command hints. When a base directory is supplied, the hints preserve it. Tests verify the commands shown in Connect and service output.

Changes: Host-aware CLI hints

Layer / File(s) Summary
Hint resolution and Connect guidance
apps/server/src/cli/invocation.ts, apps/server/src/cli/connect.ts, apps/server/src/cli/connect.test.ts
A new resolver builds host CLI hints with an optional --base-dir and additional arguments. Connect link, status, and publish guidance uses resolved hints. Tests check the status and publish suggestions with a base directory.
Service guidance
apps/server/src/cli/service.ts, apps/server/src/cli/service.test.ts
Service install and status messages use resolved host CLI hints. Tests cover the suggested up, install, and update commands, including the installed-version argument for update.

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

  • pingdotgg/t3code#27996: That PR adds the t3 up instruction after service installation; this PR updates the instruction to preserve the base directory and host launcher.
  • pingdotgg/t3code#31878: Both PRs update CLI hints to retain base-directory and launcher information. That PR covers t3 up and t3 status; this PR covers Connect and service commands.

Suggested labels: bugfix

Suggested reviewers: only21mil, marcodotio

Merge Risk: Minimal · up to d637d

The command hints appear ready to merge after normal checks; no actionable risk was established.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title clearly identifies the affected commands and the --base-dir hint fix.
Description check Passed The description covers the problem, change, scope, and verification. It reports test results, existing failures, and checks not performed.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
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

Commits

Reviewing files that changed from the base of the PR and between 202d5b5 and d637d2b.

Files selected for processing: 5

  • apps/server/src/cli/connect.test.ts
  • apps/server/src/cli/connect.ts
  • apps/server/src/cli/invocation.ts
  • apps/server/src/cli/service.test.ts
  • apps/server/src/cli/service.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 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.

1 participant