1- import {
2- withAndroidAdbProvider ,
3- type AndroidAdbExecutor ,
4- } from '../platforms/android/adb-executor.ts' ;
1+ import { withAndroidAdbProvider } from '../platforms/android/adb-executor.ts' ;
52import type { CommandFlags } from '../core/dispatch.ts' ;
63import {
74 type DeviceInventoryProvider ,
@@ -14,12 +11,6 @@ import {
1411 contextFromFlags as contextFromFlagsWithLog ,
1512 type DaemonCommandContext ,
1613} from './context.ts' ;
17- import { handleSessionCommands } from './handlers/session.ts' ;
18- import { handleSnapshotCommands } from './handlers/snapshot.ts' ;
19- import { handleFindCommands } from './handlers/find.ts' ;
20- import { handleRecordTraceCommands } from './handlers/record-trace.ts' ;
21- import { handleInteractionCommands } from './handlers/interaction.ts' ;
22- import { handleLeaseCommands } from './handlers/lease.ts' ;
2314import { assertSessionSelectorMatches } from './session-selector.ts' ;
2415import { applyRequestLockPolicy } from './request-lock-policy.ts' ;
2516import { resolveEffectiveSessionName } from './session-routing.ts' ;
@@ -49,6 +40,7 @@ import {
4940 refreshRecordingHealth ,
5041 shouldBlockForInvalidRecording ,
5142} from './request-recording-health.ts' ;
43+ import { runRequestHandlerChain } from './request-handler-chain.ts' ;
5244
5345const sessionExecutionLocks = new Map < string , Promise < unknown > > ( ) ;
5446
@@ -75,85 +67,6 @@ function contextFromFlags(
7567 } ;
7668}
7769
78- // ---------------------------------------------------------------------------
79- // Specialized handler chain
80- // ---------------------------------------------------------------------------
81-
82- async function runHandlerChain ( params : {
83- req : DaemonRequest ;
84- sessionName : string ;
85- logPath : string ;
86- sessionStore : SessionStore ;
87- leaseRegistry : LeaseRegistry ;
88- invoke : ( req : DaemonRequest ) => Promise < DaemonResponse > ;
89- androidAdbExecutor ?: AndroidAdbExecutor ;
90- contextFromFlags : (
91- flags : CommandFlags | undefined ,
92- appBundleId ?: string ,
93- traceLogPath ?: string ,
94- ) => DaemonCommandContext ;
95- } ) : Promise < DaemonResponse | null > {
96- const {
97- req,
98- sessionName,
99- logPath,
100- sessionStore,
101- leaseRegistry,
102- invoke,
103- androidAdbExecutor,
104- contextFromFlags,
105- } = params ;
106-
107- const leaseResponse = await handleLeaseCommands ( { req, leaseRegistry } ) ;
108- if ( leaseResponse ) return leaseResponse ;
109-
110- const sessionResponse = await handleSessionCommands ( {
111- req,
112- sessionName,
113- logPath,
114- sessionStore,
115- invoke,
116- androidAdbExecutor,
117- } ) ;
118- if ( sessionResponse ) return sessionResponse ;
119-
120- const snapshotResponse = await handleSnapshotCommands ( {
121- req,
122- sessionName,
123- logPath,
124- sessionStore,
125- } ) ;
126- if ( snapshotResponse ) return snapshotResponse ;
127-
128- const recordTraceResponse = await handleRecordTraceCommands ( {
129- req,
130- sessionName,
131- sessionStore,
132- logPath,
133- } ) ;
134- if ( recordTraceResponse ) return recordTraceResponse ;
135-
136- const findResponse = await handleFindCommands ( {
137- req,
138- sessionName,
139- logPath,
140- sessionStore,
141- invoke,
142- } ) ;
143- if ( findResponse ) return findResponse ;
144-
145- const interactionResponse = await handleInteractionCommands ( {
146- req,
147- sessionName,
148- logPath,
149- sessionStore,
150- contextFromFlags,
151- } ) ;
152- if ( interactionResponse ) return interactionResponse ;
153-
154- return null ;
155- }
156-
15770// ---------------------------------------------------------------------------
15871// Request handler API
15972// ---------------------------------------------------------------------------
@@ -260,7 +173,7 @@ export function createRequestHandler(
260173 // The ADB provider is scoped to this single locked request; handlers may re-read
261174 // the session state, but all device-scoped adb calls in this request share it.
262175 // Phase 1: Try specialized handler chain
263- const handlerResponse = await runHandlerChain ( {
176+ const handlerResponse = await runRequestHandlerChain ( {
264177 req : lockedReq ,
265178 sessionName,
266179 logPath,
0 commit comments