Skip to content

[codex] Structure preview automation failures#3333

Merged
juliusmarminge merged 2 commits into
mainfrom
codex/preview-automation-structural-errors
Jun 20, 2026
Merged

[codex] Structure preview automation failures#3333
juliusmarminge merged 2 commits into
mainfrom
codex/preview-automation-structural-errors

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • replace name-mutated generic automation errors and the tab-error constructor wrapper with schema-tagged errors carrying request, environment, thread, tab, operation, readiness, and timeout context
  • keep wire compatibility by letting each specialized error map itself to the existing broker response tag
  • serialize structured automation attributes as response detail while excluding causes and Error internals

Verification

  • vp test apps/web/src/components/preview/PreviewAutomationOwner.test.ts apps/web/src/components/preview/previewAutomationRequestConsumer.test.ts (6 tests)
  • vp check (passes with 20 pre-existing warnings)
  • vp run typecheck

Note

Medium Risk
Changes the shape of automation error responses (structured detail) and all failure paths in the preview owner; wire tags are preserved via responseTag but clients parsing errors may need to handle new detail fields.

Overview
Replaces ad-hoc Error objects (with mutated name fields) in preview automation handling with Effect Schema.TaggedErrorClass types that carry request/environment/thread/tab context and map to existing broker _tag values via responseTag.

PreviewAutomationOwner now throws dedicated errors for overlay timeouts, navigation readiness timeouts, stale thread owners, missing bridge/tab targets, and inactive recordings. Wait helpers take requestId (and thread context for navigation timeouts); navigation readiness defaults to load when omitted.

serializePreviewAutomationError prefers responseTag over error.name, builds detail from structured PreviewAutomation* error fields (excluding cause, stack, etc.), and adds a test asserting causes are not leaked on the wire.

Clients still see the same high-level response tags in most cases, but failures can include richer detail instead of generic messages only.

Reviewed by Cursor Bugbot for commit 2c617f3. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Replace generic errors with structured tagged error classes in preview automation

  • Adds five typed error classes (PreviewAutomationOverlayTimeoutError, PreviewAutomationNavigationTimeoutError, PreviewAutomationStaleOwnerError, PreviewAutomationTargetUnavailableError, PreviewAutomationRecordingNotActiveError) in PreviewAutomationOwner.tsx, replacing generic Error instances with structured, tagged errors carrying contextual fields (requestId, environmentId, threadId, etc.).
  • Each error carries a responseTag that controls the serialized _tag emitted to consumers, decoupling the internal error type from the protocol-level error code.
  • serializePreviewAutomationError in previewAutomationRequestConsumer.ts is extended to derive a detail object from enumerable error fields (excluding cause, stack, and other reserved keys) and to override _tag with responseTag when present.
  • Behavioral Change: serialized automation errors may now include a detail object and a different _tag than before; cause is explicitly excluded from serialized output.

Macroscope summarized 2c617f3.

Co-authored-by: codex <codex@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b4c1a4ce-73f5-4fab-97c5-a2d85ebe3b87

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/preview-automation-structural-errors

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jun 20, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Missing recording response tag
    • Added a responseTag getter returning "PreviewAutomationExecutionError" to PreviewAutomationRecordingNotActiveError, aligning its wire serialization with the pre-existing contract and the pattern used by all other automation error classes.

Create PR

Or push these changes by commenting:

@cursor push e7298b881e
Preview (e7298b881e)
diff --git a/apps/web/src/components/preview/PreviewAutomationOwner.tsx b/apps/web/src/components/preview/PreviewAutomationOwner.tsx
--- a/apps/web/src/components/preview/PreviewAutomationOwner.tsx
+++ b/apps/web/src/components/preview/PreviewAutomationOwner.tsx
@@ -121,6 +121,10 @@
     tabId: PreviewTabId,
   },
 ) {
+  get responseTag() {
+    return "PreviewAutomationExecutionError";
+  }
+
   override get message(): string {
     return `Preview automation request ${this.requestId} found no active recording for tab ${this.tabId} on environment ${this.environmentId} thread ${this.threadId}.`;
   }

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit f74d823. Configure here.

Comment thread apps/web/src/components/preview/PreviewAutomationOwner.tsx
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR refactors error handling by replacing generic Error objects with structured, typed error classes. The changes are mechanical - same error semantics with richer context metadata - and include appropriate test coverage.

You can customize Macroscope's approvability policy. Learn more.

Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge
juliusmarminge merged commit 8c03188 into main Jun 20, 2026
16 checks passed
@juliusmarminge
juliusmarminge deleted the codex/preview-automation-structural-errors branch June 20, 2026 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant