@@ -129,6 +129,11 @@ export class DesktopExecutor {
129129 private recovering : Promise < void > | null = null
130130 /** Results a previous app run left, still on their way to Sim. */
131131 private readonly recoveringIds = new Set < string > ( )
132+ /**
133+ * Results a previous app run left, until Sim answers for them, parked ones included: that run's
134+ * send of the real result may already have landed.
135+ */
136+ private readonly recoveredResults = new Set < string > ( )
132137 /** Results that have failed to reach Sim for longer than {@link DELIVERY_AWAKE_LIMIT_MS}. */
133138 private readonly stalledDeliveries = new Set < string > ( )
134139 /** Results Sim refused because it no longer recognized this device; sent once it registers again. */
@@ -190,6 +195,7 @@ export class DesktopExecutor {
190195 } )
191196 // Held awake like a running call: the result exists only on this machine until Sim has it.
192197 this . recoveringIds . add ( entry . toolCallId )
198+ this . recoveredResults . add ( entry . toolCallId )
193199 this . updateBusy ( )
194200 void this . deliver ( entry . toolCallId , entry . executionToken , completion ) . finally ( ( ) => {
195201 this . recoveringIds . delete ( entry . toolCallId )
@@ -434,7 +440,7 @@ export class DesktopExecutor {
434440 // A duplicate holds what this app run sent, unless the result was recovered unchanged from
435441 // an earlier run, whose send of the real result may have landed before the restart.
436442 const takenEarlier =
437- outcome === 'duplicate' && pending === completion && this . recoveringIds . has ( toolCallId )
443+ outcome === 'duplicate' && pending === completion && this . recoveredResults . has ( toolCallId )
438444 notDelivered = ! delivered && ! takenEarlier
439445 break
440446 } catch ( error ) {
@@ -492,6 +498,7 @@ export class DesktopExecutor {
492498 )
493499 }
494500 }
501+ this . recoveredResults . delete ( toolCallId )
495502 if ( this . disposed ) return
496503 if ( notDelivered ) this . options . onResultNotDelivered ?.( toolCallId )
497504 await this . forget ( toolCallId )
0 commit comments