Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): unlock the composer when preview capture fails #9127

Mergedt3dotgg(GitHub profile, opens in a new tab)merged 9 commits intomain fromrefs/pull/9127/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Picking an element in the browser preview and pressing send could leave the overlay stuck on "Capturing..." forever. No attachment landed, no message went out, and the composer stayed locked until the thread reloaded.

Two unbounded waits caused it. In the main process, capturePage never settles when the guest's compositor is wedged. In the picker preload, getElementContext can stay pending on some pages. Either one strands the pick session, so the renderer keeps awaiting a result that never arrives and focus never returns to the composer.

The fix bounds both capture steps with a timeout. Every exit from a pick session now resolves the renderer's promise exactly once, so a cancelled or replaced session can no longer return without settling. When the crop fails, the picker raises an error toast and sends the message without the attachment instead of holding the composer.

Closes #9026

Built by Claude Opus 5 in the Claude Code harness.


Note

Medium Risk Changes concurrent pick-session lifecycle and timed capture paths across main, preload, and renderer; legitimate crops slower than 5s may now arrive without a screenshot instead of blocking indefinitely.

Overview Fixes preview element picks that could hang on "Capturing…" and never return focus to the composer when screenshot or context capture never completes.

Desktop (PreviewManager) adds a 5-second bound on guest capturePage for annotation crops (interruptible via abort signal) and returns screenshotFailed: true when the crop times out or errors. pickElement is reworked so each session settles exactly once (cancel/replace always resolves the renderer), overlapping picks swap sessions atomically, and a late crop from a replaced pick cannot send preview:annotation-captured or tear down a newer overlay.

Guest preload (PickPreload) caps getElementContext at 5s and falls back to a DOM-only element payload instead of dropping the target; submit snapshots comment/regions/strokes/style changes, skips IPC if the overlay already finished, and tears down on capture rejection so main is not left waiting.

Web replaces direct screenshot file conversion with capturePreviewAnnotationScreenshot (timed fetch → captured / none / failed). PreviewView shows an error toast when the crop was dropped, stores/forwards annotations without a screenshot on failure, and still sends the message without an image attachment.

Contracts add optional screenshotFailed on PreviewAnnotationSubmissionResult.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit b925f2e4ecc171174c8563cafd387e63f8484f1f. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Unlock composer when preview screenshot capture fails or times out

  • Adds a 5-second timeout to desktop screenshot capture (Manager.ts), web screenshot conversion (previewAnnotation.ts), and React context lookup (PickPreload.ts) so the annotation flow always settles instead of hanging
  • Reworks PreviewManager.pickElement pick-session ownership so cancellation, replacement, and navigation each settle the pick at most once; stale captures from a replaced session no longer send annotation-captured IPC into the active session
  • Adds optional screenshotFailed to PreviewAnnotationSubmissionResult in ipc.ts and updates PreviewView.tsx to keep the annotation with a null screenshot and show an error toast when capture or conversion fails
  • Behavioral Change: annotations with a failed screenshot are now stored with screenshot: null and screenshotFailed: true instead of being dropped or hanging the composer; out-of-tree consumers expecting rejection on capture failure will receive a settled result with a null screenshot
Macroscope summarized b925f2e.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      This toast tells the user to resend, but nothing was withheld: when submission === "send" the code below immediately calls onSendAnnotation(annotation, null) (asserted by PreviewView.test.tsx → "still sends when the picked element's crop cannot be captured"), and in the draft path the annotation is already in the composer. Following the instruction would send a duplicate message. Consider stating what actually happened instead of asking for a retry.

                    description: "The annotation was kept without the screenshot.",
      Posted via Macroscope — UI Consistency
    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 wire13.6 KiB13.6 KiB+7 B (+0.1%)15.1 KiB✅
      CodexThread snapshot wire7.0 KiB7.0 KiB+5 B (+0.1%)7.3 KiB✅
      CodexLive turn WebSocket wire6.6 KiB6.6 KiB+2 B (+0.0%)7.8 KiB✅
      CodexLive turn WebSocket decoded57.1 KiB57.1 KiB0 B (0.0%)66.4 KiB✅
      CodexLive turn messages10100 (0.0%)21✅
      ClaudeTotal thread wire13.6 KiB13.6 KiB−18 B (−0.1%)15.1 KiB✅
      ClaudeThread snapshot wire7.0 KiB7.0 KiB+3 B (+0.0%)7.3 KiB✅
      ClaudeLive turn WebSocket wire6.5 KiB6.5 KiB−21 B (−0.3%)7.8 KiB✅
      ClaudeLive turn WebSocket decoded57.8 KiB57.8 KiB0 B (0.0%)66.4 KiB✅
      ClaudeLive turn messages990 (0.0%)21✅

      Baseline: 2b745ef · PR result: b925f2e · 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: 113.8 KiB
      • Claude decoded thread snapshot: 114.5 KiB

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

    4. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This change modifies the existing preview-capture flow across desktop main, Electron preload, web UI, and IPC, including concurrent session lifecycle and timeout behavior. It also broadens a file-level static-analysis suppression to disable timer diagnostics, warranting focused human review.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. Note

      🤖 Claude Fable 5.1 responding on behalf of Theo

      Fixed in f99b885. The toast now says what happened: "The message was sent without the screenshot" on send, "The annotation was added without the screenshot" on attach.

    6. Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6847d7ab3c12dbc84d473fde27ca28bf70d57f8b. Configure [here](https://www.cursor.com/dashboard/bugbot).

Sign in to join this conversation.