Commit Graph

1957 Commits

Author SHA1 Message Date
1e0d773b54 DEV: duplicate scroll-top util function to lib and replace current usage with new path (#32367)
This was refactored from an actual Mixin some time back. This PR moves
the function to the lib folder and keeps the same logic/interface
otherwise.

We'll remove the mixin file once all non-core repos change to use the
new file.
2025-04-21 08:12:51 +08:00
6c4e9dfbc8 DEV: Try fix composer rich text transcript spec (#32364)
This is to try fix this error by sending the keys
on the element itself:

```
Failure/Error: page.send_keys([PLATFORM_KEY_MODIFIER, "v"])

Selenium::WebDriver::Error::StaleElementReferenceError:
  stale element reference: stale element not found in the current frame
    (Session info: chrome=135.0.7049.84); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#stale-element-reference-exception
```
2025-04-18 15:52:35 +10:00
530f2f13af FIX: Make the 'Keep Message Deleted' reviewable option work (#32345)
When a flagged chat message has already been deleted, we offer an option
in the review queue to agree with the flag and keep the message deleted.
However, this option is currently broken due to a missing implementation
for the option.

Internal topic: t/152203.
2025-04-17 07:35:08 +03:00
f03a6f3557 UX: Onebox & quote border radius (#32242) 2025-04-14 10:55:51 -05:00
7b2b08cf89 DEV: [gjs-codemod] Convert automation/styleguide/other to gjs
Co-authored-by: Jarek Radosz <jarek@cvx.dev>
2025-04-14 15:36:16 +01:00
3462113bd4 DEV: [gjs-codemod] merge js and hbs 2025-04-14 15:27:52 +01:00
1eb953ca57 DEV: [gjs-codemod] renamed hbs to gjs 2025-04-14 15:27:47 +01:00
3ca507e008 DEV: [gjs-codemod] renamed js to gjs 2025-04-14 15:27:45 +01:00
fff1ae60f1 DEV: ensures chat can work without discourse-presence
discourse presence can be disabled, given it's a plugin the `composerPresenceManager` service couldn't be present anymore and would cause an error.

No test as it's testing imbrication of multiple plugins and hard to test reliably.
2025-04-09 17:00:31 -04:00
4c8420833e FEATURE: One-click chat reaction settings (#32150)
Adds a one-click chat reactions setting to the chat preferences page
where members can determine what one-click reactions are shown in chat.

- Frequent: This will be the default setting. (Automatically set based
on most used chat reactions)
- Custom: Members can choose up to three reactions they want to see in
their one-click chat/DM reactions menu. Defaults are `❤️`, `👍` ,
and `😄`.


![image](https://github.com/user-attachments/assets/8913db0e-d6ec-4347-ad91-2329206b127c)

This pull request is essentially the work of @dsims in
https://github.com/discourse/discourse/pull/31761

---------

Co-authored-by: dsims <1041068+dsims@users.noreply.github.com>
2025-04-04 09:15:13 +02:00
3d6b7e2574 FEATURE: Copy thread messages when copying thread OP (#32139)
This introduces functionality to chat transcripts. If
you select _only_ a thread's OP and press the Copy button,
we will now copy the OP plus all of the thread's replies
into the transcript.

This is being done to make it easier to copy all the context
of a thread easily. The old way of selecting only some messages
inside a thread still works too.

This commit also unskips and refactors some transcript specs.
2025-04-04 13:45:37 +10:00
564edc52eb UX: add flex to mentions mixin + update units (#32145)
Fixing hashtag text glued to the icon, and updated some related properties to using better units.

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2025-04-04 12:20:35 +10:00
abeb8de7b5 UX: Button fixes (#32152) 2025-04-03 16:13:34 -05:00
9be51b616b DEV: Handle the missing d-lazy-video case (#32148)
aka: lazy load lazy video

---------

Co-authored-by: David Taylor <david@taylorhq.com>
2025-04-03 18:09:02 +02:00
999ae73c78 DEV: [gjs-codemod] apply codemod
Co-authored-by: Jarek Radosz <jarek@cvx.dev>
2025-04-02 13:44:15 +01:00
dac398d6ab DEV: [gjs-codemod] merge js and hbs 2025-04-02 13:43:33 +01:00
1c8019a3c7 DEV: [gjs-codemod] renamed hbs to gjs 2025-04-02 13:43:32 +01:00
386bb974d1 DEV: [gjs-codemod] renamed js to gjs 2025-04-02 13:43:28 +01:00
cfd539a539 DEV: Fix a flaky system test by doubling timeout (#32117)
The system test relies on a MessageBus message being published and
received by the client. As we currently don't have a reliable way to
ensure that we run an assertion after the client has received all
MessageBus messages, we will just double the timeout for now.
2025-04-02 11:02:05 +08:00
8b212d95ed DEV: skip watch word when message is created by bots (#31959)
Especially with AI we have no exact control on the words and this could
create and endless loop of errors.
2025-03-31 20:09:04 +02:00
6b37aaf414 DEV: Fix FA icon deprecation 'smile' -> 'face-smile' (#32065)
Over the last few weeks, I have occasionally seen a deprecation warning
on my smartphone. Unfortunately, there was no corresponding entry in
/logs, and I never had the browser console available at the time.

I have now found the steps to reproduce the issue: the warning is
triggered by the emoji selection button in the chat.


https://github.com/user-attachments/assets/fbda7ee2-6967-48af-aa00-d081466e6aea

The icon used in the button was 'smile' instead of 'face-smile'. With
this fix, the warning no longer appears.

Otherwise, the icon will be missing once
https://github.com/discourse/discourse/pull/31866 is merged.

![After_1_April](https://github.com/user-attachments/assets/eed141e4-abd8-42c3-a27c-6dad7c4467f9)
2025-03-31 09:42:19 +01:00
d3c2bd015d FEATURE: Implement chat transcripts in rich editor (#31819)
This commit allows the ProseMirror rich editor to display chat
transcripts copied from chat using the "Copy" button.

The BBCode usually looks something like this:

```
[chat quote="hunter;29856;2025-03-20T07:13:04Z" channel="design gems 🎉" channelId="95"]
haha **ok** _cool_
[/chat]
```

But there are several variations that must be accounted for:

* Single message from single user
* Multiple messages from a single and multiple users
* Messages inside chat threads

The rich transcript extension has to ignore many of the chat transcript
markdown
tokens because they simply aren't necessary -- none of the ProseMirror
nodes need
to be editable. So, we basically recreate the same HTML that the chat
transcript markdown
rule does in the `toDOM()` function. Maybe in future we want to make the
markdown rule
do less and have this HTML creation in one place, but for now we need to
mirror in both files.

---------

Co-authored-by: Renato Atilio <renato@discourse.org>
2025-03-31 14:04:22 +10:00
016c6a6894 DEV: Fix a flaky chat system test (#32055)
We are not waiting for asynchronous operations to complete before
executing our assertions.

### Reviewer notes

Example test failure:
https://github.com/discourse/discourse/actions/runs/14100970402/job/39496976787

```
Failure/Error: measurement = Benchmark.measure { example.run }
  expected `Chat::Channel.count` to have changed by 1, but was changed by 0

[Screenshot Image]: /__w/discourse/discourse/tmp/capybara/failures_r_spec_example_groups_chat_new_message_from_params_with_multiple_users_creates_a_dm_channel_when_none_exists_626.png

~~~~~~~ JS LOGS ~~~~~~~
~~~~~ END JS LOGS ~~~~~

./plugins/chat/spec/system/chat_new_message_spec.rb:57:in `block (3 levels) in <main>'
./spec/rails_helper.rb:619:in `block (3 levels) in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/benchmark-0.4.0/lib/benchmark.rb:304:in `measure'
./spec/rails_helper.rb:619:in `block (2 levels) in <top (required)>'
./spec/rails_helper.rb:580:in `block (3 levels) in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/timeout-0.4.3/lib/timeout.rb:185:in `block in timeout'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/timeout-0.4.3/lib/timeout.rb:192:in `timeout'
./spec/rails_helper.rb:570:in `block (2 levels) in <top (required)>'
./spec/rails_helper.rb:527:in `block (2 levels) in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/webmock-3.25.1/lib/webmock/rspec.rb:39:in `block (2 levels) in <top (required)>'
```
2025-03-28 12:54:27 +08:00
1d49da467b DEV: Attempt to fix flaky search system test (#32053)
A system test in `system/search_spec.rb` was failing with the following
error frequently on CI:

```
Failure/Error: expect(search_page).to have_heading_text("Search")
  expected `#<PageObjects::Pages::Search:0x00007fb9fcd3f028>.has_heading_text?("Search")` to be truthy, got false

[Screenshot Image]: /__w/discourse/discourse/tmp/capybara/failures_r_spec_example_groups_search_when_using_full_page_search_on_mobile_works_and_clears_search_page_state_912.png

~~~~~~~ JS LOGS ~~~~~~~
(no logs)
~~~~~ END JS LOGS ~~~~~

./spec/system/search_spec.rb:42:in `block (3 levels) in <main>'
./spec/rails_helper.rb:619:in `block (3 levels) in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/benchmark-0.4.0/lib/benchmark.rb:304:in `measure'
./spec/rails_helper.rb:619:in `block (2 levels) in <top (required)>'
./spec/rails_helper.rb:580:in `block (3 levels) in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/timeout-0.4.3/lib/timeout.rb:185:in `block in timeout'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/timeout-0.4.3/lib/timeout.rb:192:in `timeout'
./spec/rails_helper.rb:570:in `block (2 levels) in <top (required)>'
./spec/rails_helper.rb:527:in `block (2 levels) in <top (required)>'
/var/www/discourse/vendor/bundle/ruby/3.3.0/gems/webmock-3.25.1/lib/webmock/rspec.rb:39:in `block (2 levels) in <top (required)>'
```

The failure screenshot shows that the "user" is on the homepage even
though we have already clicked the search icon and ensured that the user
can see the search container. I suspect there is some sort of race
condition here since Capybara executes clicks in quick sucession where
we clicked on both the homepage logo and the search icon. It may be
possible that Ember redirected the user to the search page first
before the browser was able to finish navigating the user to the `/`
href.

### Reviewer notes

Test flaked in
https://github.com/discourse/discourse/actions/runs/14085443789/job/39448197089
with the following failure screenshot:


![image](https://github.com/user-attachments/assets/55a2834f-9357-460d-adeb-dc9a2fa475e8)
2025-03-28 11:16:43 +08:00
f13ff5088c FIX: update chat icon position on mobile (#32016)
The chat icon was repositioned in #31951 but we should also account for
mobile, where it should appear before the hamburger icon.
2025-03-26 17:03:47 +04:00
525406ad20 UX: reposition chat header icon (#31951)
With header search we toggle the search icon when scrolling on topics,
which can feel visually jarring when the search icon is in the middle.

Switching the position of the chat icon in the header reduces the impact
of this.
2025-03-26 10:59:01 +04:00
d06c60ca7c FEATURE: add icons and emojis to category (#31795)
This feature allow admins to personalize their communities by
associating emojis or icons with their site categories.

There are now 3 style types for categories:
- Square (the default)
- Emoji
- Icon

### How it looks 🎨 

Adding an icon:

<img width="502" alt="Category with an icon"
src="https://github.com/user-attachments/assets/8f711340-166e-4781-a7b7-7267469dbabd"
/>

Adding an emoji:

<img width="651" alt="Category with an emoji"
src="https://github.com/user-attachments/assets/588c38ce-c719-4ed5-83f9-f1e1cb52c929"
/>

Sidebar:

<img width="248" alt="Sidebar with emojis"
src="https://github.com/user-attachments/assets/cd03d591-6170-4515-998c-0cec20118568"
/>

Category menus:

<img width="621" alt="Screenshot 2025-03-13 at 10 32 30 AM"
src="https://github.com/user-attachments/assets/7d89797a-f69f-45e5-bf64-a92d4cff8753"
/>

Within posts/topics:

<img width="382" alt="Screenshot 2025-03-13 at 10 33 41 AM"
src="https://github.com/user-attachments/assets/b7b1a951-44c6-4a4f-82ad-8ee31ddd6061"
/>

Chat messages:

<img width="392" alt="Screenshot 2025-03-13 at 10 30 20 AM"
src="https://github.com/user-attachments/assets/126f8076-0ea3-4f19-8452-1041fd2af29f"
/>

Autocomplete:

<img width="390" alt="Screenshot 2025-03-13 at 10 29 53 AM"
src="https://github.com/user-attachments/assets/cad75669-225f-4b8e-a7b5-ae5aa8f1bcad"
/>

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2025-03-26 09:46:17 +04:00
bae4cd165f SECURITY: mutex around adding users to a group DM
Whenever you are about to reach the limit of users in a group DM, if you
send requests to add new users in parallel, they might all go through
ignoring the limit due to a race condition.

Internal - t/145895
2025-03-26 09:26:41 +08:00
58819d0f69 SECURITY: respect allow private messages prefernce for DMs 2025-03-26 09:26:36 +08:00
37e72e9ad7 Update translations (#31994) 2025-03-25 17:22:59 +01:00
b4afe124b7 DEV: Remove raw-hbs from autocomplete implementation (#31957)
We intend to replace this JQuery autocomplete implementation soon. But
before that, we'd like to drop the raw-hbs compilation/runtime system.
Therefore, this commit does a 1:1 conversion of the autocomplete
templates to vanilla JS. They're fairly small/simple, so they're still
fairly readable.
2025-03-24 19:44:07 +00:00
a8b3e539c7 FEATURE: Add setting to prevent anonymous users from using chat (#31842)
Currently, anonymous/shadow users go through the same permission checks
for chat as normal users do. This means that if a site has chat enabled
for all users, anonymous users also get access to chat. This may be
undesirable for some communities, so we're adding a new site setting
`allow_chat_in_anonymous_mode` to block access to chat for anonymous
users.

Internal topic: t/148088.
2025-03-21 13:32:52 +03:00
a43ad984b1 FEATURE: allow adding members to new 1-1 DM channels (#31948)
This change allows more flexibility when starting a 1-1 direct message
with another user. If there are no messages in the new DM channel then
we should still allow them to add additional users.
2025-03-21 12:20:21 +04:00
a017f566a8 DEV: [gjs-codemod] convert second batch of files to gjs
Updated using `@embroider/template-tag-codemod`, plus some manual fixups.

Co-authored-by: Jarek Radosz <jarek@cvx.dev>
2025-03-19 10:20:56 +00:00
b20f6bd620 DEV: Remove flaky system test (#31899)
This commit removes a flaky system test without replacement given that
the test isn't really testing something in the critical path or
something that happens often.

### Reviewer notes

Example of flakiness:

1.
https://github.com/discourse/discourse/actions/runs/13901410315/job/38893877234
2.
https://github.com/discourse/discourse/actions/runs/12362090310/job/34500684809
2025-03-19 12:20:23 +08:00
1fea45eb0f DEV: Skip flaky test (#31849)
The test has been flaking in CI with the following message:

```
Failure/Error: measurement = Benchmark.measure { example.run }

  expected: "draft"
       got: ""

  (compared using ==)

[Screenshot Image]: /__w/discourse/discourse/tmp/capybara/failures_r_spec_example_groups_chat_composer_draft_when_loading_a_channel_with_a_draft_loads_the_draft_458.png

~~~~~~~ JS LOGS ~~~~~~~
~~~~~ END JS LOGS ~~~~~

./plugins/chat/spec/system/chat_composer_draft_spec.rb:31:in `block (3 levels) in <main>'
```
2025-03-17 10:39:22 +08:00
019b22c376 FIX: Incorrect chat DM group user count (#31813)
When creating a DM to a group in chat, we show
a count of users for that group if the number of
users exceeds SiteSetting.chat_max_direct_message_users.

However, we were also counting bot users here, we should
only be counting human users, this led to confusion because
the chat group count was different from the one on
e.g. /g/:group_name
2025-03-14 11:40:30 +10:00
2503e95900 FIX: ensures chat context is given to emoji picker (#31794)
This was preventing favorites emojis to work correctly as it was using
topic context. No tests for now as it's a very specific behavior hard to
test with acceptance test and a system spec seems heavy for this.
2025-03-13 10:36:01 +01:00
1f2043de4e DEV: removes code block enter edge case (#31773)
This was causing some confusion and now that we have the chat preference
to send with enter or metakey+enter it's even more confusing.

If your setting is send on enter, you need to use shift+enter for a new
line, even in codeblocks. If your setting is meta+enter you need to use
enter in the codeblock for a new line, meta+enter will send as expected.
2025-03-12 18:01:00 +01:00
1d0d7ddbb5 DEV: [gjs-codemod] convert first batch of files to gjs
Updated using `@embroider/template-tag-codemod`, plus some manual fixups.

Co-authored-by: Jarek Radosz <jarek@cvx.dev>
2025-03-12 08:54:04 +00:00
d3c68ef1a7 Update translations (#31747) 2025-03-11 17:47:42 +01:00
4433a72083 DEV: attempts to fix flakey drawer spec (#31749)
The setup was happening after the page has loaded which could lead to
inconsistent results.
2025-03-11 14:57:35 +01:00
54771b5949 FIX: remove admin_sidebar_enabled_groups setting (#31693)
Old no sidebar admin panel is deprecated and admin sidebar is not
experimental anymore. Therefore, old setting should be deleted.
2025-03-11 11:41:38 +11:00
25048b5a8d DEV: Update lint-configs and rubocop-discourse (#31728)
…and autofix issues

---------

Co-authored-by: David Taylor <david@taylorhq.com>
2025-03-10 19:52:19 +01:00
914543dbb9 FIX: dont allow channel non-members to write messages in threads (#31697)
Prevents channel non-members from seeing the composer in threads. Since
they do not have the correct permissions to post within the channel, we
should show the join channel CTA in place of the chat composer.
2025-03-07 15:50:30 +04:00
1b95a8e1e0 DEV: replace zero width space character in chat typing indicator (#31675)
We were using a zero width space added by CSS here, but have run into
occasional encoding issues for some reason? a couple people have
reported getting this instead of an empty space:


![image](https://github.com/user-attachments/assets/da39b5f5-61b0-423c-ae3e-18169e4f2f71)

I can't repro the issue, but we can avoid it by removing this space in
CSS — setting the container height to `1em` along with `line-height:
normal` should make it consistent with the height of the text within.

In the blame it seems this static height on the container was added
after the pseudo hack, and achieves the same goal when I test it across
a Firefox/Chrome/Safari
2025-03-06 15:53:50 -05:00
fb76696f45 UX: removes per channel context of favorites emojis (#31671)
This was confusing users.
2025-03-06 16:07:58 +01:00
28e00d9bfe DEV: Update lint-configs and autofix issues (#31620)
This updates us to Prettier 3.x
2025-03-05 01:20:16 +01:00
b467fe1347 Update translations (#31617) 2025-03-04 16:12:11 +01:00
d38acc5df1 DEV: discourse-emojis gem (#31408)
This commit moves most of emoji logic into the discourse-emojis gem:
https://github.com/discourse/discourse-emojis/

Most notably:
- images are now symlinked from the gem
- the gem provides path to the json files

Search aliases have also been made asynchronous and memoized. When you
will search for an emoji we will now load the aliases and store the list
for future use.

---------

Co-authored-by: David Taylor <david@taylorhq.com>
2025-03-03 13:09:08 +01:00