mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-08 01:43:07 +00:00
refactor: extract session lifecycle management and mode switching to shared module
Consolidates duplicate cleanup, signal handling, and state management logic from runClaude and runCodex into a reusable createRunnerLifecycle factory function. Extracts mode switching handler and controlled user state updates into utilities. Adds runLocalRemoteSession wrapper to handle session ready callbacks in loop base.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { MessageQueue2 } from '@/utils/MessageQueue2';
|
||||
import { logger } from '@/ui/logger';
|
||||
import { runLocalRemoteLoop } from '@/agent/loopBase';
|
||||
import { runLocalRemoteSession } from '@/agent/loopBase';
|
||||
import { CodexSession } from './session';
|
||||
import { codexLocalLauncher } from './codexLocalLauncher';
|
||||
import { codexRemoteLauncher } from './codexRemoteLauncher';
|
||||
@@ -48,15 +48,12 @@ export async function loop(opts: LoopOptions): Promise<void> {
|
||||
permissionMode: opts.permissionMode ?? 'default'
|
||||
});
|
||||
|
||||
if (opts.onSessionReady) {
|
||||
opts.onSessionReady(session);
|
||||
}
|
||||
|
||||
await runLocalRemoteLoop({
|
||||
await runLocalRemoteSession({
|
||||
session,
|
||||
startingMode: opts.startingMode,
|
||||
logTag: 'codex-loop',
|
||||
runLocal: codexLocalLauncher,
|
||||
runRemote: codexRemoteLauncher
|
||||
runRemote: codexRemoteLauncher,
|
||||
onSessionReady: opts.onSessionReady
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user