fix(mcp): preserve actionable device screenshot errors #24040
main fromrefs/pull/24040/head·opened View on GitHubProblem#
Addresses #24033: device_screenshot replaces actionable typed errors with Device screenshot failed. in text-only clients, and omits their message from structured content. A reachable hub returning HTTP 500 is also mislabeled as a communication failure.
Change#
Preserve the public message of recognized device errors in both MCP result representations. Classify non-2xx screenshot responses as the existing hub_rejected reason, with instructions to inspect device state and reopen it if needed. Keep the generic fallback for unrecognized failures and do not expose raw hub output, response bodies, stack traces, or nested causes.
No new schema, device-state probe, screenshot retry, or change to authorization. This works through the shared MCP registration for every provider and local/remote device host. It does not infer that a device is shut down from a stale cache or implement the report's proposed raw-diagnostics/correlation-ID payload; the issue remains available for those broader diagnostics.
Verification#
- The three initial MCP regression cases failed against main with the constant text: no open device, an explicitly requested device not open in the thread, and a device communication error.
- Tests invoke the real registered MCP tool and handlers with a fake device-service boundary. Both text and structured error messages are asserted, including hub rejection, and private nested cause text must not appear.
- HTTP 400/500 regression cases failed with
request_failedbefore the change and now classify ashub_rejected. vp test run apps/server/src/mcp/McpHttpServer.test.ts apps/server/src/device/DeviceService.test.ts: 53 tests pass.vp run check:changed: format, lint, knip, server GraphQL generation check, affected typechecks, and nearby tests pass.- Runtime probe used the production
DeviceHubOperationswith the real Node HTTP client against a disposable loopback HTTP server returning 500. Result:
{"httpStatus":500,"reason":"hub_rejected","message":"Device screenshot failed: The device hub could not complete the request."}
No physical device, simulator, provider turn, live environment, or client UI was operated for this backend fix. Native screenshot generation and actual SSH transport were not exercised.
Model: GPT-5-based Codex. Harness: Codex desktop.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: Approved at
f42ff72Macroscope's review found this PR approvable — This is a focused MCP error-handling fix that preserves actionable device screenshot failures and distinguishes hub rejections from transport failures. The production change is small, keeps fallback behavior intact, and includes targeted regression tests without schema or deployment impact.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: main
- File: .coderabbit.config.ts
- Commit: c3888da
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ab74cb44-033a-48eb-a654-af522aa483bc
Commits-
Reviewing files that changed from the base of the PR and between f42ff721032de86a36c3ffb6249b701965cdda7f and 987422ace4ca58a7e7bdb5785677a5e8efc2d97b.
Files selected for processing: 2-
apps/server/src/mcp/McpHttpServer.test.tsapps/server/src/mcp/McpHttpServer.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
-
Walkthrough
-
Screenshot requests now distinguish HTTP status errors from other failures. MCP screenshot errors return device-specific messages, including guidance for hub rejections.
Changes: Screenshot Error Reporting
Priority:Layer / File(s) Summary Classify screenshot hub errors
apps/server/src/device/DeviceHubOperations.ts,apps/server/src/device/DeviceService.test.tsHTTP status-code errors from screenshot requests now map to hub_rejected. Tests cover HTTP 400 and 500 responses.Format MCP screenshot errors
apps/server/src/mcp/McpHttpServer.ts,apps/server/src/mcp/McpHttpServer.test.tsMCP screenshot errors use device error messages. Hub rejections include guidance to check device state and reopen it if needed. Tests cover missing-device and screenshot failure cases, and verify that private hub output is excluded. LowEstimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Possibly related issues
- pingdotgg/t3code#24033: Reports that
device_screenshotreplaces actionable device errors with a generic message. This change returns recognized device error messages. - pingdotgg/t3code#24900: Reports an HTTP 500 screenshot failure from serve-sim. This change classifies HTTP status errors but does not address the missing
--displayargument.
Possibly related PRs
- pingdotgg/t3code#25121: Changes screenshot behavior for remote device-host responses and identifies preserving screenshot error messages as related work.
Suggested labels:
bugfixSuggested reviewers:
juliusmarminge - pingdotgg/t3code#24033: Reports that
Merge Risk:
Minimal · up to98742-
Screenshot failures now provide device-specific guidance without exposing the inspected hub diagnostics. No merge-blocking issue was identified.
Pre-merge checks:
4-
Check name Status Explanation Title check The title clearly and concisely describes the main change: preserving actionable device screenshot errors in MCP. Description check The description covers the problem, implementation, scope, verification results, limitations, issue reference, and agent details. It is focused and sufficiently complete for the repository template. Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
-
Merged current main c3888da8b4 without rewriting history in 987422ace4. Kept the actionable screenshot-error regression cases while adopting main's tool registration changes. check:changed passed all scoped gates and 55 tests across the two affected test files. No device or real account was accessed.
juliusmarminge added labelsbugfix
juliusmarminge added labelspr:needs-julius
Closing in favour of #25216, which makes the same change. Thanks for the work here!
juliusmarminge closed this
juliusmarminge removed labelspr:needs-julius
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes