feat(ui-automation): Add rs/1 runtime automation parity #416
9 issues
code-simplifier: Found 9 issues (1 medium, 8 low)
Medium
batchElements is always empty, making batch next-step block dead code - `src/mcp/tools/ui-automation/shared/runtime-next-steps.ts:349-405`
Remove batchElements and its dependent logic — it is always an empty array, so the batch spread block and its conditions in shouldPrioritizeScroll/hasUsefulRuntimeGuidance can never affect output.
Low
Duplicate `delayMs` helper copied from tap.ts instead of shared - `src/mcp/tools/ui-automation/button.ts:46-50`
The delayMs function introduced here is byte-for-byte identical to the one defined in tap.ts (lines 58–61); extract it to a shared utility (e.g. shared/delay.ts) to eliminate the duplication.
Redundant boolean exhaustion check can be simplified - `src/mcp/tools/ui-automation/shared/runtime-next-steps.ts:89-90`
Checking selected === true || selected === false is equivalent to selected !== undefined — prefer the simpler form to reduce unnecessary complexity.
framesIntersect return is a dense one-liner with four compound conditions - `src/mcp/tools/ui-automation/shared/runtime-snapshot.ts:137`
Split the AABB intersection check into named axis variables (overlapX, overlapY) for clarity, per the project's preference for explicit code over overly compact solutions.
IIFE with arrow function used instead of direct if/else chain - `src/mcp/tools/ui-automation/shared/runtime-snapshot.ts:533-545`
The const hierarchy = (() => { ... })() IIFE adds unnecessary nesting and uses an arrow function — replace with a direct if/else chain, which is simpler and consistent with the project's preference for the function keyword.
Also found at:
src/mcp/tools/ui-automation/shared/runtime-snapshot.ts:726-737
`resolveElementRef` duplicates the missing/expired detection already in `getRuntimeSnapshotLookup` - `src/mcp/tools/ui-automation/shared/snapshot-ui-state.ts:89-105`
Change snapshotExpiredError to accept ageMs: number directly (instead of (snapshot, nowMs)), then rewrite resolveElementRef to delegate to getRuntimeSnapshotLookup — eliminating the duplicate map access, expiry check, and runtimeSnapshots.delete call.
Import statements placed mid-file after export declarations - `src/types/domain-results.ts:53-58`
These import type statements are placed after several export type/export interface declarations, violating the ES module convention of grouping all imports at the top of the file before any exports.
Nested ternary operators used to determine primaryAction - `src/utils/renderers/domain-result-text.ts:1252-1261`
Replace the three-level nested ternary with an if/else chain — nested ternaries are explicitly flagged as an anti-pattern in the project's simplification standards.
Also found at:
src/utils/renderers/domain-result-text.ts:1473-1479src/utils/structured-output-envelope.ts:304-313
Redundant duplicate `JSON.stringify` branches in `formatMcpValue` - `src/utils/responses/next-step-formatting.ts:70-76`
The two separate if branches both return JSON.stringify(value) — combine them into a single condition to eliminate the redundancy.
⏱ 46m 17s · 1.9M in / 146.8k out · $5.09
Annotations
Check warning on line 405 in src/mcp/tools/ui-automation/shared/runtime-next-steps.ts
github-actions / warden: code-simplifier
batchElements is always empty, making batch next-step block dead code
Remove `batchElements` and its dependent logic — it is always an empty array, so the batch spread block and its conditions in `shouldPrioritizeScroll`/`hasUsefulRuntimeGuidance` can never affect output.