@@ -978,9 +978,12 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => {
978978 path . join ( repo , ".git" , "config" ) ,
979979 '[core]\n\tbare = false\n[remote "origin"]\n\turl = [email protected] :pingdotgg/t3code.git\n\tfetch = +refs/heads/*:refs/remotes/origin/*\n' , 980980 ) ;
981+ const worktreeGitDir = path . join ( repo , ".git" , "worktrees" , "wt" ) ;
982+ yield * fileSystem . makeDirectory ( worktreeGitDir , { recursive : true } ) ;
983+ yield * fileSystem . writeFileString ( path . join ( worktreeGitDir , "commondir" ) , "../..\n" ) ;
981984 yield * fileSystem . writeFileString (
982985 path . join ( worktree , ".git" ) ,
983- `gitdir: ${ path . join ( repo , ".git" , "worktrees" , "wt" ) } \n` ,
986+ `gitdir: ${ worktreeGitDir } \n` ,
984987 ) ;
985988 yield * fileSystem . makeDirectory ( path . join ( noRemote , ".git" ) ) ;
986989 yield * fileSystem . writeFileString ( path . join ( noRemote , ".git" , "config" ) , "[core]\n" ) ;
@@ -1022,6 +1025,75 @@ it.layer(NodeServices.layer)("AgentSessionScanner", (it) => {
10221025 } ) ,
10231026 ) ;
10241027
1028+ it . effect (
1029+ "offers bare-repository worktrees separately and imports only their own sessions" ,
1030+ ( ) =>
1031+ Effect . gen ( function * ( ) {
1032+ const path = yield * Path . Path ;
1033+ const fileSystem = yield * FileSystem . FileSystem ;
1034+ const nowMs = Date . parse ( "2026-08-24T12:00:00.000Z" ) ;
1035+ yield * TestClock . setTime ( nowMs ) ;
1036+ const claudeHomePath = yield * makeTempDir ( "t3code-claude-home-" ) ;
1037+ const codexHomePath = yield * makeTempDir ( "t3code-codex-home-" ) ;
1038+ const configBaseDir = yield * makeTempDir ( "t3code-scanner-base-" ) ;
1039+ const bare = yield * makeTempDir ( "t3code-workspace-bare-" ) ;
1040+ const bareGitDir = path . join ( bare , ".git" ) ;
1041+ yield * fileSystem . makeDirectory ( bareGitDir ) ;
1042+ yield * fileSystem . writeFileString (
1043+ path . join ( bareGitDir , "config" ) ,
1044+ '[core] bare = "true" ; bare repository\n[remote "origin"]\nurl = [email protected] :pingdotgg/t3code.git\n' , 1045+ ) ;
1046+ const dev = path . join ( bare , "dev" ) ;
1047+ const prod = path . join ( bare , "prod" ) ;
1048+ const managed = path . join ( configBaseDir , "worktrees" , "t3code" , "sandbox" ) ;
1049+ for ( const [ index , cwd ] of [ bare , dev , prod , managed ] . entries ( ) ) {
1050+ if ( cwd !== bare ) {
1051+ const gitDir = path . join ( bareGitDir , "worktrees" , path . basename ( cwd ) ) ;
1052+ yield * fileSystem . makeDirectory ( gitDir , { recursive : true } ) ;
1053+ yield * fileSystem . writeFileString ( path . join ( gitDir , "commondir" ) , "../..\n" ) ;
1054+ yield * fileSystem . makeDirectory ( cwd , { recursive : true } ) ;
1055+ yield * fileSystem . writeFileString ( path . join ( cwd , ".git" ) , `gitdir: ${ gitDir } \n` ) ;
1056+ }
1057+ yield * writeTranscript ( {
1058+ filePath : path . join (
1059+ codexHomePath ,
1060+ "sessions" ,
1061+ "2026" ,
1062+ "08" ,
1063+ "24" ,
1064+ `rollout-${ index } .jsonl` ,
1065+ ) ,
1066+ contents : [
1067+ encodeTranscriptRecord ( {
1068+ type : "session_meta" ,
1069+ payload : { id : `session-${ index } ` , cwd } ,
1070+ } ) ,
1071+ encodeTranscriptRecord ( {
1072+ type : "event_msg" ,
1073+ payload : { type : "user_message" , message : `Work in ${ cwd } ` } ,
1074+ } ) ,
1075+ ] . join ( "\n" ) ,
1076+ mtimeMs : nowMs - index * 1_000 ,
1077+ } ) ;
1078+ }
1079+
1080+ const input = { claudeHomePath, codexHomePath, configBaseDir } ;
1081+ const result = yield * runScan ( input ) ;
1082+ const git = { remoteKey : "github.com/pingdotgg/t3code" , repository : "pingdotgg/t3code" } ;
1083+ expect (
1084+ result . candidates . map ( ( candidate ) => ( { path : candidate . path , git : candidate . git } ) ) ,
1085+ ) . toEqual ( [
1086+ { path : bare , git } ,
1087+ { path : dev , git } ,
1088+ { path : prod , git } ,
1089+ ] ) ;
1090+ const threads = yield * runRecentThreads ( { ...input , workspaceRoot : dev } ) ;
1091+ expect ( threads . map ( ( thread ) => thread . providerSessionId ) ) . toEqual ( [ "session-1" ] ) ;
1092+ const managedThreads = yield * runRecentThreads ( { ...input , workspaceRoot : managed } ) ;
1093+ expect ( managedThreads ) . toEqual ( [ ] ) ;
1094+ } ) ,
1095+ ) ;
1096+
10251097 it . effect ( "excludes sandboxes under the configured worktrees dir without .t3 in the path" , ( ) =>
10261098 Effect . gen ( function * ( ) {
10271099 const path = yield * Path . Path ;
0 commit comments