@@ -239,7 +239,10 @@ function antigravityClientReadPath(update: {
239239 */
240240export function makeAntigravityReadRepair ( ) {
241241 type Outcome = "served" | "refused" ;
242- const openReads = new Map < string , { readonly path : string ; outcome ?: Outcome } > ( ) ;
242+ const openReads = new Map <
243+ string ,
244+ { readonly path : string ; readonly sessionId : string ; outcome ?: Outcome }
245+ > ( ) ;
243246 // The agent runs a client tool in a background task, so its request can precede the announcement.
244247 const earlyOutcomes : Array < { readonly path : string ; readonly outcome : Outcome } > = [ ] ;
245248 return {
@@ -248,15 +251,19 @@ export function makeAntigravityReadRepair() {
248251 openReads . clear ( ) ;
249252 earlyOutcomes . length = 0 ;
250253 } ,
251- /** Each `fs/read_text_file` request answers the oldest open read of its path, in order. */
254+ /**
255+ * Each `fs/read_text_file` request answers the oldest open read of its path, in order.
256+ * Returns the call a served read completes, so T3 can report it without waiting.
257+ */
252258 attempted : ( path : string , served : boolean ) => {
253259 const outcome = served ? "served" : "refused" ;
254- for ( const read of openReads . values ( ) ) {
260+ for ( const [ toolCallId , read ] of openReads ) {
255261 if ( read . path !== path || read . outcome !== undefined ) continue ;
256262 read . outcome = outcome ;
257- return ;
263+ return served ? { sessionId : read . sessionId , toolCallId } : undefined ;
258264 }
259265 earlyOutcomes . push ( { path, outcome } ) ;
266+ return undefined ;
260267 } ,
261268 repair : (
262269 notification : EffectAcpSchema . SessionNotification ,
@@ -269,10 +276,19 @@ export function makeAntigravityReadRepair() {
269276 if ( path !== undefined && ! openReads . has ( update . toolCallId ) ) {
270277 const early = earlyOutcomes . findIndex ( ( entry ) => entry . path === path ) ;
271278 const outcome = early === - 1 ? undefined : earlyOutcomes . splice ( early , 1 ) [ 0 ] ?. outcome ;
272- openReads . set ( update . toolCallId , outcome === undefined ? { path } : { path, outcome } ) ;
279+ const sessionId = notification . sessionId ;
280+ openReads . set (
281+ update . toolCallId ,
282+ outcome === undefined ? { path, sessionId } : { path, sessionId, outcome } ,
283+ ) ;
273284 }
274- if ( update . status !== "completed" && update . status !== "failed" ) return notification ;
275285 const read = openReads . get ( update . toolCallId ) ;
286+ if ( update . status === "pending" || update . status === "in_progress" ) {
287+ return read ?. outcome === "served"
288+ ? { ...notification , update : { ...update , status : "completed" } }
289+ : notification ;
290+ }
291+ if ( update . status !== "completed" && update . status !== "failed" ) return notification ;
276292 openReads . delete ( update . toolCallId ) ;
277293 if ( update . status === "completed" || read ?. outcome !== "served" ) return notification ;
278294 const { rawOutput : _stepError , ...rest } = update ;
0 commit comments