[codex] Structure preferred editor failures - #3390
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
ApprovabilityVerdict: Approved This is a low-risk refactoring that restructures error classes to use typed fields instead of plain message strings. The error conditions and control flow remain unchanged; only the error data structure is improved. You can customize Macroscope's approvability policy. Learn more. |
|
Superseded by #3324. The richer targetPath/environmentId/availableEditorIds error shape has been applied to the older reviewed PR. |
Summary
Opening a path in the preferred editor represented two distinct precondition failures with one
Data.TaggedErrorwhose only field was caller-supplied message text. That made “no environment selected” and “no compatible editor available” indistinguishable except by parsing their messages, and discarded the path and editor-selection context at the async command boundary.This change gives each failure its own Schema error type. The missing-environment error records the attempted path. The unavailable-editor error records the environment, attempted path, and reported editor IDs. Each message is derived from those fields, and the command error channel now exposes the distinct types directly. There are no reason switches or constructor wrappers.
No behavior test was added for this pure error-model refactor.
Validation
pnpm vp check(passes with existing repository warnings)pnpm vp run typecheckNote
Low Risk
Pure error-model refactor in editor preferences with no runtime behavior change beyond richer failure payloads and messages.
Overview
Preferred-editor open failures are no longer a single
Data.TaggedErrorwith a free-formmessage. They are split into two Effect Schema tagged error classes so callers can branch on type instead of parsing strings.PreferredEditorEnvironmentRequiredErroris returned when no environment is selected; it carriestargetPath.PreferredEditorUnavailableErroris returned when no compatible editor exists; it carriesenvironmentId,targetPath, andavailableEditorIds. User-facing text is computed from those fields via overriddenmessagegetters.useOpenInPreferredEditor’s result error union is updated to expose both types explicitly.Reviewed by Cursor Bugbot for commit 09d324b. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure preferred editor failures into distinct typed errors in
useOpenInPreferredEditorPreferredEditorUnavailableErrorinto two distinctSchema.TaggedErrorClasstypes:PreferredEditorEnvironmentRequiredError(no environment selected) andPreferredEditorUnavailableError(no matching editor found).PreferredEditorEnvironmentRequiredErrorcarriestargetPathand reports that no environment is selected.PreferredEditorUnavailableErrornow carries structured fields:environmentId,targetPath, andavailableEditorIds.effect/Schemainstead ofeffect/Data, enabling schema-based introspection of error fields.Macroscope summarized 09d324b.