From 5a7945e2da3d37a50fc5b938e8dbc81bd1459c13 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Fri, 7 Aug 2026 15:35:34 +0200 Subject: [PATCH 1/2] fix(composer): detect autocomplete from onChange for mobile keyboards --- src/app/features/room/RoomInput.tsx | 69 ++++++++++--------- .../features/room/message/MessageEditor.tsx | 16 +++-- 2 files changed, 47 insertions(+), 38 deletions(-) diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 8bb444479..c22e505b6 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -607,8 +607,42 @@ export const RoomInput = forwardRef( const dropZoneVisible = useFileDropZone(fileDropContainerRef, handleFiles); const [hasText, setHasText] = useState(false); const lastEncryptionPreparationAt = useRef(0); + const detectAutocomplete = useCallback(() => { + const firstPosition = Editor.start(editor, []); + const secondChar = Editor.after(editor, firstPosition, { + distance: 2, + unit: 'character', + }); + const quickReactPrefix = Editor.string( + editor, + Editor.range(editor, firstPosition, secondChar) + ); + if (quickReactPrefix === '+#') { + setQuickTextReact(true); + setAutocompleteQuery(undefined); + return; + } + setQuickTextReact(false); + + const prevWordRange = getPrevWorldRange(editor); + if (!prevWordRange) { + setAutocompleteQuery(undefined); + return; + } + + const isRangeAtBeginning = !Point.isAfter(Range.start(prevWordRange), firstPosition); + const query = + (isRangeAtBeginning + ? getAutocompleteQuery(editor, prevWordRange, BEGINNING_AUTOCOMPLETE_PREFIXES) + : undefined) ?? + getAutocompleteQuery(editor, prevWordRange, ANYWHERE_AUTOCOMPLETE_PREFIXES); + + setAutocompleteQuery(query); + }, [editor]); + const handleEditorChange = useCallback(() => { setHasText(!isEmptyEditor(editor)); + detectAutocomplete(); if (!room.hasEncryptionStateEvent()) return; const now = Date.now(); @@ -616,7 +650,7 @@ export const RoomInput = forwardRef( lastEncryptionPreparationAt.current = now; mx.getCrypto()?.prepareToEncrypt(room); - }, [editor, mx, room]); + }, [editor, detectAutocomplete, mx, room]); const hasContent = hasText || selectedFiles.length > 0; const isComposing = useComposingCheck(); @@ -1774,38 +1808,9 @@ export const RoomInput = forwardRef( sendTypingStatus(!isEmptyEditor(editor)); } - const firstPosition = Editor.start(editor, []); - const secondChar = Editor.after(editor, firstPosition, { - distance: 2, - unit: 'character', - }); - const quickReactPrefix = Editor.string( - editor, - Editor.range(editor, firstPosition, secondChar) - ); - if (quickReactPrefix === '+#') { - setQuickTextReact(true); - setAutocompleteQuery(undefined); - return; - } - setQuickTextReact(false); - - const prevWordRange = getPrevWorldRange(editor); - if (!prevWordRange) { - setAutocompleteQuery(undefined); - return; - } - - const isRangeAtBeginning = !Point.isAfter(Range.start(prevWordRange), firstPosition); - const query = - (isRangeAtBeginning - ? getAutocompleteQuery(editor, prevWordRange, BEGINNING_AUTOCOMPLETE_PREFIXES) - : undefined) ?? - getAutocompleteQuery(editor, prevWordRange, ANYWHERE_AUTOCOMPLETE_PREFIXES); - - setAutocompleteQuery(query); + detectAutocomplete(); }, - [editor, sendTypingStatus, hideActivity] + [editor, sendTypingStatus, hideActivity, detectAutocomplete] ); const handleEmoticonSelect = (key: string, shortcode: string) => { diff --git a/src/app/features/room/message/MessageEditor.tsx b/src/app/features/room/message/MessageEditor.tsx index fe150cff5..f72c66e36 100644 --- a/src/app/features/room/message/MessageEditor.tsx +++ b/src/app/features/room/message/MessageEditor.tsx @@ -337,6 +337,14 @@ export const MessageEditor = as<'div', MessageEditorProps>( [enterForNewline, isComposing, editor, handleSave, onCancel] ); + const detectAutocomplete = useCallback(() => { + const prevWordRange = getPrevWorldRange(editor); + const query = prevWordRange + ? getAutocompleteQuery(editor, prevWordRange, ANYWHERE_AUTOCOMPLETE_PREFIXES) + : undefined; + setAutocompleteQuery(query); + }, [editor]); + const handleKeyUp: KeyboardEventHandler = useCallback( (evt) => { if (isKeyHotkey('escape', evt)) { @@ -344,13 +352,9 @@ export const MessageEditor = as<'div', MessageEditorProps>( return; } - const prevWordRange = getPrevWorldRange(editor); - const query = prevWordRange - ? getAutocompleteQuery(editor, prevWordRange, ANYWHERE_AUTOCOMPLETE_PREFIXES) - : undefined; - setAutocompleteQuery(query); + detectAutocomplete(); }, - [editor] + [detectAutocomplete] ); const handleCloseAutocomplete = useCallback(() => { From 6297a4e16e7eeb3bd5f9529ac4f439b5838f2116 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Fri, 7 Aug 2026 16:02:00 +0200 Subject: [PATCH 2/2] fix(tauri): pin reqwest to 0.12 so native uploads keep rustls TLS --- src-tauri/Cargo.lock | 20 ++++++++++++++++++-- src-tauri/Cargo.toml | 2 +- src-tauri/src/network/native_upload.rs | 6 +++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 1b56c7686..0034a495d 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -5188,6 +5188,7 @@ dependencies = [ "cookie_store", "encoding_rs", "futures-core", + "futures-util", "h2 0.4.15", "http 1.4.2", "http-body 1.1.0", @@ -5209,12 +5210,14 @@ dependencies = [ "sync_wrapper 1.0.2", "tokio", "tokio-rustls", + "tokio-util", "tower 0.5.3", "tower-http 0.6.11", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", + "wasm-streams 0.4.2", "web-sys", "webpki-roots", ] @@ -5254,7 +5257,7 @@ dependencies = [ "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-streams", + "wasm-streams 0.5.0", "web-sys", ] @@ -5462,7 +5465,7 @@ dependencies = [ "objc2-photos", "percent-encoding", "regex", - "reqwest 0.13.4", + "reqwest 0.12.28", "sentry", "serde", "serde_json", @@ -8190,6 +8193,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "wasm-streams" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" +dependencies = [ + "futures-util", + "js-sys", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + [[package]] name = "wasm-streams" version = "0.5.0" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index cd5ed5d9a..7ab48a7ae 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -41,7 +41,7 @@ percent-encoding = "2" # Enables `stream` (for native_upload's `Body::wrap_stream`) on the reqwest that # tauri-plugin-http pulls in without it. default-features = false keeps # openssl-sys out of the Android cross-compile. -reqwest = { version = "0.13", default-features = false, features = ["stream"] } +reqwest = { version = "0.12", default-features = false, features = ["stream"] } async-stream = "0.3" base64 = "0.23" tokio-util = { version = "0.7", features = ["codec"] } diff --git a/src-tauri/src/network/native_upload.rs b/src-tauri/src/network/native_upload.rs index 58127b349..fb1afaa0a 100644 --- a/src-tauri/src/network/native_upload.rs +++ b/src-tauri/src/network/native_upload.rs @@ -7,12 +7,12 @@ use std::{ use base64::Engine; use futures_util::StreamExt; -use reqwest::{ +use serde::Serialize; +use tauri::{ipc::Channel, AppHandle, Manager, Runtime}; +use tauri_plugin_http::reqwest::{ header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE}, Body, Client, ClientBuilder, Method, Url, }; -use serde::Serialize; -use tauri::{ipc::Channel, AppHandle, Manager, Runtime}; use tokio::{ fs::{File, OpenOptions}, io::AsyncWriteExt,