Commit Graph
1217 Commits
Author SHA1 Message Date
Martin Brennan 6aae74d082 SECURITY: Rich editor chat transcript XSS
When quoting from a channel or a thread, the title
of the channel and the title of the thread could be
an XSS vector when CSP is disabled.
2025-09-30 10:09:43 +08:00
Sérgio Saquetim 813b494730 DEV: Replace deprecated Ember's array filterBy with filter (#35018)
Replaces Ember's deprecated `filterBy` with the native JavaScript method
`filter`. This aligns with modern JavaScript practices, improves code
clarity, and prepares for future deprecations.

Changes involve various components, controllers, and models across the
codebase.
2025-09-29 16:42:38 -03:00
Sérgio SaquetimandJarek Radosz ad3a2df0a4 DEV: Replace Ember's deprecated mapBy with standard .map (#34963)
Replaces usages of `mapBy` across the codebase with JavaScript's native
`.map`. This resolves deprecation warnings related to Ember's array
extensions and ensures compatibility with future Ember versions.

---------

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
2025-09-26 12:59:35 -03:00
Sérgio Saquetim e091b6e447 DEV: Replace deprecated reject and rejectBy with filter (#34974)
Refactor all instances of `reject` and `rejectBy` across the codebase to
use the native `filter` method paired with appropriate logic. Updates
include changes in models, components, and services.

This ensures compatibility with modern JavaScript standards and reduces
reliance on deprecated array extension methods.
2025-09-25 17:15:19 -03:00
David Taylor 6081bc2249 DEV: Standardize Ember route, controller and template naming (#34417)
For historical reasons, Discourse has a customized Ember resolver. This
had a much more fuzzy implementation of 'normalize' and 'findTemplate'
functions. This leniency meant that our file naming hasn't always
matched Ember conventions.

Standardizing our naming will make things easier to understand for
developers, and will make adoption of newer ecosystem tooling easier
(e.g. route-based bundle splitting in Embroider/vite)

This commit adds deprecations to the resolver when this leniency is
used, and uses a fully bespoke codemod to rename all of the affected
routes/controllers/templates in the Discourse core repository.
Backwards-compatibility is maintained for anyone looking up the old
names in the resolver.
2025-09-25 11:27:45 +01:00
Sérgio Saquetim 5b031945f7 DEV: Replace the use of Ember's .findBy for native methods on arrays (#34557)
Use the native array `.find` instead of Ember's `.findBy` which was deprecated.
2025-09-24 15:32:13 -03:00
Kelv 547d99e3b4 DEV: remove toggles for switching between jquery & floatkit autocomplete (#34867)
We've had the new floatkit-based autocomplete live in various parts of
Discourse for about a month now, and it's stable enough for us to remove
the site setting letting admins revert to the jquery-based autocomplete
library which is now deprecated.
2025-09-19 14:50:04 +08:00
Joffrey JAFFEUX cebc0d4131 UX: adds a start new dm link when no dms present (#34820)
Prior to this commit we would show the collapsible DMs section which has
a [+] on hover to start a DM but it was not very nice visually and also
had low affordance.

The new empty DMs state:

<img width="275" height="77" alt="Screenshot 2025-09-16 at 09 07 57"
src="https://github.com/user-attachments/assets/99976dfd-44ec-40f8-a6d1-c0d15f550524"
/>
2025-09-17 08:18:31 +02:00
Joffrey JAFFEUX 0436fc8034 PERF: do not fetch thread data when we have it (#34799)
Prior to this fix we would fetch thread data even if it was present in
the bus data, that's already unnecessary work in a normal situation but
that's even worse when a user is coming back to their computer as we
will have to catchup multiple new threads at once.

Also ensures we correctly await fetching data from server when
necessary.

No test as there are not behavior change.
2025-09-15 07:49:14 +02:00
Joffrey JAFFEUX 61e838781e FIX: ensures quick reactions usage shows in frequently (#34798)
Prior to this change we would have different context for quick reactions
and for channels this commit just move everything into one context which
is less surprising.
2025-09-15 07:48:22 +02:00
Joffrey JAFFEUX a96ace858e FIX: client based chat message timestamp (#34592)
Uses the timestamp at the moment where the user hits send for the
created_at value of the chat message. This should ensure very consistent
ordering.

The implementation is simple:
- collects the timestamp and send it in the request (client_created_at)
- if client_created_at is present and valid, set it as created_at when
creating the message

I suspect that we could end up in a situation where a message is routed
to a slower worker and even if sent before an other message could end up
being persisted before the first message which would cause ordering issues.
2025-08-28 10:21:19 +01:00
Gary Pendergast c333888e01 DEV: When chat is full page, scroll user cards with the avatar (#34556)
When a user card is rendered, there are two phases: first, where a
placeholder is created, then after the user card data is retrieved, the
data is inserted into the user card structure.

This causes an issue where, if the placeholder is too close to the
bottom of the viewport, and there's a lot of data being inserted into
the user card, then the user card will be partially rendered outside of
the viewport, resulting in odd scrolling behaviour.

To address this issue, this change makes use of float-kit's ability to
auto-update the position of the user-card. There are three relevant UX
changes from this:

- When the avatar is close to the bottom of the viewport, the
placeholder renders below the avatar, and the final user card is much
bigger, the user card will jump from being below the avatar, to above
the avatar.
- The user card follows the avatar when the chat window scrolls.
- When the avatar scrolls out of view, the user card is hidden.
2025-08-27 17:00:48 +10:00
Joffrey JAFFEUX 5adc33ae29 FIX: use CDN url for chat (#34541) 2025-08-26 18:04:25 +02:00
Gabriel Grubba 4782dc9cdf Revert "FIX: use CDN url for chat" (#34540)
Reverts discourse/discourse#34507

Previews are broken, the CDN URL is incorrect
2025-08-26 11:24:51 -03:00
SamandJoffrey JAFFEUX 8cf83a6104 FIX: use CDN url for chat (#34507)
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2025-08-26 13:59:59 +10:00
Sérgio Saquetim 95a95a492b DEV: Deprecate Site.mobileView/desktopView during initialization (#34122)
This commit introduces deprecation warnings for accessing Site.mobileView or
Site.desktopView during application initialization to prevent
layout-related errors and improve code reliability.

The changes include:

* Added deprecation warnings for Site.mobileView and Site.desktopView
access during the initialization phase.
* Updated multiple plugins and components to avoid these deprecated
calls during startup.
* Refactored initialization logic across discourse-ai, discourse-chat,
discourse-calendar, discourse-reactions, discourse-assign,
discourse-subscriptions, and discourse-user-notes plugins
* Improved error prevention by discouraging early access to
view-dependent properties before the application is fully initialized
* Enhanced code maintainability by establishing clearer boundaries
between initialization and runtime phases

This deprecation helps prevent subtle bugs that can occur when
components try to determine the view type before the application context
is properly established, leading to more robust plugin initialization
patterns.
2025-08-25 16:49:52 -03:00
chapoi c6b2949d64 UX: remove chat and message buttons on currentUser profile (#34513)
Remove the rendering of the chat and message CTA when viewing your own
profile.
They serve little purpose, add to confusion, and take up valuable above
the fold space on mobile.

| Before | After |
|--------|--------|
| <img width="690" height="1490" alt="CleanShot 2025-08-25 at 11 47
24@2x"
src="https://github.com/user-attachments/assets/7d3539b6-5599-448b-b610-00adcacaf28b"
/> | <img width="690" height="1490" alt="CleanShot 2025-08-25 at 11 46
47@2x"
src="https://github.com/user-attachments/assets/1c0b4512-693d-4e39-b1ae-3ee30375e127"
/> |
2025-08-25 12:04:29 +02:00
chapoi f698bb9088 UX: fix cmd-k bottom padding (#34440)
Moved some things around to fix the lack of bottom padding while
searching for results:
<img width="1706" height="398" alt="CleanShot 2025-08-20 at 15 58 32@2x"
src="https://github.com/user-attachments/assets/c67f2c35-719d-4a3d-98ee-191353a476e2"
/>

🔽 
<img width="1706" height="398" alt="CleanShot 2025-08-20 at 15 52 13@2x"
src="https://github.com/user-attachments/assets/65869c9d-06b7-4dd9-b5ef-156e320a798a"
/>
2025-08-20 16:45:39 +02:00
Jarek Radosz 07425a9fed DEV: Reduce the getOwnerWithFallback usage (#34330) 2025-08-14 20:24:59 +02:00
Jarek Radosz 41acf4eace DEV: Remove unused code (#34322) 2025-08-14 16:21:46 +02:00
chapoi 823e1b6272 UX: user status emoji alignment in sidebar and chat mention (#34320)
Follow up of https://github.com/discourse/discourse/pull/33902

Fixes:
* User status in chat mentions needed a spacing
<img width="404" height="70" alt="CleanShot 2025-08-14 at 11 00 21"
src="https://github.com/user-attachments/assets/3c3f3e8b-5a0a-4516-a152-c2e8a5e361e4"
/>

* Sidebar user status was misaligned
<img width="181" height="65" alt="CleanShot 2025-08-14 at 11 00 58"
src="https://github.com/user-attachments/assets/ef86b103-1cbd-4a2d-8169-1c3ae125b8fc"
/>
2025-08-14 11:21:49 +02:00
Kelv 282a544cce DEV: raise error on missing name properties for user autocomplete results (#34283)
Related to https://github.com/discourse/discourse/pull/34208.

Previously, missing name properties for a selected user search result
would fail silently which made it difficult to tell if something had
gone wrong with the user autocomplete.

This PR adds some error handling to make it more obvious that an error
has occurred. I've opted for using `toasts` here since it's less
intrusive compared to the `dialog` modal.

https://github.com/user-attachments/assets/92f585d8-95bf-4c5b-a08a-698c1a527b79
2025-08-14 09:12:47 +08:00
Jarek Radosz 89b108c4b2 DEV: Remove unused services from plugins/themes (#34231) 2025-08-12 22:47:31 +02:00
Kelv a71eb4108a FIX: user autocomplete search cache pollution (#34208)
The current chat autocomplete pipeline can mutate the user object
selected for autocomplete here:

https://github.com/discourse/discourse/blob/071e82140cf375e2875b87d1664ae596c19320dd/plugins/chat/assets/javascripts/discourse/components/chat-composer.gjs#L485

Specifically this occurs when we attempt to create a record in the store
service where it already exists, and the logic for fetching the right
record there deletes some properties from the input object:

https://github.com/discourse/discourse/blob/216df43502e25fcb9a228bfc09f90548712d7f49/app/assets/javascripts/discourse/app/services/store.js#L426-L435

This mutates the object that is eventually used to replace the search
term (and therefore causes an error as it is now missing all its
properties except for `id`). This also pollutes the upstream cache in
the userSearch JS module.

This PR fixes both issues by cloning the user objects before they get
passed into the processing functions.
2025-08-11 13:14:25 +08:00
Kris 98d594a7b3 FEATURE: AI header icon should remember last URL (#34108)
This change concerns these header icons

<img width="220" height="116" alt="image"
src="https://github.com/user-attachments/assets/eb7883cf-4766-4499-8d1a-116a542a2cdd"
/>


Currently the chat icon in the header switches to chat "mode" when
possible, and remembers your last forum location. The AI header icon
does not remember your last forum location, and just redirects you to
the homepage when you toggle it off.

This PR adds the last forum URL memory for the AI header icon as well. 
 
I've also updated the AI header icon to be a link when
`ai_bot_enable_dedicated_ux` is enabled, this way it can be opened in a
new tab and do all the typical link behavior (requested here:
https://meta.discourse.org/t/change-ai-bot-icon-to-link-element/377435).
It is still a button when `ai_bot_enable_dedicated_ux`, which is
appropriate for opening the composer.

This also updates the AI button title when the state changes (noted
here:
https://meta.discourse.org/t/ai-bot-header-button-title-doesnt-always-match-its-action/377402)
2025-08-08 09:12:22 +10:00
Kelv c648160d3f DEV: use floatkit autocomplete for chat composer (#33980)
This PR ports the floatkit-based autocomplete system to chat composer
under a site setting, providing consistent UX across both regular and
chat composers.

### Key Changes

* Adds floatkit_autocomplete_chat_composer setting (defaults to true)
* Adds `fixedTextareaPosition` option and
`createVirtualElementAtTextarea` to DAutocompleteModifier to allow for
positioning of the autocomplete menu relative to the whole textarea
bounds instead of following the cursor - this is better for chat UI &
aligns with current behaviour
2025-08-05 10:43:58 +08:00
David Taylor 36a42c5ea7 FIX: Initialize mobileMode earlier (#34036)
Early initializers (e.g. chat-setup) were checking mobile mode before
the lib was initialized. This moves the init into the root of the
module, so it's definitely ready before anything accesses it.

Also updates the chat-emoji-button `displayed` property to be a getter,
so that it updates dynamically in 'viewport based mobile mode'.
2025-08-01 22:30:19 +01:00
Jarek Radosz ce6368ca98 DEV: Enable ember/no-classic-components (#33978)
…and apply lint-to-the-future
2025-07-30 14:54:24 +02:00
David TaylorandMartin Brennan f6766f01b2 DEV: Fix & tidy html/body classes in chat (#33972)
Followup to 5873ea104d

Also remove the `scrollTop()`, which is now handled by `services/route-scroll-manager`.

Co-authored-by: Martin Brennan <martin@discourse.org>
2025-07-30 12:38:27 +01:00
Kelv 50f80d9809 DEV: floatkit autocomplete for d-editor (#33513)
This PR introduces a modern floatkit-based autocomplete system for the
core composer (both rich text / markdown modes), intended to replace the
legacy jQuery-based implementation. This will be enabled via a site
setting for now. All tests that cover the legacy implementation are
duplicated with the site setting enabled to ensure they keep functional
parity.

### What's changed:

* The autocomplete menu remains open between searches while typing
within a search term, instead of closing and reopening (this looks like
the menu flickering, especially if the searches are quickly resolving).
* Flip behaviour now works (the autocomplete menu should never overlap
with the header, and will appear below the cursor if there's not enough
space to appear fully in the viewport)
* On any mouse-down event outside the menu, the menu will immediately
close (previously, it stayed open during the grippie drag up/down of the
composer drawer, and closes on mouse-up)
* Preserves exact CSS structure and selectors for existing
themes/plugins
* Better use of native browser APIs
*
[scrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView)
API is used for handling scroll within the hashtag autocomplete menu
instead of manual calculation
*
[requestAnimationFrame](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame)
API is used to better time the opening of the autocomplete menu with
repaint during pasting of autocompletable terms
* `position: absolute` CSS was removed - this didn't seem to affect the
old autocomplete during testing, and keeping it broke positioning for
the Floatkit-based autocomplete

### What's the same:

* All templates specific to the different types of autocomplete (user &
group / hashtag / emoji) remain exactly the same
* we update the selected class that's used to highlight the item in the
autocomplete menu while navigating it via keyboard the same way we do in
the old autocomplete - it's fairly imperative, but allows us to avoid a
deeper refactor (including an entirely new set of templates)
2025-07-30 08:00:39 +08:00
Jordan Vidrine 4948748baf DEV: Add Chat page variables (#33936) 2025-07-29 11:22:50 -05:00
Jordan Vidrine 49a1667155 UX: Content border color (#33908) 2025-07-28 16:17:06 -05:00
dependabot[bot]dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Discourse CIJarek Radosz
e7d3c344d1 Build(deps-dev): Bump the lint group across 1 directory with 4 updates (#33881)
Bumps the lint group with 4 updates in the / directory:
[@discourse/lint-configs](https://github.com/discourse/lint-configs),
[ember-template-lint](https://github.com/ember-template-lint/ember-template-lint),
[eslint](https://github.com/eslint/eslint) and
[stylelint](https://github.com/stylelint/stylelint).


Updates `@discourse/lint-configs` from 2.22.0 to 2.28.0
- [Commits](https://github.com/discourse/lint-configs/commits)

Updates `ember-template-lint` from 7.7.0 to 7.9.1
- [Release
notes](https://github.com/ember-template-lint/ember-template-lint/releases)
-
[Changelog](https://github.com/ember-template-lint/ember-template-lint/blob/master/CHANGELOG.md)
-
[Commits](https://github.com/ember-template-lint/ember-template-lint/commits)

Updates `eslint` from 9.27.0 to 9.32.0
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/eslint/eslint/compare/v9.27.0...v9.32.0)

Updates `stylelint` from 16.19.1 to 16.22.0
- [Release notes](https://github.com/stylelint/stylelint/releases)
-
[Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md)
-
[Commits](https://github.com/stylelint/stylelint/compare/16.19.1...16.22.0)

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Discourse CI <ci@ci.invalid>
Co-authored-by: Jarek Radosz <jarek@cvx.dev>
2025-07-28 18:02:41 +02:00
Jarek Radosz 4bdbc8e78a DEV: Deprecate "discourse/helpers/get-url" (#33870)
Import from "discourse/lib/get-url" directly.
2025-07-27 12:27:31 +02:00
Joffrey JAFFEUX 2d4930fe20 FIX: correctly update last message bus id for threads and channels (#33846) 2025-07-25 09:13:16 +02:00
Jarek Radosz cfb1ea0c2c DEV: Fix random typos (#33839)
July 2025 edition

@discourse-translator-bot keep_translations
2025-07-24 22:04:13 +02:00
Jarek Radosz 21e9733f27 DEV: Fix various lint issues (#33811)
…mostly in recently bundled plugins.
2025-07-24 15:27:04 +02:00
Yuriy Kurant 477b4c2167 FIX: adds missing router service import (explicit) (#33756)
Hotfix to explicitly import `router` service.

This is a follow-up change after https://github.com/discourse/discourse/pull/33539.
2025-07-23 04:20:26 +08:00
Kris 57f4f5d60f UX: show chat in plugin list (#33735)
follow-up to 2d111e2a9a, we're showing all
plugins now but chat was hidden via CSS
2025-07-21 12:01:42 -04:00
Osama Sayegh 0dcbbe0de4 DEV: Load admin JS bundles from plugins for staff users (#33540)
JS assets defined under `admin/` in plugins are compiled into a separate
bundle that should be loaded for staff users only, but we currently load
it for all users including normal users and anons. This is wasteful and
unexpected since it could cause errors if an asset in the admin bundle
of a plugin imports a module from the admin bundle in core (which
doesn't get loaded for non-staff users).
2025-07-10 07:39:11 +03:00
Kris 6bcb38f410 REFACTOR: consolidate empty states, add invite variant (#33455)
This consolidates various empty states to use a single `EmptyState`
component. I've also added a new state when there are no pending
invites.

I've moved the SVGs to stand-alone components in a `components/svg/`
directory. I believe these need to be embedded (rather than separate
`.svg` assets) because we're using color variables within.

Most of the `EmptyState` component is optional so it should be flexible.
An optional tip block is used for when we may need to utilize an action
instead of a link (as invites do).

The invite tip includes a prefix and suffix so translators can adjust as
needed for their locale.


The existing empty states should only change slightly... 

New

![image](https://github.com/user-attachments/assets/e85b38cb-82f9-408c-bca9-d01db1ff2b4e)


Unread

![image](https://github.com/user-attachments/assets/5546b8fa-8645-4568-a155-42155c0f4477)


Chat channels

![image](https://github.com/user-attachments/assets/80efe964-85cf-4054-aa4c-efdb0864b84b)


Plus the new invite state: 

![image](https://github.com/user-attachments/assets/e2708ba4-32e8-4e47-aa99-a712b45922f9)


These simpler empty states are also using the component now, it will now
be easy to enhance these with illustrations in the future as well.


![image](https://github.com/user-attachments/assets/30f8ee5e-7cb4-45f1-9652-bbd5b1c034de)



![image](https://github.com/user-attachments/assets/98e62785-4e1f-40c6-8c86-5f98391472a0)
2025-07-09 12:34:04 -04:00
Martin Brennan a24107dd15 FIX: Escape URL when inserting/editing links in composer modal (#33501)
Fixes an issue where a URL like this:

```
https://meta.discourse.org/admin/site_settings/category/all_results?filter=discourse connect
```

Would appear to be broken when inserting into the composer via the
hyperlink modal. All we have to do is escape it before inserting,
and unescape before editing it in the modal.

Also in this commit I am renaming the InsertHyperlink modal to
UpsertHyperlink,
since it is used for both inserting and editing links.
2025-07-08 12:51:25 +10:00
David Battersby d1446355e7 FIX: chat btn order on user profile (#33494)
A recent regression caused the incorrect order of the chat button which
makes the profile controls look visually incorrect.
2025-07-07 20:10:44 +04:00
Martin Brennan 2ee7d055a2 UX: Shrink YouTube thumbnail in chat transcript (#33433)
This fixes an issue where the YouTube thumbnail was huge in a chat
transcript, like in this scenario:

* Share a link to a youtube video in channel A
* See it onebox at a reasonable size
* Grab a link to your message
* Share the link to your message in channel B (e.g. a DM to yourself)
*  See GIANT youtube image

This commit only fixes the issue visually though -- it does not apply
the LazyYoutube decorations that actually embed the video. We can do
this in a followup commit.
2025-07-03 07:51:59 +10:00
Blake Erickson 32aec6fca7 FIX: Chat video thumbnails on iOS (#33349)
Turns out we do need the iOS check, not just the safari check.

Follow up to: #33199
2025-06-25 14:00:28 -06:00
Martin Brennan f69dbcd2c1 FIX: Make Ctrl+K shortcut work consistently in RTE, and not always show chat channel switcher
Followup fb7fa2902c,
prevent opening the chat channel selector with Ctrl/Meta+K
in any inputs except the chat composer, most of the time you
do not want this, but especially in the topic composer.

In that case, you want the link insert modal to open.
2025-06-24 12:20:00 +10:00
Martin Brennan 00942ddffd FIX: Admin search labels doubled up with parent label (#33308)
Fixes an issue where the admin search results was showing
breadcrumbs with a double up of the parent label. For example,
we would show "Plugins > Plugins > AI > Usage" or
"Advanced > Advanced > Backups > Logs".

Also adds a missing translation for the chat incoming webhooks
page.
2025-06-23 16:21:29 +10:00
David Battersby bb5c2e7a00 FIX: chat message inline onebox url target (#33288)
Chat inline onebox links should open in a new tab with the help of chat
decorators by appending the `target="_blank"` attribute. I suspect this
may have been accidentally broken during a refactor in #31309

The issue was that the element that we pass into the decorator has
changed, meaning that the selector in the decorator would never find
inline links in cooked messages.
2025-06-20 18:04:37 +04:00
David Battersby af11b23309 FIX: add channel hashtag color when lazy load is disabled (#33269)
When category lazy loading was disabled, chat channel CSS classes were
not being inserted into the page markup. This meant that they would not
be styled correctly in the markdown editor preview.
2025-06-19 18:54:11 +04:00
David Taylor aab7b9fc68 DEV: Use imports for select-kit components & deprecate string lookups (#33219) 2025-06-17 10:40:46 +01:00