@@ -27,6 +27,7 @@ import * as TestClock from "effect/testing/TestClock";
2727import { ChildProcessSpawner } from "effect/unstable/process" ;
2828import { expect } from "vite-plus/test" ;
2929
30+ import packageJson from "../../package.json" with { type : "json" } ;
3031import * as ProcessRunner from "../processRunner.ts" ;
3132import * as TerminalManager from "./Manager.ts" ;
3233import * as PtyAdapter from "./PtyAdapter.ts" ;
@@ -1509,6 +1510,41 @@ it.layer(
15091510 } ) ,
15101511 ) ;
15111512
1513+ it . effect ( "identifies spawned terminals as T3 Code" , ( ) =>
1514+ Effect . gen ( function * ( ) {
1515+ const { manager, ptyAdapter } = yield * createManager ( 5 , { env : { } } ) ;
1516+
1517+ yield * manager . open ( openInput ( ) ) ;
1518+
1519+ const spawnInput = ptyAdapter . spawnInputs [ 0 ] ;
1520+ expect ( spawnInput ) . toBeDefined ( ) ;
1521+ if ( ! spawnInput ) return ;
1522+
1523+ expect ( spawnInput . env . TERM_PROGRAM ) . toBe ( "t3code" ) ;
1524+ expect ( spawnInput . env . TERM_PROGRAM_VERSION ) . toBe ( packageJson . version ) ;
1525+ } ) ,
1526+ ) ;
1527+
1528+ it . effect ( "overrides inherited parent terminal identity" , ( ) =>
1529+ Effect . gen ( function * ( ) {
1530+ const { manager, ptyAdapter } = yield * createManager ( 5 , {
1531+ env : {
1532+ TERM_PROGRAM : "Apple_Terminal" ,
1533+ TERM_PROGRAM_VERSION : "2.14" ,
1534+ } ,
1535+ } ) ;
1536+
1537+ yield * manager . open ( openInput ( ) ) ;
1538+
1539+ const spawnInput = ptyAdapter . spawnInputs [ 0 ] ;
1540+ expect ( spawnInput ) . toBeDefined ( ) ;
1541+ if ( ! spawnInput ) return ;
1542+
1543+ expect ( spawnInput . env . TERM_PROGRAM ) . toBe ( "t3code" ) ;
1544+ expect ( spawnInput . env . TERM_PROGRAM_VERSION ) . toBe ( packageJson . version ) ;
1545+ } ) ,
1546+ ) ;
1547+
15121548 it . effect ( "strips AppImage runtime env from terminal sessions" , ( ) =>
15131549 Effect . gen ( function * ( ) {
15141550 const appDir = "/tmp/.mount_T3Codeabc123" ;
@@ -1582,6 +1618,8 @@ it.layer(
15821618 T3CODE_PROJECT_ROOT : "/repo" ,
15831619 T3CODE_WORKTREE_PATH : "/repo/worktree-a" ,
15841620 CUSTOM_FLAG : "1" ,
1621+ TERM_PROGRAM : "custom-terminal" ,
1622+ TERM_PROGRAM_VERSION : "custom-version" ,
15851623 } ,
15861624 } ) ,
15871625 ) ;
@@ -1592,6 +1630,8 @@ it.layer(
15921630 assert . equal ( spawnInput . env . T3CODE_PROJECT_ROOT , "/repo" ) ;
15931631 assert . equal ( spawnInput . env . T3CODE_WORKTREE_PATH , "/repo/worktree-a" ) ;
15941632 assert . equal ( spawnInput . env . CUSTOM_FLAG , "1" ) ;
1633+ assert . equal ( spawnInput . env . TERM_PROGRAM , "custom-terminal" ) ;
1634+ assert . equal ( spawnInput . env . TERM_PROGRAM_VERSION , "custom-version" ) ;
15951635 } ) ,
15961636 ) ;
15971637
0 commit comments