Skip to content

Commit

Permalink
fix: disable send button for AI readonly mode (#1954)
Browse files Browse the repository at this point in the history
* fix: disable send button for AI readonly mode

* chore: changeset

* chore: readOnly chat
  • Loading branch information
gabriele-ct authored Mar 25, 2024
1 parent bb025af commit b661c74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/funny-beers-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-docs/gatsby-theme-docs': patch
---

Adjust readonly mode for AI assistant. It will hide the send button and enable the restart conversation button
Original file line number Diff line number Diff line change
Expand Up @@ -454,9 +454,11 @@ const ChatModal = () => {
};

useEffect(() => {
if (replayMessage) {
if (replayMessage && currentChatMode !== DEV_TOOLING_MODE) {
// if the chat mode changes and there is at least one message sent from
// the user, we switch mode and re-submit this latest message
// the user, we switch mode and re-submit this latest message.
// We don't want to replay the last message if the user is entering dev-tooling mode
// as free text input is going to be blocked.
submitChatMessages([replayMessage], formik.values);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
Expand Down Expand Up @@ -492,7 +494,7 @@ const ChatModal = () => {
setReplayMessage();
formik.resetForm();
}}
displayPrimaryButton={!!chatConfig?.readOnly}
displayPrimaryButton={false}
isPrimaryButtonDisabled={
!(formik.isValid && formik.dirty) || formik.isSubmitting
}
Expand Down Expand Up @@ -538,9 +540,10 @@ const ChatModal = () => {
/>
</ChatMessagesWrapper>

{!chatConfig?.readOnly && !chatLocked && (
{!chatLocked && (
<ChatInputBox>
<InputTextWrapper>

{!chatConfig?.readOnly && <InputTextWrapper>
<MultilineTextField
data-testid="chat-input-field"
key="chatInput"
Expand Down Expand Up @@ -577,7 +580,7 @@ const ChatModal = () => {
}
/>
</SubmitButtonBox>
</InputTextWrapper>
</InputTextWrapper>}
<RestartButtonBox>
<FlatButton
label="Tip: Restart the conversation when changing the topic"
Expand Down

0 comments on commit b661c74

Please sign in to comment.