Skip to content

Commit 6f96d0e

Browse files
saphidclaude
andauthored
fix(cli): t3 pair's no-running-server hint keeps --base-dir (pingdotgg#30689)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 8b9a954 commit 6f96d0e

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

‎apps/server/src/cli/pair.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
persistServerRuntimeState,
3535
type PersistedServerRuntimeState,
3636
} from "../serverRuntimeState.ts";
37+
import { resolveHostCliCommand } from "./invocation.ts";
3738
import { DevServerNotProxiableError, resolveTailscaleLocalTarget } from "./pair.ts";
3839

3940
import packageJson from "../../package.json" with { type: "json" };
@@ -315,7 +316,7 @@ describe("t3 pair", () => {
315316
it.effect("ignores runtime state whose recorded pid is no longer alive", () =>
316317
withDescriptorServer((origin) =>
317318
Effect.gen(function* () {
318-
const baseDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3-pair-pid-test-"));
319+
const baseDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "t3 pair pid test-"));
319320
const statePath = NodePath.join(baseDir, "userdata", "server-runtime.json");
320321
const state = yield* makePersistedServerRuntimeState({
321322
config: { host: "127.0.0.1", devUrl: undefined },
@@ -334,6 +335,10 @@ describe("t3 pair", () => {
334335
typeof error === "object" && error !== null && "cause" in error ? error.cause : error,
335336
);
336337
assert.include(rendered, "No running T3 Code server found.");
338+
for (const subcommand of ["serve", "connect"]) {
339+
const { command } = yield* resolveHostCliCommand(subcommand, ["--base-dir", baseDir]);
340+
assert.include(rendered, `\`${command}\``);
341+
}
337342
}),
338343
).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))),
339344
);

‎apps/server/src/cli/pair.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ import {
4848
} from "../startupAccess.ts";
4949
import { authScopesFlag } from "./authScopes.ts";
5050
import { baseDirFlag, DurationFromString } from "./config.ts";
51+
import { resolveHostCliCommand } from "./invocation.ts";
5152

5253
const WELL_KNOWN_ENVIRONMENT_PATH = "/.well-known/t3/environment";
5354
const PAIR_PROBE_TIMEOUT = Duration.millis(2_500);
@@ -65,6 +66,8 @@ export class NoRunningServerError extends Schema.TaggedError<NoRunningServerErro
6566
{
6667
checkedStatePaths: Schema.Array(Schema.String),
6768
inLinkedWorktree: Schema.Boolean,
69+
serveCommand: Schema.String,
70+
connectCommand: Schema.String,
6871
},
6972
) {
7073
override get message(): string {
@@ -74,7 +77,7 @@ export class NoRunningServerError extends Schema.TaggedError<NoRunningServerErro
7477
...(this.inLinkedWorktree
7578
? ["In a linked worktree, pass --base-dir to pair with a server outside it."]
7679
: []),
77-
"Start one with `npx t3 serve`, or connect this machine with T3 Connect: `npx t3 connect`.",
80+
`Start one with \`${this.serveCommand}\`, or connect this machine with T3 Connect: \`${this.connectCommand}\`.`,
7881
].join("\n");
7982
}
8083
}
@@ -245,7 +248,8 @@ const discoverPairTarget = Effect.fn("pair.discoverPairTarget")(function* (
245248
) {
246249
const bases: Array<string> = [];
247250
let inLinkedWorktree = false;
248-
if (explicitBaseDir !== undefined && explicitBaseDir.trim().length > 0) {
251+
const hasExplicitBaseDir = explicitBaseDir !== undefined && explicitBaseDir.trim().length > 0;
252+
if (hasExplicitBaseDir) {
249253
bases.push(yield* resolveBaseDir(explicitBaseDir));
250254
} else {
251255
// Same precedence as dev-runner: inside a linked worktree only its own
@@ -292,7 +296,13 @@ const discoverPairTarget = Effect.fn("pair.discoverPairTarget")(function* (
292296
} satisfies DiscoveredPairTarget;
293297
}
294298
}
295-
return yield* new NoRunningServerError({ checkedStatePaths, inLinkedWorktree });
299+
const baseDirArgs = hasExplicitBaseDir ? ["--base-dir", explicitBaseDir] : [];
300+
return yield* new NoRunningServerError({
301+
checkedStatePaths,
302+
inLinkedWorktree,
303+
serveCommand: (yield* resolveHostCliCommand("serve", baseDirArgs)).command,
304+
connectCommand: (yield* resolveHostCliCommand("connect", baseDirArgs)).command,
305+
});
296306
});
297307

298308
/** Use the discovered state directory, independent of ambient config variables. */

0 commit comments

Comments
 (0)