Skip to content

Conversation

@jattasNI
Copy link
Contributor

Pull Request

🤨 Rationale

One of the tasks in #2610 is to create separate components for different message types instead of a single chat message with a message-type attribute. This would have some benefits:

  • certain APIs should only be available on certain message types (e.g. slots for footer-actions and end are only available on inbound messages) but are currently present on all
  • new message types will soon appear with more unique APIs and visual presentations. Candidates include welcome/login message (HLD updates for new Spright chat components: welcome and disclaimer #2799), error message, tool progress message, context message.

👩‍💻 Implementation

  1. Create new components spright-chat-message-inbound, spright-chat-message-outbound, spright-chat-message-system by copying existing message and removing code that was specific to other types.
  2. Added framework wrappers
  3. Marked existing spright-chat-message as deprecated. We can remove it once clients migrate to the new messages.
  4. Updated docs and example apps to only refer to the new components
  5. Updated HLD to reflect this plan

🧪 Testing

  1. Duplicated unit tests from the original message type to the new ones. Some tests (e.g. Angular directive) could be removed because the message-type attribute no longer exists
  2. Duplicated Chromatic tests for messages and for conversation message layout. Updated other conversation-specific tests to only refer to the new message components.
  3. Visual inspection of storybook and example apps to ensure styling is correct

✅ Checklist

  • I have updated the project documentation to reflect my changes or determined no changes are needed.

@jattasNI jattasNI changed the title Separate message types Separate components for chat message types Jan 28, 2026
@jattasNI jattasNI changed the title Separate components for chat message types Separate components for spright chat message types Jan 28, 2026
@@ -0,0 +1,53 @@
import { observable } from '@ni/fast-element';
Copy link
Contributor Author

@jattasNI jattasNI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to feedback about file layout. I went with this for spright-components and spright-angular:

chat/message // deprectated
chat/message/inbound
chat/message/outbound
chat/message/system

This roughly matches what we do for table columns although we decided not to put them under the /table path.

table-column/anchor
table-column/date-text
...

I decided to keep these under the chat path because all of our other chat components are there:

chat/input
chat/conversation

@@ -0,0 +1,45 @@
import { css } from '@ni/fast-element';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I debated trying to share more styles but opted not to. There is some duplication right now (layout, fonts) but also some uniqueness (slots for inbound messages, bubble background for outbound messages, different justify-content settings to control left/center/right layout).

Ultimately I think these are more likely to diverge than converge over time and the benefit of consistency didn't seem to outweigh the mental overhead of reasoning about custom styles applied on top of shared styles. I'd propose we start here and revisit as we add more messages.

namespace SprightBlazor;

/// <summary>
/// SprightChatMessage is deprecated. Use specific message component types instead.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using the [Obsolete] tag but as Milan / Darren predicted, that caused build failures (even within Nimble, presumably also within clients) because warnings are treated as errors.

export const chatMessageRichText: StoryObj<ChatMessageRichTextArgs> = {
render: createUserSelectedThemeStory(html`
<${chatMessageTag} message-type="${x => ChatMessageType[x.messageType]}">
<${chatMessageInboundTag}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this from outbound to inbound to more closely match real product use cases for rich text messages. This explains the one Chromatic diff that isn't a new story.

@jattasNI jattasNI marked this pull request as ready for review January 29, 2026 16:42
Comment on lines +21 to +22
min-width: 16px;
min-height: 16px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to use a token value for the min width/height styling?

Same in the outbound message styles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just laziness / perpetuating the pattern from the original implementation! We have a lot of tokens with the value of 16px but none of them had quite the correct naming for this purpose. But given how many places this is used I agree a token makes sense. I'm on the fence between using standardPadding or creating a new token. Feel free to weigh in if you have an opinion, or I'll just pick one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there isn't a better option standard padding is fine. It's the generic size ramp with an unhelpful name at this point (essentially the base tokens for size) and we don't have super well defined high level sizing tokens

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants