[codex] Structure mobile file rendering errors#3397
Conversation
Co-authored-by: codex <codex@users.noreply.github.com>
ApprovabilityVerdict: Approved This PR refactors error classes to use Schema-based definitions with better structure and contextual information. The changes are mechanical - error throwing logic remains the same, only the error structure is enhanced. Tests verify the new error format. You can customize Macroscope's approvability policy. Learn more. |
Co-authored-by: codex <codex@users.noreply.github.com>
Dismissing prior approval to re-evaluate 1cb9811
|
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 |
|
Superseded by #3287, which preserves the same source-highlight context while modeling native prefetch unavailability and rejected prefetches as distinct Schema errors. |
Summary\n\n- convert mobile source-highlighting and image-prefetch failures to Schema errors\n- attach source path/theme context without retaining file contents\n- preserve exact native highlighter and image-prefetch causes\n- replace schema-error instanceof checks with exported Schema.is predicates\n\n## Validation\n\n- pnpm vp test apps/mobile/src/features/files/sourceHighlightingState.test.ts apps/mobile/src/features/files/workspace-file-image-cache.test.ts\n- pnpm vp check\n- pnpm vp run typecheck\n- pnpm vp run lint:mobile
Note
Low Risk
Localized refactor of error types and catch handling in two mobile file-rendering caches, with expanded unit tests and no auth or data-path changes.
Overview
Mobile source highlighting and workspace image prefetch failures now use
Schema.TaggedErrorClassinstead ofData.TaggedError, with validated fields and user-facingmessagegetters.SourceHighlightErrorcarriespath,theme, andcause(file contents are not stored on the error).WorkspaceImagePrefetchErrorcarriesuriand an optionalcause; afalseprefetch result still fails with uri only. Catch paths use exportedSchema.isguards (isSourceHighlightError,isWorkspaceImagePrefetchError) instead ofinstanceof.Tests assert the structured error shape via
Cause.findErrorOption, including separate cases for boolean prefetch failure vs thrown native errors.Reviewed by Cursor Bugbot for commit 1cb9811. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Structure mobile file rendering errors with typed
SourceHighlightErrorandWorkspaceImagePrefetchErrorData.TaggedErrorwithSchema.TaggedErrorClassforSourceHighlightErrorandWorkspaceImagePrefetchError, adding structured fields (path, theme, uri) and an optional defect cause to each.isSourceHighlightErrorandisWorkspaceImagePrefetchErrortype guards viaSchema.isto replaceinstanceofchecks.Cause.findErrorOptionand assert error shape and preserved cause using the new type guards.Macroscope summarized 1cb9811.