fix(app): preserve IME composition across text fields (#3517)

* fix(app): preserve IME composition in form inputs

Form model publication was replaying changing default text into the native or DOM editing surface. Keep the editing surface authoritative, defer web publication until composition commits, and reserve resetKey changes for explicit text replacement.

* refactor(app): centralize text editing authority

Route every app text field, including the composer and plugin runtime, through one platform-owned editing primitive. Its type and runtime reject controlled value replay, its command handle owns programmatic replacement, and lint prevents raw React Native TextInput imports outside the boundary.

* fix(app): restore composer placeholder styling
This commit is contained in:
Mohamed Boudra
2026-08-18 11:32:49 +00:00
committed by GitHub
parent cd2b6bca9d
commit e2e97e4854
39 changed files with 575 additions and 390 deletions
@@ -1,12 +1,15 @@
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef } from "react";
import {
StyleSheet,
TextInput,
type NativeSyntheticEvent,
type StyleProp,
type TextInputKeyPressEventData,
type TextStyle,
} from "react-native";
import {
EditingTextInput as TextInput,
type EditingTextInputHandle,
} from "@/components/ui/text-input";
import { resolveNativeTerminalKey, type NativeTerminalKey } from "./terminal-key-events";
export const TERMINAL_INPUT_CONTEXT_MENU_HIDDEN = true;
@@ -181,7 +184,7 @@ export function createTerminalTextInputState(): TerminalTextInputState {
export const TerminalInput = forwardRef<TerminalInputHandle, TerminalInputProps>(
function TerminalInput({ isKeyboardVisible, onFocus, onInput, onTerminalKey, style }, ref) {
const inputRef = useRef<TextInput>(null);
const inputRef = useRef<EditingTextInputHandle>(null);
const isFocusedRef = useRef(false);
const pendingFocusFrameRef = useRef<number | null>(null);
const inputState = useMemo(() => createTerminalTextInputState(), []);
@@ -197,7 +200,7 @@ export const TerminalInput = forwardRef<TerminalInputHandle, TerminalInputProps>
const resetNativeInput = useCallback(() => {
inputState.reset();
inputRef.current?.clear();
inputRef.current?.replaceText("");
}, [inputState]);
const showNativeKeyboard = useCallback(() => {
@@ -314,7 +317,7 @@ export const TerminalInput = forwardRef<TerminalInputHandle, TerminalInputProps>
autoCorrect={false}
caretHidden={true}
contextMenuHidden={TERMINAL_INPUT_CONTEXT_MENU_HIDDEN}
defaultValue=""
initialValue=""
blurOnSubmit={false}
importantForAutofill="no"
multiline={true}