Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mcp): preserve actionable device screenshot errors #24040

ClosednateEc(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/24040/headopened View on GitHub

Problem

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_failed before the change and now classify as hub_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 DeviceHubOperations with 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. Approvability

      Verdict: Approved at f42ff72

      Macroscope'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).
    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review.

      Recent review info
      Run configuration
      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.ts
      • apps/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

      Layer / File(s)Summary
      Classify screenshot hub errors
      apps/server/src/device/DeviceHubOperations.ts, apps/server/src/device/DeviceService.test.ts
      HTTP 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.ts
      MCP 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.
      Priority: Low

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Possibly related issues

      • pingdotgg/t3code#24033: Reports that device_screenshot replaces 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 --display argument.

      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: bugfix

      Suggested reviewers: juliusmarminge

      Merge Risk: Minimal · up to 98742

      Screenshot failures now provide device-specific guidance without exposing the inspected hub diagnostics. No merge-blocking issue was identified.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title clearly and concisely describes the main change: preserving actionable device screenshot errors in MCP.
      Description checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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
      Comment `@coderabbitai help` to get the list of available commands.
    3. 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.

    4. juliusmarminge added labelsbugfix

    5. juliusmarminge added labelspr:needs-julius

    6. Closing in favour of #25216, which makes the same change. Thanks for the work here!

    7. juliusmarminge closed this

    8. juliusmarminge removed labelspr:needs-julius

Sign in to join this conversation.