The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 24, 22:45 UTC
[codex] Structure native view resolution failures (#3353)
Co-authored-by: codex <codex@users.noreply.github.com>
Julius Marminge committed
Jun 20, 2026 at 11:06 UTC
779c2374876884992c7cdf059556acd255db824e
5 files changed
+71
-4
apps/mobile/src/features/diffs/nativeReviewDiffSurface.test.ts
+14
-1
@@ -58,10 +58,23 @@ describe("resolveNativeReviewDiffView", () => {
58
59
it("returns null when the view manager cannot be required", async () => {
60
setExpoViewConfigAvailable();
61
+ const cause = new Error("boom");
62
expoMocks.requireNativeView.mockImplementation(() => {
62
- throw new Error("boom");
63
+ throw cause;
64
});
65
+ const consoleError = vi.spyOn(console, "error").mockImplementation(() => undefined);
66
const { resolveNativeReviewDiffView } = await import("./nativeReviewDiffSurface");
67
+
68
+ expect(resolveNativeReviewDiffView()).toBeNull();
69
expect(resolveNativeReviewDiffView()).toBeNull();
70
+ expect(expoMocks.requireNativeView).toHaveBeenCalledTimes(1);
71
+ expect(consoleError).toHaveBeenCalledWith(
72
+ expect.objectContaining({
73
+ _tag: "NativeViewResolutionError",
74
+ nativeModuleName: "T3ReviewDiffSurface",
75
+ cause,
76
+ }),
77
+ );
78
+ expect(consoleError).toHaveBeenCalledTimes(1);
79
});
80
});
apps/mobile/src/features/diffs/nativeReviewDiffSurface.ts
+15
-1
@@ -2,6 +2,8 @@ import type { ComponentType } from "react";
2
import type { NativeSyntheticEvent, ViewProps } from "react-native";
3
import { requireNativeView } from "expo";
4
5
+import { NativeViewResolutionError } from "../../native/nativeViewResolutionError";
6
+
7
const NATIVE_REVIEW_DIFF_MODULE_NAME = "T3ReviewDiffSurface";
8
9
interface ExpoGlobalWithViewConfig {
@@ -128,6 +130,7 @@ export interface NativeReviewDiffViewProps extends ViewProps {
130
}
131
132
let cachedNativeReviewDiffView: ComponentType<NativeReviewDiffViewProps> | undefined;
133
+let nativeReviewDiffViewResolutionFailed = false;
134
135
function getExpoViewConfig(moduleName: string) {
136
return (globalThis as typeof globalThis & ExpoGlobalWithViewConfig).expo?.getViewConfig?.(
@@ -140,6 +143,10 @@ export function resolveNativeReviewDiffView(): ComponentType<NativeReviewDiffVie
143
return cachedNativeReviewDiffView;
144
}
145
146
+ if (nativeReviewDiffViewResolutionFailed) {
147
+ return null;
148
+ }
149
+
150
if (getExpoViewConfig(NATIVE_REVIEW_DIFF_MODULE_NAME) == null) {
151
return null;
152
}
@@ -148,7 +155,14 @@ export function resolveNativeReviewDiffView(): ComponentType<NativeReviewDiffVie
155
cachedNativeReviewDiffView = requireNativeView<NativeReviewDiffViewProps>(
156
NATIVE_REVIEW_DIFF_MODULE_NAME,
157
);
151
- } catch {
158
+ } catch (cause) {
159
+ nativeReviewDiffViewResolutionFailed = true;
160
+ console.error(
161
+ new NativeViewResolutionError({
162
+ nativeModuleName: NATIVE_REVIEW_DIFF_MODULE_NAME,
163
+ cause,
164
+ }),
165
+ );
166
return null;
167
}
168
apps/mobile/src/features/terminal/nativeTerminalModule.test.ts
+14
-1
@@ -43,10 +43,23 @@ describe("resolveNativeTerminalSurfaceView", () => {
43
44
it("returns null when the view manager cannot be required", async () => {
45
setExpoViewConfigAvailable();
46
+ const cause = new Error("boom");
47
expoMocks.requireNativeView.mockImplementation(() => {
47
- throw new Error("boom");
48
+ throw cause;
49
});
50
+ const consoleError = vi.spyOn(console, "error").mockImplementation(() => undefined);
51
const { resolveNativeTerminalSurfaceView } = await import("./nativeTerminalModule");
52
+
53
+ expect(resolveNativeTerminalSurfaceView()).toBeNull();
54
expect(resolveNativeTerminalSurfaceView()).toBeNull();
55
+ expect(expoMocks.requireNativeView).toHaveBeenCalledTimes(1);
56
+ expect(consoleError).toHaveBeenCalledWith(
57
+ expect.objectContaining({
58
+ _tag: "NativeViewResolutionError",
59
+ nativeModuleName: "T3TerminalSurface",
60
+ cause,
61
+ }),
62
+ );
63
+ expect(consoleError).toHaveBeenCalledTimes(1);
64
});
65
});
apps/mobile/src/features/terminal/nativeTerminalModule.ts
+15
-1
@@ -2,6 +2,8 @@ import type { ComponentType } from "react";
2
import type { NativeSyntheticEvent, ViewProps } from "react-native";
3
import { requireNativeView } from "expo";
4
5
+import { NativeViewResolutionError } from "../../native/nativeViewResolutionError";
6
+
7
const NATIVE_TERMINAL_MODULE_NAME = "T3TerminalSurface";
8
9
interface ExpoGlobalWithViewConfig {
@@ -33,6 +35,7 @@ export interface NativeTerminalSurfaceProps extends ViewProps {
35
}
36
37
let cachedNativeTerminalSurfaceView: ComponentType<NativeTerminalSurfaceProps> | undefined;
38
+let nativeTerminalSurfaceViewResolutionFailed = false;
39
40
function getExpoViewConfig(moduleName: string) {
41
return (globalThis as typeof globalThis & ExpoGlobalWithViewConfig).expo?.getViewConfig?.(
@@ -45,6 +48,10 @@ export function resolveNativeTerminalSurfaceView(): ComponentType<NativeTerminal
48
return cachedNativeTerminalSurfaceView;
49
}
50
51
+ if (nativeTerminalSurfaceViewResolutionFailed) {
52
+ return null;
53
+ }
54
+
55
if (getExpoViewConfig(NATIVE_TERMINAL_MODULE_NAME) == null) {
56
return null;
57
}
@@ -53,7 +60,14 @@ export function resolveNativeTerminalSurfaceView(): ComponentType<NativeTerminal
60
cachedNativeTerminalSurfaceView = requireNativeView<NativeTerminalSurfaceProps>(
61
NATIVE_TERMINAL_MODULE_NAME,
62
);
56
- } catch {
63
+ } catch (cause) {
64
+ nativeTerminalSurfaceViewResolutionFailed = true;
65
+ console.error(
66
+ new NativeViewResolutionError({
67
+ nativeModuleName: NATIVE_TERMINAL_MODULE_NAME,
68
+ cause,
69
+ }),
70
+ );
71
return null;
72
}
73
apps/mobile/src/native/nativeViewResolutionError.ts
new
+13
@@ -0,0 +1,13 @@
1
+import * as Schema from "effect/Schema";
2
+
3
+export class NativeViewResolutionError extends Schema.TaggedErrorClass<NativeViewResolutionError>()(
4
+ "NativeViewResolutionError",
5
+ {
6
+ nativeModuleName: Schema.String,
7
+ cause: Schema.Defect(),
8
+ },
9
+) {
10
+ override get message(): string {
11
+ return `Failed to resolve native view ${this.nativeModuleName}.`;
12
+ }
13
+}