From c4ff5599c76bb63ff56c3ce4d65f5fdcfcc26fed Mon Sep 17 00:00:00 2001 From: Mohamed Boudra Date: Sun, 15 Nov 2026 20:34:17 +0700 Subject: [PATCH] fix(app): close slash picker after inserting a command (#9755) Publish the resolved replacement selection to the composer. iOS does not emit a native selection event for this edit, leaving autocomplete at the slash until the next keystroke. --- .../native-composer-command-selection.ios.ad | 13 +++++++++++++ packages/app/src/composer/input/input.tsx | 13 ++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 packages/app/e2e/mobile/agent-device/native-composer-command-selection.ios.ad diff --git a/packages/app/e2e/mobile/agent-device/native-composer-command-selection.ios.ad b/packages/app/e2e/mobile/agent-device/native-composer-command-selection.ios.ad new file mode 100644 index 0000000000..c02272bf8e --- /dev/null +++ b/packages/app/e2e/mobile/agent-device/native-composer-command-selection.ios.ad @@ -0,0 +1,13 @@ +context platform=ios timeout=60000 retries=0 +# Start in an empty, connected composer with the Claude provider selected. +# COMMAND_ROW must name an inserting command, not an immediate client action. +env COMMAND_ROW="/advisor, Let Claude consult a stronger model at key moments" +env COMMAND_TEXT="/advisor " +open sh.paseo.debug +wait "editable=true" 60000 +fill "editable=true" "/" +wait "label=\"${COMMAND_ROW}\"" 15000 +press "label=\"${COMMAND_ROW}\"" +# Do not type or move the caret: replacement itself must close autocomplete. +wait absent "label=\"${COMMAND_ROW}\"" 3000 +wait "editable=true value=\"${COMMAND_TEXT}\"" 3000 diff --git a/packages/app/src/composer/input/input.tsx b/packages/app/src/composer/input/input.tsx index b0ed623304..0153911627 100644 --- a/packages/app/src/composer/input/input.tsx +++ b/packages/app/src/composer/input/input.tsx @@ -204,7 +204,7 @@ export interface MessageInputProps { onSubmitLoadingPress?: () => void; /** Intercept key press events before default handling. Return true to prevent default. */ onKeyPress?: (event: ComposerKeyPressEvent) => boolean; - /** Reports cursor selection updates from the underlying input. */ + /** Reports selection updates from user input and programmatic replacements. */ onSelectionChange?: (selection: { start: number; end: number }) => void; onFocusChange?: (focused: boolean) => void; onHeightChange?: (height: number) => void; @@ -1468,11 +1468,18 @@ export const MessageInput = forwardRef( if (nextText === "") { textInputRef.current?.reset(); } else { - textInputRef.current?.replaceText(nextText, selection); + textInputRef.current?.replaceText(nextText, selectionRef.current); } onChangeText(nextText); + // iOS does not emit a selection event for a programmatic text replacement. + onSelectionChangeCallback?.(selectionRef.current); }, - [onChangeText, updateComposerHeightForText, updateLiveTextPresence], + [ + onChangeText, + onSelectionChangeCallback, + updateComposerHeightForText, + updateLiveTextPresence, + ], ); useLayoutEffect(