@@ -9,6 +9,7 @@ import { AuthStandardClientScopes } from "@t3tools/contracts";
99import * as NetService from "@t3tools/shared/Net" ;
1010import * as HostProcess from "@t3tools/shared/HostProcess" ;
1111import { assert , describe , expect , it } from "@effect/vitest" ;
12+ import * as ConfigProvider from "effect/ConfigProvider" ;
1213import * as Effect from "effect/Effect" ;
1314import * as Layer from "effect/Layer" ;
1415import * as Sink from "effect/Sink" ;
@@ -287,6 +288,46 @@ describe("t3 pair", () => {
287288 ) . pipe ( Effect . provide ( NodeServices . layer ) ) ,
288289 ) ;
289290
291+ // regression: #10516 minting opens the target database with this checkout's
292+ // migrations, so a worktree must never fall back to the live install.
293+ it . effect ( "does not fall back to the shared home from a linked worktree" , ( ) =>
294+ withDescriptorServer ( ( origin ) =>
295+ Effect . gen ( function * ( ) {
296+ const root = NodeFS . mkdtempSync ( NodePath . join ( NodeOS . tmpdir ( ) , "t3-pair-worktree-test-" ) ) ;
297+ const worktree = NodePath . join ( root , "worktree" ) ;
298+ NodeFS . mkdirSync ( worktree ) ;
299+ NodeFS . writeFileSync (
300+ NodePath . join ( worktree , ".git" ) ,
301+ `gitdir: ${ NodePath . join ( root , "repo" , ".git" , "worktrees" , "worktree" ) } \n` ,
302+ ) ;
303+ const sharedHome = NodePath . join ( root , "shared" ) ;
304+ yield * persistServerRuntimeState ( {
305+ path : NodePath . join ( sharedHome , "userdata" , "server-runtime.json" ) ,
306+ state : yield * makePersistedServerRuntimeState ( {
307+ config : { host : "127.0.0.1" , devUrl : undefined } ,
308+ port : Number ( new URL ( origin ) . port ) ,
309+ } ) ,
310+ } ) ;
311+
312+ const error = yield * provideCliTestLayers (
313+ runCli ( [ "pair" ] ) . pipe (
314+ Effect . provideService ( HostProcess . WorkingDirectory , worktree ) ,
315+ Effect . provide (
316+ ConfigProvider . layer ( ConfigProvider . fromEnv ( { env : { T3CODE_HOME : sharedHome } } ) ) ,
317+ ) ,
318+ Effect . flip ,
319+ ) ,
320+ ) ;
321+
322+ assert . include ( String ( error ) , "No running T3 Code server found." ) ;
323+ assert . notInclude ( String ( error ) , sharedHome ) ;
324+ assert . deepEqual ( NodeFS . readdirSync ( NodePath . join ( sharedHome , "userdata" ) ) , [
325+ "server-runtime.json" ,
326+ ] ) ;
327+ } ) ,
328+ ) . pipe ( Effect . provide ( NodeServices . layer ) ) ,
329+ ) ;
330+
290331 // Without the capability `tailscale serve` blocks on an enablement URL, so
291332 // pairing must stop at status instead of spawning it.
292333 it . effect ( "explains a tailnet without HTTPS serve instead of running tailscale serve" , ( ) =>
0 commit comments