The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 12:15 UTC
fix(cli): t3 up and t3 status hints keep --base-dir (#31878)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
spoukyii committed
Nov 14, 2026 at 21:00 UTC
eefba1a8af92c3933673987f5443f45096dda3ce
3 files changed
+61
-26
apps/server/src/cli/invocation.ts
+2
-1
@@ -185,7 +185,8 @@ export const resolveHostCliCommand = Effect.fn("invocation.resolveHostCliCommand
185
) {
186
const platform = yield* HostProcess.Platform;
187
const withArgs = (prefix: string) =>
188
- [prefix, ...args.map((arg) => hostShellWord(platform, arg))].join(" ");
188
+ // An empty subcommand names the root `t3` command.
189
+ [prefix.trimEnd(), ...args.map((arg) => hostShellWord(platform, arg))].join(" ");
190
const command = yield* resolveCliCommand(subcommand);
191
if (command !== `t3 ${subcommand}`) return { command: withArgs(command), launcher: false };
192
const onPath = yield* resolveCommandPath("t3");
apps/server/src/cli/up.test.ts
+23
-7
@@ -166,7 +166,8 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer))
166
readonly reportStatus?: boolean;
167
/** Runs as if in a terminal, answering each question with this text. */
168
readonly answer?: string;
169
- readonly prints?: string;
169
+ /** Lines the run prints, with `<baseDir>` standing for the test's home. */
170
+ readonly prints?: ReadonlyArray<string>;
171
readonly omits?: string;
172
readonly json?: object;
173
readonly env: string;
@@ -186,7 +187,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer))
187
},
188
{
189
label: "the local network opens",
189
- prints: "Run `t3 pair --base-dir <baseDir>`.",
190
+ prints: ["Run `t3 pair --base-dir <baseDir>`."],
191
installed: true,
192
env: "T3CODE_LAN=false\n",
193
args: ["--lan"],
@@ -205,6 +206,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer))
206
},
207
{
208
label: "a route turns off with no service to run",
209
+ prints: ["Run `t3 --base-dir <baseDir>` to use T3 Code here."],
210
installed: false,
211
env: "T3CODE_LAN=true\n",
212
args: ["--no-lan"],
@@ -225,7 +227,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer))
227
{
228
label: "a failed update keeps service.env matching the old service",
229
// The old service still runs, so no foreground server is offered.
228
- prints: "Fix that, then run `t3 up --base-dir <baseDir>` again.",
230
+ prints: ["Fix that, then run `t3 up --base-dir <baseDir>` again."],
231
installed: true,
232
status: { current: false },
233
installFails: true,
@@ -283,12 +285,26 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer))
285
restarts: 0,
286
envAfter: "",
287
},
288
+ {
289
+ label: "status hints keep the caller's --base-dir",
290
+ installed: true,
291
+ reportStatus: true,
292
+ prints: [
293
+ "Turn it off: `t3 up --base-dir <baseDir> --no-lan`.",
294
+ "Change access: `t3 up --base-dir <baseDir>`.",
295
+ ],
296
+ env: "",
297
+ args: [],
298
+ installs: 0,
299
+ restarts: 0,
300
+ envAfter: "",
301
+ },
302
{
303
label: "a host override gets no --no-lan hint it would ignore",
304
installed: true,
305
reportStatus: true,
290
- prints: "overridden · T3CODE_HOST=0.0.0.0",
291
- omits: "t3 up --no-lan",
306
+ prints: ["overridden · T3CODE_HOST=0.0.0.0"],
307
+ omits: "--no-lan",
308
env: "T3CODE_HOST=0.0.0.0\n",
309
args: [],
310
installs: 0,
@@ -386,8 +402,8 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer, NetService.layer))
402
),
403
),
404
);
389
- if (input.prints !== undefined) {
390
- expect(lines.join("\n")).toContain(input.prints.replace("<baseDir>", baseDir));
405
+ for (const line of input.prints ?? []) {
406
+ expect(lines.join("\n")).toContain(line.replace("<baseDir>", baseDir));
407
}
408
if (input.omits !== undefined) {
409
expect(lines.join("\n")).not.toContain(input.omits);
apps/server/src/cli/up.ts
+36
-18
@@ -125,7 +125,25 @@ const CHOICES = {
125
lan: { title: "Local network", description: "LAN and tailnet. Pairing code required." },
126
} satisfies Record<Route, { readonly title: string; readonly description: string }>;
127
128
-const formatSetup = (setup: Setup) => {
128
+/** The commands hints name, run with the caller's --base-dir and launcher. */
129
+const resolveHints = Effect.fn("cli.up.resolve_hints")(function* (baseDir: Option.Option<string>) {
130
+ const baseDirArgs = Option.match(baseDir, {
131
+ onNone: () => [],
132
+ onSome: (dir) => ["--base-dir", dir],
133
+ });
134
+ const command = (subcommand: string, args: ReadonlyArray<string> = []) =>
135
+ Effect.map(resolveHostCliCommand(subcommand, [...baseDirArgs, ...args]), (r) => r.command);
136
+ return {
137
+ run: yield* command(""),
138
+ pair: yield* command("pair"),
139
+ up: yield* command("up"),
140
+ upNoLan: yield* command("up", ["--no-lan"]),
141
+ connect: yield* command("connect"),
142
+ };
143
+});
144
+type Hints = Effect.Success<ReturnType<typeof resolveHints>>;
145
+
146
+const formatSetup = (setup: Setup, hints: Hints) => {
147
const { service } = setup;
148
// This home's access settings reach no service, so only the service is shown.
149
if (service.otherBaseDir !== undefined) {
@@ -152,7 +170,7 @@ const formatSetup = (setup: Setup) => {
170
setup.connect
171
? "on · your T3 account"
172
: setup.connectRevoked
155
- ? "off · link revoked. Run `t3 connect`."
173
+ ? `off · link revoked. Run \`${hints.connect}\`.`
174
: "off",
175
] as const,
176
]),
@@ -172,7 +190,7 @@ const formatSetup = (setup: Setup) => {
190
? ["Anyone on your LAN or tailnet can reach the port. A pairing code is the only lock."]
191
: []),
192
...(setup.lanFromOldDefault
175
- ? ["Older installs keep LAN access on. Turn it off: `t3 up --no-lan`."]
193
+ ? [`Older installs keep LAN access on. Turn it off: \`${hints.upNoLan}\`.`]
194
: []),
195
];
196
return [
@@ -181,18 +199,18 @@ const formatSetup = (setup: Setup) => {
199
].join("\n");
200
};
201
184
-const formatNextSteps = (routes: Routes, serviceInstalled: boolean, pairCommand: string) =>
202
+const formatNextSteps = (routes: Routes, serviceInstalled: boolean, hints: Hints) =>
203
[
204
...(routes.connect
205
? ["On your other device, sign in to T3 Connect with the same account."]
206
: []),
189
- ...(routes.lan ? [`Run \`${pairCommand}\`. Use the code on your other device.`] : []),
207
+ ...(routes.lan ? [`Run \`${hints.pair}\`. Use the code on your other device.`] : []),
208
...(routes.connect || routes.lan
209
? []
210
: [
211
serviceInstalled
212
? "Remote access is off. T3 Code still runs here in the background."
195
- : "Remote access is off. Run `t3` to use T3 Code here.",
213
+ : `Remote access is off. Run \`${hints.run}\` to use T3 Code here.`,
214
]),
215
].join("\n");
216
@@ -211,7 +229,7 @@ const setUp = Effect.fn("cli.up")(function* (flags: {
229
onNone: () => [],
230
onSome: (dir) => ["--base-dir", dir],
231
});
214
- const { command: pairCommand } = yield* resolveHostCliCommand("pair", baseDirArgs);
232
+ const hints = yield* resolveHints(flags.baseDir);
233
const before = yield* readSetup();
234
// Before any question or write: install would refuse only after both.
235
if (before.service.otherBaseDir !== undefined) {
@@ -237,7 +255,8 @@ const setUp = Effect.fn("cli.up")(function* (flags: {
255
const interactive = !flags.yes && interactiveTerminal();
256
let routes = plan.routes;
257
if (plan.ask.length > 0 && interactive) {
240
- if (before.service.installed) yield* Console.log(`Current setup\n${formatSetup(before)}\n`);
258
+ if (before.service.installed)
259
+ yield* Console.log(`Current setup\n${formatSetup(before, hints)}\n`);
260
const picked = yield* Prompt.run(
261
Prompt.MultiSelect({
262
message: "Allow connections through:",
@@ -274,7 +293,7 @@ const setUp = Effect.fn("cli.up")(function* (flags: {
293
yield* disconnectCloud({ clearAuthorization: false });
294
}
295
if (current.lan) yield* CliService.writeServiceEnv(baseDir, { T3CODE_LAN: "false" });
277
- return yield* Console.log(formatNextSteps(routes, false, pairCommand));
296
+ return yield* Console.log(formatNextSteps(routes, false, hints));
297
}
298
const { installedVersion } = before.service;
299
const newer =
@@ -384,9 +403,8 @@ const setUp = Effect.fn("cli.up")(function* (flags: {
403
if ("failed" in result && before.service.installed) {
404
// The old service still runs, so a foreground server would clash with it.
405
yield* restoreServiceEnv;
387
- const { command } = yield* resolveHostCliCommand("up", baseDirArgs);
406
yield* Console.log(
389
- `Service setup failed: ${result.failed} Fix that, then run \`${command}\` again.`,
407
+ `Service setup failed: ${result.failed} Fix that, then run \`${hints.up}\` again.`,
408
);
409
} else if ("failed" in result) {
410
yield* printServeCommand(`Service setup failed: ${result.failed}`);
@@ -429,10 +447,10 @@ const setUp = Effect.fn("cli.up")(function* (flags: {
447
const after = yield* readSetup();
448
yield* Console.log(
449
// From what took effect: a failed service step can undo a choice.
432
- `\nThis machine\n${formatSetup(after)}\n\n${formatNextSteps(
450
+ `\nThis machine\n${formatSetup(after, hints)}\n\n${formatNextSteps(
451
{ connect: after.connect === true, lan: after.lan },
452
after.service.installed,
435
- pairCommand,
453
+ hints,
454
)}`,
455
);
456
});
@@ -536,12 +554,12 @@ export const statusCommand = Command.make("status", {
554
),
555
),
556
);
557
+ if (flags.json) return yield* Console.log(setupJson(setup));
558
+ const hints = yield* resolveHints(flags.baseDir);
559
yield* Console.log(
540
- flags.json
541
- ? setupJson(setup)
542
- : setup.service.otherBaseDir !== undefined
543
- ? `This machine\n${formatSetup(setup)}`
544
- : `This machine\n${formatSetup(setup)}\n\nChange access: \`t3 up\`.`,
560
+ setup.service.otherBaseDir !== undefined
561
+ ? `This machine\n${formatSetup(setup, hints)}`
562
+ : `This machine\n${formatSetup(setup, hints)}\n\nChange access: \`${hints.up}\`.`,
563
);
564
}),
565
),