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 ( <>
- {message.status === MessageStatus.Errored ? ( - <> - {MESSAGE_FAILED} Please{" "} - - . - - ) : message.status === MessageStatus.InProgress ? ( - MESSAGE_ANSWERING - ) : ( - MESSAGE_ANSWERED - )} + {messageForStatus(message.status)}
)} {message.content && ( diff --git a/client/src/ui/_vars.scss b/client/src/ui/_vars.scss index 5f97a83aebd9..c77a0ba3bfa6 100644 --- a/client/src/ui/_vars.scss +++ b/client/src/ui/_vars.scss @@ -159,6 +159,7 @@ $mdn-theme-light-text-active: #{$mdn-color-neutral-50}; $mdn-theme-light-text-inactive: #{$mdn-color-neutral-40}a6; $mdn-theme-light-text-link: $mdn-color-light-theme-blue-60; $mdn-theme-light-text-invert: $mdn-color-white; +$mdn-theme-light-text-muted: #6f6f6f; $mdn-theme-light-background-primary: $mdn-color-white; $mdn-theme-light-background-secondary: $mdn-color-neutral-light-70; $mdn-theme-light-background-tertiary: $mdn-color-white; @@ -206,6 +207,7 @@ $mdn-theme-dark-text-active: #{$mdn-color-neutral-50}; $mdn-theme-dark-text-inactive: #{$mdn-color-neutral-20}a6; $mdn-theme-dark-text-link: $mdn-color-dark-theme-blue-30; $mdn-theme-dark-text-invert: $mdn-color-neutral-90; +$mdn-theme-dark-text-muted: #858585; $mdn-theme-dark-background-primary: $mdn-color-neutral-90; $mdn-theme-dark-background-secondary: $mdn-color-neutral-75; $mdn-theme-dark-background-tertiary: $mdn-color-neutral-90; diff --git a/client/src/ui/base/_themes.scss b/client/src/ui/base/_themes.scss index 312ce44d5619..1f4b910005f3 100644 --- a/client/src/ui/base/_themes.scss +++ b/client/src/ui/base/_themes.scss @@ -10,6 +10,7 @@ --text-link: #{$mdn-theme-light-text-link}; --text-visited: #551a8b; // Source: https://searchfox.org/mozilla-central/rev/02841791400cf7cf5760c0cfaf31f5d772624253/modules/libpref/init/StaticPrefList.yaml#1787-1790 --text-invert: #{$mdn-theme-light-text-invert}; + --text-muted: #{$mdn-theme-light-text-muted}; --background-primary: #{$mdn-theme-light-background-primary}; --background-secondary: #{$mdn-theme-light-background-secondary}; @@ -283,6 +284,7 @@ --text-link: #{$mdn-theme-dark-text-link}; --text-visited: #ffadff; // Source: https://searchfox.org/mozilla-central/rev/02841791400cf7cf5760c0cfaf31f5d772624253/modules/libpref/init/StaticPrefList.yaml#1794-1797 --text-invert: #{$mdn-theme-dark-text-invert}; + --text-muted: #{$mdn-theme-dark-text-muted}; --background-primary: #{$mdn-theme-dark-background-primary}; --background-secondary: #{$mdn-theme-dark-background-secondary};