Skip to content
Source
Sign inSign up
pingdotgg/t3code

feat(preview): add automatic browser control preference #17081

Closed0bkevin(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/17081/headopened View on GitHub

Showing 27 changed files with 61 additions and 22 deletions (loading 24).

x
0 of 27 viewed, 27 left
10 additions and 1 deletionapps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsxModified
View file
@@ -1,3 +1,7 @@
+import { useAtomValue } from "@effect/atom-react";
+import { AsyncResult } from "effect/reactivity";
+import { previewStreamCanInteract } from "@t3tools/client-runtime/preview/server-browser-stream";
+import { mobilePreferencesAtom } from "../../state/preferences";
import { useIsFocused, useNavigation, type StaticScreenProps } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import {
@@ -84,6 +88,9 @@
// Address bar commands only reach a page that is streaming.
const [streaming, setStreaming] = useState(false);
const [canControl, setCanControl] = useState(false);
+ const preferences = useAtomValue(mobilePreferencesAtom);
+ const automaticControl =
+ AsyncResult.isSuccess(preferences) && preferences.value.browserAutomaticControl === true;
const streamRef = useRef<PreviewStreamRef>(null);
const { tabs, loaded } = useThreadServerBrowserTabs({ environmentId, threadId, enabled: true });
const tab = tabs.find((entry) => entry.tabId === selectedTabId) ?? latestBrowserTab(tabs);
@@ -187,7 +194,9 @@
background={themeVariables["--color-sheet-solid"]}
onPictureInPicture={onPictureInPicture}
onStreamingChange={setStreaming}
- onControl={(control) => setCanControl(control?.controller === "you")}
+ onControl={(control) =>
+ setCanControl(previewStreamCanInteract(control, automaticControl))
+ }
) : (
<View className="flex-1" />