Browse Source

feat: wire SessionLifecycle coordinator into plugin

Michael Henke 1 month ago
parent
commit
bc91160f5a
2 changed files with 11 additions and 10 deletions
  1. 1 0
      src/hooks/index.ts
  2. 10 10
      src/index.ts

+ 1 - 0
src/hooks/index.ts

@@ -15,4 +15,5 @@ export { createLoopCommandHook } from './loop-command';
 export { createPhaseReminderHook } from './phase-reminder';
 export { createPostFileToolNudgeHook } from './post-file-tool-nudge';
 export { createReflectCommandHook } from './reflect';
+export { SessionLifecycle } from './session-lifecycle';
 export { createTaskSessionManagerHook } from './task-session-manager';

+ 10 - 10
src/index.ts

@@ -31,6 +31,7 @@ import {
   createReflectCommandHook,
   createTaskSessionManagerHook,
   ForegroundFallbackManager,
+  SessionLifecycle,
 } from './hooks';
 import { processImageAttachments } from './hooks/image-hook';
 import type { MessageWithParts } from './hooks/types';
@@ -268,6 +269,8 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
       void multiplexerSessionManager.retryDeferredIdleClose(taskID);
     });
 
+    const sessionLifecycle = new SessionLifecycle(log);
+
     // Initialize auto-update checker hook
     autoUpdateChecker = createAutoUpdateCheckerHook(ctx, {
       autoUpdate: config.autoUpdate ?? true,
@@ -275,7 +278,7 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
     });
 
     // Initialize phase reminder hook for workflow compliance
-    phaseReminderHook = createPhaseReminderHook();
+    phaseReminderHook = createPhaseReminderHook(sessionLifecycle);
 
     // Initialize available skills filter hook
     filterAvailableSkillsHook = createFilterAvailableSkillsHook(ctx, config);
@@ -287,6 +290,7 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
     postFileToolNudgeHook = createPostFileToolNudgeHook({
       shouldInject: (sessionID) =>
         sessionAgentMap.get(sessionID) === 'orchestrator',
+      coordinator: sessionLifecycle,
     });
 
     chatHeadersHook = createChatHeadersHook(ctx);
@@ -306,6 +310,7 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
       runtimeChains,
       config.fallback?.enabled !== false,
       config.fallback?.maxRetries ?? 3,
+      sessionLifecycle,
     );
 
     deepworkCommandHook = createDeepworkCommandHook();
@@ -320,6 +325,7 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
         sessionAgentMap.get(sessionID) === 'orchestrator',
       isFallbackInProgress: (sessionID) =>
         foregroundFallback.isFallbackInProgress(sessionID),
+      coordinator: sessionLifecycle,
     });
     interviewManager = createInterviewManager(ctx, config);
     presetManager = createPresetManager(ctx, config);
@@ -847,15 +853,6 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
         },
       );
 
-      await postFileToolNudgeHook.event(
-        input as {
-          event: {
-            type: string;
-            properties?: { info?: { id?: string }; sessionID?: string };
-          };
-        },
-      );
-
       if (
         event.type === 'permission.asked' ||
         event.type === 'question.asked'
@@ -889,6 +886,9 @@ const OhMyOpenCodeLite: Plugin = async (ctx) => {
           | undefined;
         const sessionID = extractSessionId(props?.info, props?.sessionID);
 
+        if (sessionID) {
+          sessionLifecycle.dispatchSessionDeleted(sessionID);
+        }
         companionManager.onSessionDeleted(sessionID);
         if (depthTracker && sessionID) {
           depthTracker.cleanup(sessionID);