@@ -22,12 +22,11 @@ import { app } from "electron";
2222import { inject , injectable , preDestroy } from "inversify" ;
2323import type { ExecutionMode } from "@/shared/types.js" ;
2424import type { AcpMessage } from "../../../shared/types/session-events.js" ;
25- import { container } from "../../di/container.js" ;
2625import { MAIN_TOKENS } from "../../di/tokens.js" ;
2726import { logger } from "../../lib/logger.js" ;
2827import { TypedEventEmitter } from "../../lib/typed-event-emitter.js" ;
2928import type { ProcessTrackingService } from "../process-tracking/service.js" ;
30- import type { SleepService } from "../sleep/service.js" ;
29+ import { SleepService } from "../sleep/service.js" ;
3130import {
3231 AgentServiceEvent ,
3332 type AgentServiceEvents ,
@@ -220,17 +219,17 @@ export class AgentService extends TypedEventEmitter<AgentServiceEvents> {
220219 private currentToken : string | null = null ;
221220 private pendingPermissions = new Map < string , PendingPermission > ( ) ;
222221 private processTracking : ProcessTrackingService ;
222+ private sleepService : SleepService ;
223223
224224 constructor (
225225 @inject ( MAIN_TOKENS . ProcessTrackingService )
226226 processTracking : ProcessTrackingService ,
227+ @inject ( MAIN_TOKENS . SleepService )
228+ sleepService : SleepService ,
227229 ) {
228230 super ( ) ;
229231 this . processTracking = processTracking ;
230- }
231-
232- private get sleepService ( ) {
233- return container . get < SleepService > ( MAIN_TOKENS . SleepService ) ;
232+ this . sleepService = sleepService ;
234233 }
235234
236235 public updateToken ( newToken : string ) : void {
@@ -1027,7 +1026,10 @@ For git operations while detached:
10271026 } ,
10281027 ) ;
10291028 } finally {
1030- service . sleepService . acquire ( taskRunId ) ;
1029+ // Only re-acquire if session wasn't cleaned up while waiting
1030+ if ( service . sessions . has ( taskRunId ) ) {
1031+ service . sleepService . acquire ( taskRunId ) ;
1032+ }
10311033 }
10321034 }
10331035
0 commit comments