From 8c988be94b8e89d26c0a847a3f98d443b7ab0421 Mon Sep 17 00:00:00 2001 From: Claas Augner <495429+caugner@users.noreply.github.com> Date: Thu, 29 Feb 2024 16:41:15 +0100 Subject: [PATCH] enhance(ai-help): improve stopped state (#10580) * feat(ui): add --text-muted color * enhance(ai-help): add "Stopped answering" in new line * fix(ai-help): animate status icon only if active * refactor(ai-help): extract messageForStatus() helper * enhance(ai-help): add suffix to answer status if stopped --- client/src/plus/ai-help/constants.tsx | 1 + client/src/plus/ai-help/index.scss | 14 +++++---- client/src/plus/ai-help/index.tsx | 43 ++++++++++++++++++--------- client/src/ui/_vars.scss | 2 ++ client/src/ui/base/_themes.scss | 2 ++ 5 files changed, 42 insertions(+), 20 deletions(-) diff --git a/client/src/plus/ai-help/constants.tsx b/client/src/plus/ai-help/constants.tsx index eb7e133f832b..2b4159ee1270 100644 --- a/client/src/plus/ai-help/constants.tsx +++ b/client/src/plus/ai-help/constants.tsx @@ -6,6 +6,7 @@ export const MESSAGE_SEARCHING = "Searching for MDN content…"; export const MESSAGE_SEARCHED = "Consulted MDN content:"; export const MESSAGE_ANSWERING = "Generating your answer…"; export const MESSAGE_ANSWERED = "Answer:"; +export const MESSAGE_STOPPED = "Answer (stopped):"; export const MESSAGE_FAILED = "Error generating your answer!"; export const EVENT_TIMEOUT = 15000; diff --git a/client/src/plus/ai-help/index.scss b/client/src/plus/ai-help/index.scss index 1db7e99daf5c..0a7b0d4e155a 100644 --- a/client/src/plus/ai-help/index.scss +++ b/client/src/plus/ai-help/index.scss @@ -397,7 +397,6 @@ color: var(--text-secondary); &::before { - animation: pulse 1s infinite alternate; background-color: var(--text-secondary); content: ""; display: inline-block; @@ -422,8 +421,11 @@ } } + &.active::before { + animation: pulse 1s infinite alternate; + } + &.complete::before { - animation: none; background-color: var(--ai-help-icon); mask-image: url("../../assets/icons/progress-check.svg"); } @@ -436,7 +438,6 @@ padding: 0.5rem 1rem; &::before { - animation: none; background-color: var(--icon-critical); mask-image: url("../../assets/icons/alert-circle.svg"); } @@ -480,9 +481,10 @@ > ol:last-child li:last-child:after, > pre:last-child code:after, > ul:last-child li:last-child:after { - content: "…"; - margin-left: 0.25rem; - vertical-align: baseline; + color: var(--text-muted); + content: "■\00a0Stopped answering"; + display: block; + margin-top: 1.7rem; } &.empty::after { diff --git a/client/src/plus/ai-help/index.tsx b/client/src/plus/ai-help/index.tsx index 237aff815fa4..7373d8daa374 100644 --- a/client/src/plus/ai-help/index.tsx +++ b/client/src/plus/ai-help/index.tsx @@ -55,6 +55,7 @@ import { MESSAGE_FAILED, MESSAGE_ANSWERED, MESSAGE_SEARCHED, + MESSAGE_STOPPED, } from "./constants"; import InternalLink from "../../ui/atoms/internal-link"; import { isPlusSubscriber } from "../../utils"; @@ -287,12 +288,36 @@ function AIHelpAssistantResponse({ let sample = 0; + function messageForStatus(status: MessageStatus) { + switch (status) { + case MessageStatus.Errored: + return ( + <> + {MESSAGE_FAILED} Please{" "} + + . + > + ); + + case MessageStatus.Stopped: + return MESSAGE_STOPPED; + + case MessageStatus.InProgress: + return MESSAGE_ANSWERING; + + default: + return MESSAGE_ANSWERED; + } + } + return ( <>