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 23, 01:45 UTC
fix(mobile): Browser menu pastes the phone's clipboard into the page (#19648)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
spiky02plateau committed
Oct 19, 2026 at 07:49 UTC
6cf704beb5c9fb77603ca846fef18ca96ab3d669
3 files changed
+24
-1
apps/mobile/src/features/browser/BrowserPreviewRouteScreen.tsx
+9
-1
@@ -177,6 +177,7 @@ function BrowserPreviewScreen({
177
streaming={streaming}
178
ready={streaming && canControl}
179
onCommand={(input) => streamRef.current?.command(input)}
180
+ onPaste={() => streamRef.current?.paste()}
181
/>
182
{live ? (
183
<PreviewStreamWebView
@@ -213,12 +214,14 @@ function BrowserAddressBar({
214
ready,
215
streaming,
216
onCommand,
217
+ onPaste,
218
}: {
219
readonly environmentId: EnvironmentId;
220
readonly tab: PreviewSessionSnapshot;
221
readonly ready: boolean;
222
readonly streaming: boolean;
223
readonly onCommand: PreviewStreamRef["command"];
224
+ readonly onPaste: () => void;
225
}) {
226
const url = browserTabUrl(tab);
227
const [draft, setDraft] = useState<string | null>(null);
@@ -268,7 +271,12 @@ function BrowserAddressBar({
271
disabled={!ready}
272
onPress={() => onCommand({ type: "reload" })}
273
/>
271
- <BrowserTabMenu environmentId={environmentId} tab={tab} disabled={!streaming} />
274
+ <BrowserTabMenu
275
+ environmentId={environmentId}
276
+ tab={tab}
277
+ disabled={!streaming}
278
+ onPaste={ready ? onPaste : undefined}
279
+ />
280
</View>
281
);
282
}
apps/mobile/src/features/browser/BrowserTabMenu.tsx
+4
@@ -41,10 +41,12 @@ export function BrowserTabMenu({
41
environmentId,
42
tab,
43
disabled,
44
+ onPaste,
45
}: {
46
readonly environmentId: EnvironmentId;
47
readonly tab: PreviewSessionSnapshot;
48
readonly disabled: boolean;
49
+ readonly onPaste?: () => void;
50
}) {
51
const adjust = useAtomCommand(previewEnvironment.adjust, "browser tab change");
52
const resize = useAtomCommand(previewEnvironment.resize, "browser viewport change");
@@ -64,6 +66,7 @@ export function BrowserTabMenu({
66
: "custom";
67
68
const actions: MenuAction[] = [
69
+ ...(onPaste ? [{ id: "paste", title: "Paste", image: "doc.on.clipboard" }] : []),
70
{ id: "hard-reload", title: "Hard reload", image: "arrow.clockwise.circle" },
71
{
72
id: "appearance",
@@ -112,6 +115,7 @@ export function BrowserTabMenu({
115
};
116
117
const onAction = (id: string) => {
118
+ if (id === "paste") return onPaste?.();
119
if (id === "hard-reload") return void run({ hardReload: true });
120
if (id === "zoom:in") return void run({ zoomFactor: zoomTo(1) });
121
if (id === "zoom:out") return void run({ zoomFactor: zoomTo(-1) });
apps/mobile/src/features/browser/PreviewStreamWebView.tsx
+11
@@ -39,6 +39,7 @@ import {
39
40
export interface PreviewStreamRef {
41
readonly command: (input: PreviewStreamInput) => void;
42
+ readonly paste: () => void;
43
readonly togglePictureInPicture: () => void;
44
}
45
@@ -271,6 +272,15 @@ function PreviewStreamDocumentView({
272
webView.current?.injectJavaScript(
273
`window.T3PreviewStream?.command(${JSON.stringify(input)}); true;`,
274
);
275
+ // Reads here rather than in the screen: a tab switch during the iOS paste prompt unmounts
276
+ // this view and nulls its WebView ref, so the text can never type into another tab.
277
+ const paste = () =>
278
+ void Clipboard.getStringAsync().then(
279
+ (text) => {
280
+ if (text) command({ type: "text", text });
281
+ },
282
+ () => Dialog.alert("Could not read the clipboard"),
283
+ );
284
const fail = (message: string) => {
285
if (!active.current || failed.current) return;
286
failed.current = true;
@@ -299,6 +309,7 @@ function PreviewStreamDocumentView({
309
);
310
useImperativeHandle(ref, () => ({
311
command,
312
+ paste,
313
togglePictureInPicture: () =>
314
webView.current?.injectJavaScript("window.T3PreviewStream?.pictureInPicture(); true;"),
315
}));