[codex] Structure mobile project thread validation errors#3387
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 |
Co-authored-by: codex <codex@users.noreply.github.com>
ApprovabilityVerdict: Approved This is a straightforward refactor extracting validation logic into structured error classes. The only behavioral change is adding You can customize Macroscope's approvability policy. Learn more. |
Summary
Mobile project-thread creation represented two distinct input failures as generic
Errorvalues. That discarded the environment, project, and creation-mode context needed to correlate repeated failures, and made both cases indistinguishable except for their message text.This change introduces separate Schema error classes for a missing task and a missing worktree base branch. The task error records the environment, project, and environment mode; the branch error records the environment and project. Their messages remain stable and are derived from the error type rather than an opaque reason string. A focused validation function now returns those errors before the command is dispatched, and the existing user-facing pending error behavior is unchanged.
No behavior test was added for this pure validation refactor.
Validation
pnpm vp check(passes with the repository existing warnings)pnpm vp run typecheckpnpm vp run lint:mobileNote
Low Risk
Client-side input validation only; behavior and displayed messages are unchanged aside from failure values being tagged errors instead of plain Error.
Overview
Project thread creation on mobile now validates through
validateProjectThreadCreationinstead of inline checks that threw genericErrorvalues.Two Effect Schema tagged errors cover the same cases as before: missing task text (includes environment, project, and local/worktree mode) and missing base branch for worktree creation (includes environment and project).
use-project-actionsstill surfaces the same user-facing strings viasetPendingConnectionError, but failures are returned asAsyncResult.failure(Cause.fail(validationError))so callers can distinguish error kinds by type.Reviewed by Cursor Bugbot for commit 4e208c3. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Replace generic errors with tagged validation errors for project thread creation
projectThreadCreationValidation.tswith two tagged error classes (ProjectThreadTaskRequiredError,ProjectThreadBaseBranchRequiredError) and avalidateProjectThreadCreationfunction that returns the appropriate error ornull.useCreateProjectThreadinuse-project-actions.tsto use the new validation function, replacing ad-hocErrorinstances with structured tagged errors.Errorto a tagged schema type.Macroscope summarized 4e208c3.