Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

Mergedmaria-rcksmerged 3 commits intomain fromrefs/pull/25216/headmerged by maria-rcks View on GitHub

maria-rckscommented

Problem

device_screenshot hides actionable typed errors from agents and omits their messages from structured results. A reachable hub's HTTP rejection is also mislabeled as a transport failure.

Change

Preserve recognized device errors' public messages in both MCP result formats, with device-list/reopen guidance for hub rejection. Classify non-2xx screenshot responses as hub_rejected; keep unknown failures generic and nested diagnostics private.

Verification

  • Six regression cases failed on main before the fix: missing/open-device errors, transport failure, hub rejection, and HTTP 400/500 classification.
  • Blacksmith: 55 focused tests pass; vp run check:changed passes format, lint, knip, GraphQL generation, affected typechecks, and nearby tests.
  • Runtime: production hub operations with the Node HTTP client against a loopback HTTP 500 returned hub_rejected and its public message.
  • GitHub CI passes; the head is mergeable. Two independent GPT-6.1-Sol reviews found no actionable issues. Macroscope approved; CodeRabbit was rate limited and did not review.
  • Unverified: a live provider turn, physical device/simulator capture, and SSH transport. No UI changes.

Takeover

Replaces #24040, with thanks to @nateEc for the original implementation.

