Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(mobile): 避免 Android 解析 iOS WebView 属性崩溃 (#4254)

DavidShenXDad42d5801c8e
diff --git a/apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx b/apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx
index 610c49677e..6711f56e22 100644
--- a/apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx
+++ b/apps/mobile/src/remote-desktop/RemoteDesktopScreen.tsx
@@ -1527,7 +1527,7 @@ export default function RemoteDesktopScreen() {
hideKeyboardAccessoryView
textInteractionEnabled={false}
allowsLinkPreview={false}
- dataDetectorTypes="none"
+ {...(Platform.OS === "ios" ? { dataDetectorTypes: "none" as const } : {})}
javaScriptEnabled
allowsInlineMediaPlayback
mediaPlaybackRequiresUserAction={false}
diff --git a/apps/mobile/src/remote-desktop/__tests__/screen.test.tsx b/apps/mobile/src/remote-desktop/__tests__/screen.test.tsx
index 1eaf88baa8..619c9f9891 100644
--- a/apps/mobile/src/remote-desktop/__tests__/screen.test.tsx
+++ b/apps/mobile/src/remote-desktop/__tests__/screen.test.tsx
@@ -68,6 +68,7 @@ const fixture = vi.hoisted(() => ({
status: "online",
appState: null as null | ((state: string) => void),
crashed: null as null | (() => void),
+ webViewProps: null as null | Record<string, unknown>,
retryPermissions: null as null | (() => void),
}));
vi.mock("react-native", async () => {
@@ -278,6 +279,7 @@ vi.mock("../PermissionGuide", () => ({
}));
vi.mock("react-native-webview", () => ({
WebView: forwardRef((p: any, ref) => {
+ fixture.webViewProps = p;
fixture.message = p.onMessage;
fixture.crashed = p.onContentProcessDidTerminate;
useImperativeHandle(ref, () => ({
@@ -313,6 +315,7 @@ beforeEach(() => {
fixture.lockSupported = true;
fixture.views = {};
fixture.keyboardListeners = {};
+ fixture.webViewProps = null;
vi.useFakeTimers();
fixture.focused = true;
fixture.status = "online";
@@ -377,6 +380,16 @@ const connect = async () => {
};
describe("remote desktop controls", () => {
+ it("keeps iOS data detection disabled without passing its prop to Android", async () => {
+ await act(async () => {});
+ expect(fixture.webViewProps).toMatchObject({ dataDetectorTypes: "none" });
+
+ fixture.platform = "android";
+ await act(async () => root.render(<RemoteDesktopScreen />));
+
+ expect(fixture.webViewProps).not.toHaveProperty("dataDetectorTypes");
+ });
+
it("fetches ICE configuration only through native auth and sends sanitized short-term credentials", async () => {
await connect();
const iceServers = [