-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added new slots for the spright-chat-message to allow adding action buttons and follow-up prompts #2552
base: main
Are you sure you want to change the base?
Conversation
The action controls provide "actions" that can be done to the chat-message like copying and thumbs up/down.
Action buttons on outbound messages appear on the left side when hovering over the message row
* main: Created Blazor wrapper for nimble-rich-text-viewer component (#2544)
* main: applying package updates [skip ci] Migrate to `@ni/fast-*` packages (#2550)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looked at the spec and the docs, not the implementation yet
packages/storybook/src/spright/chat/conversation/chat-conversation.stories.ts
Show resolved
Hide resolved
packages/storybook/src/spright/chat/conversation/chat-conversation.stories.ts
Outdated
Show resolved
Hide resolved
packages/storybook/src/spright/chat/message/chat-message.stories.ts
Outdated
Show resolved
Hide resolved
packages/storybook/src/spright/chat/message/chat-message.stories.ts
Outdated
Show resolved
Hide resolved
packages/storybook/src/spright/chat/conversation/chat-conversation.stories.ts
Outdated
Show resolved
Hide resolved
packages/storybook/src/spright/chat/message/chat-message.stories.ts
Outdated
Show resolved
Hide resolved
display: none; | ||
} | ||
|
||
[part='end'] ::slotted(*) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some changes to make to this styling. We want the element which contains the content to be sized according to the content but right now it's tiny:
And while we may want the slot to provide some initial spacing, that should largely be applied to the container, not set on the buttons that the client provides.

And finally we should check if there are tokens we can use rather than hard coding values like 16px.
I can push some changes to address this if you'd like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will greatly appreciate if you make those changes. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I'll get to this today but tomorrow morning looks open.
packages/storybook/src/spright/chat/conversation/chat-conversation-matrix.stories.ts
Outdated
Show resolved
Hide resolved
@@ -119,6 +144,15 @@ export const systemSizing: StoryFn = createStory(html` | |||
])} | |||
`); | |||
|
|||
export const messageInteractionsThemeMatrix: StoryFn = createMatrixThemeStory( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good that you're adding matrix test coverage for the new slots. But there are a few issues:
- it's not necessary to include coverage for states combinations like hover and active. Those states will be covered by existing button tests and we don't need to verify that they still work inside a message slot
- we should add coverage for layout and sizing. If there are multiple buttons, what's the default padding between them? If there are more buttons than the width of the message, how do they layout? If there are more buttons than fit in the width of the conversation, how do they layout?
For 2 I think the designers are still deciding but we could add the tests with whatever behavior we get today and then when we adopt the designers' suggestions we'll see a useful diff in the snapshots for the tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there examples I can look at for those types of tests? If not, I am concern about how much time it will take to write them. I am under a very tight schedule and I need to minimize the amount of time I spend on non-chat Blazor UI changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your existing conversation sizing tests cover some similar cases. You could just add a few more cases to those:
- a couple footer action buttons and end buttons on the same message
- lots of footer action buttons
- wider than the message but narrower than the conversation
- wider than the conversation
- lots of end buttons
- wider than the message but narrower than the conversation
- wider than the conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Milan and I discussed a couple more ideas. Let me take a stab at this along with the styling changes. I think we want some of this in a new matrix test and some of it in the existing sizing tests.
packages/blazor-workspace/Examples/Demo.Shared/Pages/ComponentsDemo.razor
Show resolved
Hide resolved
* SprightChatMessage configuration options | ||
* @public | ||
*/ | ||
export type ChatMessageOptions = FoundationElementDefinition & StartEndOptions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with the our/FAST's StartEndOptions pattern. It looks like this follows what the tab does by exporting this type and using it from the template. But I was expecting to see the pattern in more other components. @rajsite could you double check that it's being applied correctly?
Pull Request
🤨 Rationale
UX design calls for adding action buttons to chat messages to allow user to edit prompts and provide feedback on AI responses.
Also, messages can have suggested follow-up button prompts and those should be below the action buttons.
👩💻 Implementation
Added slots to allow adding buttons to the left and bottom-left side of a message. In the future, we might allow adding buttons to the top-left, top-left and bottom-right. This is the main reason I have decided to call the bottom slot
left-bottom
.I also have added a new slot for follow-up prompts which is below the bottom action buttons slot.
🧪 Testing
Since changes are visual only, I added a new interactions from states matrix.
✅ Checklist