Skip to content

Commit 2415bff

Browse files
committed
fix(mobile): gate terminal replay on native capability
1 parent 668404b commit 2415bff

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎apps/mobile/src/features/terminal/NativeTerminalSurface.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import { useAppearancePreferences } from "../settings/appearance/AppearancePrefe
2222
import {
2323
getNativeTerminalHardwareKeyRevision,
2424
getNativeTerminalStreamingRevision,
25-
NATIVE_TERMINAL_STREAMING_REVISION,
2625
resolveNativeTerminalSurfaceView,
26+
supportsNativeReplayStreaming,
2727
type NativeTerminalSurfaceHandle,
2828
} from "./nativeTerminalModule";
2929
import {
@@ -211,8 +211,7 @@ export const TerminalSurface = memo(function TerminalSurface(props: TerminalSurf
211211
const NativeTerminalSurfaceView = resolveNativeTerminalSurfaceView();
212212
const hasNativeSurface = Boolean(NativeTerminalSurfaceView);
213213
const streamingRevision = getNativeTerminalStreamingRevision();
214-
const supportsStreaming =
215-
streamingRevision !== null && streamingRevision >= NATIVE_TERMINAL_STREAMING_REVISION;
214+
const supportsStreaming = supportsNativeReplayStreaming();
216215
const themeConfig = buildGhosttyThemeConfig(theme);
217216
const nativeRef = useRef<NativeTerminalSurfaceHandle>(null);
218217
const nativeCommandQueueRef = useRef(Promise.resolve());

‎apps/mobile/src/features/terminal/nativeTerminalModule.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test"
22

33
const expoMocks = vi.hoisted(() => ({
44
requireNativeView: vi.fn(),
5+
requireOptionalNativeModule: vi.fn(),
56
}));
67
const nativeView = () => null;
78
const originalExpo = globalThis.expo;
@@ -14,6 +15,7 @@ function setExpoViewConfigAvailable() {
1415

1516
vi.mock("expo", () => ({
1617
requireNativeView: expoMocks.requireNativeView,
18+
requireOptionalNativeModule: expoMocks.requireOptionalNativeModule,
1719
}));
1820

1921
describe("resolveNativeTerminalSurfaceView", () => {
@@ -63,3 +65,19 @@ describe("resolveNativeTerminalSurfaceView", () => {
6365
expect(consoleError).toHaveBeenCalledTimes(1);
6466
});
6567
});
68+
69+
describe("supportsNativeReplayStreaming", () => {
70+
it.each([
71+
[undefined, false],
72+
[{ streamingRevision: 1 }, false],
73+
[{ streamingRevision: 2 }, true],
74+
])(
75+
"selects replay streaming only for a capable installed binary (%j)",
76+
async (module, expected) => {
77+
expoMocks.requireOptionalNativeModule.mockReturnValue(module);
78+
const { supportsNativeReplayStreaming } = await import("./nativeTerminalModule");
79+
80+
expect(supportsNativeReplayStreaming()).toBe(expected);
81+
},
82+
);
83+
});

0 commit comments

Comments
 (0)