You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(device): hard-fail device_screenshot on explicit-platform raw failure (closes#136 sub-issue 1) (#174)
* chore: gitignore codex-pair per-developer artifacts
codex-pair (ask-llm plugin) is opt-in via a .codex-pair-context.md marker
in the project root. The marker enables the PostToolUse hook; its content
is the per-file project context the reviewer uses.
Marker is per-developer (own model/threshold preferences, own rules) so
it does not belong in shared history. Same for the log, cache, and pause
sentinel directories — all developer-local.
See https://github.com/Lykhoyda/ask-llm marketplace plugin for details.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
* fix(device): hard-fail device_screenshot when platform: explicit and raw path fails
Closes#136 (sub-issue 1 — re-evidence on #60).
PR #142's "graceful degradation" — on raw screenshot failure, fall through to
runAgentDevice — was the regression vector. agent-device's --platform routing
is exactly the broken path PR #142 was created to avoid. The fallback re-
introduced the bug whenever the raw path tripped on transient state (the
user's session: OOM-unstable emulator → adb devices reports it as 'offline'
→ parseAdbDevicesEmu skips it → resolver returns null → fallback fires →
iOS screen captured for a platform=android request).
New behavior: when platform: is passed explicitly and the raw path fails,
return a structured failResult with code=SCREENSHOT_FAILED and
meta.reason=('no-device' | 'capture-failed') instead of trying agent-device.
The error message names the underlying CLI (xcrun simctl / adb) and the
sub-cause so the caller knows what to fix (boot a device vs retry a transient
state). Implicit-platform calls (platformExplicit=false) still route through
runAgentDevice — backward parity preserved by the existing
'platformExplicit=false → uses runAgentDevice (backward parity)' test.
Changes:
- src/tools/device-screenshot-raw.ts: tryRawScreenshot now returns a
discriminated union {ok:true,path} | {ok:false,reason} so callers can
distinguish resolver miss from capturer failure.
- src/tools/device-list.ts: captureAndResizeScreenshot returns failResult
on explicit-platform raw failure; imports failResult.
- test/unit/gh-136-screenshot-raw-platform.test.js: inverted the existing
'falls through' test to assert hard-fail; added a second hard-fail test
for the capture-failed surface; tightened the three pre-existing
resolver/capturer null-checks to deepEqual on the new union shape.
Verified: 1465/1465 cdp-bridge unit tests passing (+1 net new test).
Also included: scripts/cdp-bridge/dist/tools/device-permission.js — dist
was stale relative to source (PR #169's second escapeRegex site fix never
made it to dist). Rebuilt locally; no source change.
NOTE: codex-pair flagged an unrelated pre-existing issue in this file:
deriveScreenshotPath throws PathTraversalScreenshotError on a '..' path,
but no catch wraps the handler, so a bad path becomes an uncaught tool
exception. Filed as #136-followup, NOT addressed here.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
? `No booted ${args.platform==='ios' ? 'iOS Simulator' : 'Android emulator'} detected by ${cli}. Boot one and retry; if your emulator is in 'offline' or 'unauthorized' state, restart it.`
170
+
: `Capture command failed (${cli}). The device may be transitioning state (booting, OOM, locked). Retry once it stabilizes.`;
? `No booted ${args.platform==='ios' ? 'iOS Simulator' : 'Android emulator'} detected by ${cli}. Boot one and retry; if your emulator is in 'offline' or 'unauthorized' state, restart it.`
233
+
: `Capture command failed (${cli}). The device may be transitioning state (booting, OOM, locked). Retry once it stabilizes.`;
0 commit comments