From 32894e5a0a8584d1b20b7d371941b75ffe6dcd40 Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Wed, 26 Aug 2026 15:41:57 +1000 Subject: [PATCH 1/7] fix(desktop): scope composer autocomplete to focus Prevent inactive channel composers from rendering stale inline autocomplete state while a thread send toggles their shared disabled state. Preserve editor focus for composer mention controls and cover the thread-send regression end to end. Co-authored-by: Jitter <2b2e6415e748c35180847a37aadae06a11e30dddc76b784e7fd9354c4eb42e7a@buzz.block.builderlab.xyz> Signed-off-by: Matt Toohey --- .../messages/lib/useRichTextEditor.ts | 8 +-- .../messages/ui/ComposerAddressControls.tsx | 6 ++- .../features/messages/ui/MessageComposer.tsx | 22 ++++---- .../e2e/persistent-agent-audience.spec.ts | 53 +++++++++++++++++++ 4 files changed, 73 insertions(+), 16 deletions(-) diff --git a/desktop/src/features/messages/lib/useRichTextEditor.ts b/desktop/src/features/messages/lib/useRichTextEditor.ts index e3e17071fad..4d5ccd39c82 100644 --- a/desktop/src/features/messages/lib/useRichTextEditor.ts +++ b/desktop/src/features/messages/lib/useRichTextEditor.ts @@ -165,18 +165,15 @@ export function useRichTextEditor({ onLinkShortcut, }: RichTextEditorOptions) { const addressedAgentMentionNamesRef = React.useRef([]); + const [isFocused, setIsFocused] = React.useState(false); const onUpdateRef = React.useRef(onUpdate); onUpdateRef.current = onUpdate; - const onSubmitRef = React.useRef(onSubmit); onSubmitRef.current = onSubmit; - const onEditLastOwnMessageRef = React.useRef(onEditLastOwnMessage); onEditLastOwnMessageRef.current = onEditLastOwnMessage; - const onEditLinkRef = React.useRef(onEditLink); onEditLinkRef.current = onEditLink; - const onLinkSelectionChangeRef = React.useRef(onLinkSelectionChange); onLinkSelectionChangeRef.current = onLinkSelectionChange; @@ -600,6 +597,8 @@ export function useRichTextEditor({ buildPreviewUpdate(ed.state.doc, ed.state.selection.anchor), ); }, + onFocus: () => setIsFocused(true), + onBlur: () => setIsFocused(false), }, [], ); @@ -930,6 +929,7 @@ export function useRichTextEditor({ return { editor, + isFocused, getMarkdown, isEmpty, clearContent, diff --git a/desktop/src/features/messages/ui/ComposerAddressControls.tsx b/desktop/src/features/messages/ui/ComposerAddressControls.tsx index ae39931334e..30bfe196e3f 100644 --- a/desktop/src/features/messages/ui/ComposerAddressControls.tsx +++ b/desktop/src/features/messages/ui/ComposerAddressControls.tsx @@ -195,7 +195,10 @@ export function ComposerMentionButton({ data-testid="message-insert-mention" disabled={disabled} onClick={onOpen} - onMouseDown={onCaptureSelection} + onMouseDown={(event) => { + onCaptureSelection(); + event.preventDefault(); + }} type="button" >