@@ -279,6 +279,17 @@ const awaitWithinDeadline = <A, E, R>(
279279 Effect . flatMap ( ( fiber ) => Fiber . join ( fiber ) . pipe ( Effect . timeoutOption ( deadline ) ) ) ,
280280 ) ;
281281
282+ /**
283+ * Resolves once a reader has opened the FIFO, so its read deadline is already
284+ * scheduled on the TestClock. The writer stays open until the scope closes, so
285+ * the reader sees no EOF and has to wait out that deadline.
286+ */
287+ const awaitGateReader = ( gatePath : string ) =>
288+ Effect . acquireRelease (
289+ Effect . promise ( ( ) => NodeFS . promises . open ( gatePath , NodeFS . constants . O_WRONLY ) ) ,
290+ ( handle ) => Effect . promise ( ( ) => handle . close ( ) ) ,
291+ ) ;
292+
282293const scanUntilDeadline = < E , R > (
283294 scan : Effect . Effect < { readonly candidates : ReadonlyArray < { readonly path : string } > } , E , R > ,
284295) =>
@@ -1757,7 +1768,7 @@ describe.skipIf(HostProcess.Platform.defaultValue() === "win32")(
17571768 } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
17581769 ) ;
17591770
1760- it . live ( "waits about one read deadline when several git configs block in one scan ", ( ) =>
1771+ it . effect ( "reads every blocked git config of a scan under one deadline ", ( ) =>
17611772 Effect . gen ( function * ( ) {
17621773 const path = yield * Path . Path ;
17631774 const fileSystem = yield * FileSystem . FileSystem ;
@@ -1789,16 +1800,20 @@ describe.skipIf(HostProcess.Platform.defaultValue() === "win32")(
17891800 } ) ;
17901801 }
17911802
1792- // Each blocked read costs one deadline; reading them one after another
1793- // would take a deadline per config.
1794- expect (
1795- yield * awaitWithinDeadline (
1796- runScan ( { claudeHomePath, codexHomePath } ) . pipe (
1797- Effect . map ( ( { candidates } ) => candidates . map ( ( { path } ) => path ) . toSorted ( ) ) ,
1798- ) ,
1799- "4 seconds" ,
1803+ const scan = yield * Effect . forkChild (
1804+ runScan ( { claudeHomePath, codexHomePath } ) . pipe (
1805+ Effect . map ( ( { candidates } ) => candidates . map ( ( { path } ) => path ) . toSorted ( ) ) ,
18001806 ) ,
1801- ) . toEqual ( Option . some ( repos ) ) ;
1807+ ) ;
1808+ // Every blocked config is open before any deadline passes; reading them
1809+ // one after another would leave the later ones unopened.
1810+ yield * Effect . forEach (
1811+ [ ...repos . map ( ( repo ) => path . join ( repo , ".git" ) ) , bareGitDir ] ,
1812+ ( gitDir ) => awaitGateReader ( path . join ( gitDir , "config" ) ) ,
1813+ { concurrency : "unbounded" } ,
1814+ ) ;
1815+ yield * TestClock . adjust ( "2 seconds" ) ;
1816+ expect ( yield * Fiber . join ( scan ) ) . toEqual ( repos ) ;
18021817 } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
18031818 ) ;
18041819
@@ -1847,6 +1862,54 @@ describe.skipIf(HostProcess.Platform.defaultValue() === "win32")(
18471862 ) . toBe ( true ) ;
18481863 } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
18491864 ) ;
1865+
1866+ it . effect ( "reads a once-blocked git config again after the retry interval" , ( ) =>
1867+ Effect . gen ( function * ( ) {
1868+ const path = yield * Path . Path ;
1869+ const fileSystem = yield * FileSystem . FileSystem ;
1870+ const claudeHomePath = yield * makeTempDir ( "t3code-claude-home-" ) ;
1871+ const codexHomePath = yield * makeTempDir ( "t3code-codex-home-" ) ;
1872+ const repo = yield * makeTempDir ( "t3code-workspace-unblocked-config-" ) ;
1873+ yield * fileSystem . makeDirectory ( path . join ( repo , ".git" ) ) ;
1874+ const configPath = path . join ( repo , ".git" , "config" ) ;
1875+ yield * makeOpenGate ( configPath ) ;
1876+ yield * writeTranscript ( {
1877+ filePath : path . join ( claudeHomePath , "projects" , "-unblocked" , "a.jsonl" ) ,
1878+ contents : claudeSessionLine ( repo ) ,
1879+ mtimeMs : Date . parse ( "2026-05-03T00:00:00.000Z" ) ,
1880+ } ) ;
1881+ const gitOfScan = ( scan : AgentSessionScanner . AgentSessionScanner [ "Service" ] [ "scan" ] ) =>
1882+ scan . pipe ( Effect . map ( ( { candidates } ) => candidates . map ( ( { git } ) => git ) ) ) ;
1883+
1884+ yield * Effect . gen ( function * ( ) {
1885+ const scanner = yield * AgentSessionScanner . AgentSessionScanner ;
1886+ const blockedScan = yield * Effect . forkChild ( gitOfScan ( scanner . scan ) ) ;
1887+ yield * Effect . scoped (
1888+ Effect . gen ( function * ( ) {
1889+ yield * awaitGateReader ( configPath ) ;
1890+ yield * TestClock . adjust ( "2 seconds" ) ;
1891+ expect ( yield * Fiber . join ( blockedScan ) ) . toEqual ( [
1892+ { remoteKey : null , repository : null } ,
1893+ ] ) ;
1894+ } ) ,
1895+ ) ;
1896+
1897+ yield * fileSystem . remove ( configPath ) ;
1898+ yield * fileSystem . writeFileString (
1899+ configPath ,
1900+ `[remote "origin"]\n\turl = [email protected] :pingdotgg/unblocked.git\n` , 1901+ ) ;
1902+ expect ( yield * gitOfScan ( scanner . scan ) , "a blocked path is skipped for a while" ) . toEqual ( [
1903+ { remoteKey : null , repository : null } ,
1904+ ] ) ;
1905+
1906+ yield * TestClock . adjust ( "10 minutes" ) ;
1907+ expect ( yield * gitOfScan ( scanner . scan ) ) . toEqual ( [
1908+ { remoteKey : "github.com/pingdotgg/unblocked" , repository : "pingdotgg/unblocked" } ,
1909+ ] ) ;
1910+ } ) . pipe ( Effect . provide ( layerScannerTest ( { claudeHomePath, codexHomePath } ) ) ) ;
1911+ } ) . pipe ( Effect . scoped , Effect . provide ( NodeServices . layer ) ) ,
1912+ ) ;
18501913 } ,
18511914) ;
18521915
0 commit comments