chore: remove unreachable read-only find handling from daemon find handler#1290
Merged
Conversation
…ndler dispatchFindReadOnlyViaRuntime intercepts every read-only find action (exists/wait/get_text/get_attrs) inside handleFindCommands and always returns a response for them, so the legacy handleFindWait polling loop, handleFindExists/GetText/GetAttrs, attachIssuedRefsGeneration, and the sessionless-find device resolution behind them were unreachable (verified empirically in #1288 and again here by planting throws in all four handlers — the full find suite stays green). With only mutating actions (click/fill/focus/type) able to reach the snapshot path, requiresRect is constant true; fold it and drop the now-dead scope threading, including the legacyIosSparse recovery scope field that was only ever populated with undefined.
Size Report
Startup median (7 runs, lower is better):
Top changed chunks:
|
Member
Author
Member
Author
|
Reviewed current head |
|
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
handleFindWaitand the rest of the read-only action handling insrc/daemon/handlers/find.tswere dead code:dispatchFindReadOnlyViaRuntime(called at the top ofhandleFindCommands) intercepts every read-only find action before the legacy handlers can run. This removes the dead path and the constants it leaves behind. Follows up the empirical observation in #1288 (and the correction on #1270).Unreachability proof
Every dispatch route converges on the same choke point:
find) to the find route (registry.ts→runFindHandlerinrequest-handler-chain.ts), whose only handler ishandleFindCommands. CLI, MCP, replay, and thetestengine all dispatch through this chain;src/compat/maestro's onlyfindreference is export-direction. No other file importshandlers/find.ts.handleFindCommandscallsdispatchFindReadOnlyViaRuntimebefore any action dispatch, so even direct callers (unit tests) hit the interception.parseFindArgs) on the same positionals, and theirisReadOnlyFindActionsets are identical (exists/wait/get_text/get_attrs).dispatchFindReadOnlyViaRuntimereturns a non-nullDaemonResponse: arg-validation errors return responses,createSelectorRuntimereturns{ok:false, response}or{ok:true}, and the finaltoDaemonResponsewrapper catches all errors into a response. A throw (from device resolution) propagates out ofhandleFindCommandsentirely — there is no fall-through.Therefore after the interception,
action ∈ {click, fill, focus, type}: thewaitbranch, theexists/get_text/get_attrshandlers,attachIssuedRefsGeneration, and the sessionless-find device resolution were unreachable, andfindActionRequiresRectwas constanttrue.Empirical confirmation: planted
throw new Error('DEAD_CODE_PROBE_…')at the top of all four read-only handlers — the full find handler suite (16 tests, including the threefind … waittests) stays green, matching the #1288 live evidence that a debug marker inhandleFindWaitnever fired.Changes
handleFindWait,handleFindExists,handleFindGetText,handleFindGetAttrs,attachIssuedRefsGeneration,isReadOnlyFindAction,findActionRequiresRect, and the sessionlessresolveTargetDevice/ensureDeviceReadyfallback fromhandlers/find.ts.requiresRect === true: match resolution always requires rects, always filters the root container, always prefers on-screen matches;FindContext.sessionis now non-nullable.scopethreading: the find fetcher'ssnapshotScopewas alwaysundefined, so thelegacyIosSparse.scoperecovery field (only ever populated withundefined, only ever by find) is removed fromselector-capture-runtime.ts.The
find … wait/exists/getbehavior itself is unchanged — it lives in the selector runtime (selector-read.ts) and its tests (including the wait tests infind.test.ts, which exercise the runtime route) are untouched and green.Gates
pnpm typecheck,pnpm lint,pnpm format✅pnpm check:fallow,pnpm check:production-exports,pnpm check:layering— no issues ✅pnpm test:unit: 4100/4102 passed; the 2 failures are the known CPU-contention flake inruntime-hints.test.ts(26s under load, passes in isolation in 2.6s) ✅pnpm build+pnpm test:smoke✅No live device run: the removal is behavior-preserving by construction (dead code) and the surviving mutating-find paths are covered by the handler suite.