Built with GPT-6.1-Sol in the Codex harness on T3 Code.

    1. 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 476590d0adede15a4eec0d05b8adac8c63736452 and 8260a35ca348c9cc33ed1e198abddf55f326631f.

      Files selected for processing: 4
      • apps/server/src/device/DeviceHubOperations.ts
      • apps/server/src/device/DeviceService.test.ts
      • 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; 8 remain after this review.

      Walkthrough

      Screenshot HTTP status-code errors now map to hub_rejected. MCP screenshot errors return recognized messages, with additional guidance for hub rejections.

      Changes: Screenshot error handling

      Layer / File(s)Summary
      Classify hub screenshot rejections
      apps/server/src/device/DeviceHubOperations.ts, apps/server/src/device/DeviceService.test.ts
      Screenshot HTTP status-code errors 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
      The formatter returns recognized device or orchestrator error messages. For hub rejections, it adds guidance to check device state and reopen the device. Tests cover failure cases and verify that private hub output is not exposed.
      Priority: Normal

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

      Change: Bug fix

      Possibly related issues

      • pingdotgg/t3code issue 24033: This change addresses the issue’s reported loss of device error messages and hub failure reasons. The broader payload described in the issue is not covered.

      Suggested labels: bugfix

      Suggested reviewers: juliusmarminge, gabrielelpidio

      Merge Risk: Minimal · up to 8260a

      Screenshot failures provide actionable messages while keeping hub diagnostics private. No material merge risk remains.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Title checkPassedThe title "fix(mcp): preserve actionable device screenshot errors" follows conventional commit format and names the main change. The raw summary shows changes to McpHttpServer's screenshot error forma…
      Description checkPassedThe description covers the Problem, Change, and Verification sections from the template. The Problem and Change sections are clear and specific. The Verification section lists focused tests, a check r…
      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.
      Full details: Title check

      Explanation

      The title "fix(mcp): preserve actionable device screenshot errors" follows conventional commit format and names the main change. The raw summary shows changes to McpHttpServer's screenshot error formatter, which keeps recognized device error messages in results. It also shows hub HTTP non-2xx responses classified as hub_rejected in DeviceHubOperations, which the title does not mention. That part is a secondary aspect of the change.

      Full details: Description check

      Explanation

      The description covers the Problem, Change, and Verification sections from the template. The Problem and Change sections are clear and specific. The Verification section lists focused tests, a check run, a runtime check against loopback HTTP 500, and unverified areas. The Scope and approval section is missing. It has no linked issue, no maintainer-approved discussion, and no explanation for an exemption. The description says it replaces #24040 but does not link a triaged issue or approval. The template requires this section, so the description is not fully complete. Most of the template is filled, so the check passes.

      Resolution

      Add the "Scope and approval" section. Link the triaged bug issue or the maintainer-approved discussion, including the approval comment. If no prior issue exists, explain why this small, focused fix of an obvious bug qualifies for an exemption. The #24040 reference may serve as context but does not replace the approval link.

      Finishing Touches
      📝 Generate docstrings
      • Commit to this branch
      • Create a new PR
      🧪 Generate unit tests (beta)
      • Commit to this branch
      • 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.
    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 8260a35

      Macroscope's review found this PR approvable — Screenshot failures now distinguish hub rejection from communication failure and provide conditional device-list/reopen guidance. The change affects error reporting only, without automatically changing device state or exposing nested diagnostics.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. github-actions[bot](GitHub profile, opens in a new tab)commented

      Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.6 KiB21.6 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Baseline: 476590d · PR result: 8260a35 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. Note

      Written by gpt-6.1-sol on behalf of Maria

      Verified in a real dev environment

      verified the no-open-device error paths on linux through the actual web composer → codex gpt-6.1-sol → t3-code mcp → running dev server. used repo playwright and /usr/bin/google-chrome; created the projects and threads through the app and enabled device access in settings. no mocks or scenario fixtures.

      • before: github/main at f6d3700ac3, installed with vp i in ../main. both device_screenshot({}) and device_screenshot({deviceId:"missing",hostId:"local"}) returned only Device screenshot failed. and omitted error.message from structured content. device_list confirmed no open devices.
      • after: exact head c313e782817ee44b3e70668a26b5be77c9950519, installed with vp i, running in an explicit isolated .t3 home after stopping main. the same calls returned No device is open in this thread. Call device_open first. and Device missing on host local is not open in this thread. Call device_open first. respectively. both text and structuredContent.error.message carried the exact message.
      • neighbors: device_list succeeded; device_close({}) on the empty thread succeeded, and a subsequent list still returned devices:[] and open:[].
      • existing focused tests passed on blacksmith: 57 tests across McpHttpServer.test.ts, DeviceService.test.ts, and McpDeviceToolkit.test.ts. existing ci reports 29 successful checks, none failing or pending. no source changes or pushes.

      raw tool-response transcript

      main: generic screenshot failure and missing structured message

      pr: both actionable screenshot errors preserved in text and structured content

      Not verified

      successful device image capture, actual hub http rejection / transport failure, ssh device hosts, physical devices, native ios/android clients, and macos/windows. device listing reports ios requires macos/xcode and android emulator is missing; no remote hosts are configured. the http 400/500 classification and private-diagnostic filtering passed existing tests, but those are not live-device verification. no visual or timing behavior changed, so server tool-response transcripts and screenshots are the evidence.

      setup note: the first pr launch from the root checkout defaulted to ~/.t3; it was stopped and restarted with --home-dir /home/user/t3code/.t3 before any pr provider turns. the reported after results use only the isolated server.

    5. Note

      Written by gpt-6.1-sol on behalf of Maria

      verified head 8260a35ca348c9cc33ed1e198abddf55f326631f after merging github/main with a merge commit. the conflict resolution preserves main's actionable host errors and this pr's hub rejection guidance. updated the existing screenshot regression mock for main's locateSession lookup. the diff remains four files.

      • blacksmith vp run check:changed passed: format, lint, knip, graphql, typecheck of three packages, and 70 tests. neighboring McpDeviceToolkit.test.ts passed 14/14.
      • two independent read-only reviewers approved this exact head with no remaining findings.
      • ran a real codex gpt-6-luna turn through an isolated dev server and inspected its completed thread in the web client using playwright with /usr/bin/google-chrome.
      • device_screenshot({}) returned No device is open in this thread. Call device_open first. in text and structuredContent.error.message.
      • device_screenshot({"deviceId":"missing","hostId":"local"}) returned Device missing is not open in this thread. Call device_open first. in both fields.
      • device_list, empty device_close, and the subsequent device_list succeeded. the disabled-access guard also returned its actionable error in both screenshot fields.
      • all 32 checks are green, github reports CLEAN / MERGEABLE, and there are no inline review comments. no merge performed.

      successful image capture, live hub rejection/transport failures, remote device hosts, physical devices, and native clients remain unverified here. HTTP 400/500 classification and diagnostic filtering are covered by the passing existing tests. no UI code changed.

    6. maria-rcks merged thisc3d8c4b

    7. maria-rcks closed this

Sign in to join this conversation.