The best way to control Claude Code, Codex and more from any computer or phone
fix(android): a composer focused through an app switch stays above the keyboard (#20803)
Co-authored-by: Pixel Perfect <me@pixp.cc> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Julius Marminge committed
Oct 17, 2026 at 00:05 UTC
b987b5785f614171a11af69cfd2b9643ff1fe952
2 files changed
+24
-5
apps/mobile/src/features/threads/QuestionAttachments.tsx
+17
-3
@@ -6,7 +6,7 @@ import { convertPastedImagesToAttachments } from "../../lib/composerImages";
6
import { PROVIDER_SEND_TURN_MAX_ATTACHMENTS, type UserInputQuestion } from "@t3tools/contracts";
7
import { useAtomValue } from "@effect/atom-react";
8
import { View } from "react-native";
9
-import { useEffect, useRef, useState } from "react";
9
+import { useEffect, useEffectEvent, useRef, useState } from "react";
10
import { ComposerAttachmentButton } from "./ComposerAttachmentButton";
11
import { ComposerAttachmentStrip } from "../../components/ComposerAttachmentStrip";
12
import { pickComposerFiles, pickComposerMedia } from "../../lib/composerImages";
@@ -49,6 +49,14 @@ export function QuestionAttachments(props: {
49
props.requestId,
50
props.question.id,
51
]);
52
+ // A focused input that unmounts never delivers its onBlur, so release focus here or
53
+ // the screen would keep treating the keyboard as owned by a removed input.
54
+ const focusedRef = useRef(false);
55
+ const onInputFocusChange = props.onInputFocusChange;
56
+ const releaseFocus = useEffectEvent(() => {
57
+ if (focusedRef.current) onInputFocusChange?.(false);
58
+ });
59
+ useEffect(() => () => releaseFocus(), []);
60
const pickerScope = useRef<{ key: string; active: boolean } | null>(null);
61
useEffect(() => {
62
const scope = { key: scopeKey, active: true };
@@ -197,8 +205,14 @@ export function QuestionAttachments(props: {
205
submitBehavior={props.question.initialAnswer !== undefined ? "newline" : undefined}
206
editable={!props.disabled}
207
onChangeText={props.onChangeText}
200
- onFocus={() => props.onInputFocusChange?.(true)}
201
- onBlur={() => props.onInputFocusChange?.(false)}
208
+ onFocus={() => {
209
+ focusedRef.current = true;
210
+ onInputFocusChange?.(true);
211
+ }}
212
+ onBlur={() => {
213
+ focusedRef.current = false;
214
+ onInputFocusChange?.(false);
215
+ }}
216
placeholder="Or type a custom answer"
217
className="min-h-[54px] rounded-2xl border border-input-border bg-input px-3.5 py-3 font-sans text-base text-foreground"
218
/>
apps/mobile/src/features/threads/ThreadDetailScreen.tsx
+7
-2
@@ -363,15 +363,19 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
363
// Android can swallow the IME hide callbacks when the app is backgrounded mid keyboard-hide
364
// (the reported repro: send — which blurs and starts the hide — then Home within a second). The
365
// keyboard library's height AND visibility then stay frozen open, so gating the sticky
366
- // translation on visibility alone still strands the composer after resume.
366
+ // translation on visibility alone still strands the composer after resume. An input that kept
367
+ // focus through the switch is exempt: Android restores its keyboard unchanged, so no keyboard
368
+ // or focus event would ever lift the quarantine. Hiding the keyboard with Back keeps focus, so
369
+ // Back then Home mid-hide takes the exemption and can still strand the composer.
370
const [keyboardStateSuspect, setKeyboardStateSuspect] = useState(false);
371
+ const ownedInputFocusedRef = useRef(false);
372
useEffect(() => {
373
if (Platform.OS !== "android") {
374
return;
375
}
376
const subscription = AppState.addEventListener("change", (state) => {
377
if (state === "active") {
374
- setKeyboardStateSuspect(true);
378
+ setKeyboardStateSuspect(!ownedInputFocusedRef.current);
379
}
380
});
381
return () => {
@@ -382,6 +386,7 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
386
setKeyboardStateSuspect(false);
387
}, [isKeyboardVisible, liveKeyboardHeight]);
388
const handleOwnedInputFocusChange = useCallback((focused: boolean) => {
389
+ ownedInputFocusedRef.current = focused;
390
if (focused) {
391
setKeyboardStateSuspect(false);
392
}