Skip to content

Commit 49b2a98

Browse files
AlinaVarkkiDevtools-frontend LUCI CQ
authored andcommitted
[RPP][AI] Add error state for when generation failed and rename setting
video: http://screencast/cast/NTE5NTMyODgxMzc5MzI4MHw3NTMzNGFmNy1mNQ I think at this point we have so many button states that we should create an enum with states and track the current state. I started doing it, but realised it won't be super straightforward so let's refactor it later. Also changing the setting name. Bug: 405354265 Change-Id: I203e80d86ac6788949a813b5d2f91eb3c0e2cfb7 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6403233 Commit-Queue: Jack Franklin <[email protected]> Auto-Submit: Alina Varkki <[email protected]> Commit-Queue: Alina Varkki <[email protected]> Reviewed-by: Jack Franklin <[email protected]>
1 parent 77ba8df commit 49b2a98

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

front_end/panels/settings/AISettingsTab.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ describeWithEnvironment('AISettingsTab', () => {
9292

9393
const settingCards = view.shadowRoot.querySelectorAll('.setting-card h2');
9494
const settingNames = Array.from(settingCards).map(element => element.textContent);
95-
assert.deepEqual(settingNames, ['Console Insights', 'AI assistance', 'AI annotations']);
95+
assert.deepEqual(settingNames, ['Console Insights', 'AI assistance', 'Auto annotations']);
9696

9797
const settingCardDesc = view.shadowRoot.querySelectorAll('.setting-description');
9898
assert.strictEqual(settingCardDesc[0].textContent, 'Helps you understand and fix console warnings and errors');

front_end/panels/settings/AISettingsTab.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ export class AISettingsTab extends LegacyWrapper.LegacyWrapper.WrappableComponen
334334

335335
if (this.#aiAnnotationsSetting) {
336336
const aiAssistanceData: AiSettingParams = {
337-
settingName: i18n.i18n.lockedString('AI annotations'),
337+
settingName: i18n.i18n.lockedString('Auto annotations'),
338338
iconName: 'pen-spark',
339339
settingDescription: i18nString(UIStrings.getAIAnnotationsSuggestions),
340340
enableSettingText: i18nString(UIStrings.enableAiSuggestedAnnotations),

front_end/panels/timeline/overlays/components/EntryLabelOverlay.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ const UIStringsNotTranslate = {
9090
*@description Text shown when the AI-powered annotation is being generated.
9191
*/
9292
generatingLabel: 'Generating label',
93+
/**
94+
*@description Text shown when the generation of the AI-powered annotation failed.
95+
*/
96+
generationFailed: 'Generation failed',
9397
/**
9498
*@description First disclaimer item text for the fre dialog - AI won't always get it right.
9599
*/
@@ -191,6 +195,8 @@ export class EntryLabelOverlay extends HTMLElement {
191195
#inAIConsentDialogFlow = false;
192196
// Keep track of the AI label loading state to render a loading component if the label is being generated
193197
#isAILabelLoading = false;
198+
// Set to true when the generation of an AI label failed so we know when to display the 'generation failed' disclaimer
199+
#isAILabelGenerationFailed = false;
194200
/**
195201
* The entry label overlay consists of 3 parts - the label part with the label string inside,
196202
* the line connecting the label to the entry, and a black box around an entry to highlight the entry with a label.
@@ -518,7 +524,9 @@ export class EntryLabelOverlay extends HTMLElement {
518524
// Trigger a re-render to hide the AI Button and display the generated label.
519525
this.#render();
520526
} catch {
521-
// TODO(b/405354265): handle the error state
527+
this.#isAILabelLoading = false;
528+
this.#isAILabelGenerationFailed = true;
529+
void ComponentHelpers.ScheduledRender.scheduleRender(this, this.#boundRender);
522530
}
523531
} else {
524532
this.#isAILabelLoading = false;
@@ -657,6 +665,24 @@ export class EntryLabelOverlay extends HTMLElement {
657665
// clang-format on
658666
}
659667

668+
if (this.#isAILabelGenerationFailed) {
669+
// Only show the error message on the first component render render after the failure.
670+
this.#isAILabelGenerationFailed = false;
671+
// clang-format off
672+
return html`
673+
<span
674+
class="ai-label-error">
675+
<devtools-icon
676+
class="warning"
677+
.name=${'warning'}
678+
.data=${{
679+
iconName: 'warning', color: 'var(--ref-palette-error50)', width: '20px'}}>
680+
</devtools-icon>
681+
<span class="generate-label-text">${lockedString(UIStringsNotTranslate.generationFailed)}</span>
682+
</span>
683+
`;
684+
// clang-format on
685+
}
660686
// clang-format off
661687
return html`
662688
<!-- 'preventDefault' on the AI label button to prevent the label removal on blur -->

front_end/panels/timeline/overlays/components/entryLabelOverlay.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
.ai-label-button-wrapper,
2020
.ai-label-disabled-button-wrapper,
21-
.ai-label-loading {
21+
.ai-label-loading,
22+
.ai-label-error {
2223
/* position the button wrapper on the very right of the label */
2324
position: absolute;
2425
left: 100%;
@@ -49,7 +50,8 @@
4950
}
5051
}
5152

52-
.ai-label-loading {
53+
.ai-label-loading,
54+
.ai-label-error {
5355
gap: var(--sys-size-6);
5456
padding: var(--sys-size-5) var(--sys-size-8);
5557
}

front_end/ui/visual_logging/KnownContextValues.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,8 @@ export const knownContextValues = new Set([
673673
'caret-color',
674674
'category',
675675
'change',
676+
'change-workspace',
677+
'change-workspace-dialog',
676678
'changes',
677679
'changes.changes',
678680
'changes.copy',

0 commit comments

Comments
 (0)