Skip to content

[codex] Structure preview automation boundary failures - #3436

Merged
juliusmarminge merged 1 commit into
mainfrom
codex/structure-preview-automation-boundary
Jun 20, 2026
Merged

[codex] Structure preview automation boundary failures#3436
juliusmarminge merged 1 commit into
mainfrom
codex/structure-preview-automation-boundary

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • move the preview-owner error model into a dedicated module and add a structured operation boundary error
  • preserve existing tagged preview failures while wrapping unexpected open, bridge, IPC, and recording failures with request, operation, environment, thread, and tab context
  • keep the immediate failure as cause while returning only attribute-derived messages and bounded structural detail to the remote caller
  • sanitize unexpected handler rejections at the final response boundary instead of collapsing them through String(error)

Why

Unexpected preview automation failures previously escaped as raw errors. The response serializer could expose their messages while dropping the request context needed to correlate the failure. This keeps the diagnostic chain locally and sends a predictable, non-cause-derived response upstream.

Validation

  • vp test run src/components/preview/previewAutomationRequestConsumer.test.ts --project unit (from apps/web)
  • vp check
  • vp run typecheck

Note

Medium Risk
Changes how automation errors are surfaced to remote callers; behavior is intentional sanitization but affects debugging and any consumers expecting raw error text.

Overview
Preview automation failures are centralized in previewAutomationErrors.ts, with tagged errors, a PreviewAutomationOperationError wrapper, and serializePreviewAutomationOwnerError so remote responses use stable tags/messages and bounded detail without leaking cause.

PreviewAutomationOwner wraps the request handler in try/catch, tracks tabId through operations, and rethrows via PreviewAutomationOperationError.fromCause (known tagged errors pass through). The request consumer now takes environmentId and serializes failures with full operation context instead of inferring from raw Error names/messages.

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

Note

Standardize preview automation boundary failures into structured tagged errors

  • Extracts all error classes (PreviewAutomationOverlayTimeoutError, PreviewAutomationNavigationTimeoutError, PreviewAutomationStaleOwnerError, PreviewAutomationTargetUnavailableError, PreviewAutomationRecordingNotActiveError) into previewAutomationErrors.ts with rich contextual fields (requestId, environmentId, threadId, tabId).
  • Adds PreviewAutomationOperationError as a catch-all wrapper for unexpected failures, with a static fromCause that preserves known owner errors or wraps unknown ones, and a serializePreviewAutomationOwnerError function that converts errors to safe response payloads.
  • Updates PreviewAutomationOwner.handleRequest in PreviewAutomationOwner.tsx to wrap all operation branches in a try/catch and rethrow via PreviewAutomationOperationError.fromCause, and consistently awaits async calls.
  • Updates serializePreviewAutomationError in previewAutomationRequestConsumer.ts to accept operation context and always produce a standardized, sanitized error response.
  • Behavioral Change: createPreviewAutomationRequestConsumerAtom now requires environmentId; all error responses include structured context and raw causes are never leaked.

Macroscope summarized b4ba73d.

@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: 53994842-86ca-48b3-9daf-173b3d5be8f2

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/structure-preview-automation-boundary

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
Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge
juliusmarminge force-pushed the codex/structure-preview-automation-boundary branch from 2489dcc to b4ba73d Compare June 20, 2026 20:35
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

Refactors error handling by extracting error classes to a dedicated file and adding a structured error boundary that wraps all exceptions with context for consistent serialization. The existing operation logic is unchanged; tests verify sensitive information is not leaked in error responses.

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

@juliusmarminge
juliusmarminge merged commit fc2cdec into main Jun 20, 2026
16 checks passed
@juliusmarminge
juliusmarminge deleted the codex/structure-preview-automation-boundary branch June 20, 2026 20:50
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