Skip to content

Commit bfff92e

Browse files
PR Batch Testerclaude
andcommitted
fix(server): include the service home in the t3 pair hint
Bare `t3 pair` only finds a server in the default home, so a service installed with a custom home now prints `t3 pair --base-dir <home>`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent be4d5ef commit bfff92e

2 files changed

Lines changed: 30 additions & 4 deletions

File tree

‎apps/server/src/startupAccess.test.ts‎

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import type * as NodeOS from "node:os";
22
import * as NodeUtil from "node:util";
33

44
import { describe, expect, it } from "@effect/vitest";
5+
import * as HostProcess from "@t3tools/shared/HostProcess";
56
import * as Console from "effect/Console";
67
import * as DateTime from "effect/DateTime";
78
import * as Effect from "effect/Effect";
89
import * as Layer from "effect/Layer";
910
import * as NetAddress from "effect/net/NetAddress";
11+
import * as Path from "effect/Path";
1012
import { HttpServer } from "effect/http";
1113

1214
import * as EnvironmentAuth from "./auth/EnvironmentAuth.ts";
@@ -85,11 +87,24 @@ describe("acceptsPrivateNetworkConnection", () => {
8587
});
8688

8789
it.effect.each([
88-
{ serviceManaged: false, issued: 1, printsToken: true },
89-
{ serviceManaged: true, issued: 0, printsToken: false },
90+
{ serviceManaged: false, baseDir: "/home/u/.t3", issued: 1, printsToken: true, hint: "" },
91+
{
92+
serviceManaged: true,
93+
baseDir: "/home/u/.t3",
94+
issued: 0,
95+
printsToken: false,
96+
hint: "Run `t3 pair` to pair a device.",
97+
},
98+
{
99+
serviceManaged: true,
100+
baseDir: "/srv/it's t3",
101+
issued: 0,
102+
printsToken: false,
103+
hint: "Run `t3 pair --base-dir '/srv/it'\\''s t3'` to pair a device.",
104+
},
90105
])(
91106
"prints a startup pairing token only outside the background service: %o",
92-
({ serviceManaged, issued, printsToken }) =>
107+
({ serviceManaged, baseDir, issued, printsToken, hint }) =>
93108
Effect.gen(function* () {
94109
const printed: Array<string> = [];
95110
let issuedCount = 0;
@@ -100,6 +115,7 @@ it.effect.each([
100115
host: "127.0.0.1",
101116
port: 3773,
102117
privateNetworkOnly: false,
118+
baseDir,
103119
} as never),
104120
Layer.mock(HttpServer.HttpServer)({
105121
address: NetAddress.inetAddressFromIpStringUnsafe("127.0.0.1", 3773),
@@ -115,8 +131,10 @@ it.effect.each([
115131
};
116132
}),
117133
}),
134+
Path.layer,
118135
),
119136
),
137+
Effect.provideService(HostProcess.HomeDirectory, "/home/u"),
120138
Effect.provideService(Console.Console, {
121139
...globalThis.console,
122140
log: (...args: ReadonlyArray<unknown>) => {
@@ -126,5 +144,6 @@ it.effect.each([
126144
);
127145
expect(issuedCount).toBe(issued);
128146
expect(printed.join("\n").includes("startup-secret")).toBe(printsToken);
147+
expect(printed.join("\n").includes(hint)).toBe(true);
129148
}),
130149
);

‎apps/server/src/startupAccess.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as NetAddress from "effect/net/NetAddress";
1111

1212
import * as ServerConfig from "./config.ts";
1313
import * as EnvironmentAuth from "./auth/EnvironmentAuth.ts";
14+
import { resolveBaseDir } from "./os-jank.ts";
1415

1516
interface HeadlessServeAccessInfo {
1617
readonly connectionString: string;
@@ -217,7 +218,13 @@ export const announceHeadlessAccess = Effect.fn("announceHeadlessAccess")(functi
217218
readonly serviceManaged: boolean;
218219
}) {
219220
if (input.serviceManaged) {
220-
return yield* Console.log("T3 Code server is ready. Run `t3 pair` to pair a device.");
221+
// Bare `t3 pair` only finds a server in the default home.
222+
const { baseDir } = yield* ServerConfig.ServerConfig;
223+
const pair =
224+
baseDir === (yield* resolveBaseDir(undefined))
225+
? "t3 pair"
226+
: `t3 pair --base-dir '${baseDir.replaceAll("'", `'\\''`)}'`;
227+
return yield* Console.log(`T3 Code server is ready. Run \`${pair}\` to pair a device.`);
221228
}
222229
const accessInfo = yield* issueHeadlessServeAccessInfo();
223230
yield* Console.log(formatHeadlessServeOutput(accessInfo));

0 commit comments

Comments
 (0)