diff --git a/.changeset/add-forward-errors.md b/.changeset/add-forward-errors.md new file mode 100644 index 00000000..753f99d2 --- /dev/null +++ b/.changeset/add-forward-errors.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Add detailed error messages to forwarding failures. diff --git a/.changeset/add_black_theme.md b/.changeset/add_black_theme.md new file mode 100644 index 00000000..b499f1ef --- /dev/null +++ b/.changeset/add_black_theme.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +# Add black theme diff --git a/.changeset/add_location_command.md b/.changeset/add_location_command.md new file mode 100644 index 00000000..6a794f9a --- /dev/null +++ b/.changeset/add_location_command.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +Add /location sharing command, and a /sharemylocation command. diff --git a/.changeset/add_pmp_sending.md b/.changeset/add_pmp_sending.md deleted file mode 100644 index 5b5c2419..00000000 --- a/.changeset/add_pmp_sending.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -added the posibility to send using per message profiles with `/usepmp` diff --git a/.changeset/add_quickreply_keybinds.md b/.changeset/add_quickreply_keybinds.md new file mode 100644 index 00000000..b97761de --- /dev/null +++ b/.changeset/add_quickreply_keybinds.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +Add quick reply keybinds by using ctrl+up / ctrl+down you can now cycle through the message you are replying to with keybinds diff --git a/.changeset/cap_unread_badges.md b/.changeset/cap_unread_badges.md new file mode 100644 index 00000000..affe5ee1 --- /dev/null +++ b/.changeset/cap_unread_badges.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Cap unread badge numbers at `1k+`, and something extra :) diff --git a/.changeset/feat-room-abbreviations.md b/.changeset/feat-room-abbreviations.md new file mode 100644 index 00000000..d2323849 --- /dev/null +++ b/.changeset/feat-room-abbreviations.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +Add room abbreviations with hover tooltips: moderators define term/definition pairs in room settings; matching terms are highlighted in messages. diff --git a/.changeset/fix-mentions-leaking-nicknames.md b/.changeset/fix-mentions-leaking-nicknames.md deleted file mode 100644 index 3f4f299d..00000000 --- a/.changeset/fix-mentions-leaking-nicknames.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -fix [accidental leaking of private nicknames](https://github.com/SableClient/Sable/issues/362) for users to be included in the message diff --git a/.changeset/fix-pmp-encrypted.md b/.changeset/fix-pmp-encrypted.md new file mode 100644 index 00000000..f9f0ab17 --- /dev/null +++ b/.changeset/fix-pmp-encrypted.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fixes the most recent pmp message in encrypted rooms not consistently rendering the pmp and not grouping with previous pmps. diff --git a/.changeset/fix-pmp-sending-message-with-attachments.md b/.changeset/fix-pmp-sending-message-with-attachments.md new file mode 100644 index 00000000..a04dcf59 --- /dev/null +++ b/.changeset/fix-pmp-sending-message-with-attachments.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +fixed sending sticker and attachments while having a persona selected diff --git a/.changeset/fix-presence-badge-member-list.md b/.changeset/fix-presence-badge-member-list.md deleted file mode 100644 index f227b478..00000000 --- a/.changeset/fix-presence-badge-member-list.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Hide presence badge in members list for users without homeserver support, mimicking room profile apperance. diff --git a/.changeset/fix-sliding-sync-known-issues-link.md b/.changeset/fix-sliding-sync-known-issues-link.md new file mode 100644 index 00000000..3262e84f --- /dev/null +++ b/.changeset/fix-sliding-sync-known-issues-link.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix broken link to Sliding Sync known issues — now points to SableClient/Sable#39 instead of the old repository. diff --git a/.changeset/fix-sliding-sync-memory.md b/.changeset/fix-sliding-sync-memory.md deleted file mode 100644 index 42e0ce51..00000000 --- a/.changeset/fix-sliding-sync-memory.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Tighten sliding sync memory management: stop the polling loop on client dispose, persist then prune large room timelines when leaving a room, remove adaptive timeline-limit logic, and auto-unsubscribe when the local user leaves or is banned from a room. diff --git a/.changeset/fix-sw-media-auth-401.md b/.changeset/fix-sw-media-auth-401.md new file mode 100644 index 00000000..5390991b --- /dev/null +++ b/.changeset/fix-sw-media-auth-401.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix service worker authenticated media requests returning 401 errors after SW restart or when session data is missing/stale. diff --git a/.changeset/fix-thread-classic-sync.md b/.changeset/fix-thread-classic-sync.md deleted file mode 100644 index bb8cda0b..00000000 --- a/.changeset/fix-thread-classic-sync.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Fix thread drawer showing no messages when using classic sync. diff --git a/.changeset/fix-thread-indicator-badge.md b/.changeset/fix-thread-indicator-badge.md deleted file mode 100644 index c9303ac1..00000000 --- a/.changeset/fix-thread-indicator-badge.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Hide the redundant "Thread" indicator badge in the compose box when inside the Thread Drawer. diff --git a/.changeset/fix-thread-ui-spacing.md b/.changeset/fix-thread-ui-spacing.md deleted file mode 100644 index 445ff082..00000000 --- a/.changeset/fix-thread-ui-spacing.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Reduce dead space around the root message in the thread drawer. diff --git a/.changeset/fix_confusing_ui_with_client_side_embeds_setting.md b/.changeset/fix_confusing_ui_with_client_side_embeds_setting.md new file mode 100644 index 00000000..6fd108a6 --- /dev/null +++ b/.changeset/fix_confusing_ui_with_client_side_embeds_setting.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +# Fix confusing ui with `Client Side Embeds in Encrypted Rooms` setting diff --git a/.changeset/fix_forwarding_metadata.md b/.changeset/fix_forwarding_metadata.md new file mode 100644 index 00000000..36e50223 --- /dev/null +++ b/.changeset/fix_forwarding_metadata.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +fix forwarding metadata by removing the `null` value diff --git a/.changeset/fix_pmp_jumbo_emoji_display.md b/.changeset/fix_pmp_jumbo_emoji_display.md new file mode 100644 index 00000000..68fd7bdb --- /dev/null +++ b/.changeset/fix_pmp_jumbo_emoji_display.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +fix the display of jumbo emojis on messages sent with a persona diff --git a/.changeset/fix_sidebar_badge_alignment.md b/.changeset/fix_sidebar_badge_alignment.md new file mode 100644 index 00000000..65f35747 --- /dev/null +++ b/.changeset/fix_sidebar_badge_alignment.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Fix sidebar notification badge positioning so unread and unverified counts align consistently. diff --git a/.changeset/improve_youtube_embeds.md b/.changeset/improve_youtube_embeds.md new file mode 100644 index 00000000..9fbe326a --- /dev/null +++ b/.changeset/improve_youtube_embeds.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +# Add support for timestamps, playlists and youtube music links for the youtube embeds diff --git a/.changeset/mention-highlight-toggle.md b/.changeset/mention-highlight-toggle.md deleted file mode 100644 index d2c7ddd2..00000000 --- a/.changeset/mention-highlight-toggle.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Added a toggle to notifications to disable full message mention highlighting. diff --git a/.changeset/move_filtering_pronouns_by_language_setting_to_appearance.md b/.changeset/move_filtering_pronouns_by_language_setting_to_appearance.md new file mode 100644 index 00000000..29e9b861 --- /dev/null +++ b/.changeset/move_filtering_pronouns_by_language_setting_to_appearance.md @@ -0,0 +1,5 @@ +--- +default: note +--- + +moved the setting for filtering pronouns by language from experimental to the appearance setting diff --git a/.changeset/pronoun-pills.md b/.changeset/pronoun-pills.md deleted file mode 100644 index 416f3764..00000000 --- a/.changeset/pronoun-pills.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -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/.changeset/reduce-mention-highlight-opacity.md b/.changeset/reduce-mention-highlight-opacity.md deleted file mode 100644 index 85cb022c..00000000 --- a/.changeset/reduce-mention-highlight-opacity.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: patch ---- - -Reduced the opacity of mention highlight backgrounds to be less visually intrusive while remaining noticeable. diff --git a/.changeset/replace_millify_with_intl.md b/.changeset/replace_millify_with_intl.md new file mode 100644 index 00000000..805f9f89 --- /dev/null +++ b/.changeset/replace_millify_with_intl.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +Use the browser's native compact number formatting for room and member counts. diff --git a/.changeset/sentry-scrub-opaque-matrix-ids.md b/.changeset/sentry-scrub-opaque-matrix-ids.md new file mode 100644 index 00000000..23eb1ef9 --- /dev/null +++ b/.changeset/sentry-scrub-opaque-matrix-ids.md @@ -0,0 +1,5 @@ +--- +default: patch +--- + +fix(sentry): scrub percent-encoded Matrix IDs and opaque base64url tokens from Sentry URLs diff --git a/.changeset/settings-sync.md b/.changeset/settings-sync.md new file mode 100644 index 00000000..95ff8852 --- /dev/null +++ b/.changeset/settings-sync.md @@ -0,0 +1,5 @@ +--- +default: minor +--- + +Add settings sync across devices via Matrix account data, with JSON export/import diff --git a/.changeset/update_calls_to_have_rnnoise_noise_suppression.md b/.changeset/update_calls_to_have_rnnoise_noise_suppression.md deleted file mode 100644 index ada13936..00000000 --- a/.changeset/update_calls_to_have_rnnoise_noise_suppression.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -default: minor ---- - -# Update calls to have RNNoise noise suppression. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d481c26b..8d22671f 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ - + ### Description @@ -20,3 +20,9 @@ Fixes # - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings + +### AI disclosure: + +- [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). +- [ ] Fully AI generated (explain what all the generated code does in moderate detail). + diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 84867463..3c4f0f7e 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -46,9 +46,10 @@ updates: commit-message: prefix: chore groups: - # Group all non-major updates together to reduce noise - npm-minor-patch: + npm-major: + update-types: + - major + npm-non-major: update-types: - minor - patch - # Major updates are ungrouped so they get individual review diff --git a/.github/workflows/cloudflare-web-deploy.yml b/.github/workflows/cloudflare-web-deploy.yml index 413b7104..d3d2c446 100644 --- a/.github/workflows/cloudflare-web-deploy.yml +++ b/.github/workflows/cloudflare-web-deploy.yml @@ -20,7 +20,7 @@ on: env: CLOUDFLARE_API_TOKEN: ${{ secrets.TF_CLOUDFLARE_API_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TF_VAR_workers_message: ${{ github.event_name == 'pull_request' && github.event.pull_request.title || github.event.head_commit.message || github.sha }} + TF_VAR_workers_message: ${{ github.event_name == 'pull_request' && github.event.pull_request.title || github.ref_name }} TF_VAR_account_id: ${{ secrets.TF_VAR_ACCOUNT_ID }} TF_VAR_zone_id: ${{ secrets.TF_VAR_ZONE_ID }} TF_HTTP_ADDRESS: ${{ secrets.TF_HTTP_ADDRESS }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b2e647c..d3314e27 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,10 +14,18 @@ jobs: permissions: contents: write steps: + - name: Generate bot token + id: generate-token + uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 - persist-credentials: false + persist-credentials: true + token: ${{ steps.generate-token.outputs.token }} - uses: knope-dev/action@19617851f9f13ab2f27a05989c55efb18aca3675 # v2.1.2 with: @@ -26,4 +34,4 @@ jobs: - name: Create Release run: knope release --verbose env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 46b8a198..7ecbe982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,157 @@ # Sable Client Changelog +## 1.12.3 (2026-03-24) + +### Fixes + +* Fixed text autocomplete issues ([#487](https://github.com/SableClient/Sable/pull/487) by @nushea) +* Fix crash when url contains malformed/dangling uri components. ([#512](https://github.com/SableClient/Sable/pull/512) by @7w1) + +## 1.12.2 (2026-03-24) + +### Fixes + +* Fix standard embed links not rendering. ([#506](https://github.com/SableClient/Sable/pull/506) by @7w1) +* Added maximum height to state events ([#491](https://github.com/SableClient/Sable/pull/491) by @nushea) + +## 1.12.1 (2026-03-24) + +### Fixes + +* Change cloudflare deploy worker message to something much shorter to avoid char limit. ([#504](https://github.com/SableClient/Sable/pull/504) by @7w1) + +## 1.12.0 (2026-03-24) + +### Features + +* `Ctrl + K` search menu is now context aware and lists the current space's rooms at the top. ([#499](https://github.com/SableClient/Sable/pull/499) by @7w1) +* Add knocking support when attempting to join a room from the directory, an address, a room mention, or space hierarchy, as well as text command support for knocking. Also improves rendering for knock notifications in rooms. ([#470](https://github.com/SableClient/Sable/pull/470) by @polyjitter) +* Add Android/iOS PWA-specific icon variants. ([#473](https://github.com/SableClient/Sable/pull/473) by @Septicity) +* Add support for youtube embeds. ([#497](https://github.com/SableClient/Sable/pull/497) by @thundertheidiot) +* Add sidebar three dot menu for quick access to related settings ([#474](https://github.com/SableClient/Sable/pull/474) by @wolterkam) +* Replies that mention the OP are now indicated by the OP username being prefixed with @ ([#465](https://github.com/SableClient/Sable/pull/465) by @mini-bomba) +* Made pin events show a tally of the messages that are pinned. ([#462](https://github.com/SableClient/Sable/pull/462) by @nushea) + +#### Improve multiline composer and voice recording ([#476](https://github.com/SableClient/Sable/pull/476) by @hazre) + +- Add a multiline composer layout for longer drafts. +- Keep the voice recorder between composer actions in multiline mode. +- Show the recorder inside the composer on mobile while recording. +- Prevent the composer from expanding when recording starts. +- Make the recorder footer and waveform fit better across screen sizes. +- Let interrupted mobile recording gestures still stop correctly. +- Stabilize wrap detection around edge cases like narrow widths and trailing spaces. + +### Fixes + +* Added error messages provided by homeserver to unknown login errors. ([#496](https://github.com/SableClient/Sable/pull/496) by @7w1) +* Ensure new updates always reload the page properly. ([#502](https://github.com/SableClient/Sable/pull/502) by @7w1) +* Removed the blocked users moved notice from notifications setting page. ([#490](https://github.com/SableClient/Sable/pull/490) by @7w1) +* Fix recieved encrypted message per-message profiles not triggering rerenders. ([#464](https://github.com/SableClient/Sable/pull/464) by @7w1) +* Add `.m4a` files as a recognized audio type. ([#472](https://github.com/SableClient/Sable/pull/472) by @henk717) +* Fix messages disappearing from rooms after reconnects and timeline resets. ([#478](https://github.com/SableClient/Sable/pull/478) by @hazre) +* Fix Camera being enabled by default even when the client has it off pre joining in browsers that permit the video (Electron/Tauri as examples). ([#485](https://github.com/SableClient/Sable/pull/485) by @Rawrington) +* Fix cinny-dark-theme link colors being too dark ([#469](https://github.com/SableClient/Sable/pull/469) by @Elec3137) +* Fix "Default" menu item height in room notification switcher. ([#466](https://github.com/SableClient/Sable/pull/466) by @polyjitter) +* fix the issue of empty displaynames of a persona, causing an empty fallback message, it will now ommit the fallback, if the name is empty or only consists of whitespace ([#495](https://github.com/SableClient/Sable/pull/495) by @dozro) +* Fixed an Android issue where recording a voice message with headphones could leave audio stuck in low-quality mode until the app was restarted. ([#476](https://github.com/SableClient/Sable/pull/476) by @hazre) +* Fixed voice message scrubbing/seeking on Firefox by switching the recorder from WebM (no seek index) to Ogg/Opus. ([#476](https://github.com/SableClient/Sable/pull/476) by @hazre) +* fixes touchpad zooming behaviour ([#481](https://github.com/SableClient/Sable/pull/481) by @integralfunction) +* Fixes width mismatch for the call chat view. ([#460](https://github.com/SableClient/Sable/pull/460) by @polyjitter) +* Fix messages sent from sable showing wrong on other client(s) ([#468](https://github.com/SableClient/Sable/pull/468) by @nushea) + +### Documentation + +* Updated PR template and CONTRIBUTING.md to add AI disclosure requirement. ([#456](https://github.com/SableClient/Sable/pull/456) by @Rosy-iso) + +## 1.11.1 (2026-03-21) + +### Fixes + +* Fix conditional memo in reply renderer leading to crashes. ([#453](https://github.com/SableClient/Sable/pull/453) by @7w1) + +## 1.11.0 (2026-03-21) + +### Features + +* Implemented improved rendering for space hierarchies in nav bar and lobby. ([#252](https://github.com/SableClient/Sable/pull/252) by @KaceCottam) +* Added styling for replies to non-messages. ([#416](https://github.com/SableClient/Sable/pull/416) by @nushea) + +### Fixes + +* Fix message composer clearing when edited messages are saved. ([#447](https://github.com/SableClient/Sable/pull/447) by @7w1) +* Fix editor flowing off screen when editing large messages in compact and bubble layouts. ([#447](https://github.com/SableClient/Sable/pull/447) by @7w1) +* Fix extra spacing in message editor. ([#447](https://github.com/SableClient/Sable/pull/447) by @7w1) +* Fix menu items not clickable due to menu transform. ([#450](https://github.com/SableClient/Sable/pull/450) by @7w1) +* Fix replies not rendering matrix.to links and opening them in new tabs instead of jumping to them. ([#448](https://github.com/SableClient/Sable/pull/448) by @7w1) +* Fix per-message profile messages collapsing together when different profiles are used. ([#449](https://github.com/SableClient/Sable/pull/449) by @7w1) +* Fix per-message profiles not updating avatar/name if edit events are recieved. ([#449](https://github.com/SableClient/Sable/pull/449) by @7w1) +* Fix editing per-message profile messages injecting profile name into message. ([#451](https://github.com/SableClient/Sable/pull/451) by @7w1) +* Fix per-message profiles not rendering in encrypted rooms. ([#449](https://github.com/SableClient/Sable/pull/449) by @7w1) +* Fix thread chips not appearing on thread root messages. ([#446](https://github.com/SableClient/Sable/pull/446) by @7w1) +* Fix up arrow to edit messages not editing messages. ([#447](https://github.com/SableClient/Sable/pull/447) by @7w1) + +## 1.10.6 (2026-03-21) + +### Fixes + +* Change default notification server. ([#443](https://github.com/SableClient/Sable/pull/443) by @7w1) + +## 1.10.5 (2026-03-20) + +### Fixes + +* Hide unread dot/highlight for rooms with notification mode set to Mute. ([#429](https://github.com/SableClient/Sable/pull/429) by @saschabuehrle) +* Fix thread drawer flooding console with "Ignoring event" warnings when server-side thread support is enabled. ([#438](https://github.com/SableClient/Sable/pull/438) by @Just-Insane) + +## 1.10.4 (2026-03-20) + +### Fixes + +* Change default push notification server. ([#433](https://github.com/SableClient/Sable/pull/433) by @7w1) + +## 1.10.3 (2026-03-20) + +### Fixes + +* Place persona settings behind a toggle in experimental. ([#431](https://github.com/SableClient/Sable/pull/431) by @7w1) + +## 1.10.2 (2026-03-20) + +### Fixes + +* Fix edit button not always editing. ([#413](https://github.com/SableClient/Sable/pull/413) by @7w1) +* Fix search/nav/links/etc not loading messages. ([#413](https://github.com/SableClient/Sable/pull/413) by @7w1) +* Fix timeline not sticking to the bottom in non-reduced motion setting. ([#413](https://github.com/SableClient/Sable/pull/413) by @7w1) +* Replace matrix.org with matrixrooms.info in default featured servers section. ([#413](https://github.com/SableClient/Sable/pull/413) by @7w1) + +## 1.10.1 (2026-03-20) + +### Fixes + +* Fix messages overlapping in timeline. ([#411](https://github.com/SableClient/Sable/pull/411) by @7w1) + +## 1.10.0 (2026-03-20) + +### Features + +* added the posibility to send using per message profiles with `/usepmp` ([#309](https://github.com/SableClient/Sable/pull/309) by @dozro) +* Added a setting to Appearance that attempts to convert text in names like (it/its) into a pronoun pill, enlabed by default. ([#353](https://github.com/SableClient/Sable/pull/353) by @7w1) +* Rewrite the room timeline using Virtua to fix all the scroll bugs. ([#175](https://github.com/SableClient/Sable/pull/175) by @7w1) +* Update calls to have RNNoise noise suppression. ([#392](https://github.com/SableClient/Sable/pull/392) by @melogale) + +### Fixes + +* fix [accidental leaking of private nicknames](https://github.com/SableClient/Sable/issues/362) for users to be included in the message ([#365](https://github.com/SableClient/Sable/pull/365) by @dozro) +* Hide presence badge in members list for users without homeserver support, mimicking room profile apperance. ([#354](https://github.com/SableClient/Sable/pull/354) by @7w1) +* Tighten sliding sync memory management: stop the polling loop on client dispose, persist then prune large room timelines when leaving a room, remove adaptive timeline-limit logic, and auto-unsubscribe when the local user leaves or is banned from a room. ([#348](https://github.com/SableClient/Sable/pull/348) by @Just-Insane) +* Fix thread drawer showing no messages when using classic sync. ([#343](https://github.com/SableClient/Sable/pull/343) by @Just-Insane) +* Hide the redundant "Thread" indicator badge in the compose box when inside the Thread Drawer. ([#347](https://github.com/SableClient/Sable/pull/347) by @Just-Insane) +* Reduce dead space around the root message in the thread drawer. ([#344](https://github.com/SableClient/Sable/pull/344) by @Just-Insane) +* Added a toggle to notifications to disable full message mention highlighting. ([#355](https://github.com/SableClient/Sable/pull/355) by @7w1) +* Add a setting to disable reply mentions by default ([#405](https://github.com/SableClient/Sable/pull/405) by @mini-bomba) +* Reduced the opacity of mention highlight backgrounds to be less visually intrusive while remaining noticeable. ([#401](https://github.com/SableClient/Sable/pull/401) by @sachin-dul) + ## 1.9.3 (2026-03-17) ### Fixes diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c417e207..29f53db0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,7 +53,10 @@ We expect and appreciate authentic engagement in our community. Do not post output from Large Language Models or similar generative AI as comments on GitHub, as such comments tend to be formulaic and low content. -If you use generative AI tools as an aid in developing code, ensure that you fully understand the proposed changes and can explain why they are the correct approach. +If you use generative AI tools as an aid in developing code, ensure that you fully understand the proposed changes and can explain why they are the correct approach; additionally, you **must** disclose which parts of the code were: + +- Fully generated by the AI tool. +- Written alongside the AI tool (examples: line completion, rewriting code generated by AI). Make sure you have added value based on your personal competency to your contributions. Just taking some input, feeding it to an AI and posting the result is not of value to the project. We reserve the right to rigorously reject seemingly AI generated low-value contributions. diff --git a/config.json b/config.json index 24d3e65e..1bdffb67 100644 --- a/config.json +++ b/config.json @@ -8,9 +8,9 @@ "hideUsernamePasswordFields": false, "pushNotificationDetails": { - "pushNotifyUrl": "https://cinny.cc/_matrix/push/v1/notify", - "vapidPublicKey": "BHLwykXs79AbKNiblEtZZRAgnt7o5_ieImhVJD8QZ01MVwAHnXwZzNgQEJJEU3E5CVsihoKtb7yaNe5x3vmkWkI", - "webPushAppID": "cc.cinny.web" + "pushNotifyUrl": "https://sygnal.sable.moe/_matrix/push/v1/notify", + "vapidPublicKey": "BCnS4SbHjeOaqVFW4wjt5xDt_pYIL62qMzKePfYF9fl9PQU14RieIaObh7nLR_9dQf4sykZa-CTrcjkgMIE1mcg", + "webPushAppID": "moe.sable.app.sygnal" }, "slidingSync": { @@ -35,7 +35,7 @@ "#PrivSec.dev:arcticfoxes.net", "#disroot:aria-net.org" ], - "servers": ["matrix.org", "mozilla.org", "unredacted.org"] + "servers": ["matrixrooms.info", "mozilla.org", "unredacted.org"] }, "hashRouter": { diff --git a/index.html b/index.html index 62ce1dab..c22ea427 100644 --- a/index.html +++ b/index.html @@ -35,55 +35,86 @@ + + + + + + + diff --git a/knope.toml b/knope.toml index cb3b69a7..4b3d2fb8 100644 --- a/knope.toml +++ b/knope.toml @@ -64,6 +64,6 @@ repo = "Sable" [release_notes] # The marker is used by prepare-release.yml change_templates = [ - # "### $summary \n\n$details", + "### $summary \n\n$details", "* $summary ", ] diff --git a/package.json b/package.json index 1b3cb9db..23853c9e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sable", - "version": "1.9.3", + "version": "1.12.3", "description": "An almost stable Matrix client", "type": "module", "packageManager": "pnpm@10.32.1+sha512.a706938f0e89ac1456b6563eab4edf1d1faf3368d1191fc5c59790e96dc918e4456ab2e67d613de1043d2e8c81f87303e6b40d4ffeca9df15ef1ad567348f2be", @@ -22,6 +22,7 @@ "test:run": "vitest run", "test:coverage": "vitest run --coverage", "knip": "knip", + "tunnel": "cloudflared tunnel --url http://localhost:8080", "knope": "knope", "document-change": "knope document-change", "postinstall": "node scripts/install-knope.js" @@ -34,9 +35,9 @@ "@atlaskit/pragmatic-drag-and-drop-auto-scroll": "^1.4.0", "@atlaskit/pragmatic-drag-and-drop-hitbox": "^1.1.0", "@fontsource-variable/nunito": "5.2.7", - "@sentry/react": "^10.43.0", "@fontsource/space-mono": "5.2.9", "@phosphor-icons/react": "^2.1.10", + "@sentry/react": "^10.43.0", "@tanstack/react-query": "^5.90.21", "@tanstack/react-query-devtools": "^5.91.3", "@tanstack/react-virtual": "^3.13.19", @@ -72,7 +73,6 @@ "linkifyjs": "^4.3.2", "matrix-js-sdk": "^38.4.0", "matrix-widget-api": "^1.16.1", - "millify": "^6.1.0", "pdfjs-dist": "^5.4.624", "prismjs": "^1.30.0", "react": "^18.3.1", @@ -91,16 +91,17 @@ "slate-history": "^0.113.1", "slate-react": "^0.123.0", "ua-parser-js": "^1.0.41", + "virtua": "^0.48.8", "workbox-precaching": "^7.4.0" }, "devDependencies": { "@cloudflare/vite-plugin": "^1.26.0", - "@sableclient/sable-call-embedded": "v1.1.4", "@esbuild-plugins/node-globals-polyfill": "^0.2.3", "@eslint/compat": "2.0.2", "@eslint/js": "9.39.3", "@rollup/plugin-inject": "^5.0.5", "@rollup/plugin-wasm": "^6.2.2", + "@sableclient/sable-call-embedded": "v1.1.4", "@sentry/vite-plugin": "^5.1.1", "@testing-library/jest-dom": "^6.9.1", "@testing-library/react": "^16.3.2", @@ -119,6 +120,7 @@ "@vitest/coverage-v8": "^4.1.0", "@vitest/ui": "^4.1.0", "buffer": "^6.0.3", + "cloudflared": "^0.7.1", "eslint": "9.39.3", "eslint-config-airbnb-extended": "3.0.1", "eslint-config-prettier": "10.1.8", @@ -137,4 +139,4 @@ "vitest": "^4.1.0", "wrangler": "^4.70.0" } -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 75323029..c0a9719b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,8 @@ overrides: minimatch: '>=10.2.3' rollup: '>=4.59.0' serialize-javascript: '>=7.0.3' + flatted: '>=3.4.2' + undici: '>=7.24.0' importers: @@ -142,9 +144,6 @@ importers: matrix-widget-api: specifier: ^1.16.1 version: 1.17.0 - millify: - specifier: ^6.1.0 - version: 6.1.0 pdfjs-dist: specifier: ^5.4.624 version: 5.5.207 @@ -199,6 +198,9 @@ importers: ua-parser-js: specifier: ^1.0.41 version: 1.0.41 + virtua: + specifier: ^0.48.8 + version: 0.48.8(react-dom@18.3.1(react@18.3.1))(react@18.3.1) workbox-precaching: specifier: ^7.4.0 version: 7.4.0 @@ -278,6 +280,9 @@ importers: buffer: specifier: ^6.0.3 version: 6.0.3 + cloudflared: + specifier: ^0.7.1 + version: 0.7.1 eslint: specifier: 9.39.3 version: 9.39.3(jiti@2.6.1) @@ -3321,6 +3326,10 @@ packages: resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==} engines: {node: '>=12'} + cloudflared@0.7.1: + resolution: {integrity: sha512-jJn1Gu9Tf4qnIu8tfiHZ25Hs8rNcRYSVf8zAd97wvYdOCzftm1CTs1S/RPhijjGi8gUT1p9yzfDi9zYlU/0RwA==} + hasBin: true + clsx@2.1.1: resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==} engines: {node: '>=6'} @@ -3527,9 +3536,6 @@ packages: electron-to-chromium@1.5.307: resolution: {integrity: sha512-5z3uFKBWjiNR44nFcYdkcXjKMbg5KXNdciu7mhTPo9tB7NbqSNP2sSnGR+fqknZSCwKkBN+oxiiajWs4dT6ORg==} - emoji-regex@8.0.0: - resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} - emoji-regex@9.2.2: resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} @@ -3878,11 +3884,8 @@ packages: resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==} engines: {node: '>=16'} - flatted@3.4.0: - resolution: {integrity: sha512-kC6Bb+ooptOIvWj5B63EQWkF0FEnNjV2ZNkLMLZRDDduIiWeFF4iKnslwhiWxjAdbg4NzTNo6h0qLuvFrcx+Sw==} - - flatted@3.4.1: - resolution: {integrity: sha512-IxfVbRFVlV8V/yRaGzk0UVIcsKKHMSfYw66T/u4nTwlWteQePsxe//LjudR1AMX4tZW3WFCh3Zqa/sjlqpbURQ==} + flatted@3.4.2: + resolution: {integrity: sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==} focus-trap-react@10.3.1: resolution: {integrity: sha512-PN4Ya9xf9nyj/Nd9VxBNMuD7IrlRbmaG6POAQ8VLqgtc6IY/Ln1tYakow+UIq4fihYYYFM70/2oyidE6bbiPgw==} @@ -3957,10 +3960,6 @@ packages: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} engines: {node: '>=6.9.0'} - get-caller-file@2.0.5: - resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} - engines: {node: 6.* || 8.* || >= 10.*} - get-intrinsic@1.3.0: resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==} engines: {node: '>= 0.4'} @@ -4196,10 +4195,6 @@ packages: resolution: {integrity: sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==} engines: {node: '>= 0.4'} - is-fullwidth-code-point@3.0.0: - resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} - engines: {node: '>=8'} - is-generator-function@1.1.2: resolution: {integrity: sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==} engines: {node: '>= 0.4'} @@ -4539,10 +4534,6 @@ packages: resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} - millify@6.1.0: - resolution: {integrity: sha512-H/E3J6t+DQs/F2YgfDhxUVZz/dF8JXPPKTLHL/yHCcLZLtCXJDUaqvhJXQwqOVBvbyNn4T0WjLpIHd7PAw7fBA==} - hasBin: true - min-indent@1.0.1: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} @@ -4928,10 +4919,6 @@ packages: resolution: {integrity: sha512-NZQZdC5wOE/H3UT28fVGL+ikOZcEzfMGk/c3iN9UGxzWHMa1op7274oyiUVrAG4B2EuFhus8SvkaYnhvW92p9Q==} hasBin: true - require-directory@2.1.1: - resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} - engines: {node: '>=0.10.0'} - require-from-string@2.0.2: resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} engines: {node: '>=0.10.0'} @@ -5127,10 +5114,6 @@ packages: resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==} engines: {node: '>= 0.4'} - string-width@4.2.3: - resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} - engines: {node: '>=8'} - string.prototype.includes@2.0.1: resolution: {integrity: sha512-o7+c9bW6zpAdJHTtujeePODAhkuicdAryFsfVKwA+wGw89wJ4GTY484WTucM9hLtDEOpOvI+aHnzqnC5lHp4Rg==} engines: {node: '>= 0.4'} @@ -5158,10 +5141,6 @@ packages: resolution: {integrity: sha512-rHqiFh1elqCQ9WPLIC8I0Q/g/wj5J1eMkyoiD6eoQApWHP0FtlK7rqnhmabL5VUY9JQCcqwwvlOaSuutekgyrw==} engines: {node: '>=4'} - strip-ansi@6.0.1: - resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} - engines: {node: '>=8'} - strip-bom@3.0.0: resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} engines: {node: '>=4'} @@ -5347,10 +5326,6 @@ packages: undici-types@7.16.0: resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==} - undici@7.18.2: - resolution: {integrity: sha512-y+8YjDFzWdQlSE9N5nzKMT3g4a5UBX1HKowfdXh0uvAnTaqqwqB92Jt4UXBAeKekDs5IaDKyJFR4X1gYVCgXcw==} - engines: {node: '>=20.18.1'} - undici@7.24.3: resolution: {integrity: sha512-eJdUmK/Wrx2d+mnWWmwwLRyA7OQCkLap60sk3dOK4ViZR7DKwwptwuIvFBg2HaiP9ESaEdhtpSymQPvytpmkCA==} engines: {node: '>=20.18.1'} @@ -5414,6 +5389,26 @@ packages: resolution: {integrity: sha512-XQegIaBTVUjSHliKqcnFqYypAd4S+WCYt5NIeRs6w/UAry7z8Y9j5ZwRRL4kzq9U3sD6v+85er9FvkEaBpji2w==} hasBin: true + virtua@0.48.8: + resolution: {integrity: sha512-jpsxOw5V4B6hg44JePRLo9DL0TV7N1lBEVtPjKpAJebXyhI2s9lfiXJESaLapNtr3vtiSk/pWHiLf7B2a6UcgQ==} + peerDependencies: + react: '>=16.14.0' + react-dom: '>=16.14.0' + solid-js: '>=1.0' + svelte: '>=5.0' + vue: '>=3.2' + peerDependenciesMeta: + react: + optional: true + react-dom: + optional: true + solid-js: + optional: true + svelte: + optional: true + vue: + optional: true + vite-node@3.2.4: resolution: {integrity: sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==} engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0} @@ -5655,10 +5650,6 @@ packages: '@cloudflare/workers-types': optional: true - wrap-ansi@7.0.0: - resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} - engines: {node: '>=10'} - ws@8.18.0: resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==} engines: {node: '>=10.0.0'} @@ -5678,10 +5669,6 @@ packages: xmlchars@2.2.0: resolution: {integrity: sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==} - y18n@5.0.8: - resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} - engines: {node: '>=10'} - yallist@3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} @@ -5690,14 +5677,6 @@ packages: engines: {node: '>= 14.6'} hasBin: true - yargs-parser@21.1.1: - resolution: {integrity: sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==} - engines: {node: '>=12'} - - yargs@17.7.2: - resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==} - engines: {node: '>=12'} - yocto-queue@0.1.0: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} @@ -8831,7 +8810,7 @@ snapshots: dependencies: '@vitest/utils': 4.1.0 fflate: 0.8.2 - flatted: 3.4.0 + flatted: 3.4.2 pathe: 2.0.3 sirv: 3.0.2 tinyglobby: 0.2.15 @@ -9115,6 +9094,8 @@ snapshots: strip-ansi: 6.0.1 wrap-ansi: 7.0.0 + cloudflared@0.7.1: {} + clsx@2.1.1: {} color-convert@2.0.1: @@ -9291,8 +9272,6 @@ snapshots: electron-to-chromium@1.5.307: {} - emoji-regex@8.0.0: {} - emoji-regex@9.2.2: {} emojibase-data@15.3.2(emojibase@15.3.1): @@ -9810,12 +9789,10 @@ snapshots: flat-cache@4.0.1: dependencies: - flatted: 3.4.1 + flatted: 3.4.2 keyv: 4.5.4 - flatted@3.4.0: {} - - flatted@3.4.1: {} + flatted@3.4.2: {} focus-trap-react@10.3.1(prop-types@15.8.1)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: @@ -9886,8 +9863,6 @@ snapshots: gensync@1.0.0-beta.2: {} - get-caller-file@2.0.5: {} - get-intrinsic@1.3.0: dependencies: call-bind-apply-helpers: 1.0.2 @@ -10154,8 +10129,6 @@ snapshots: dependencies: call-bound: 1.0.4 - is-fullwidth-code-point@3.0.0: {} - is-generator-function@1.1.2: dependencies: call-bound: 1.0.4 @@ -10488,17 +10461,13 @@ snapshots: braces: 3.0.3 picomatch: 2.3.1 - millify@6.1.0: - dependencies: - yargs: 17.7.2 - min-indent@1.0.1: {} miniflare@4.20260310.0: dependencies: '@cspotcode/source-map-support': 0.8.1 sharp: 0.34.5 - undici: 7.18.2 + undici: 7.24.3 workerd: 1.20260310.1 ws: 8.18.0 youch: 4.1.0-beta.10 @@ -10929,8 +10898,6 @@ snapshots: dependencies: jsesc: 3.1.0 - require-directory@2.1.1: {} - require-from-string@2.0.2: {} require-like@0.1.2: {} @@ -11202,12 +11169,6 @@ snapshots: es-errors: 1.3.0 internal-slot: 1.1.0 - string-width@4.2.3: - dependencies: - emoji-regex: 8.0.0 - is-fullwidth-code-point: 3.0.0 - strip-ansi: 6.0.1 - string.prototype.includes@2.0.1: dependencies: call-bind: 1.0.8 @@ -11264,10 +11225,6 @@ snapshots: is-obj: 1.0.1 is-regexp: 1.0.0 - strip-ansi@6.0.1: - dependencies: - ansi-regex: 5.0.1 - strip-bom@3.0.0: {} strip-comments@2.0.1: {} @@ -11448,8 +11405,6 @@ snapshots: undici-types@7.16.0: {} - undici@7.18.2: {} - undici@7.24.3: {} unenv@2.0.0-rc.24: @@ -11519,6 +11474,11 @@ snapshots: uuid@13.0.0: {} + virtua@0.48.8(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + optionalDependencies: + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + vite-node@3.2.4(@types/node@24.10.13)(jiti@2.6.1)(terser@5.46.0)(yaml@2.8.2): dependencies: cac: 6.7.14 @@ -11856,37 +11816,17 @@ snapshots: - bufferutil - utf-8-validate - wrap-ansi@7.0.0: - dependencies: - ansi-styles: 4.3.0 - string-width: 4.2.3 - strip-ansi: 6.0.1 - ws@8.18.0: {} xml-name-validator@5.0.0: {} xmlchars@2.2.0: {} - y18n@5.0.8: {} - yallist@3.1.1: {} yaml@2.8.2: optional: true - yargs-parser@21.1.1: {} - - yargs@17.7.2: - dependencies: - cliui: 8.0.1 - escalade: 3.2.0 - get-caller-file: 2.0.5 - require-directory: 2.1.1 - string-width: 4.2.3 - y18n: 5.0.8 - yargs-parser: 21.1.1 - yocto-queue@0.1.0: {} youch-core@0.3.3: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index b3fbcdfa..fbcf9139 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,6 +1,7 @@ allowBuilds: '@sentry/cli': true '@swc/core': true + cloudflared: true esbuild: true sharp: true unrs-resolver: true @@ -13,10 +14,12 @@ minimumReleaseAgeExclude: overrides: brace-expansion: '>=1.1.12' esbuild: '>=0.25.0' + flatted: '>=3.4.2' lodash: '>=4.17.23' minimatch: '>=10.2.3' rollup: '>=4.59.0' serialize-javascript: '>=7.0.3' + undici: '>=7.24.0' peerDependencyRules: allowedVersions: diff --git a/public/manifest.json b/public/manifest.json index 696b875e..134a5eb4 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -11,49 +11,166 @@ "theme_color": "#1b1a21", "icons": [ { - "src": "./public/android/android-chrome-36x36.png", - "sizes": "36x36", - "type": "image/png" + "src": "./public/svg/cinny-logo-maskable.svg", + "sizes": "any", + "type": "image/svg+xml", + "purpose": "maskable" }, { - "src": "./public/android/android-chrome-48x48.png", - "sizes": "48x48", - "type": "image/png" - }, - { - "src": "./public/android/android-chrome-72x72.png", - "sizes": "72x72", - "type": "image/png" - }, - { - "src": "./public/android/android-chrome-96x96.png", - "sizes": "96x96", - "type": "image/png" - }, - { - "src": "./public/android/android-chrome-144x144.png", - "sizes": "144x144", - "type": "image/png" - }, - { - "src": "./public/android/android-chrome-192x192.png", - "sizes": "192x192", - "type": "image/png" - }, - { - "src": "./public/android/android-chrome-256x256.png", - "sizes": "256x256", - "type": "image/png" - }, - { - "src": "./public/android/android-chrome-384x384.png", - "sizes": "384x384", - "type": "image/png" - }, - { - "src": "./public/android/android-chrome-512x512.png", + "src": "./public/logo-maskable/cinny-logo-maskable-512x512.png", "sizes": "512x512", - "type": "image/png" + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-384x384.png", + "sizes": "384x384", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-256x256.png", + "sizes": "256x256", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-180x180.png", + "sizes": "180x180", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-167x167.png", + "sizes": "167x167", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-152x152.png", + "sizes": "152x152", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-144x144.png", + "sizes": "144x144", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-120x120.png", + "sizes": "120x120", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-114x114.png", + "sizes": "114x114", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-96x96.png", + "sizes": "96x96", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-76x76.png", + "sizes": "76x76", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-72x72.png", + "sizes": "72x72", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-60x60.png", + "sizes": "60x60", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-57x57.png", + "sizes": "57x57", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-48x48.png", + "sizes": "48x48", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/logo-maskable/cinny-logo-maskable-36x36.png", + "sizes": "36x36", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "./public/svg/cinny-logo.svg", + "sizes": "any", + "type": "image/svg+xml", + "purpose": "any" + }, + { + "src": "./public/logo/cinny-logo-512x512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "any" + }, + { + "src": "./public/logo/cinny-logo-384x384.png", + "sizes": "384x384", + "type": "image/png", + "purpose": "any" + }, + { + "src": "./public/logo/cinny-logo-256x256.png", + "sizes": "256x256", + "type": "image/png", + "purpose": "any" + }, + { + "src": "./public/logo/cinny-logo-192x192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "any" + }, + { + "src": "./public/logo/cinny-logo-144x144.png", + "sizes": "144x144", + "type": "image/png", + "purpose": "any" + }, + { + "src": "./public/logo/cinny-logo-96x96.png", + "sizes": "96x96", + "type": "image/png", + "purpose": "any" + }, + { + "src": "./public/logo/cinny-logo-72x72.png", + "sizes": "72x72", + "type": "image/png", + "purpose": "any" + }, + { + "src": "./public/logo/cinny-logo-48x48.png", + "sizes": "48x48", + "type": "image/png", + "purpose": "any" } ] } diff --git a/public/res/apple/apple-touch-icon-114x114.png b/public/res/apple/apple-touch-icon-114x114.png deleted file mode 100644 index 6b965455..00000000 Binary files a/public/res/apple/apple-touch-icon-114x114.png and /dev/null differ diff --git a/public/res/apple/apple-touch-icon-120x120.png b/public/res/apple/apple-touch-icon-120x120.png deleted file mode 100644 index 657e436e..00000000 Binary files a/public/res/apple/apple-touch-icon-120x120.png and /dev/null differ diff --git a/public/res/apple/apple-touch-icon-144x144.png b/public/res/apple/apple-touch-icon-144x144.png deleted file mode 100644 index a2d3a55e..00000000 Binary files a/public/res/apple/apple-touch-icon-144x144.png and /dev/null differ diff --git a/public/res/apple/apple-touch-icon-152x152.png b/public/res/apple/apple-touch-icon-152x152.png deleted file mode 100644 index 2088a738..00000000 Binary files a/public/res/apple/apple-touch-icon-152x152.png and /dev/null differ diff --git a/public/res/apple/apple-touch-icon-167x167.png b/public/res/apple/apple-touch-icon-167x167.png deleted file mode 100644 index 0f1a60a6..00000000 Binary files a/public/res/apple/apple-touch-icon-167x167.png and /dev/null differ diff --git a/public/res/apple/apple-touch-icon-180x180.png b/public/res/apple/apple-touch-icon-180x180.png deleted file mode 100644 index 9d863d8d..00000000 Binary files a/public/res/apple/apple-touch-icon-180x180.png and /dev/null differ diff --git a/public/res/apple/apple-touch-icon-57x57.png b/public/res/apple/apple-touch-icon-57x57.png deleted file mode 100644 index 12dd241f..00000000 Binary files a/public/res/apple/apple-touch-icon-57x57.png and /dev/null differ diff --git a/public/res/apple/apple-touch-icon-60x60.png b/public/res/apple/apple-touch-icon-60x60.png deleted file mode 100644 index 9992a65d..00000000 Binary files a/public/res/apple/apple-touch-icon-60x60.png and /dev/null differ diff --git a/public/res/apple/apple-touch-icon-72x72.png b/public/res/apple/apple-touch-icon-72x72.png deleted file mode 100644 index 5b12fd92..00000000 Binary files a/public/res/apple/apple-touch-icon-72x72.png and /dev/null differ diff --git a/public/res/apple/apple-touch-icon-76x76.png b/public/res/apple/apple-touch-icon-76x76.png deleted file mode 100644 index 522d74c1..00000000 Binary files a/public/res/apple/apple-touch-icon-76x76.png and /dev/null differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-114x114.png b/public/res/logo-maskable/cinny-logo-maskable-114x114.png new file mode 100644 index 00000000..59463adb Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-114x114.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-120x120.png b/public/res/logo-maskable/cinny-logo-maskable-120x120.png new file mode 100644 index 00000000..4e185fba Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-120x120.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-144x144.png b/public/res/logo-maskable/cinny-logo-maskable-144x144.png new file mode 100644 index 00000000..f674110f Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-144x144.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-152x152.png b/public/res/logo-maskable/cinny-logo-maskable-152x152.png new file mode 100644 index 00000000..8de192a1 Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-152x152.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-167x167.png b/public/res/logo-maskable/cinny-logo-maskable-167x167.png new file mode 100644 index 00000000..146db2de Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-167x167.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-180x180.png b/public/res/logo-maskable/cinny-logo-maskable-180x180.png new file mode 100644 index 00000000..14e2764b Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-180x180.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-192x192.png b/public/res/logo-maskable/cinny-logo-maskable-192x192.png new file mode 100644 index 00000000..45b3f74d Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-192x192.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-256x256.png b/public/res/logo-maskable/cinny-logo-maskable-256x256.png new file mode 100644 index 00000000..ebfadb35 Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-256x256.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-36x36.png b/public/res/logo-maskable/cinny-logo-maskable-36x36.png new file mode 100644 index 00000000..f80ba44c Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-36x36.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-384x384.png b/public/res/logo-maskable/cinny-logo-maskable-384x384.png new file mode 100644 index 00000000..e6fbb3dc Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-384x384.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-48x48.png b/public/res/logo-maskable/cinny-logo-maskable-48x48.png new file mode 100644 index 00000000..4dd14e8f Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-48x48.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-512x512.png b/public/res/logo-maskable/cinny-logo-maskable-512x512.png new file mode 100644 index 00000000..e4e31a72 Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-512x512.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-57x57.png b/public/res/logo-maskable/cinny-logo-maskable-57x57.png new file mode 100644 index 00000000..cc23be00 Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-57x57.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-60x60.png b/public/res/logo-maskable/cinny-logo-maskable-60x60.png new file mode 100644 index 00000000..6a11f207 Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-60x60.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-72x72.png b/public/res/logo-maskable/cinny-logo-maskable-72x72.png new file mode 100644 index 00000000..35e533ec Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-72x72.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-76x76.png b/public/res/logo-maskable/cinny-logo-maskable-76x76.png new file mode 100644 index 00000000..19765815 Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-76x76.png differ diff --git a/public/res/logo-maskable/cinny-logo-maskable-96x96.png b/public/res/logo-maskable/cinny-logo-maskable-96x96.png new file mode 100644 index 00000000..0cd72dbf Binary files /dev/null and b/public/res/logo-maskable/cinny-logo-maskable-96x96.png differ diff --git a/public/res/android/android-chrome-144x144.png b/public/res/logo/cinny-logo-144x144.png similarity index 100% rename from public/res/android/android-chrome-144x144.png rename to public/res/logo/cinny-logo-144x144.png diff --git a/public/res/android/android-chrome-192x192.png b/public/res/logo/cinny-logo-192x192.png similarity index 100% rename from public/res/android/android-chrome-192x192.png rename to public/res/logo/cinny-logo-192x192.png diff --git a/public/res/android/android-chrome-256x256.png b/public/res/logo/cinny-logo-256x256.png similarity index 100% rename from public/res/android/android-chrome-256x256.png rename to public/res/logo/cinny-logo-256x256.png diff --git a/public/res/android/android-chrome-36x36.png b/public/res/logo/cinny-logo-36x36.png similarity index 100% rename from public/res/android/android-chrome-36x36.png rename to public/res/logo/cinny-logo-36x36.png diff --git a/public/res/android/android-chrome-384x384.png b/public/res/logo/cinny-logo-384x384.png similarity index 100% rename from public/res/android/android-chrome-384x384.png rename to public/res/logo/cinny-logo-384x384.png diff --git a/public/res/android/android-chrome-48x48.png b/public/res/logo/cinny-logo-48x48.png similarity index 100% rename from public/res/android/android-chrome-48x48.png rename to public/res/logo/cinny-logo-48x48.png diff --git a/public/res/android/android-chrome-512x512.png b/public/res/logo/cinny-logo-512x512.png similarity index 100% rename from public/res/android/android-chrome-512x512.png rename to public/res/logo/cinny-logo-512x512.png diff --git a/public/res/android/android-chrome-72x72.png b/public/res/logo/cinny-logo-72x72.png similarity index 100% rename from public/res/android/android-chrome-72x72.png rename to public/res/logo/cinny-logo-72x72.png diff --git a/public/res/android/android-chrome-96x96.png b/public/res/logo/cinny-logo-96x96.png similarity index 100% rename from public/res/android/android-chrome-96x96.png rename to public/res/logo/cinny-logo-96x96.png diff --git a/public/res/svg/cinny-logo-maskable.svg b/public/res/svg/cinny-logo-maskable.svg new file mode 100644 index 00000000..1b3b15eb --- /dev/null +++ b/public/res/svg/cinny-logo-maskable.svg @@ -0,0 +1,60 @@ + + + + + + + + + diff --git a/public/res/svg/cinny.svg b/public/res/svg/cinny-logo.svg similarity index 100% rename from public/res/svg/cinny.svg rename to public/res/svg/cinny-logo.svg diff --git a/src/app/components/GlobalKeyboardShortcuts.tsx b/src/app/components/GlobalKeyboardShortcuts.tsx index 5e2a43ee..0571e54a 100644 --- a/src/app/components/GlobalKeyboardShortcuts.tsx +++ b/src/app/components/GlobalKeyboardShortcuts.tsx @@ -5,10 +5,11 @@ * Alt+N — jump to the highest-priority unread room * Alt+Shift+Down — cycle forward through unread rooms * Alt+Shift+Up — cycle backward through unread rooms + * Ctrl+Down / Ctrl+Up: cycle through messages to reply to */ import { useCallback, useRef } from 'react'; import { useNavigate, useLocation, matchPath } from 'react-router-dom'; -import { useAtomValue } from 'jotai'; +import { useAtomValue, useSetAtom } from 'jotai'; import { isKeyHotkey } from 'is-hotkey'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { roomToParentsAtom } from '$state/room/roomToParents'; @@ -19,6 +20,8 @@ import { getDirectRoomPath, getHomeRoomPath, getSpaceRoomPath } from '$pages/pat import { HOME_ROOM_PATH, DIRECT_ROOM_PATH, SPACE_ROOM_PATH } from '$pages/paths'; import { getCanonicalAliasOrRoomId } from '$utils/matrix'; import { announce } from '$utils/announce'; +import { roomIdToReplyDraftAtomFamily } from '$state/room/roomInputDrafts'; +import { Room } from 'matrix-js-sdk'; export function GlobalKeyboardShortcuts() { const navigate = useNavigate(); @@ -37,15 +40,17 @@ export function GlobalKeyboardShortcuts() { const roomIdOrAlias = roomMatch?.params.roomIdOrAlias ? decodeURIComponent(roomMatch.params.roomIdOrAlias) : undefined; - let currentRoomId: string | null = null; + let currentRoom: Room | null = null; if (roomIdOrAlias) { if (roomIdOrAlias.startsWith('!')) { - currentRoomId = roomIdOrAlias; + currentRoom = mx.getRoom(roomIdOrAlias); } else { - currentRoomId = - mx.getRooms().find((r) => r.getCanonicalAlias() === roomIdOrAlias)?.roomId ?? null; + currentRoom = mx.getRooms().find((r) => r.getCanonicalAlias() === roomIdOrAlias) ?? null; } } + const replyDraftAtomFamily = roomIdToReplyDraftAtomFamily(currentRoom?.roomId ?? ''); + const replyDraft = useAtomValue(replyDraftAtomFamily); + const setReplyDraft = useSetAtom(replyDraftAtomFamily); /** Navigate to a room by ID and announce it to screen readers. */ const navigateToRoom = useCallback( @@ -76,7 +81,7 @@ export function GlobalKeyboardShortcuts() { (evt: KeyboardEvent) => { if (!isKeyHotkey('alt+n', evt)) return; const unreadEntries = Array.from(roomToUnread.entries()) - .filter(([id, u]) => u.total > 0 && id !== currentRoomId) + .filter(([id, u]) => u.total > 0 && id !== currentRoom?.roomId) .sort((a, b) => b[1].highlight - a[1].highlight || b[1].total - a[1].total); if (unreadEntries.length === 0) return; evt.preventDefault(); @@ -84,7 +89,7 @@ export function GlobalKeyboardShortcuts() { const [roomId] = unreadEntries[0]; navigateToRoom(roomId, unreadEntries.length - 1); }, - [roomToUnread, currentRoomId, navigateToRoom] + [roomToUnread, currentRoom?.roomId, navigateToRoom] ); /** Alt+Shift+Down / Alt+Shift+Up: cycle through unread rooms. */ @@ -110,8 +115,38 @@ export function GlobalKeyboardShortcuts() { [roomToUnread, navigateToRoom] ); + /** Ctrl+Down / Ctrl+Up: cycle through messages to reply to. */ + const handleReplyKeyDown = useCallback( + (evt: KeyboardEvent) => { + const isDown = isKeyHotkey('mod+down', evt); + const isUp = isKeyHotkey('mod+up', evt); + if (currentRoom === null) return; + if (!isDown && !isUp) return; + + const events = currentRoom.getUnfilteredTimelineSet().getLiveTimeline().getEvents(); + + // when no message is currently targeted, just target the first one + if (replyDraft?.eventId === undefined) { + const latestEvent = events.at(-1); + if (latestEvent === undefined) return; + const eventId = latestEvent.event.event_id; + if (eventId === undefined) return; + setReplyDraft({ userId: currentRoom.myUserId, eventId, body: '' }); + return; + } + const currentReplyIndex = events.findIndex((e) => e.event.event_id === replyDraft.eventId); + if (currentReplyIndex === events.length - 1 && isDown) return; // you cant go further down than that idiot + const newTargetEvent = isUp ? events[currentReplyIndex - 1] : events[currentReplyIndex + 1]; + const eventId = newTargetEvent.event.event_id; + if (eventId === undefined) return; + setReplyDraft({ userId: currentRoom.myUserId, eventId, body: '' }); + }, + [currentRoom, replyDraft, setReplyDraft] + ); + useKeyDown(window, handleNextUnreadKeyDown); useKeyDown(window, handleUnreadNavKeyDown); + useKeyDown(window, handleReplyKeyDown); return null; } diff --git a/src/app/components/RenderMessageContent.tsx b/src/app/components/RenderMessageContent.tsx index b892f769..6f361785 100644 --- a/src/app/components/RenderMessageContent.tsx +++ b/src/app/components/RenderMessageContent.tsx @@ -27,7 +27,7 @@ import { UnsupportedContent, VideoContent, } from './message'; -import { UrlPreviewCard, UrlPreviewHolder } from './url-preview'; +import { UrlPreviewCard, UrlPreviewHolder, ClientPreview, youtubeUrl } from './url-preview'; import { Image, MediaControl, PersistedVolumeVideo } from './media'; import { ImageViewer } from './image-viewer'; import { PdfViewer } from './Pdf-viewer'; @@ -43,6 +43,7 @@ type RenderMessageContentProps = { getContent: () => T; mediaAutoLoad?: boolean; urlPreview?: boolean; + clientUrlPreview?: boolean; highlightRegex?: RegExp; htmlReactParserOptions: HTMLReactParserOptions; linkifyOpts: Opts; @@ -68,6 +69,7 @@ function RenderMessageContentInternal({ getContent, mediaAutoLoad, urlPreview, + clientUrlPreview, highlightRegex, htmlReactParserOptions, linkifyOpts, @@ -112,13 +114,22 @@ function RenderMessageContentInternal({ return ( - {toRender.map(({ url, type }) => ( - - ))} + {toRender.map(({ url, type }) => { + if (type) { + return ; + } + if (clientUrlPreview && youtubeUrl(url)) { + return ; + } + if (urlPreview) { + return ; + } + return null; + })} ); }, - [ts] + [ts, clientUrlPreview, urlPreview] ); const renderCaption = () => { diff --git a/src/app/components/RoomNotificationSwitcher.tsx b/src/app/components/RoomNotificationSwitcher.tsx index 26875850..0b5c9e38 100644 --- a/src/app/components/RoomNotificationSwitcher.tsx +++ b/src/app/components/RoomNotificationSwitcher.tsx @@ -1,4 +1,4 @@ -import { Box, config, Icon, Menu, MenuItem, PopOut, RectCords, Text } from 'folds'; +import { Box, config, Icon, Menu, MenuItem, PopOut, RectCords, Text, toRem } from 'folds'; import { MouseEventHandler, ReactNode, useMemo, useState } from 'react'; import FocusTrap from 'focus-trap-react'; import { stopPropagation } from '$utils/keyboard'; @@ -93,6 +93,7 @@ export function RoomNotificationModeSwitcher({ size="300" variant="Surface" aria-pressed={mode === value} + style={mode === RoomNotificationMode.Unset ? { height: toRem(48) } : undefined} radii="300" disabled={changing} onClick={() => handleSelect(mode)} diff --git a/src/app/components/editor/Editor.css.ts b/src/app/components/editor/Editor.css.ts index 290f7596..077519d1 100644 --- a/src/app/components/editor/Editor.css.ts +++ b/src/app/components/editor/Editor.css.ts @@ -13,6 +13,28 @@ export const Editor = style([ }, ]); +export const EditorRow = style({ + gridTemplateColumns: 'auto 1fr auto', + alignItems: 'center', +}); + +export const EditorRowMultiline = style({ + gridTemplateColumns: 'auto 1fr', + gridTemplateAreas: ` + "before textarea" + "before after" + `, + alignItems: 'start', +}); + +export const EditorRowMultilineWithResponsiveAfter = style({ + gridTemplateColumns: 'auto 1fr auto', + gridTemplateAreas: ` + "before textarea textarea" + "before responsive-after after" + `, +}); + export const EditorOptions = style([ DefaultReset, { @@ -20,14 +42,30 @@ export const EditorOptions = style([ }, ]); -export const EditorTextareaScroll = style({}); +export const EditorOptionsMultiline = style({ + gridArea: 'before', + alignSelf: 'end', +}); + +export const EditorOptionsAfterMultiline = style({ + gridArea: 'after', + justifySelf: 'end', +}); + +export const EditorTextareaScroll = style({ + minWidth: 0, +}); + +export const EditorTextareaScrollMultiline = style({ + gridArea: 'textarea', +}); export const EditorTextarea = style([ DefaultReset, { flexGrow: 1, - height: '100%', - padding: `${toRem(13)} ${toRem(1)}`, + height: 'auto', + padding: `${toRem(13)} 0 0`, selectors: { [`${EditorTextareaScroll}:first-child &`]: { paddingLeft: toRem(13), @@ -42,6 +80,15 @@ export const EditorTextarea = style([ }, ]); +export const EditorResponsiveAfterMultiline = style([ + EditorOptions, + { + gridArea: 'responsive-after', + minWidth: 0, + alignSelf: 'stretch', + }, +]); + export const EditorPlaceholderContainer = style([ DefaultReset, { @@ -57,6 +104,11 @@ export const EditorPlaceholderTextVisual = style([ display: 'block', paddingTop: toRem(13), paddingLeft: toRem(1), + selectors: { + [`${EditorTextareaScroll}:first-child &`]: { + paddingLeft: toRem(13), + }, + }, }, ]); diff --git a/src/app/components/editor/Editor.test.tsx b/src/app/components/editor/Editor.test.tsx new file mode 100644 index 00000000..ab38d73a --- /dev/null +++ b/src/app/components/editor/Editor.test.tsx @@ -0,0 +1,543 @@ +import { act, fireEvent, render, screen, waitFor } from '@testing-library/react'; +import { useState } from 'react'; +import { Transforms } from 'slate'; +import { afterEach, beforeEach, describe, expect, it } from 'vitest'; +import { useEditor, CustomEditor } from './Editor'; +import { BlockType } from './types'; +import * as css from './Editor.css'; + +let shouldWrapToggleHarness = false; +let measurementCacheScrollHeightReads = 0; + +function EditorHarness() { + const editor = useEditor(); + + return ( + <> + + Attach} + after={} + responsiveAfter={
Recorder
} + /> + + ); +} + +function ToggleRecorderHarness() { + const editor = useEditor(); + const [showRecorder, setShowRecorder] = useState(false); + + return ( + <> + + + Attach} + after={} + responsiveAfter={ + showRecorder ?
Recorder
: undefined + } + /> + + ); +} + +function ForcedFooterHarness() { + const editor = useEditor(); + + return ( + Attach} + after={} + responsiveAfter={
Recorder
} + forceMultilineLayout + /> + ); +} + +function PasteWrapHarness() { + const editor = useEditor(); + + return ( + <> + + + + ); +} + +function NearThresholdWrapHarness() { + const editor = useEditor(); + + return ( + <> + + + + ); +} + +function TrailingSpacesWrapHarness() { + const editor = useEditor(); + + return ( + <> + + + + ); +} + +function PasteNoWrapHarness() { + const editor = useEditor(); + + return ( + <> + + + + ); +} + +function MeasurementCacheHarness() { + const editor = useEditor(); + + return ( + <> + + + + ); +} + +const createResizeObserverStub = ( + observedElements: Set, + onCreate: (callback: ResizeObserverCallback) => void +) => + function ResizeObserverStub(callback: ResizeObserverCallback) { + onCreate(callback); + + return { + observe(target: Element) { + observedElements.add(target); + }, + unobserve(target: Element) { + observedElements.delete(target); + }, + disconnect() { + observedElements.clear(); + }, + }; + } as unknown as typeof ResizeObserver; + +const nativeScrollHeight = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'scrollHeight'); +const nativeOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetWidth'); +const nativeClientWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'clientWidth'); +const nativeRequestAnimationFrame = window.requestAnimationFrame; +const nativeCancelAnimationFrame = window.cancelAnimationFrame; +const nativeGlobalRequestAnimationFrame = globalThis.requestAnimationFrame; +const nativeGlobalCancelAnimationFrame = globalThis.cancelAnimationFrame; +const nativeResizeObserver = globalThis.ResizeObserver; + +beforeEach(() => { + shouldWrapToggleHarness = false; + measurementCacheScrollHeightReads = 0; + + Object.defineProperty(HTMLElement.prototype, 'scrollHeight', { + configurable: true, + get() { + if (this instanceof HTMLElement) { + const measurerName = this.getAttribute('data-editor-measurer'); + const measuredText = this.textContent ?? ''; + const hasMeasuredText = measuredText.length > 0; + const isSingleLineProbe = measuredText === 'M'; + + if (measurerName === 'ToggleRecorderHarness') { + if (!hasMeasuredText || isSingleLineProbe) return 20; + return shouldWrapToggleHarness ? 40 : 20; + } + + if (measurerName === 'PasteWrapHarness') { + if (isSingleLineProbe) return 20; + return hasMeasuredText ? 40 : 20; + } + + if (measurerName === 'NearThresholdWrapHarness') { + if (!hasMeasuredText || isSingleLineProbe) return 20; + return this.style.width === '319px' ? 29 : 20; + } + + if (measurerName === 'TrailingSpacesWrapHarness') { + if (!hasMeasuredText || isSingleLineProbe) return 20; + return measuredText.endsWith('\u200B') ? 29 : 20; + } + + if (measurerName === 'PasteNoWrapHarness') { + if (!hasMeasuredText || isSingleLineProbe) return 20; + return 20; + } + + if (measurerName === 'MeasurementCacheHarness') { + if (!hasMeasuredText || isSingleLineProbe) return 20; + measurementCacheScrollHeightReads += 1; + return 40; + } + } + + return nativeScrollHeight?.get?.call(this) ?? 0; + }, + }); + + Object.defineProperty(HTMLElement.prototype, 'offsetWidth', { + configurable: true, + get() { + if (this instanceof HTMLElement && this.classList.contains(css.EditorRow)) { + return 320; + } + return nativeOffsetWidth?.get?.call(this) ?? 0; + }, + }); + + Object.defineProperty(HTMLElement.prototype, 'clientWidth', { + configurable: true, + get() { + if (this instanceof HTMLElement && this.classList.contains(css.EditorTextareaScroll)) { + if (this.querySelector('[data-editable-name="NearThresholdWrapHarness"]')) { + return 319; + } + + return 320; + } + + return nativeClientWidth?.get?.call(this) ?? 0; + }, + }); +}); + +afterEach(() => { + shouldWrapToggleHarness = false; + measurementCacheScrollHeightReads = 0; + window.requestAnimationFrame = nativeRequestAnimationFrame; + window.cancelAnimationFrame = nativeCancelAnimationFrame; + globalThis.requestAnimationFrame = nativeGlobalRequestAnimationFrame; + globalThis.cancelAnimationFrame = nativeGlobalCancelAnimationFrame; + globalThis.ResizeObserver = nativeResizeObserver; + if (nativeScrollHeight) { + Object.defineProperty(HTMLElement.prototype, 'scrollHeight', nativeScrollHeight); + } else { + Reflect.deleteProperty(HTMLElement.prototype, 'scrollHeight'); + } + + if (nativeOffsetWidth) { + Object.defineProperty(HTMLElement.prototype, 'offsetWidth', nativeOffsetWidth); + } else { + Reflect.deleteProperty(HTMLElement.prototype, 'offsetWidth'); + } + + if (nativeClientWidth) { + Object.defineProperty(HTMLElement.prototype, 'clientWidth', nativeClientWidth); + } else { + Reflect.deleteProperty(HTMLElement.prototype, 'clientWidth'); + } +}); + +describe('CustomEditor', () => { + it('moves responsive after content into the multiline footer without keeping the textarea max height', async () => { + render(); + const editable = document.querySelector('[data-editable-name="EditorHarness"]'); + const scroll = editable?.parentElement as HTMLElement | null; + const editorRoot = scroll?.parentElement?.parentElement as HTMLElement | null; + const measurer = document.querySelector('[data-editor-measurer="EditorHarness"]'); + + expect(scroll).not.toBeNull(); + expect(editorRoot).not.toBeNull(); + expect(editorRoot?.contains(measurer)).toBe(true); + expect(measurer?.parentElement).not.toBe(document.body); + expect(scroll?.style.maxHeight).toBe('50vh'); + expect(screen.getByText('Attach')).toBeVisible(); + expect(screen.getByText('Send')).toBeVisible(); + expect(screen.getByTestId('recorder').parentElement).toHaveClass(css.EditorOptions); + + fireEvent.click(screen.getByRole('button', { name: 'Make multiline' })); + + await waitFor(() => { + expect(screen.getByTestId('recorder').parentElement).toHaveClass( + css.EditorResponsiveAfterMultiline + ); + expect(scroll?.style.maxHeight).toBe(''); + }); + + expect(screen.getByText('Attach')).toBeVisible(); + expect(screen.getByText('Send')).toBeVisible(); + }); + + it('recomputes multiline layout when inline responsive content makes existing text wrap', async () => { + render(); + + fireEvent.click(screen.getByRole('button', { name: 'Add text' })); + fireEvent.click(screen.getByRole('button', { name: 'Start recorder' })); + + await waitFor(() => { + expect(screen.getByTestId('toggle-recorder').parentElement).toHaveClass( + css.EditorResponsiveAfterMultiline + ); + }); + }); + + it('supports forcing multiline layout so responsive content moves into the footer immediately', () => { + render(); + + expect(screen.getByTestId('forced-footer-recorder').parentElement).toHaveClass( + css.EditorResponsiveAfterMultiline + ); + }); + + it('detects pasted text that exceeds the single-line width after the deferred layout measurement', async () => { + render(); + const editable = document.querySelector('[data-editable-name="PasteWrapHarness"]'); + const scroll = editable?.parentElement as HTMLElement | null; + + expect(scroll).not.toBeNull(); + expect(scroll).not.toHaveClass(css.EditorTextareaScrollMultiline); + + fireEvent.click(screen.getByRole('button', { name: 'Paste wrapped text' })); + + await waitFor(() => { + expect(scroll).toHaveClass(css.EditorTextareaScrollMultiline); + }); + }); + + it('does not oscillate back to single-line when multiline layout slightly increases the available width', async () => { + const queuedFrames = new Map(); + let nextFrameId = 1; + let resizeObserverCallback: ResizeObserverCallback | undefined; + const observedElements = new Set(); + const flushQueuedFrames = () => { + const pendingFrames = Array.from(queuedFrames.entries()); + queuedFrames.clear(); + pendingFrames.forEach(([, callback]) => { + callback(performance.now()); + }); + }; + + const requestAnimationFrameStub = ((callback: FrameRequestCallback) => { + const frameId = nextFrameId; + nextFrameId += 1; + queuedFrames.set(frameId, callback); + return frameId; + }) as typeof window.requestAnimationFrame; + const cancelAnimationFrameStub = ((frameId: number) => { + queuedFrames.delete(frameId); + }) as typeof window.cancelAnimationFrame; + + window.requestAnimationFrame = requestAnimationFrameStub; + window.cancelAnimationFrame = cancelAnimationFrameStub; + globalThis.requestAnimationFrame = requestAnimationFrameStub; + globalThis.cancelAnimationFrame = cancelAnimationFrameStub; + globalThis.ResizeObserver = createResizeObserverStub(observedElements, (callback) => { + resizeObserverCallback = callback; + }); + + render(); + const editable = document.querySelector('[data-editable-name="NearThresholdWrapHarness"]'); + const scroll = editable?.parentElement as HTMLElement | null; + + expect(scroll).not.toBeNull(); + expect(scroll).not.toHaveClass(css.EditorTextareaScrollMultiline); + + fireEvent.click(screen.getByRole('button', { name: 'Paste near-threshold wrap' })); + + await waitFor(() => { + expect(scroll).toHaveClass(css.EditorTextareaScrollMultiline); + }); + expect(resizeObserverCallback).toBeDefined(); + + act(() => { + resizeObserverCallback?.( + Array.from(observedElements).map((target) => ({ target }) as ResizeObserverEntry), + {} as ResizeObserver + ); + }); + + act(() => { + flushQueuedFrames(); + }); + + expect(scroll).toHaveClass(css.EditorTextareaScrollMultiline); + }); + + it('counts trailing spaces toward the single-line wrap threshold', async () => { + render(); + const editable = document.querySelector('[data-editable-name="TrailingSpacesWrapHarness"]'); + const scroll = editable?.parentElement as HTMLElement | null; + + expect(scroll).not.toBeNull(); + expect(scroll).not.toHaveClass(css.EditorTextareaScrollMultiline); + + fireEvent.click(screen.getByRole('button', { name: 'Paste trailing spaces' })); + + await waitFor(() => { + expect(scroll).toHaveClass(css.EditorTextareaScrollMultiline); + }); + }); + + it('keeps fitting pasted text in single-line mode without deferring to the next frame', () => { + const queuedFrames = new Map(); + let nextFrameId = 1; + + const requestAnimationFrameStub = ((callback: FrameRequestCallback) => { + const frameId = nextFrameId; + nextFrameId += 1; + queuedFrames.set(frameId, callback); + return frameId; + }) as typeof window.requestAnimationFrame; + const cancelAnimationFrameStub = ((frameId: number) => { + queuedFrames.delete(frameId); + }) as typeof window.cancelAnimationFrame; + window.requestAnimationFrame = requestAnimationFrameStub; + window.cancelAnimationFrame = cancelAnimationFrameStub; + globalThis.requestAnimationFrame = requestAnimationFrameStub; + globalThis.cancelAnimationFrame = cancelAnimationFrameStub; + + render(); + const editable = document.querySelector('[data-editable-name="PasteNoWrapHarness"]'); + const scroll = editable?.parentElement as HTMLElement | null; + + expect(scroll).not.toBeNull(); + expect(scroll).not.toHaveClass(css.EditorTextareaScrollMultiline); + + act(() => { + fireEvent.click(screen.getByRole('button', { name: 'Paste short text' })); + }); + + expect(queuedFrames.size).toBe(0); + expect(scroll).not.toHaveClass(css.EditorTextareaScrollMultiline); + }); + + it('reuses the cached measurement when resize observer fires without changing the single-line width', async () => { + const queuedFrames = new Map(); + let nextFrameId = 1; + let resizeObserverCallback: ResizeObserverCallback | undefined; + const observedElements = new Set(); + const flushQueuedFrames = () => { + let safetyCounter = 0; + while (queuedFrames.size > 0 && safetyCounter < 10) { + const pendingFrames = Array.from(queuedFrames.entries()); + queuedFrames.clear(); + pendingFrames.forEach(([, callback]) => { + callback(performance.now()); + }); + safetyCounter += 1; + } + }; + + const requestAnimationFrameStub = ((callback: FrameRequestCallback) => { + const frameId = nextFrameId; + nextFrameId += 1; + queuedFrames.set(frameId, callback); + return frameId; + }) as typeof window.requestAnimationFrame; + const cancelAnimationFrameStub = ((frameId: number) => { + queuedFrames.delete(frameId); + }) as typeof window.cancelAnimationFrame; + + window.requestAnimationFrame = requestAnimationFrameStub; + window.cancelAnimationFrame = cancelAnimationFrameStub; + globalThis.requestAnimationFrame = requestAnimationFrameStub; + globalThis.cancelAnimationFrame = cancelAnimationFrameStub; + globalThis.ResizeObserver = createResizeObserverStub(observedElements, (callback) => { + resizeObserverCallback = callback; + }); + + render(); + + act(() => { + fireEvent.click(screen.getByRole('button', { name: 'Add cached text' })); + }); + + await waitFor(() => { + expect(measurementCacheScrollHeightReads).toBe(1); + }); + expect(resizeObserverCallback).toBeDefined(); + + act(() => { + resizeObserverCallback?.( + Array.from(observedElements).map((target) => ({ target }) as ResizeObserverEntry), + {} as ResizeObserver + ); + }); + + act(() => { + flushQueuedFrames(); + }); + + expect(measurementCacheScrollHeightReads).toBe(1); + }); +}); diff --git a/src/app/components/editor/Editor.tsx b/src/app/components/editor/Editor.tsx index 27df4cf6..7595fd46 100644 --- a/src/app/components/editor/Editor.tsx +++ b/src/app/components/editor/Editor.tsx @@ -5,10 +5,13 @@ import { ReactNode, forwardRef, useCallback, + useEffect, + useLayoutEffect, + useRef, useState, } from 'react'; import { Box, Scroll, Text } from 'folds'; -import { Descendant, Editor, createEditor } from 'slate'; +import { Descendant, Editor, Node, createEditor } from 'slate'; import { Slate, Editable, @@ -53,12 +56,28 @@ export const useEditor = (): Editor => { }; export type EditorChangeHandler = (value: Descendant[]) => void; +const MAX_MULTILINE_MEASURE_RETRIES = 2; +const MULTILINE_HEIGHT_EPSILON = 1; +const TRAILING_SPACE_SENTINEL = '\u200B'; + +const normalizeMeasurementText = (text: string): string => + /[ \t]+$/.test(text) ? `${text}${TRAILING_SPACE_SENTINEL}` : text; + +type MultilineMeasurementCache = { + result: boolean; + singleLineWidth: number; + styleKey: string; + text: string; +}; + type CustomEditorProps = { editableName?: string; top?: ReactNode; bottom?: ReactNode; before?: ReactNode; after?: ReactNode; + responsiveAfter?: ReactNode; + forceMultilineLayout?: boolean; maxHeight?: string; editor: Editor; placeholder?: string; @@ -77,6 +96,8 @@ export const CustomEditor = forwardRef( bottom, before, after, + responsiveAfter, + forceMultilineLayout = false, maxHeight = '50vh', editor, placeholder, @@ -97,6 +118,265 @@ export const CustomEditor = forwardRef( const [slateInitialValue] = useState(() => [ { type: BlockType.Paragraph, children: [{ text: '' }] }, ]); + const rootRef = useRef(null); + const editableRef = useRef(null); + const rowRef = useRef(null); + const beforeRef = useRef(null); + const afterRef = useRef(null); + const textMeasurerRef = useRef(null); + const measurementCacheRef = useRef(null); + const multilineMeasureFrameRef = useRef(null); + const multilineMeasureRetryRef = useRef(0); + const singleLineWidthOffsetRef = useRef(0); + const latestValueRef = useRef(editor.children); + const isMultilineRef = useRef(false); + const [isMultiline, setIsMultiline] = useState(false); + const [measurementVersion, setMeasurementVersion] = useState(0); + const hasBefore = Boolean(before); + const hasAfter = Boolean(after); + const hasResponsiveAfter = Boolean(responsiveAfter); + const layoutIsMultiline = isMultiline || forceMultilineLayout; + const showResponsiveAfterInFooter = hasResponsiveAfter && layoutIsMultiline; + const showResponsiveAfterInline = hasResponsiveAfter && !showResponsiveAfterInFooter; + + const setRootRef = useCallback( + (node: HTMLDivElement | null) => { + rootRef.current = node; + if (typeof ref === 'function') { + ref(node); + } else if (ref) { + Reflect.set(ref, 'current', node); + } + }, + [ref] + ); + + const updateMultilineLayout = useCallback( + (value: Descendant[] = editor.children) => { + const hasMultipleBlocks = value.length > 1; + const text = value.map((node) => Node.string(node)).join(''); + const hasExplicitNewlines = text.includes('\n'); + + const editable = editableRef.current; + const row = rowRef.current; + const textMeasurer = textMeasurerRef.current; + if (editable && row && textMeasurer) { + const scroll = editable.parentElement as HTMLDivElement | null; + const computedStyle = getComputedStyle(editable); + const beforeWidth = beforeRef.current?.offsetWidth ?? 0; + const afterWidth = afterRef.current?.offsetWidth ?? 0; + const rowSingleLineWidth = row.offsetWidth - beforeWidth - afterWidth; + const isRenderedSingleLine = !layoutIsMultiline; + + if (isRenderedSingleLine && scroll) { + // Scroll.clientWidth is the width the editable actually gets after padding and + // scrollbar math. Cache that delta while we are rendered single-line so later + // hidden measurements can compare against the same usable width. + const renderedSingleLineWidth = scroll.clientWidth; + if (renderedSingleLineWidth > 0) { + singleLineWidthOffsetRef.current = Math.max( + 0, + rowSingleLineWidth - renderedSingleLineWidth + ); + } + } + + const singleLineWidth = Math.max( + 0, + rowSingleLineWidth - singleLineWidthOffsetRef.current + ); + + if ( + text.length > 0 && + singleLineWidth <= 0 && + multilineMeasureRetryRef.current < MAX_MULTILINE_MEASURE_RETRIES + ) { + multilineMeasureRetryRef.current += 1; + if (multilineMeasureFrameRef.current !== null) { + cancelAnimationFrame(multilineMeasureFrameRef.current); + } + multilineMeasureFrameRef.current = requestAnimationFrame(() => { + multilineMeasureFrameRef.current = null; + updateMultilineLayout(); + }); + return; + } + + multilineMeasureRetryRef.current = 0; + let nextMultiline = hasMultipleBlocks || hasExplicitNewlines; + if (!nextMultiline && text.length > 0) { + const styleKey = [ + computedStyle.font, + computedStyle.lineHeight, + computedStyle.letterSpacing, + computedStyle.fontKerning, + computedStyle.fontFeatureSettings, + computedStyle.fontVariationSettings, + computedStyle.textTransform, + computedStyle.textIndent, + computedStyle.tabSize, + ].join('|'); + const cachedMeasurement = measurementCacheRef.current; + + if ( + cachedMeasurement?.text === text && + cachedMeasurement.singleLineWidth === singleLineWidth && + cachedMeasurement.styleKey === styleKey + ) { + nextMultiline = cachedMeasurement.result; + } else { + textMeasurer.style.font = computedStyle.font; + textMeasurer.style.lineHeight = computedStyle.lineHeight; + textMeasurer.style.letterSpacing = computedStyle.letterSpacing; + textMeasurer.style.fontKerning = computedStyle.fontKerning; + textMeasurer.style.fontFeatureSettings = computedStyle.fontFeatureSettings; + textMeasurer.style.fontVariationSettings = computedStyle.fontVariationSettings; + textMeasurer.style.textTransform = computedStyle.textTransform; + textMeasurer.style.textIndent = computedStyle.textIndent; + textMeasurer.style.tabSize = computedStyle.tabSize; + // Measure against a hidden clone instead of the live editable so we can ask + // "would this wrap at single-line width?" without the current layout feeding + // back into the answer. + const measureHeight = (content: string, width: string): number => { + textMeasurer.style.width = width; + textMeasurer.textContent = normalizeMeasurementText(content); + return textMeasurer.scrollHeight; + }; + const singleLineHeight = measureHeight('M', 'max-content'); + const measuredHeight = measureHeight(text, `${Math.max(singleLineWidth, 0)}px`); + nextMultiline = measuredHeight > singleLineHeight + MULTILINE_HEIGHT_EPSILON; + measurementCacheRef.current = { + result: nextMultiline, + singleLineWidth, + styleKey, + text, + }; + } + } else { + measurementCacheRef.current = null; + } + + isMultilineRef.current = nextMultiline; + setIsMultiline(nextMultiline); + } else { + const nextMultiline = hasMultipleBlocks || hasExplicitNewlines; + isMultilineRef.current = nextMultiline; + setIsMultiline(nextMultiline); + } + }, + [editor, layoutIsMultiline] + ); + + useEffect(() => { + const root = rootRef.current; + if (!root) { + return undefined; + } + + const measurerHost = document.createElement('div'); + const textMeasurer = document.createElement('div'); + measurerHost.setAttribute('aria-hidden', 'true'); + textMeasurer.setAttribute('aria-hidden', 'true'); + if (editableName) { + textMeasurer.dataset.editorMeasurer = editableName; + } + Object.assign(measurerHost.style, { + position: 'absolute', + inset: '0', + width: '0', + height: '0', + overflow: 'hidden', + pointerEvents: 'none', + visibility: 'hidden', + zIndex: '-1', + }); + Object.assign(textMeasurer.style, { + padding: '0', + border: '0', + margin: '0', + whiteSpace: 'pre-wrap', + overflowWrap: 'break-word', + wordBreak: 'break-word', + boxSizing: 'border-box', + }); + measurerHost.appendChild(textMeasurer); + root.appendChild(measurerHost); + textMeasurerRef.current = textMeasurer; + + return () => { + measurementCacheRef.current = null; + textMeasurerRef.current = null; + measurerHost.remove(); + }; + }, [editableName]); + + useEffect( + () => () => { + if (multilineMeasureFrameRef.current !== null) { + cancelAnimationFrame(multilineMeasureFrameRef.current); + } + measurementCacheRef.current = null; + multilineMeasureRetryRef.current = 0; + }, + [] + ); + + const queueMultilineMeasurement = useCallback( + (resetRetry = true) => { + if (multilineMeasureFrameRef.current !== null) { + cancelAnimationFrame(multilineMeasureFrameRef.current); + } + if (resetRetry) { + multilineMeasureRetryRef.current = 0; + } + multilineMeasureFrameRef.current = requestAnimationFrame(() => { + multilineMeasureFrameRef.current = null; + updateMultilineLayout(); + }); + }, + [updateMultilineLayout] + ); + + useEffect(() => { + if (typeof ResizeObserver === 'undefined') { + return undefined; + } + + const observer = new ResizeObserver(() => { + queueMultilineMeasurement(); + }); + const observedElements = [rowRef.current, beforeRef.current, afterRef.current].filter( + (element): element is HTMLDivElement => element !== null + ); + + observedElements.forEach((element) => observer.observe(element)); + + return () => observer.disconnect(); + }, [ + queueMultilineMeasurement, + updateMultilineLayout, + hasBefore, + hasAfter, + showResponsiveAfterInline, + ]); + + useLayoutEffect(() => { + updateMultilineLayout(latestValueRef.current); + }, [measurementVersion, updateMultilineLayout]); + + const handleChange = useCallback( + (value: Descendant[]) => { + latestValueRef.current = value; + measurementCacheRef.current = null; + if (multilineMeasureFrameRef.current !== null) { + cancelAnimationFrame(multilineMeasureFrameRef.current); + multilineMeasureFrameRef.current = null; + } + setMeasurementVersion((version) => version + 1); + onChange?.(value); + }, + [onChange] + ); const renderElement = useCallback( (props: RenderElementProps) => , @@ -133,24 +413,36 @@ export const CustomEditor = forwardRef( ); return ( -
- +
+ {top} - - {before && ( - + + {hasBefore && ( + {before} )} ( }} /> - {after && ( - + {(hasAfter || showResponsiveAfterInline) && ( + + {showResponsiveAfterInline && responsiveAfter} {after} )} + {showResponsiveAfterInFooter && ( + + {responsiveAfter} + + )} {bottom} diff --git a/src/app/components/editor/autocomplete/AutocompleteMenu.test.tsx b/src/app/components/editor/autocomplete/AutocompleteMenu.test.tsx deleted file mode 100644 index f0e2fd2f..00000000 --- a/src/app/components/editor/autocomplete/AutocompleteMenu.test.tsx +++ /dev/null @@ -1,193 +0,0 @@ -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 9b907a8a..fdb4b570 100644 --- a/src/app/components/editor/autocomplete/AutocompleteMenu.tsx +++ b/src/app/components/editor/autocomplete/AutocompleteMenu.tsx @@ -1,25 +1,29 @@ -import { ReactNode, useEffect, useLayoutEffect, useRef, useState } from 'react'; +import { ReactNode, useEffect, useRef, useState } from 'react'; import FocusTrap from 'focus-trap-react'; +import { isKeyHotkey } from 'is-hotkey'; import { Header, Menu, Scroll, config } from 'folds'; import { preventScrollWithArrowKey, stopPropagation } from '$utils/keyboard'; import { useAlive } from '$hooks/useAlive'; +import { Editor } from 'slate'; +import { ReactEditor } from 'slate-react'; import * as css from './AutocompleteMenu.css'; import { BaseAutocompleteMenu } from './BaseAutocompleteMenu'; -export const AUTOCOMPLETE_NAVIGATE_EVENT = 'autocomplete-navigate'; -export type AutocompleteNavigateDetail = { direction: 1 | -1 }; - type AutocompleteMenuProps = { requestClose: () => void; headerContent: ReactNode; children: ReactNode; + editor: Editor; }; -export function AutocompleteMenu({ headerContent, requestClose, children }: AutocompleteMenuProps) { +export function AutocompleteMenu({ + headerContent, + requestClose, + children, + editor, +}: AutocompleteMenuProps) { const alive = useAlive(); const itemsRef = useRef(null); - const [selectedIndex, setSelectedIndex] = useState(0); - const prevButtonCountRef = useRef(-1); const handleDeactivate = () => { if (alive()) { @@ -27,69 +31,42 @@ export function AutocompleteMenu({ headerContent, requestClose, children }: Auto requestClose(); } }; - - // 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') ?? [] - ); - const count = buttons.length; - - let idx = selectedIndex; - if (count !== prevButtonCountRef.current) { - prevButtonCountRef.current = count; - idx = 0; - if (selectedIndex !== 0) setSelectedIndex(0); - } - - const safeIdx = Math.max(0, Math.min(idx, count - 1)); - buttons.forEach((btn, i) => { - btn.setAttribute('data-selected', String(i === safeIdx)); - }); - }); - - // Listen for navigation events dispatched by the editor key handler - useEffect(() => { - const container = itemsRef.current?.closest('[data-autocomplete-menu]'); - if (!container) return undefined; - const handler = (e: Event) => { - const { direction } = (e as CustomEvent).detail; - setSelectedIndex((prev) => { - const buttons = itemsRef.current?.querySelectorAll('button') ?? []; - return Math.max(0, Math.min(prev + direction, buttons.length - 1)); - }); - }; - container.addEventListener(AUTOCOMPLETE_NAVIGATE_EVENT, handler); - return () => container.removeEventListener(AUTOCOMPLETE_NAVIGATE_EVENT, handler); - }, []); + const [isActive, setIsActive] = useState(true); + useEffect(() => ReactEditor.focus(editor), [editor, isActive]); + function handleInput(evt: any) { + if (!evt) return; + if ( + isKeyHotkey('arrowdown', evt) || + isKeyHotkey('arrowup', evt) || + isKeyHotkey('tab', evt) || + isKeyHotkey('esc', evt) || + isKeyHotkey('Enter', evt) + ) + return; + setIsActive(false); + } return ( isKeyHotkey('arrowdown', evt), + isKeyBackward: (evt: KeyboardEvent) => isKeyHotkey('arrowup', evt), escapeDeactivates: stopPropagation, }} > - + handleInput(evt)}>
{headerContent}
-
+
{children}
diff --git a/src/app/components/editor/autocomplete/EmoticonAutocomplete.tsx b/src/app/components/editor/autocomplete/EmoticonAutocomplete.tsx index 85e0c0e3..b4c8e8f4 100644 --- a/src/app/components/editor/autocomplete/EmoticonAutocomplete.tsx +++ b/src/app/components/editor/autocomplete/EmoticonAutocomplete.tsx @@ -106,6 +106,7 @@ export function EmoticonAutocomplete({ {title ?? 'Emojis'}} requestClose={requestClose} + editor={editor} > {autoCompleteEmoticon.map((emoticon) => { const isCustomEmoji = 'url' in emoticon; diff --git a/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx b/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx index ff690edc..9ad67aad 100644 --- a/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx +++ b/src/app/components/editor/autocomplete/RoomMentionAutocomplete.tsx @@ -135,7 +135,11 @@ export function RoomMentionAutocomplete({ }); return ( - Rooms} requestClose={requestClose}> + Rooms} + requestClose={requestClose} + editor={editor} + > {autoCompleteRoomIds.length === 0 ? ( ) : ( diff --git a/src/app/components/editor/autocomplete/UserMentionAutocomplete.tsx b/src/app/components/editor/autocomplete/UserMentionAutocomplete.tsx index e47fe9d0..e3883807 100644 --- a/src/app/components/editor/autocomplete/UserMentionAutocomplete.tsx +++ b/src/app/components/editor/autocomplete/UserMentionAutocomplete.tsx @@ -143,7 +143,11 @@ export function UserMentionAutocomplete({ }); return ( - Mentions} requestClose={requestClose}> + Mentions} + requestClose={requestClose} + editor={editor} + > {query.text === 'room' && ( ( }; const handleWheel = (e: WheelEvent) => { - if (e.deltaY < 0) zoomIn(); - else zoomOut(); + const { deltaY } = e; + // Mouse wheel scrolls only by integer delta values, therefore + // If deltaY is an integer, then it's a mouse wheel action + if (Number.isInteger(deltaY)) { + if (deltaY < 0) { + zoomIn(); + } else zoomOut(); + } + // If it's not an integer, then it's a touchpad action, do nothing and let the browser handle the zooming }; return ( diff --git a/src/app/components/knock-room-prompt/KnockRoomPrompt.tsx b/src/app/components/knock-room-prompt/KnockRoomPrompt.tsx new file mode 100644 index 00000000..a7948e9a --- /dev/null +++ b/src/app/components/knock-room-prompt/KnockRoomPrompt.tsx @@ -0,0 +1,139 @@ +import { useCallback, useEffect, FormEventHandler } from 'react'; +import FocusTrap from 'focus-trap-react'; +import { + Dialog, + Overlay, + OverlayCenter, + OverlayBackdrop, + Header, + config, + Box, + Text, + IconButton, + Icon, + Icons, + Input, + color, + Button, + Spinner, +} from 'folds'; +import { MatrixError } from '$types/matrix-sdk'; + +import { useMatrixClient } from '$hooks/useMatrixClient'; +import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; +import { stopPropagation } from '$utils/keyboard'; +import { createDebugLogger } from '$utils/debugLogger'; + +const debugLog = createDebugLogger('KnockRoomPrompt'); + +type KnockRoomProps = { + roomId: string; + via?: string | string[]; + onDone: () => void; + onCancel: () => void; +}; +export function KnockRoomPrompt({ roomId, via, onDone, onCancel }: KnockRoomProps) { + const mx = useMatrixClient(); + + const [knockState, knockRoom] = useAsyncCallback( + useCallback( + async (reason?: string) => { + debugLog.info('ui', 'Knock room button clicked', { roomId }); + mx.knockRoom(roomId, { viaServers: via || undefined, reason }); + }, + [mx, roomId, via] + ) + ); + + const handleKnock: FormEventHandler = (evt) => { + evt.preventDefault(); + const target = evt.target as HTMLFormElement; + const reasonInput = (target?.reasonInput as HTMLInputElement) || undefined; + const reason = reasonInput?.value.trim() || undefined; + knockRoom(reason); + }; + + useEffect(() => { + if (knockState.status === AsyncStatus.Success) { + debugLog.info('ui', 'Successfully knocked on room', { roomId }); + onDone(); + } + }, [knockState, onDone, roomId]); + + return ( + }> + + + +
+ + Knock On Room + + + + +
+ + + + Request to join this room. You can optionally leave a reason for the moderators. + + + + Reason{' '} + + (Optional) + + + + {knockState.status === AsyncStatus.Error && ( + + Failed to knock! {knockState.error.message} + + )} + + + + +
+
+
+
+ ); +} diff --git a/src/app/components/knock-room-prompt/index.ts b/src/app/components/knock-room-prompt/index.ts new file mode 100644 index 00000000..b53201d5 --- /dev/null +++ b/src/app/components/knock-room-prompt/index.ts @@ -0,0 +1 @@ +export * from './KnockRoomPrompt'; diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx index 5cf1eef0..6d1a63cc 100644 --- a/src/app/components/message/MsgTypeRenderers.tsx +++ b/src/app/components/message/MsgTypeRenderers.tsx @@ -121,6 +121,12 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }: const isJumbo = useMemo(() => { if (!trimmedBody || trimmedBody.length >= 500) return false; + if ( + (unwrappedPerMessageProfileMessage ?? safeCustomBody)?.match( + /^(]*data-mx-emoticon[^>]*\/>){1,20}$/i + ) + ) + return true; if (!JUMBO_EMOJI_REG.test(trimmedBody)) return false; if (trimmedBody.includes(':')) { @@ -129,7 +135,7 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }: } return true; - }, [trimmedBody, safeCustomBody]); + }, [unwrappedPerMessageProfileMessage, trimmedBody, safeCustomBody]); if (!body && !customBody) return ; @@ -139,7 +145,11 @@ export function MText({ edited, content, renderBody, renderUrlsPreview, style }: if ((content['com.beeper.per_message_profile'] as PerMessageProfileBeeperFormat)?.has_fallback) { // unwrap per-message profile fallback if present return ( - + {renderBody({ body: trimmedBody, customBody: unwrappedPerMessageProfileMessage, diff --git a/src/app/components/message/RenderBody.tsx b/src/app/components/message/RenderBody.tsx index 03714750..e26b237b 100644 --- a/src/app/components/message/RenderBody.tsx +++ b/src/app/components/message/RenderBody.tsx @@ -1,10 +1,94 @@ +import { MouseEventHandler, useEffect, useState } from 'react'; import parse, { HTMLReactParserOptions } from 'html-react-parser'; import Linkify from 'linkify-react'; import { Opts } from 'linkifyjs'; +import { PopOut, RectCords, Text, Tooltip, TooltipProvider, toRem } from 'folds'; import { sanitizeCustomHtml } from '$utils/sanitize'; import { highlightText, scaleSystemEmoji } from '$plugins/react-custom-html-parser'; +import { useRoomAbbreviationsContext } from '$hooks/useRoomAbbreviations'; +import { splitByAbbreviations } from '$utils/abbreviations'; import { MessageEmptyContent } from './content'; +type AbbreviationTermProps = { + text: string; + definition: string; +}; +function AbbreviationTerm({ text, definition }: AbbreviationTermProps) { + const [anchor, setAnchor] = useState(); + + const handleClick: MouseEventHandler = (e) => { + e.stopPropagation(); + setAnchor((prev) => (prev ? undefined : e.currentTarget.getBoundingClientRect())); + }; + + // On mobile, tapping an abbreviation pins the tooltip open. + // Tapping anywhere else (outside the abbr) dismisses it. + useEffect(() => { + if (!anchor) return undefined; + const dismiss = () => setAnchor(undefined); + document.addEventListener('click', dismiss, { once: true }); + return () => document.removeEventListener('click', dismiss); + }, [anchor]); + + const tooltipContent = ( + + {definition} + + ); + + return ( + <> + + {(triggerRef) => ( + // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions + } + onClick={handleClick} + style={{ textDecoration: 'underline dotted', cursor: 'help' }} + > + {text} + + )} + + {anchor && ( + + {null} + + )} + + ); +} + +/** + * Builds a `replaceTextNode` callback for use with {@link getReactCustomHtmlParser}. + * Returns `undefined` when there are no abbreviations to apply (avoids creating + * extra closures in the common case). + */ +export function buildAbbrReplaceTextNode( + abbrMap: Map +): ((text: string) => JSX.Element | undefined) | undefined { + if (abbrMap.size === 0) return undefined; + return function replaceTextNode(text: string) { + const segments = splitByAbbreviations(text, abbrMap); + if (!segments.some((s) => s.termKey !== undefined)) return undefined; + return ( + <> + {segments.map((seg) => + seg.termKey !== undefined ? ( + + ) : ( + seg.text + ) + )} + + ); + }; +} + type RenderBodyProps = { body: string; customBody?: string; @@ -20,12 +104,37 @@ export function RenderBody({ htmlReactParserOptions, linkifyOpts, }: Readonly) { + const abbrMap = useRoomAbbreviationsContext(); + if (customBody) { if (customBody === '') return ; return parse(sanitizeCustomHtml(customBody), htmlReactParserOptions); } if (body === '') return ; + if (abbrMap.size > 0) { + const segments = splitByAbbreviations(body, abbrMap); + if (segments.some((s) => s.termKey !== undefined)) { + return ( + <> + {segments.map((seg) => { + if (seg.termKey !== undefined) { + const definition = abbrMap.get(seg.termKey) ?? ''; + return ; + } + return ( + + {highlightRegex + ? highlightText(highlightRegex, scaleSystemEmoji(seg.text)) + : scaleSystemEmoji(seg.text)} + + ); + })} + + ); + } + } + return ( {highlightRegex diff --git a/src/app/components/message/Reply.tsx b/src/app/components/message/Reply.tsx index 1e047e9e..3342b0d5 100644 --- a/src/app/components/message/Reply.tsx +++ b/src/app/components/message/Reply.tsx @@ -1,5 +1,5 @@ -import { Box, Chip, Icon, Icons, Text, as, color, toRem } from 'folds'; -import { EventTimelineSet, Room } from '$types/matrix-sdk'; +import { Box, Chip, Icon, IconSrc, Icons, Text, as, color, toRem } from 'folds'; +import { EventTimelineSet, IMentions, Room, SessionMembershipData } from '$types/matrix-sdk'; import { MouseEventHandler, ReactNode, useCallback, useMemo } from 'react'; import { useQueryClient } from '@tanstack/react-query'; import classNames from 'classnames'; @@ -12,6 +12,9 @@ import { getReactCustomHtmlParser, scaleSystemEmoji, LINKIFY_OPTS, + makeMentionCustomProps, + factoryRenderLinkifyWithMention, + renderMatrixMention, } from '$plugins/react-custom-html-parser'; import { useRoomEvent } from '$hooks/useRoomEvent'; import { useSableCosmetics } from '$hooks/useSableCosmetics'; @@ -19,6 +22,11 @@ import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; import { useIgnoredUsers } from '$hooks/useIgnoredUsers'; import { nicknamesAtom } from '$state/nicknames'; import { useMatrixClient } from '$hooks/useMatrixClient'; +import { useMemberEventParser } from '$hooks/useMemberEventParser'; +import { StateEvent, MessageEvent } from '$types/matrix/room'; +import { useMentionClickHandler } from '$hooks/useMentionClickHandler'; +import { useTranslation } from 'react-i18next'; +import * as customHtmlCss from '$styles/CustomHtml.css'; import { MessageBadEncryptedContent, MessageBlockedContent, @@ -31,9 +39,12 @@ import { LinePlaceholder } from './placeholder'; type ReplyLayoutProps = { userColor?: string; username?: ReactNode; + icon?: IconSrc; + mentioned: boolean; + replyIcon?: JSX.Element; }; export const ReplyLayout = as<'div', ReplyLayoutProps>( - ({ username, userColor, className, children, ...props }, ref) => ( + ({ username, userColor, icon, className, mentioned, children, replyIcon, ...props }, ref) => ( ( {...props} ref={ref} > + + {replyIcon || } + + {!!icon && } - + {mentioned && } {username} @@ -71,11 +86,16 @@ type ReplyProps = { timelineSet?: EventTimelineSet; replyEventId: string; threadRootId?: string; + mentions?: IMentions; onClick?: MouseEventHandler; + replyIcon?: JSX.Element; }; export const Reply = as<'div', ReplyProps>( - ({ room, timelineSet, replyEventId, threadRootId, onClick, ...props }, ref) => { + ( + { room, timelineSet, replyEventId, threadRootId, mentions, onClick, replyIcon, ...props }, + ref + ) => { const placeholderWidth = useMemo(() => randomNumberBetween(40, 400), []); const getFromLocalTimeline = useCallback( () => timelineSet?.findEventById(replyEventId), @@ -88,21 +108,23 @@ export const Reply = as<'div', ReplyProps>( const { body, formatted_body: formattedBody, format } = replyEvent?.getContent() ?? {}; const sender = replyEvent?.getSender(); + const eventType = replyEvent?.getType(); const ignoredUsers = useIgnoredUsers(); const isBlockedSender = !!sender && ignoredUsers.includes(sender); + const { t } = useTranslation(); + const isRedacted = replyEvent?.isRedacted() === true; + + const parseMemberEvent = useMemberEventParser(); const { color: usernameColor, font: usernameFont } = useSableCosmetics(sender ?? '', room); const nicknames = useAtomValue(nicknamesAtom); const useAuthentication = useMediaAuthentication(); - const fallbackBody = replyEvent?.isRedacted() ? ( - - ) : ( - - ); + const fallbackBody = isRedacted ? : ; const badEncryption = replyEvent?.getContent().msgtype === 'm.bad.encrypted'; + const mentionClickHandler = useMentionClickHandler(room.roomId); // An encrypted event that hasn't been decrypted yet (keys pending) has an // empty result from getClearContent(). Treat it as still-loading rather @@ -116,6 +138,24 @@ export const Reply = as<'div', ReplyProps>( !replyEvent.getClearContent(); let bodyJSX: ReactNode = fallbackBody; + let image: IconSrc | undefined; + let mentioned = sender != null && (mentions?.user_ids?.includes(sender) ?? false); + + const replyLinkifyOpts = useMemo( + () => ({ + ...LINKIFY_OPTS, + render: factoryRenderLinkifyWithMention((href) => + renderMatrixMention( + mx, + room.roomId, + href, + makeMentionCustomProps(mentionClickHandler), + nicknames + ) + ), + }), + [mx, room.roomId, mentionClickHandler, nicknames] + ); if (format === 'org.matrix.custom.html' && formattedBody) { const strippedHtml = trimReplyFromFormattedBody(formattedBody) @@ -126,16 +166,70 @@ export const Reply = as<'div', ReplyProps>( .replaceAll(/<\/?(ul|ol|li|blockquote|h[1-6]|pre|div)[^>]*>/gi, '') .replaceAll(/(?:\r\n|\r|\n)/g, ' '); const parserOpts = getReactCustomHtmlParser(mx, room.roomId, { - linkifyOpts: LINKIFY_OPTS, + linkifyOpts: replyLinkifyOpts, useAuthentication, nicknames, + handleMentionClick: mentionClickHandler, }); bodyJSX = parse(strippedHtml, parserOpts) as JSX.Element; } else if (body) { const strippedBody = trimReplyFromBody(body).replaceAll(/(?:\r\n|\r|\n)/g, ' '); bodyJSX = scaleSystemEmoji(strippedBody); + } else if (eventType === StateEvent.RoomMember && !!replyEvent) { + const parsedMemberEvent = parseMemberEvent(replyEvent); + image = parsedMemberEvent.icon; + mentioned = false; + bodyJSX = ( + + {' '} + {parsedMemberEvent.body}{' '} + + ); + } else if (eventType === StateEvent.RoomName) { + image = Icons.Hash; + bodyJSX = t('Organisms.RoomCommon.changed_room_name'); + } else if (eventType === StateEvent.RoomTopic) { + image = Icons.Hash; + bodyJSX = ' changed room topic'; + } else if (eventType === StateEvent.RoomAvatar) { + image = Icons.Hash; + bodyJSX = ' changed room avatar'; + } else if (eventType === StateEvent.GroupCallMemberPrefix && !!replyEvent) { + const callJoined = replyEvent.getContent().application; + image = callJoined ? Icons.Phone : Icons.PhoneDown; + bodyJSX = callJoined ? ' joined the call' : ' ended the call'; + } else if (eventType === StateEvent.RoomPinnedEvents && replyEvent) { + const { pinned } = replyEvent.getContent(); + const prevPinned = replyEvent.getPrevContent().pinned; + const pinsAdded = + prevPinned && pinned && pinned.filter((x: string) => !prevPinned.includes(x)); + const pinsRemoved = + prevPinned && pinned && prevPinned.filter((x: string) => !pinned.includes(x)); + image = Icons.Pin; + bodyJSX = ( + <> + {(pinsAdded?.length > 0 && + `pinned ${pinsAdded.length} message${pinsAdded.length > 1 ? 's' : ''}`) || + ''} + {(pinsAdded?.length > 0 && pinsRemoved?.length > 0 && `and`) || ''} + {(pinsRemoved?.length > 0 && + `unpinned ${pinsRemoved.length} message${pinsRemoved.length > 1 ? 's' : ''}`) || + ''} + {(!pinsAdded || pinsAdded.length <= 0) && + (!pinsRemoved || pinsRemoved.length <= 0) && + `has not changed the pins`} + + ); + } else if (Object.values(MessageEvent).every((v) => v !== eventType && !!eventType)) { + image = Icons.Code; + bodyJSX = ( + <> + {' sent '} + {eventType} + {' state event'} + + ); } - return ( {threadRootId && ( @@ -144,8 +238,12 @@ export const Reply = as<'div', ReplyProps>( {getMemberDisplayName(room, sender, nicknames) ?? getMxIdLocalPart(sender)} @@ -163,13 +261,15 @@ export const Reply = as<'div', ReplyProps>( })()} ) : ( - + (isRedacted && ) || ( + + ) )} {replyEvent === null && ( diff --git a/src/app/components/message/modals/MessageForward.tsx b/src/app/components/message/modals/MessageForward.tsx index 219e4119..7f6758b5 100644 --- a/src/app/components/message/modals/MessageForward.tsx +++ b/src/app/components/message/modals/MessageForward.tsx @@ -93,9 +93,9 @@ type ForwardMeta = { // see https://github.com/hummlbach/matrix-doc/blob/acea0854a1c9489599295a858b068ce02a6b2b20/proposals/2723-add-forward-info.md type MSC2723ForwardMeta = { - event_id: string; - room_id: string; - sender: string | null; // we won't set this field + event_id?: string; + room_id?: string; + sender?: string; // we won't set this field origin_server_ts: number; }; @@ -109,7 +109,7 @@ export function MessageForwardInternal({ const [isTargetSelected, setIsTargetSelected] = useState(false); const [isForwardSuccess, setIsForwardSuccess] = useState(false); const [isForwarding, setIsForwarding] = useState(false); - const [isForwardError, setIsForwardError] = useState(false); + const [forwardError, setForwardError] = useState(null); const [targetRoomId, setTargetRoomId] = useState(null); // detect if it's a public room or not @@ -205,9 +205,9 @@ export function MessageForwardInternal({ newBodyPlain = originalBody.length > 0 ? `${bodyModifText}\n\n${quotedBody}` : bodyModifText; const safeHtml = - originalFormattedBody !== undefined - ? sanitizeCustomHtml(originalFormattedBody) - : sanitizeCustomHtml(originalBody).replaceAll('\n', '
'); + originalFormattedBody === undefined + ? sanitizeCustomHtml(originalBody).replaceAll('\n', '
') + : sanitizeCustomHtml(originalFormattedBody); newBodyHtml = `
` + @@ -241,6 +241,9 @@ export function MessageForwardInternal({ original_timestamp: mEvent.getTs(), original_event_private: true, } satisfies ForwardMeta, + 'com.famedly.app.forwarded': { + origin_server_ts: mEvent.getTs(), + } satisfies MSC2723ForwardMeta, }; } else { content = { @@ -261,7 +264,6 @@ export function MessageForwardInternal({ 'com.famedly.app.forwarded': { event_id: eventId, room_id: room.roomId, - sender: null, // we won't set this field, as a design decision to avoid potential privacy issues and since the sender can be inferred from the event_id and room_id if needed origin_server_ts: mEvent.getTs(), } satisfies MSC2723ForwardMeta, }; @@ -285,15 +287,16 @@ export function MessageForwardInternal({ setIsForwardSuccess(true); }) .catch((err: unknown) => { + const message = err instanceof Error ? err.message : String(err); debugLog.error('ui', 'Message forward failed', { sourceRoomId: room.roomId, targetRoomId: targetRoom.roomId, - error: err instanceof Error ? err.message : String(err), + error: message, }); Sentry.metrics.count('sable.message.forward.error', 1); setIsForwarding(false); setIsForwardSuccess(false); - setIsForwardError(true); + setForwardError(message); }); }; @@ -348,9 +351,9 @@ export function MessageForwardInternal({ Forward to {getRoom(targetRoomId)?.name} )} - {isForwardError && ( + {forwardError && ( - Failed to forward message. Please try again. + Failed to forward: {forwardError} )} diff --git a/src/app/components/room-card/RoomCard.tsx b/src/app/components/room-card/RoomCard.tsx index afd66d3c..7f9046d7 100644 --- a/src/app/components/room-card/RoomCard.tsx +++ b/src/app/components/room-card/RoomCard.tsx @@ -1,5 +1,5 @@ import { ReactNode, useCallback, useRef, useState } from 'react'; -import { MatrixError, Room } from '$types/matrix-sdk'; +import { JoinRule, MatrixError, Room } from '$types/matrix-sdk'; import { Avatar, Badge, @@ -21,7 +21,6 @@ import classNames from 'classnames'; import FocusTrap from 'focus-trap-react'; import { getMxIdLocalPart, mxcUrlToHttp } from '$utils/matrix'; import { nameInitials } from '$utils/common'; -import { millify } from '$plugins/millify'; import { useMatrixClient } from '$hooks/useMatrixClient'; import { AsyncStatus, useAsyncCallback } from '$hooks/useAsyncCallback'; import { onEnterOrSpace, stopPropagation } from '$utils/keyboard'; @@ -31,7 +30,9 @@ import { useElementSizeObserver } from '$hooks/useElementSizeObserver'; import { getRoomAvatarUrl, getStateEvent } from '$utils/room'; import { useStateEventCallback } from '$hooks/useStateEventCallback'; import { useMediaAuthentication } from '$hooks/useMediaAuthentication'; +import { KnockRoomPrompt } from '$components/knock-room-prompt'; import { RoomAvatar } from '$components/room-avatar'; +import { formatCompactNumber } from '$utils/formatCompactNumber'; import * as css from './style.css'; type GridColumnCount = '1' | '2' | '3'; @@ -143,6 +144,7 @@ type RoomCardProps = { topic?: string; memberCount?: number; roomType?: string; + joinRule?: JoinRule; viaServers?: string[]; onView?: (roomId: string) => void; renderTopicViewer: (name: string, topic: string, requestClose: () => void) => ReactNode; @@ -158,6 +160,7 @@ export const RoomCard = as<'div', RoomCardProps>( topic, memberCount, roomType, + joinRule, viaServers, onView, renderTopicViewer, @@ -172,7 +175,7 @@ export const RoomCard = as<'div', RoomCardProps>( const [topicEvent, setTopicEvent] = useState(() => joinedRoom ? getStateEvent(joinedRoom, StateEvent.RoomTopic) : undefined ); - + const [knocking, setKnocking] = useState(false); const fallbackName = getMxIdLocalPart(roomIdOrAlias) ?? roomIdOrAlias; const fallbackTopic = roomIdOrAlias; @@ -256,7 +259,7 @@ export const RoomCard = as<'div', RoomCardProps>( {typeof joinedMemberCount === 'number' && ( - {`${millify(joinedMemberCount)} Members`} + {`${formatCompactNumber(joinedMemberCount)} Members`} )} {typeof joinedRoomId === 'string' && ( @@ -271,19 +274,38 @@ export const RoomCard = as<'div', RoomCardProps>( )} - {typeof joinedRoomId !== 'string' && joinState.status !== AsyncStatus.Error && ( - - )} + {typeof joinedRoomId !== 'string' && + joinState.status !== AsyncStatus.Error && + (joinRule === JoinRule.Knock ? ( + <> + + + {knocking && ( + setKnocking(false)} + onCancel={() => setKnocking(false)} + /> + )} + + ) : ( + + ))} {typeof joinedRoomId !== 'string' && joinState.status === AsyncStatus.Error && (