@@ -184,6 +184,9 @@ import { OAUTH_CALLBACK_SERVER } from "@posthog/workspace-server/services/oauth-
184184import { oauthCallbackModule } from "@posthog/workspace-server/services/oauth-callback/oauth-callback.module" ;
185185import { onboardingImportModule } from "@posthog/workspace-server/services/onboarding-import/onboarding-import.module" ;
186186import { osModule } from "@posthog/workspace-server/services/os/os.module" ;
187+ import { PI_SESSION_SERVICE } from "@posthog/workspace-server/services/pi-session/identifiers" ;
188+ import type { PiSessionService } from "@posthog/workspace-server/services/pi-session/pi-session" ;
189+ import { piSessionModule } from "@posthog/workspace-server/services/pi-session/pi-session.module" ;
187190import { POSTHOG_PLUGIN_SERVICE } from "@posthog/workspace-server/services/posthog-plugin/identifiers" ;
188191import { posthogPluginModule } from "@posthog/workspace-server/services/posthog-plugin/posthog-plugin.module" ;
189192import { PROCESS_TRACKING_SERVICE } from "@posthog/workspace-server/services/process-tracking/identifiers" ;
@@ -356,6 +359,7 @@ container
356359 . bind ( MAIN_DEFAULT_ADDITIONAL_DIRECTORY_REPOSITORY )
357360 . toService ( DEFAULT_ADDITIONAL_DIRECTORY_REPOSITORY ) ;
358361container . load ( agentModule ) ;
362+ container . load ( piSessionModule ) ;
359363container . bind ( AGENT_SLEEP_COORDINATOR ) . toService ( MAIN_SLEEP_SERVICE ) ;
360364container . bind ( AGENT_MCP_APPS ) . toService ( MCP_APPS_SERVICE ) ;
361365container . bind ( AGENT_REPO_FILES ) . toService ( MAIN_FS_SERVICE ) ;
@@ -391,8 +395,12 @@ container.bind(MCP_PROXY_AUTH).toDynamicValue((ctx) => {
391395} ) ;
392396container . load ( archiveModule ) ;
393397container . bind ( ARCHIVE_SESSION_CANCELLER ) . toDynamicValue ( ( ctx ) => ( {
394- cancelSessionsByTaskId : ( taskId : string ) =>
395- ctx . get < AgentService > ( AGENT_SERVICE ) . cancelSessionsByTaskId ( taskId ) ,
398+ cancelSessionsByTaskId : async ( taskId : string ) => {
399+ await Promise . all ( [
400+ ctx . get < AgentService > ( AGENT_SERVICE ) . cancelSessionsByTaskId ( taskId ) ,
401+ ctx . get < PiSessionService > ( PI_SESSION_SERVICE ) . stop ( taskId ) ,
402+ ] ) ;
403+ } ,
396404} ) ) ;
397405container . bind ( ARCHIVE_FILE_WATCHER ) . toDynamicValue ( ( ctx ) => ( {
398406 stopWatching : async ( worktreePath : string ) => {
@@ -403,8 +411,12 @@ container.bind(ARCHIVE_FILE_WATCHER).toDynamicValue((ctx) => ({
403411} ) ) ;
404412container . load ( suspensionModule ) ;
405413container . bind ( SUSPENSION_SESSION_CANCELLER ) . toDynamicValue ( ( ctx ) => ( {
406- cancelSessionsByTaskId : ( taskId : string ) =>
407- ctx . get < AgentService > ( AGENT_SERVICE ) . cancelSessionsByTaskId ( taskId ) ,
414+ cancelSessionsByTaskId : async ( taskId : string ) => {
415+ await Promise . all ( [
416+ ctx . get < AgentService > ( AGENT_SERVICE ) . cancelSessionsByTaskId ( taskId ) ,
417+ ctx . get < PiSessionService > ( PI_SESSION_SERVICE ) . stop ( taskId ) ,
418+ ] ) ;
419+ } ,
408420} ) ) ;
409421container . bind ( SUSPENSION_FILE_WATCHER ) . toDynamicValue ( ( ctx ) => ( {
410422 stopWatching : async ( worktreePath : string ) => {
@@ -675,7 +687,12 @@ container.load(workspaceModule);
675687container . bind ( WORKSPACE_AGENT ) . toDynamicValue ( ( ctx ) : WorkspaceAgent => {
676688 const agent = ctx . get < AgentService > ( AGENT_SERVICE ) ;
677689 return {
678- cancelSessionsByTaskId : ( taskId ) => agent . cancelSessionsByTaskId ( taskId ) ,
690+ cancelSessionsByTaskId : async ( taskId ) => {
691+ await Promise . all ( [
692+ agent . cancelSessionsByTaskId ( taskId ) ,
693+ ctx . get < PiSessionService > ( PI_SESSION_SERVICE ) . stop ( taskId ) ,
694+ ] ) ;
695+ } ,
679696 onAgentFileActivity : ( handler ) =>
680697 agent . on ( AgentServiceEvent . AgentFileActivity , handler ) ,
681698 } ;
0 commit comments