Skip to content

[codex] Split preferred editor precondition errors - #3324

Merged
juliusmarminge merged 2 commits into
mainfrom
codex/web-editor-errors
Jun 20, 2026
Merged

[codex] Split preferred editor precondition errors#3324
juliusmarminge merged 2 commits into
mainfrom
codex/web-editor-errors

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • split the two preferred-editor precondition failures into distinct Schema error tags
  • attach attempted path, environment ID, and available editor IDs as structured fields
  • derive stable messages from those fields so callers never need to parse arbitrary text
  • keep the command result error channel structurally discriminable

No behavior test was added for this pure error-model refactor.

Validation

  • pnpm vp check (passes with existing repository warnings)
  • pnpm vp run typecheck

Note

Split useOpenInPreferredEditor precondition errors into distinct typed errors

  • Adds PreferredEditorEnvironmentRequiredError for the case where no environment is selected, carrying targetPath and a specific message.
  • Refactors PreferredEditorUnavailableError into a Schema.TaggedErrorClass with structured fields: environmentId, targetPath, and availableEditorIds.
  • The useOpenInPreferredEditor hook now returns distinct error types for these two failure cases instead of reusing a single error class.

Macroscope summarized 9f64e27.


Note

Low Risk
Localized change to editor open preconditions in editorPreferences.ts; callers must handle an additional error tag if they pattern-match failures.

Overview
useOpenInPreferredEditor now returns two discriminable precondition failures instead of one generic PreferredEditorUnavailableError with a free-form message.

When environmentId is null, callers get PreferredEditorEnvironmentRequiredError with targetPath. When no editor can be resolved, they get PreferredEditorUnavailableError carrying environmentId, targetPath, and availableEditorIds. Both types move from Data.TaggedError to Schema.TaggedErrorClass, with user-facing text from a message getter rather than caller-supplied strings.

The hook’s result error union is updated accordingly. Any code that only handled PreferredEditorUnavailableError for the “no environment” case must handle PreferredEditorEnvironmentRequiredError separately.

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

Co-authored-by: codex <codex@users.noreply.github.com>
@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Jun 20, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR refactors error handling by splitting one error class into two more specific ones with structured properties. The runtime behavior remains the same - errors are thrown in identical conditions, just with better typing and messages. Low-risk code quality improvement.

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

@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: bb34be0e-dfc2-4b27-89b7-ba2e3b1d7238

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/web-editor-errors

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

Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp
macroscopeapp Bot dismissed their stale review June 20, 2026 14:51

Dismissing prior approval to re-evaluate 9f64e27

@juliusmarminge
juliusmarminge merged commit 7160814 into main Jun 20, 2026
16 checks passed
@juliusmarminge
juliusmarminge deleted the codex/web-editor-errors branch June 20, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 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