Skip to content

[codex] Structure native view resolution failures - #3353

Merged
juliusmarminge merged 2 commits into
mainfrom
codex/mobile-native-view-errors
Jun 20, 2026
Merged

[codex] Structure native view resolution failures#3353
juliusmarminge merged 2 commits into
mainfrom
codex/mobile-native-view-errors

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Jun 20, 2026

Copy link
Copy Markdown
Member

What Changed

  • added a schema-backed native-view resolution error carrying the Expo module name and exact cause
  • report failures to require the terminal and review-diff native views before retaining their existing null fallback
  • extended the focused resolver tests to verify structured diagnostics and cause preservation

Why

Both resolvers silently discarded requireNativeView failures. The UI fallback is intentional, but the failure now remains diagnosable without changing availability behavior.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI changes

Validation

  • vp test apps/mobile/src/features/terminal/nativeTerminalModule.test.ts apps/mobile/src/features/diffs/nativeReviewDiffSurface.test.ts
  • vp check (passes with 20 pre-existing warnings)
  • vp run typecheck
  • vp run lint:mobile

Note

Low Risk
Observability and retry-avoidance only; public resolver return values and UI fallback paths are unchanged.

Overview
Native Expo view resolvers for review diff and terminal surfaces no longer swallow requireNativeView failures. On error they log a NativeViewResolutionError (module name + original cause) via console.error, set a one-shot failure flag so later calls skip re-invoking requireNativeView, and still return null for the existing JS fallback.

Adds nativeViewResolutionError.ts as a shared Effect Schema tagged error. Resolver tests now assert structured logging, preserved cause, and that a second resolve attempt does not call requireNativeView again.

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

Note

Structure native view resolution failures with NativeViewResolutionError and memoized failure state

  • Adds a new NativeViewResolutionError tagged error class (via effect/Schema) carrying nativeModuleName and cause fields.
  • Updates resolveNativeReviewDiffView and resolveNativeTerminalSurfaceView to catch failures, log a NativeViewResolutionError to console.error, and set a module-level flag so subsequent calls return null immediately without retrying.
  • Behavioral Change: after the first requireNativeView failure, the resolver short-circuits all subsequent calls rather than re-attempting resolution.

Macroscope summarized 4b5ceb1.

Co-authored-by: codex <codex@users.noreply.github.com>
@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: 05eb3bb1-8353-4b0e-9b15-96380ef0b21b

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/mobile-native-view-errors

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:M 30-99 changed lines (additions + deletions). labels Jun 20, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Uncached failures repeat logging
    • Added a module-level boolean flag in each resolver that is set to true in the catch block, causing subsequent calls to short-circuit and return null without retrying or re-logging the error.

Create PR

Or push these changes by commenting:

@cursor push cf34a749ca
Preview (cf34a749ca)
diff --git a/apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts b/apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts
--- a/apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts
+++ b/apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts
@@ -130,6 +130,7 @@
 }
 
 let cachedNativeReviewDiffView: ComponentType<NativeReviewDiffViewProps> | undefined;
+let reviewDiffResolutionFailed = false;
 
 function getExpoViewConfig(moduleName: string) {
   return (globalThis as typeof globalThis & ExpoGlobalWithViewConfig).expo?.getViewConfig?.(
@@ -142,6 +143,10 @@
     return cachedNativeReviewDiffView;
   }
 
+  if (reviewDiffResolutionFailed) {
+    return null;
+  }
+
   if (getExpoViewConfig(NATIVE_REVIEW_DIFF_MODULE_NAME) == null) {
     return null;
   }
@@ -151,6 +156,7 @@
       NATIVE_REVIEW_DIFF_MODULE_NAME,
     );
   } catch (cause) {
+    reviewDiffResolutionFailed = true;
     console.error(
       new NativeViewResolutionError({
         nativeModuleName: NATIVE_REVIEW_DIFF_MODULE_NAME,

diff --git a/apps/mobile/src/features/terminal/nativeTerminalModule.ts b/apps/mobile/src/features/terminal/nativeTerminalModule.ts
--- a/apps/mobile/src/features/terminal/nativeTerminalModule.ts
+++ b/apps/mobile/src/features/terminal/nativeTerminalModule.ts
@@ -35,6 +35,7 @@
 }
 
 let cachedNativeTerminalSurfaceView: ComponentType<NativeTerminalSurfaceProps> | undefined;
+let terminalResolutionFailed = false;
 
 function getExpoViewConfig(moduleName: string) {
   return (globalThis as typeof globalThis & ExpoGlobalWithViewConfig).expo?.getViewConfig?.(
@@ -47,6 +48,10 @@
     return cachedNativeTerminalSurfaceView;
   }
 
+  if (terminalResolutionFailed) {
+    return null;
+  }
+
   if (getExpoViewConfig(NATIVE_TERMINAL_MODULE_NAME) == null) {
     return null;
   }
@@ -56,6 +61,7 @@
       NATIVE_TERMINAL_MODULE_NAME,
     );
   } catch (cause) {
+    terminalResolutionFailed = true;
     console.error(
       new NativeViewResolutionError({
         nativeModuleName: NATIVE_TERMINAL_MODULE_NAME,

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit fb0588b. Configure here.

Comment thread apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts
@macroscopeapp

macroscopeapp Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR adds structured error handling for native view resolution failures. The changes are self-contained, well-tested, and don't alter core functionality - they improve error observability and add a minor optimization to track failed resolution attempts.

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

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 20, 2026
Co-authored-by: codex <codex@users.noreply.github.com>
@macroscopeapp
macroscopeapp Bot dismissed their stale review June 20, 2026 13:10

Dismissing prior approval to re-evaluate 4b5ceb1

@juliusmarminge
juliusmarminge merged commit 779c237 into main Jun 20, 2026
16 checks passed
@juliusmarminge
juliusmarminge deleted the codex/mobile-native-view-errors branch June 20, 2026 18:06
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