Skip to content

Commit 8c988be

Browse files
authored
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
1 parent ad5f5a4 commit 8c988be

File tree

5 files changed

+42
-20
lines changed

5 files changed

+42
-20
lines changed

Diff for: client/src/plus/ai-help/constants.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const MESSAGE_SEARCHING = "Searching for MDN content…";
66
export const MESSAGE_SEARCHED = "Consulted MDN content:";
77
export const MESSAGE_ANSWERING = "Generating your answer…";
88
export const MESSAGE_ANSWERED = "Answer:";
9+
export const MESSAGE_STOPPED = "Answer (stopped):";
910
export const MESSAGE_FAILED = "Error generating your answer!";
1011

1112
export const EVENT_TIMEOUT = 15000;

Diff for: client/src/plus/ai-help/index.scss

+8-6
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,6 @@
397397
color: var(--text-secondary);
398398

399399
&::before {
400-
animation: pulse 1s infinite alternate;
401400
background-color: var(--text-secondary);
402401
content: "";
403402
display: inline-block;
@@ -422,8 +421,11 @@
422421
}
423422
}
424423

424+
&.active::before {
425+
animation: pulse 1s infinite alternate;
426+
}
427+
425428
&.complete::before {
426-
animation: none;
427429
background-color: var(--ai-help-icon);
428430
mask-image: url("../../assets/icons/progress-check.svg");
429431
}
@@ -436,7 +438,6 @@
436438
padding: 0.5rem 1rem;
437439

438440
&::before {
439-
animation: none;
440441
background-color: var(--icon-critical);
441442
mask-image: url("../../assets/icons/alert-circle.svg");
442443
}
@@ -480,9 +481,10 @@
480481
> ol:last-child li:last-child:after,
481482
> pre:last-child code:after,
482483
> ul:last-child li:last-child:after {
483-
content: "";
484-
margin-left: 0.25rem;
485-
vertical-align: baseline;
484+
color: var(--text-muted);
485+
content: "\00a0Stopped answering";
486+
display: block;
487+
margin-top: 1.7rem;
486488
}
487489

488490
&.empty::after {

Diff for: client/src/plus/ai-help/index.tsx

+29-14
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import {
5555
MESSAGE_FAILED,
5656
MESSAGE_ANSWERED,
5757
MESSAGE_SEARCHED,
58+
MESSAGE_STOPPED,
5859
} from "./constants";
5960
import InternalLink from "../../ui/atoms/internal-link";
6061
import { isPlusSubscriber } from "../../utils";
@@ -287,12 +288,36 @@ function AIHelpAssistantResponse({
287288

288289
let sample = 0;
289290

291+
function messageForStatus(status: MessageStatus) {
292+
switch (status) {
293+
case MessageStatus.Errored:
294+
return (
295+
<>
296+
{MESSAGE_FAILED} Please{" "}
297+
<Button type="link" onClickHandler={retryLastQuestion}>
298+
try again
299+
</Button>
300+
.
301+
</>
302+
);
303+
304+
case MessageStatus.Stopped:
305+
return MESSAGE_STOPPED;
306+
307+
case MessageStatus.InProgress:
308+
return MESSAGE_ANSWERING;
309+
310+
default:
311+
return MESSAGE_ANSWERED;
312+
}
313+
}
314+
290315
return (
291316
<>
292317
<div
293318
className={[
294319
"ai-help-message-progress",
295-
message.status !== MessageStatus.Pending && "complete",
320+
message.status === MessageStatus.Pending && "active",
296321
]
297322
.filter(Boolean)
298323
.join(" ")}
@@ -322,25 +347,15 @@ function AIHelpAssistantResponse({
322347
<div
323348
className={[
324349
"ai-help-message-progress",
350+
message.status === MessageStatus.InProgress && "active",
325351
message.status === MessageStatus.Complete && "complete",
326352
message.status === MessageStatus.Errored && "errored",
353+
message.status === MessageStatus.Stopped && "stopped",
327354
]
328355
.filter(Boolean)
329356
.join(" ")}
330357
>
331-
{message.status === MessageStatus.Errored ? (
332-
<>
333-
{MESSAGE_FAILED} Please{" "}
334-
<Button type="link" onClickHandler={retryLastQuestion}>
335-
try again
336-
</Button>
337-
.
338-
</>
339-
) : message.status === MessageStatus.InProgress ? (
340-
MESSAGE_ANSWERING
341-
) : (
342-
MESSAGE_ANSWERED
343-
)}
358+
{messageForStatus(message.status)}
344359
</div>
345360
)}
346361
{message.content && (

Diff for: client/src/ui/_vars.scss

+2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ $mdn-theme-light-text-active: #{$mdn-color-neutral-50};
159159
$mdn-theme-light-text-inactive: #{$mdn-color-neutral-40}a6;
160160
$mdn-theme-light-text-link: $mdn-color-light-theme-blue-60;
161161
$mdn-theme-light-text-invert: $mdn-color-white;
162+
$mdn-theme-light-text-muted: #6f6f6f;
162163
$mdn-theme-light-background-primary: $mdn-color-white;
163164
$mdn-theme-light-background-secondary: $mdn-color-neutral-light-70;
164165
$mdn-theme-light-background-tertiary: $mdn-color-white;
@@ -206,6 +207,7 @@ $mdn-theme-dark-text-active: #{$mdn-color-neutral-50};
206207
$mdn-theme-dark-text-inactive: #{$mdn-color-neutral-20}a6;
207208
$mdn-theme-dark-text-link: $mdn-color-dark-theme-blue-30;
208209
$mdn-theme-dark-text-invert: $mdn-color-neutral-90;
210+
$mdn-theme-dark-text-muted: #858585;
209211
$mdn-theme-dark-background-primary: $mdn-color-neutral-90;
210212
$mdn-theme-dark-background-secondary: $mdn-color-neutral-75;
211213
$mdn-theme-dark-background-tertiary: $mdn-color-neutral-90;

Diff for: client/src/ui/base/_themes.scss

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
--text-link: #{$mdn-theme-light-text-link};
1111
--text-visited: #551a8b; // Source: https://searchfox.org/mozilla-central/rev/02841791400cf7cf5760c0cfaf31f5d772624253/modules/libpref/init/StaticPrefList.yaml#1787-1790
1212
--text-invert: #{$mdn-theme-light-text-invert};
13+
--text-muted: #{$mdn-theme-light-text-muted};
1314

1415
--background-primary: #{$mdn-theme-light-background-primary};
1516
--background-secondary: #{$mdn-theme-light-background-secondary};
@@ -283,6 +284,7 @@
283284
--text-link: #{$mdn-theme-dark-text-link};
284285
--text-visited: #ffadff; // Source: https://searchfox.org/mozilla-central/rev/02841791400cf7cf5760c0cfaf31f5d772624253/modules/libpref/init/StaticPrefList.yaml#1794-1797
285286
--text-invert: #{$mdn-theme-dark-text-invert};
287+
--text-muted: #{$mdn-theme-dark-text-muted};
286288

287289
--background-primary: #{$mdn-theme-dark-background-primary};
288290
--background-secondary: #{$mdn-theme-dark-background-secondary};

0 commit comments

Comments
 (0)