From e033e36a1e8e1c0afffb8169cc4d05d1645e53aa Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Tue, 17 Mar 2026 15:17:37 -0400 Subject: [PATCH 01/10] fix(autocomplete): Enter always selects first item; first item not highlighted Two related bugs in the mention/room/emoji autocomplete: 1. Enter key always inserted the first suggestion instead of the highlighted one. Cause: querySelector('[data-selected]') matched ALL buttons since every button has the attribute set to either 'true' or 'false'. The first button in DOM order was always returned. Fix: use '[data-selected="true"]' to select only the active item. 2. The first item had no visual highlight on initial open (the CSS rule requires data-selected='true', but the useLayoutEffect responsible for stamping that attribute only re-ran when selectedIndex changed -- not when buttons first appeared after async search results loaded). Fix: remove the dep array so the effect runs after every render; newly-loaded buttons are stamped immediately. --- src/app/components/editor/autocomplete/AutocompleteMenu.tsx | 6 ++++-- src/app/features/room/RoomInput.tsx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/components/editor/autocomplete/AutocompleteMenu.tsx b/src/app/components/editor/autocomplete/AutocompleteMenu.tsx index 0b82001b..def55c2f 100644 --- a/src/app/components/editor/autocomplete/AutocompleteMenu.tsx +++ b/src/app/components/editor/autocomplete/AutocompleteMenu.tsx @@ -28,7 +28,9 @@ export function AutocompleteMenu({ headerContent, requestClose, children }: Auto } }; - // Sync data-selected to DOM; reset to index 0 when the item list changes + // Sync data-selected to DOM; reset to index 0 when the item list changes. + // No dep array — runs after every render so newly-loaded buttons are stamped + // immediately (buttons arrive async when search results load). useLayoutEffect(() => { const buttons = Array.from( itemsRef.current?.querySelectorAll('button') ?? [] @@ -46,7 +48,7 @@ export function AutocompleteMenu({ headerContent, requestClose, children }: Auto buttons.forEach((btn, i) => { btn.setAttribute('data-selected', String(i === safeIdx)); }); - }, [selectedIndex]); + }); // Listen for navigation events dispatched by the editor key handler useEffect(() => { diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index be7a468b..84036812 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -833,7 +833,7 @@ export const RoomInput = forwardRef( if (isKeyHotkey('enter', evt) && !isComposing(evt)) { const selectedItem = - autocompleteMenu.querySelector('button[data-selected]') ?? +autocompleteMenu.querySelector('button[data-selected="true"]') ?? autocompleteMenu.querySelector('button'); if (selectedItem) { From 0fb883bfaa2a99a06f7145cfb3e2edb09adae797 Mon Sep 17 00:00:00 2001 From: Evie Gauthier Date: Tue, 17 Mar 2026 15:43:20 -0400 Subject: [PATCH 02/10] test(autocomplete): add tests for data-selected stamping and keyboard navigation Covers the two bugs fixed in the previous commit: - Verifies the first button gets data-selected="true" on initial render so the CSS highlight rule fires immediately (regression for the dep-array fix). - Verifies the first button is also stamped when async search results load new buttons after the initial render (the original regression). - Verifies keyboard navigation via the AUTOCOMPLETE_NAVIGATE_EVENT moves the selected index and that it clamps at the list boundaries. Also adds an eslint-disable comment in AutocompleteMenu.tsx explaining why the no-dep-array useLayoutEffect is intentional (setSelectedIndex is a stable React setter; the conditional call cannot cause an infinite loop). --- .changeset/fix-autocomplete-selection.md | 5 + .../autocomplete/AutocompleteMenu.test.tsx | 193 ++++++++++++++++++ .../editor/autocomplete/AutocompleteMenu.tsx | 3 + src/app/features/room/RoomInput.tsx | 2 +- 4 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-autocomplete-selection.md create mode 100644 src/app/components/editor/autocomplete/AutocompleteMenu.test.tsx diff --git a/.changeset/fix-autocomplete-selection.md b/.changeset/fix-autocomplete-selection.md new file mode 100644 index 00000000..6abefe18 --- /dev/null +++ b/.changeset/fix-autocomplete-selection.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix autocomplete Enter key always selecting the first item and the first item not being highlighted on open. diff --git a/src/app/components/editor/autocomplete/AutocompleteMenu.test.tsx b/src/app/components/editor/autocomplete/AutocompleteMenu.test.tsx new file mode 100644 index 00000000..f0e2fd2f --- /dev/null +++ b/src/app/components/editor/autocomplete/AutocompleteMenu.test.tsx @@ -0,0 +1,193 @@ +import { type ReactNode } from 'react'; +import { describe, it, expect, vi } from 'vitest'; +import { render, act } from '@testing-library/react'; +import { + AutocompleteMenu, + AUTOCOMPLETE_NAVIGATE_EVENT, + type AutocompleteNavigateDetail, +} from './AutocompleteMenu'; + +// ── Mocks ───────────────────────────────────────────────────────────────────── + +vi.mock('focus-trap-react', () => ({ + default: ({ children }: { children: ReactNode }) => <>{children}, +})); + +vi.mock('folds', () => ({ + Header: ({ children }: { children: ReactNode }) =>
{children}
, + Menu: ({ children }: { children: ReactNode }) =>
{children}
, + Scroll: ({ children, onKeyDown }: { children: ReactNode; onKeyDown?: unknown }) => ( + // eslint-disable-next-line jsx-a11y/no-static-element-interactions +
{children}
+ ), + config: { space: { S200: '8px' } }, + Icons: {}, +})); + +vi.mock('$utils/keyboard', () => ({ + preventScrollWithArrowKey: vi.fn(), + stopPropagation: vi.fn(() => true), +})); + +vi.mock('$hooks/useAlive', () => ({ + useAlive: () => () => true, +})); + +// ── Helpers ─────────────────────────────────────────────────────────────────── + +function dispatchNavigate(container: HTMLElement, direction: 1 | -1) { + const menu = container.querySelector('[data-autocomplete-menu]'); + if (!menu) throw new Error('data-autocomplete-menu element not found'); + menu.dispatchEvent( + new CustomEvent(AUTOCOMPLETE_NAVIGATE_EVENT, { + bubbles: true, + detail: { direction }, + }) + ); +} + +function renderMenu(children: ReactNode) { + return render( + header} requestClose={() => {}}> + {children} + + ); +} + +// ── Tests ───────────────────────────────────────────────────────────────────── + +describe('AutocompleteMenu — data-selected stamping', () => { + it('stamps the first button with data-selected="true" on initial render', () => { + const { container } = renderMenu( + <> + + + + + ); + + const buttons = container.querySelectorAll('button'); + expect(buttons[0].getAttribute('data-selected')).toBe('true'); + expect(buttons[1].getAttribute('data-selected')).toBe('false'); + expect(buttons[2].getAttribute('data-selected')).toBe('false'); + }); + + it('stamps buttons when children load after initial render (async results)', async () => { + // Start with no children (empty search, buttons not yet present) + const { container, rerender } = renderMenu(null); + + // Simulate async search results arriving + await act(async () => { + rerender( + header} requestClose={() => {}}> + + + + ); + }); + + const buttons = container.querySelectorAll('button'); + expect(buttons).toHaveLength(2); + // First button must be marked selected — this was the bug: with the old + // [selectedIndex] dep array the effect didn't re-run when buttons appeared. + expect(buttons[0].getAttribute('data-selected')).toBe('true'); + expect(buttons[1].getAttribute('data-selected')).toBe('false'); + }); + + it('resets selection to the first button when the item list changes', async () => { + const { container } = renderMenu( + <> + + + + ); + + // Navigate to the second item + act(() => dispatchNavigate(container, 1)); + + const before = container.querySelectorAll('button'); + expect(before[1].getAttribute('data-selected')).toBe('true'); + + // Re-render with a completely different set of buttons (new search results) + await act(async () => { + render( + header} requestClose={() => {}}> + + + + , + { container: container.firstElementChild?.parentElement ?? document.body } + ); + }); + }); +}); + +describe('AutocompleteMenu — keyboard navigation', () => { + it('moves selection forward with direction +1', () => { + const { container } = renderMenu( + <> + + + + + ); + + act(() => dispatchNavigate(container, 1)); + + const buttons = container.querySelectorAll('button'); + expect(buttons[0].getAttribute('data-selected')).toBe('false'); + expect(buttons[1].getAttribute('data-selected')).toBe('true'); + expect(buttons[2].getAttribute('data-selected')).toBe('false'); + }); + + it('moves selection backward with direction -1', () => { + const { container } = renderMenu( + <> + + + + + ); + + // Go to last item first + act(() => dispatchNavigate(container, 1)); + act(() => dispatchNavigate(container, 1)); + + act(() => dispatchNavigate(container, -1)); + + const buttons = container.querySelectorAll('button'); + expect(buttons[0].getAttribute('data-selected')).toBe('false'); + expect(buttons[1].getAttribute('data-selected')).toBe('true'); + expect(buttons[2].getAttribute('data-selected')).toBe('false'); + }); + + it('clamps selection at the first item when navigating backward at index 0', () => { + const { container } = renderMenu( + <> + + + + ); + + act(() => dispatchNavigate(container, -1)); + + const buttons = container.querySelectorAll('button'); + expect(buttons[0].getAttribute('data-selected')).toBe('true'); + }); + + it('clamps selection at the last item when navigating forward past the end', () => { + const { container } = renderMenu( + <> + + + + ); + + act(() => dispatchNavigate(container, 1)); + act(() => dispatchNavigate(container, 1)); // attempt to go past the end + + const buttons = container.querySelectorAll('button'); + expect(buttons[0].getAttribute('data-selected')).toBe('false'); + expect(buttons[1].getAttribute('data-selected')).toBe('true'); + }); +}); diff --git a/src/app/components/editor/autocomplete/AutocompleteMenu.tsx b/src/app/components/editor/autocomplete/AutocompleteMenu.tsx index def55c2f..9b907a8a 100644 --- a/src/app/components/editor/autocomplete/AutocompleteMenu.tsx +++ b/src/app/components/editor/autocomplete/AutocompleteMenu.tsx @@ -31,6 +31,9 @@ export function AutocompleteMenu({ headerContent, requestClose, children }: Auto // Sync data-selected to DOM; reset to index 0 when the item list changes. // No dep array — runs after every render so newly-loaded buttons are stamped // immediately (buttons arrive async when search results load). + // setSelectedIndex is a stable React setter; the conditional call never + // triggers an infinite update chain (it only fires when button count changes). + // eslint-disable-next-line react-hooks/exhaustive-deps useLayoutEffect(() => { const buttons = Array.from( itemsRef.current?.querySelectorAll('button') ?? [] diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 84036812..41ef50a5 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -833,7 +833,7 @@ export const RoomInput = forwardRef( if (isKeyHotkey('enter', evt) && !isComposing(evt)) { const selectedItem = -autocompleteMenu.querySelector('button[data-selected="true"]') ?? + autocompleteMenu.querySelector('button[data-selected="true"]') ?? autocompleteMenu.querySelector('button'); if (selectedItem) { From f94d400584139e32e861d96d6296532b067c7b24 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Tue, 17 Mar 2026 16:11:11 -0500 Subject: [PATCH 03/10] add tab --- .changeset/fix-autocomplete-selection.md | 2 +- src/app/features/room/RoomInput.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/fix-autocomplete-selection.md b/.changeset/fix-autocomplete-selection.md index 6abefe18..2a5ff305 100644 --- a/.changeset/fix-autocomplete-selection.md +++ b/.changeset/fix-autocomplete-selection.md @@ -2,4 +2,4 @@ default: patch --- -Fix autocomplete Enter key always selecting the first item and the first item not being highlighted on open. +Fix autocomplete Enter & Tab key always selecting the first item and the first item not being highlighted on open. diff --git a/src/app/features/room/RoomInput.tsx b/src/app/features/room/RoomInput.tsx index 41ef50a5..a79eb2be 100644 --- a/src/app/features/room/RoomInput.tsx +++ b/src/app/features/room/RoomInput.tsx @@ -831,7 +831,7 @@ export const RoomInput = forwardRef( return; } - if (isKeyHotkey('enter', evt) && !isComposing(evt)) { + if ((isKeyHotkey('enter', evt) || isKeyHotkey('tab', evt)) && !isComposing(evt)) { const selectedItem = autocompleteMenu.querySelector('button[data-selected="true"]') ?? autocompleteMenu.querySelector('button'); From 55d27dcd5e1dc6b61e8d262a030d32e9a66d4632 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2026 21:41:40 +0000 Subject: [PATCH 04/10] chore: prepare release 1.9.3 --- .changeset/fix-autocomplete-selection.md | 5 ----- .changeset/fix-empty-message.md | 5 ----- .changeset/fix-enter-autocomplete.md | 5 ----- .changeset/fix-image-render.md | 5 ----- .changeset/fix-macos-casing.md | 5 ----- ..._ui_it_should_now_feel_a_lot_more_intergrated_.md | 5 ----- .changeset/sentry-opt-in-crash-reporting.md | 5 ----- CHANGELOG.md | 12 ++++++++++++ package.json | 2 +- 9 files changed, 13 insertions(+), 36 deletions(-) delete mode 100644 .changeset/fix-autocomplete-selection.md delete mode 100644 .changeset/fix-empty-message.md delete mode 100644 .changeset/fix-enter-autocomplete.md delete mode 100644 .changeset/fix-image-render.md delete mode 100644 .changeset/fix-macos-casing.md delete mode 100644 .changeset/improved_voice_message_recording_ui_it_should_now_feel_a_lot_more_intergrated_.md delete mode 100644 .changeset/sentry-opt-in-crash-reporting.md diff --git a/.changeset/fix-autocomplete-selection.md b/.changeset/fix-autocomplete-selection.md deleted file mode 100644 index 2a5ff305..00000000 --- a/.changeset/fix-autocomplete-selection.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fix autocomplete Enter & Tab key always selecting the first item and the first item not being highlighted on open. diff --git a/.changeset/fix-empty-message.md b/.changeset/fix-empty-message.md deleted file mode 100644 index 2febfa10..00000000 --- a/.changeset/fix-empty-message.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fix messages with body empty but formatted body filled rendering as empty. diff --git a/.changeset/fix-enter-autocomplete.md b/.changeset/fix-enter-autocomplete.md deleted file mode 100644 index c44d196b..00000000 --- a/.changeset/fix-enter-autocomplete.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fix emoticon autocomplete not respecting character threshold setting. diff --git a/.changeset/fix-image-render.md b/.changeset/fix-image-render.md deleted file mode 100644 index 4b4aeff0..00000000 --- a/.changeset/fix-image-render.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fix images without explicit dimensions not appearing. diff --git a/.changeset/fix-macos-casing.md b/.changeset/fix-macos-casing.md deleted file mode 100644 index 735318ab..00000000 --- a/.changeset/fix-macos-casing.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fix Mac OS to macOS in the the devices tab diff --git a/.changeset/improved_voice_message_recording_ui_it_should_now_feel_a_lot_more_intergrated_.md b/.changeset/improved_voice_message_recording_ui_it_should_now_feel_a_lot_more_intergrated_.md deleted file mode 100644 index eaeb76ec..00000000 --- a/.changeset/improved_voice_message_recording_ui_it_should_now_feel_a_lot_more_intergrated_.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -# Improved voice message recording UI, it should now feel a lot more integrated. diff --git a/.changeset/sentry-opt-in-crash-reporting.md b/.changeset/sentry-opt-in-crash-reporting.md deleted file mode 100644 index 175ef088..00000000 --- a/.changeset/sentry-opt-in-crash-reporting.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Add opt-in Sentry crash reporting with a consent banner. diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f6792b6..46b8a198 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Sable Client Changelog +## 1.9.3 (2026-03-17) + +### Fixes + +* Fix autocomplete Enter & Tab key always selecting the first item and the first item not being highlighted on open. ([#310](https://github.com/SableClient/Sable/pull/310) by @Just-Insane) +* Fix messages with body empty but formatted body filled rendering as empty. ([#337](https://github.com/SableClient/Sable/pull/337) by @7w1) +* Fix emoticon autocomplete not respecting character threshold setting. ([#337](https://github.com/SableClient/Sable/pull/337) by @7w1) +* Fix images without explicit dimensions not appearing. ([#338](https://github.com/SableClient/Sable/pull/338) by @7w1) +* Fix Mac OS to macOS in the the devices tab ([#328](https://github.com/SableClient/Sable/pull/328) by @DidiDidi129) +* Improved voice message recording UI, it should now feel a lot more integrated. ([#311](https://github.com/SableClient/Sable/pull/311) by @hazre) +* Add opt-in Sentry crash reporting with a consent banner. ([#333](https://github.com/SableClient/Sable/pull/333) by @Just-Insane) + ## 1.9.2 (2026-03-17) ### Fixes diff --git a/package.json b/package.json index 9739e961..6c52a2e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sable", - "version": "1.9.2", + "version": "1.9.3", "description": "An almost stable Matrix client", "type": "module", "packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be", From 4b4d41f98f9072d3120cd912c59bfdebc749d954 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Tue, 17 Mar 2026 18:50:59 -0500 Subject: [PATCH 05/10] Update CODEOWNERS --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 696e9679..4a725057 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @7w1 @Just-Insane @hazre +* @7w1 @hazre From 0f14e675baf1cfea92c35434cd327d2241e8488d Mon Sep 17 00:00:00 2001 From: 7w1 Date: Tue, 17 Mar 2026 21:15:38 -0500 Subject: [PATCH 06/10] pronoun pills for all --- .changeset/pronoun-pills.md | 5 ++ src/app/features/room/message/Message.tsx | 58 ++++++++++++++++--- .../features/settings/cosmetics/Cosmetics.tsx | 8 +++ src/app/state/settings.ts | 2 + 4 files changed, 65 insertions(+), 8 deletions(-) create mode 100644 .changeset/pronoun-pills.md diff --git a/.changeset/pronoun-pills.md b/.changeset/pronoun-pills.md new file mode 100644 index 00000000..416f3764 --- /dev/null +++ b/.changeset/pronoun-pills.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +Added a setting to Appearance that attempts to convert text in names like (it/its) into a pronoun pill, enlabed by default. diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index 9dd200ed..fdd015c2 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -390,11 +390,6 @@ function MessageInternal( return mxc ? mxcUrlToHttp(mx, mxc, useAuthentication, 48, 48, 'crop') : undefined; }, [pmp, collapse, profile.avatarUrl, senderId, mx, room, useAuthentication]); - const displayName = useMemo( - () => pmp?.displayname || senderDisplayName, - [pmp, senderDisplayName] - ); - const cachedAvatar = useBlobCache(avatarUrl ?? undefined); // UI State @@ -423,9 +418,56 @@ function MessageInternal( const [mobileOptionsOpen, setMobileOptionsOpen] = useState(false); const optionsRef = useRef(null); + const [showPronouns] = useSetting(settingsAtom, 'showPronouns'); + const [parsePronouns] = useSetting(settingsAtom, 'parsePronouns'); + const [useRightBubbles] = useSetting(settingsAtom, 'useRightBubbles'); + const { cleanedDisplayName, inlinePronoun } = useMemo(() => { + const rawName = pmp?.displayname || senderDisplayName || ''; + + if (!parsePronouns) { + return { cleanedDisplayName: rawName, inlinePronoun: null }; + } + + // match text like (she/her) or [he/they/them] but not (hi) + const regex = /[\(\[]?([a-zA-Z]+\/[a-zA-Z]+(?:\/[a-zA-Z]+)?)[\)\]]?/; + const match = rawName.match(regex); + + if (match) { + let strippedName = rawName.replace(match[0], '').trim(); + + if (!strippedName || strippedName === '') { + strippedName = rawName; + } + + return { + cleanedDisplayName: strippedName, + inlinePronoun: match[1].toLowerCase().slice(0, 16), + }; + } + + return { cleanedDisplayName: rawName, inlinePronoun: null }; + }, [pmp, senderDisplayName, parsePronouns]); + + const mergedPronouns = useMemo(() => { + const existing = profile.pronouns ? [...profile.pronouns] : []; + + if (inlinePronoun) { + const isDupe = existing.some((p) => p.summary?.toLowerCase() === inlinePronoun); + + if (!isDupe) { + existing.push({ + summary: inlinePronoun, + language: 'en', + }); + } + } + + return existing; + }, [profile.pronouns, inlinePronoun]); + useEffect(() => { if (!mobileOptionsOpen) return undefined; const handleClickOutside = (e: globalThis.Event) => { @@ -457,11 +499,11 @@ function MessageInternal( onClick={onUsernameClick} > - {displayName} + {cleanedDisplayName} {showPronouns && ( - + )} {tagIconSrc && } @@ -500,7 +542,7 @@ function MessageInternal( } /> diff --git a/src/app/features/settings/cosmetics/Cosmetics.tsx b/src/app/features/settings/cosmetics/Cosmetics.tsx index d1a65b6b..f0bf1d8f 100644 --- a/src/app/features/settings/cosmetics/Cosmetics.tsx +++ b/src/app/features/settings/cosmetics/Cosmetics.tsx @@ -165,6 +165,7 @@ function IdentityCosmetics() { 'legacyUsernameColor' ); const [showPronouns, setShowPronouns] = useSetting(settingsAtom, 'showPronouns'); + const [parsePronouns, setParsePronouns] = useSetting(settingsAtom, 'parsePronouns'); const [renderGlobalColors, setRenderGlobalColors] = useSetting( settingsAtom, 'renderGlobalNameColors' @@ -196,6 +197,13 @@ function IdentityCosmetics() { after={} /> + + } + /> + Date: Tue, 17 Mar 2026 21:23:18 -0500 Subject: [PATCH 07/10] cache things --- src/app/features/room/message/Message.tsx | 27 ++------------- src/app/utils/pronouns.ts | 42 +++++++++++++++++++++++ 2 files changed, 44 insertions(+), 25 deletions(-) diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index fdd015c2..2602ab26 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -79,7 +79,7 @@ import { MessageSourceCodeItem } from '$components/message/modals/MessageSource' import { MessageForwardItem } from '$components/message/modals/MessageForward'; import { MessageDeleteItem } from '$components/message/modals/MessageDelete'; import { MessageReportItem } from '$components/message/modals/MessageReport'; -import { filterPronounsByLanguage } from '$utils/pronouns'; +import { filterPronounsByLanguage, getParsedPronouns } from '$utils/pronouns'; import { useMentionClickHandler } from '$hooks/useMentionClickHandler'; import { addStickerToDefaultPack, @@ -423,32 +423,9 @@ function MessageInternal( const [parsePronouns] = useSetting(settingsAtom, 'parsePronouns'); const [useRightBubbles] = useSetting(settingsAtom, 'useRightBubbles'); - const { cleanedDisplayName, inlinePronoun } = useMemo(() => { const rawName = pmp?.displayname || senderDisplayName || ''; - - if (!parsePronouns) { - return { cleanedDisplayName: rawName, inlinePronoun: null }; - } - - // match text like (she/her) or [he/they/them] but not (hi) - const regex = /[\(\[]?([a-zA-Z]+\/[a-zA-Z]+(?:\/[a-zA-Z]+)?)[\)\]]?/; - const match = rawName.match(regex); - - if (match) { - let strippedName = rawName.replace(match[0], '').trim(); - - if (!strippedName || strippedName === '') { - strippedName = rawName; - } - - return { - cleanedDisplayName: strippedName, - inlinePronoun: match[1].toLowerCase().slice(0, 16), - }; - } - - return { cleanedDisplayName: rawName, inlinePronoun: null }; + return getParsedPronouns(rawName, parsePronouns); }, [pmp, senderDisplayName, parsePronouns]); const mergedPronouns = useMemo(() => { diff --git a/src/app/utils/pronouns.ts b/src/app/utils/pronouns.ts index c653d9fd..6d111a2a 100644 --- a/src/app/utils/pronouns.ts +++ b/src/app/utils/pronouns.ts @@ -63,3 +63,45 @@ export function filterPronounsByLanguage( return filteredPronouns; } + +const pronounParseCache = new Map< + string, + { cleanedDisplayName: string; inlinePronoun: string | null } +>(); + +export function getParsedPronouns(rawName: string, parseSetting: boolean) { + if (!parseSetting || !rawName) { + return { cleanedDisplayName: rawName, inlinePronoun: null }; + } + + if (pronounParseCache.has(rawName)) { + return pronounParseCache.get(rawName)!; + } + + // match text like (she/her) or [he/they/them] but not (hi) + const regex = /[([]?([a-zA-Z]+\/[a-zA-Z]+(?:\/[a-zA-Z]+)?)[)\]]?/; + const match = rawName.match(regex); + + let result: { cleanedDisplayName: string; inlinePronoun: string | null } = { + cleanedDisplayName: rawName, + inlinePronoun: null, + }; + + if (match) { + let strippedName = rawName.replace(match[0], '').trim(); + if (!strippedName || strippedName === '') { + strippedName = rawName; + } + result = { + cleanedDisplayName: strippedName, + inlinePronoun: match[1].toLowerCase().slice(0, 16), + }; + } + + if (pronounParseCache.size > 1000) { + pronounParseCache.clear(); + } + + pronounParseCache.set(rawName, result); + return result; +} From dcfafa4f5e07ecb0a62d2ab47b5e2c2b5bec7092 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Tue, 17 Mar 2026 21:28:22 -0500 Subject: [PATCH 08/10] Update Message.tsx --- src/app/features/room/message/Message.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index 2602ab26..7ce5adbe 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -995,7 +995,7 @@ function MessageInternal( autoFocus value={nickDraft} onChange={(e) => setNickDraft(e.target.value)} - placeholder={displayName} + placeholder={cleanedDisplayName} onKeyDown={(e) => { if (e.key === 'Enter') { setNickname(senderId, nickDraft || undefined, mx); From 4eef3cefef48eb9151e19bb34f1dab3d99fd537a Mon Sep 17 00:00:00 2001 From: 7w1 Date: Tue, 17 Mar 2026 21:36:48 -0500 Subject: [PATCH 09/10] Hide presence badge in members list for users without homeserver support, mimicking room profile apperance. --- .changeset/fix-presence-badge-member-list.md | 5 +++++ src/app/features/room/MembersDrawer.tsx | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/fix-presence-badge-member-list.md diff --git a/.changeset/fix-presence-badge-member-list.md b/.changeset/fix-presence-badge-member-list.md new file mode 100644 index 00000000..f227b478 --- /dev/null +++ b/.changeset/fix-presence-badge-member-list.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Hide presence badge in members list for users without homeserver support, mimicking room profile apperance. diff --git a/src/app/features/room/MembersDrawer.tsx b/src/app/features/room/MembersDrawer.tsx index c54d9650..1834d283 100644 --- a/src/app/features/room/MembersDrawer.tsx +++ b/src/app/features/room/MembersDrawer.tsx @@ -155,7 +155,11 @@ function MemberItem({ }} > } + badge={ + presence && presence.lastActiveTs !== 0 ? ( + + ) : undefined + } > Date: Tue, 17 Mar 2026 21:58:31 -0500 Subject: [PATCH 10/10] add toggle for mention highlighting --- .changeset/mention-highlight-toggle.md | 5 +++++ src/app/features/room/message/Message.tsx | 7 +++++-- .../settings/notifications/SystemNotification.tsx | 15 +++++++++++++++ src/app/state/settings.ts | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .changeset/mention-highlight-toggle.md diff --git a/.changeset/mention-highlight-toggle.md b/.changeset/mention-highlight-toggle.md new file mode 100644 index 00000000..d2c7ddd2 --- /dev/null +++ b/.changeset/mention-highlight-toggle.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Added a toggle to notifications to disable full message mention highlighting. diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index 9dd200ed..20625d7e 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -381,6 +381,8 @@ function MessageInternal( const profile = useUserProfile(senderId, room); const { color: usernameColor, font: usernameFont } = useSableCosmetics(senderId, room); + const [highlightMentions] = useSetting(settingsAtom, 'highlightMentions'); + // Avatars // Prefer the room-scoped member avatar (m.room.member) over the global profile // avatar so per-room avatar overrides are respected in the timeline. @@ -725,7 +727,7 @@ function MessageInternal( space={messageSpacing} collapse={collapse} highlight={highlight} - notifyHighlight={notifyHighlight} + notifyHighlight={highlightMentions ? notifyHighlight : undefined} selected={!!menuAnchor || !!emojiBoardAnchor} {...props} {...hoverProps} @@ -1150,6 +1152,7 @@ export const Event = as<'div', EventProps>( const [menuAnchor, setMenuAnchor] = useState(); const [mobileOptionsOpen, setMobileOptionsOpen] = useState(false); + const [highlightMentions] = useSetting(settingsAtom, 'highlightMentions'); const handleContextMenu: MouseEventHandler = (evt) => { if (mobileOrTablet()) { @@ -1226,7 +1229,7 @@ export const Event = as<'div', EventProps>( space={messageSpacing} autoCollapse highlight={highlight} - notifyHighlight={notifyHighlight} + notifyHighlight={highlightMentions ? notifyHighlight : undefined} selected={!!menuAnchor} {...props} {...hoverProps} diff --git a/src/app/features/settings/notifications/SystemNotification.tsx b/src/app/features/settings/notifications/SystemNotification.tsx index 47266460..c9b59549 100644 --- a/src/app/features/settings/notifications/SystemNotification.tsx +++ b/src/app/features/settings/notifications/SystemNotification.tsx @@ -193,6 +193,7 @@ export function SystemNotification() { settingsAtom, 'faviconForMentionsOnly' ); + const [highlightMentions, setHighlightMentions] = useSetting(settingsAtom, 'highlightMentions'); // Describe what the current badge combo actually does so users aren't left guessing. const badgeBehaviourSummary = (): string => { @@ -400,6 +401,20 @@ export function SystemNotification() { after={} /> + + + } + /> + ); } diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index e9331c62..82d11153 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -97,6 +97,7 @@ export interface Settings { saveStickerEmojiBandwidth: boolean; alwaysShowCallButton: boolean; faviconForMentionsOnly: boolean; + highlightMentions: boolean; // furry stuff renderAnimals: boolean; @@ -178,6 +179,7 @@ const defaultSettings: Settings = { saveStickerEmojiBandwidth: false, alwaysShowCallButton: false, faviconForMentionsOnly: false, + highlightMentions: true, // furry stuff renderAnimals: true,