@@ -3131,6 +3131,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
31313131 const prepareReviewIndex = Effect . fn ( "prepareReviewIndex" ) ( function * (
31323132 cwd : string ,
31333133 untrackedPaths : ReadonlyArray < string > ,
3134+ maxBytes ?: number ,
31343135 ) {
31353136 const [ stagedDeletionsStdout , indexValue ] = yield * Effect . all (
31363137 [
@@ -3160,6 +3161,19 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
31603161 const stagedDeletions = new Set ( stagedDeletionsStdout . split ( "\0" ) . filter ( Boolean ) ) ;
31613162 const pathsToAdd = untrackedPaths . filter ( ( relativePath ) => ! stagedDeletions . has ( relativePath ) ) ;
31623163 if ( pathsToAdd . length === 0 ) return undefined ;
3164+ if ( maxBytes !== undefined ) {
3165+ const sizes = yield * Effect . forEach (
3166+ pathsToAdd ,
3167+ ( relativePath ) =>
3168+ fileSystem . lstat ( path . resolve ( cwd , relativePath ) ) . pipe (
3169+ Effect . map ( ( info ) => ( info . type === "File" ? Number ( info . size ) : 0 ) ) ,
3170+ Effect . orElseSucceed ( ( ) => 0 ) ,
3171+ ) ,
3172+ { concurrency : 16 } ,
3173+ ) ;
3174+ // null: over the byte budget, so the caller reports totals as unavailable.
3175+ if ( sizes . reduce ( ( total , size ) => total + size , 0 ) > maxBytes ) return null ;
3176+ }
31633177
31643178 const indexPath = path . isAbsolute ( indexValue . trim ( ) )
31653179 ? indexValue . trim ( )
@@ -3251,20 +3265,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
32513265 if ( paths . length === 0 ) return { env : undefined } ;
32523266 if ( paths . length > REVIEW_UNTRACKED_MAX_FILES )
32533267 return { unavailable : "Too many untracked files to count." } ;
3254- if ( maxBytes !== undefined ) {
3255- const sizes = yield * Effect . forEach (
3256- paths ,
3257- ( relativePath ) =>
3258- fileSystem . lstat ( path . resolve ( cwd , relativePath ) ) . pipe (
3259- Effect . map ( ( info ) => ( info . type === "File" ? Number ( info . size ) : 0 ) ) ,
3260- Effect . orElseSucceed ( ( ) => 0 ) ,
3261- ) ,
3262- { concurrency : 16 } ,
3263- ) ;
3264- if ( sizes . reduce ( ( total , size ) => total + size , 0 ) > maxBytes )
3265- return { unavailable : "Untracked files are too large to count." } ;
3266- }
3267- const env = yield * prepareReviewIndex ( cwd , paths ) . pipe (
3268+ const env = yield * prepareReviewIndex ( cwd , paths , maxBytes ) . pipe (
32683269 Effect . catchTags ( {
32693270 PlatformError : ( cause ) =>
32703271 Effect . fail (
@@ -3278,6 +3279,7 @@ export const makeGitVcsDriverCore = Effect.fn("makeGitVcsDriverCore")(function*
32783279 ) ,
32793280 } ) ,
32803281 ) ;
3282+ if ( env === null ) return { unavailable : "Untracked files are too large to count." } ;
32813283 return { env } ;
32823284 } ) ;
32833285 const prepareUntrackedReviewIndex = (
0 commit comments