feat: room abbreviations with hover tooltips and space inheritance#514
feat: room abbreviations with hover tooltips and space inheritance#5147w1 merged 18 commits intoSableClient:devfrom
Conversation
|
requested review from @Rosy-iso because it seems to be an ui change and from @TastelessVoid because they (according to github) recently worked on the changed files |
|
I'll give it a look soon |
- Add StateEvent.RoomAbbreviations ('moe.sable.room.abbreviations')
- Include abbreviations event in sliding sync required state
- Add AbbreviationsPage to RoomSettingsPage enum
- New RoomAbbreviations settings page (add/remove term+definition pairs)
- Wire page into RoomSettings.tsx menu
- New useRoomAbbreviations hook + RoomAbbreviationsContext
- Provide context in Room.tsx
- RenderBody.tsx: highlight defined terms in plain-text messages with
TooltipProvider+abbr tooltip; HTML messages unaffected
- buildAbbreviationsMap now stores exact-case keys (no .toLowerCase()) - splitByAbbreviations regex uses 'g' flag instead of 'gi' — user-defined casing is matched exactly (FOSS won't match 'foss' in text) - Word boundaries (\b) still prevent matching inside longer words - RoomAbbreviations settings page duplicate check updated to exact match - Add 19 unit tests covering edge cases: empty map, no-match, start/mid/end splits, case sensitivity, word boundaries, longest-match priority
- Revert to case-insensitive matching (gi flag, lowercase map keys) and
update tests and duplicate-entry check accordingly
- Remove title attribute from <abbr> — was causing native browser tooltip
to overlap with our custom TooltipProvider tooltip
- Extract AbbreviationTerm component; adds click/tap handler that pins
the definition as a PopOut positioned above the term
- Desktop: hover still shows tooltip via TooltipProvider
- Mobile: tap pins the tooltip open; tap anywhere else dismisses it
(one-shot document click listener, stopped by e.stopPropagation so
the opening click does not immediately close it)
- Add textDecoration: 'underline dotted' and cursor: 'help' to <abbr> elements in AbbreviationTerm so users can see the hover indicator - RoomAbbreviations: add isSpace prop; when true, show 'Space Abbreviations' / 'space-level' labels and hide the inherited-from-space section - SpaceSettings: pass isSpace to RoomAbbreviations
- useMergedAbbreviations: drop space param; use getAllParents+roomToParentsAtom to traverse the full ancestor chain and subscribe to state events at every level (not just direct parent) via useStateEventCallback on the mx client - Room.tsx: drop parentSpace/useSpaceOptionally — hook handles it internally - RoomAbbreviations settings: replace two-section layout with a single flat list; room entries shown without badge, inherited entries show a 'Space - <SpaceName>' chip badge; supports arbitrary nesting depth (mirrors the useImagePackRooms multi-level pattern)
…idity on input change
0232c4e to
6d68944
Compare
Rosy-iso
left a comment
There was a problem hiding this comment.
Interesting feature! I like the concept a lot actually, is this idea from you or is it from some matrix spec?
That aside, consistency wise things are mostly okay: the abbreviations list is perfectly consistent while the abbreviation creation modal is...almost consistent. While the fact that the modal itself is not split into multiple sections might seem the issue at first, that is actually perfectly fine as this is something with precedence that is rarely done for the few settings that must work with multiple elements at once (room settings, emoji pack settings)
The inaccuracy is in the spacing and placement: the elements of the modal are too close together and the button should be on the left, not the right, use the other modals as reference
|
The abbreviation concept is mine, I wanted a lightweight way for rooms to define their own jargon/acronyms without needing a full wiki or pinned message. Saw a few people asking about PMP messages were while that was being developed. Fixed both spacing issues: bumped the form's internal gap from |
|
Seems to be an issue with abbreviations not showing properly, trying to track that down. Edit: looks good now, looks like it was an issue with messages sent via PMPs |
Previously, abbreviation term highlighting was skipped for any message that has a formatted_body (virtually all messages from modern clients using a rich-text editor), because RenderBody returned early from the customBody path before reaching the abbreviation logic. The fix adds an optional replaceTextNode callback to getReactCustomHtmlParser. Since opts closes over itself, renderChildren inside element handlers recurses through the same replace function, so text nodes nested inside <p>, <strong>, <em>, list items, etc. are all processed correctly. buildAbbrReplaceTextNode is exported from RenderBody.tsx and wired into both RoomTimeline and ThreadDrawer via useRoomAbbreviationsContext.
Rosy-iso
left a comment
There was a problem hiding this comment.
Seems to be consistent now indeed, this works :)
(This approval is purely UI wise, the code should still be audited and reviewed separately by someone else!)
src/app/features/room-settings/abbreviations/RoomAbbreviations.tsx
Outdated
Show resolved
Hide resolved
src/app/features/room-settings/abbreviations/RoomAbbreviations.tsx
Outdated
Show resolved
Hide resolved
> [!IMPORTANT] > Merging this PR will create a new release. ## Features * Add ability to click on usernames in member and state events to view user info ([#536](#536) by @thundertheidiot) * Add black theme ([#437](#437) by @Elec3137) * added a limited compatibility with `pk;member` commands ([#550](#550) by @dozro) * Add /location sharing command, and a /sharemylocation command. ([#509](#509) by @nushea) * added option to use shorthands to send a message with a Persona, for example `✨:test` ([#550](#550) by @dozro) * Add quick reply keybinds by using <kbd>ctrl</kbd>+<kbd>up</kbd> / <kbd>ctrl</kbd>+<kbd>down</kbd> you can now cycle through the message you are replying to with keybinds ([#524](#524) by @CodeF53) * Adds a `/html` command to send HTML messages ([#560](#560) by @Vespe-r) * Add room abbreviations with hover tooltips: moderators define term/definition pairs in room settings; matching terms are highlighted in messages. ([#514](#514) by @Just-Insane) * Add support for timestamps, playlists and youtube music links for the youtube embeds ([#534](#534) by @thundertheidiot) * Add settings sync across devices via Matrix account data, with JSON export/import ([#515](#515) by @Just-Insane) ## Fixes * Add detailed error messages to forwarding failures. ([#532](#532) by @7w1) * Cap unread badge numbers at `1k+`, and something extra :) ([#484](#484) by @hazre) * Fix scroll-to-bottom after room navigation, timeline pagination reliability, and URL preview deduplication. ([#529](#529) by @Just-Insane) * Fixes the most recent pmp message in encrypted rooms not consistently rendering the pmp and not grouping with previous pmps. ([#526](#526) by @7w1) * fixed sending sticker and attachments while having a persona selected ([#525](#525) by @dozro) * Fix push notifications missing sender/room avatar and showing stale display names when using event_id_only push format. ([#551](#551) by @Just-Insane) * Sanitize formatted reply previews before rendering to prevent unsafe HTML from being parsed in reply snippets. ([#569](#569) by @Just-Insane) * Fix broken link to Sliding Sync known issues — now points to #39 instead of the old repository. ([#519](#519) by @Just-Insane) * Fix service worker authenticated media requests returning 401 errors after SW restart or when session data is missing/stale. ([#516](#516) by @Just-Insane) * rephrased the command describtion for `/usepmp` and made `/usepmp reset` actually reset the room association of the pmp ([#550](#550) by @dozro) * Fix confusing ui with `Client Side Embeds in Encrypted Rooms` setting ([#535](#535) by @thundertheidiot) * fix forwarding metadata by removing the `null` value ([#540](#540) by @dozro) * fix forwarding issue for users on synapse homeservers, by removing the relation ([#558](#558) by @dozro) * fixed the syntax issues regarding `/addpmp` and `usepmp` (note that the syntax for `/usepmp` has changed) ([#550](#550) by @dozro) * fix the display of jumbo emojis on messages sent with a persona ([#530](#530) by @dozro) * Fix sidebar notification badge positioning so unread and unverified counts align consistently. ([#484](#484) by @hazre) * Use the browser's native compact number formatting for room and member counts. ([#484](#484) by @hazre) * fix(sentry): scrub percent-encoded Matrix IDs and opaque base64url tokens from Sentry URLs ([#531](#531) by @Just-Insane) ## Notes * new/changed bios will now also be saved in the format MSC4440 expects ([#559](#559) by @dozro) * moved the setting for filtering pronouns by language from experimental to the appearance setting ([#521](#521) by @dozro)
Description
Adds a room abbreviations feature: moderators can define term/definition pairs in room settings. Defined terms are highlighted with a dotted underline in messages and show a tooltip on hover (tap-to-pin on mobile). Abbreviations defined in a parent space are inherited by child rooms and nested spaces, with overrides allowed at each level. The settings UI shows a flat list of inherited and locally-defined entries.
Fixes #
Type of change
Checklist:
AI disclosure:
The code adds changes that allow for setting and viewing room abbreviations, with an on-hover tooltip (or press on mobile - semi-persistent). It stores these in the room state under a new key, and recursively fetches abbreviations from the space level. This also adds regex so that abbreviations correctly work at word boundaries. Also adds the needed hooks to
room.tsandslidingSync.ts