Skip to content

Commit 5e628fd

Browse files
Kateryna ProkopenkoDevtools-frontend LUCI CQ
authored andcommitted
Align thinking pill with greenlines when walkthrough is closed
Bug: 496838810 Change-Id: I071c82693e8210c65306f17cb7811a65a7f4f918 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7736551 Auto-Submit: Kateryna Prokopenko <kprokopenko@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org> Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
1 parent 155667f commit 5e628fd

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

front_end/panels/ai_assistance/components/ChatMessage.test.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,72 @@ describeWithEnvironment('ChatMessage', () => {
344344
assert.strictEqual(button.innerText, 'Investigating XYZ');
345345
});
346346

347+
it('accessible label appends "Show thinking" when showing step title', async () => {
348+
const loadingMessage: AiAssistance.ChatMessage.ModelChatMessage = {
349+
entity: AiAssistance.ChatMessage.ChatMessageEntity.MODEL,
350+
parts: [{
351+
type: 'step',
352+
step: {
353+
isLoading: true,
354+
title: 'Investigating XYZ',
355+
code: 'console.log("test")',
356+
},
357+
}],
358+
rpcId: 99,
359+
};
360+
const target = renderView({
361+
isLoading: true,
362+
message: loadingMessage,
363+
walkthrough: {
364+
...DEFAULT_WALKTHROUGH,
365+
isInlined: false,
366+
}
367+
});
368+
const button = querySelectorErrorOnMissing(target, '[data-show-walkthrough]');
369+
assert.strictEqual(button.getAttribute('accessibleLabel'), 'Investigating XYZ Show thinking');
370+
});
371+
372+
it('accessible label appends "Show thinking" when showing paused state', async () => {
373+
const pausedMessage: AiAssistance.ChatMessage.ModelChatMessage = {
374+
entity: AiAssistance.ChatMessage.ChatMessageEntity.MODEL,
375+
parts: [{
376+
type: 'step',
377+
step: {
378+
isLoading: false,
379+
title: 'Set background color to red',
380+
requestApproval: {
381+
description: 'Confirm!',
382+
onAnswer: () => {},
383+
},
384+
},
385+
}],
386+
rpcId: 99,
387+
};
388+
const target = renderView({
389+
isLoading: false,
390+
message: pausedMessage,
391+
walkthrough: {
392+
...DEFAULT_WALKTHROUGH,
393+
isInlined: false,
394+
}
395+
});
396+
const button = querySelectorErrorOnMissing(target, '[data-show-walkthrough]');
397+
assert.strictEqual(button.getAttribute('accessibleLabel'), 'Set background color to red Show thinking');
398+
});
399+
400+
it('accessible label defaults to visible text when generic', async () => {
401+
const target = renderView({
402+
isLoading: false,
403+
message: stepMessage,
404+
walkthrough: {
405+
...DEFAULT_WALKTHROUGH,
406+
isInlined: false,
407+
}
408+
});
409+
const button = querySelectorErrorOnMissing(target, '[data-show-walkthrough]');
410+
assert.strictEqual(button.getAttribute('accessibleLabel'), 'Show thinking');
411+
});
412+
347413
it('does not render "Show thinking" button when inline', () => {
348414
const target = renderView({
349415
message: stepMessage,

front_end/panels/ai_assistance/components/ChatMessage.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ const UIStringsNotTranslate = {
204204
* @description Title for the bottom up thread activity widget.
205205
*/
206206
bottomUpTree: 'Bottom-up thread activity',
207+
/**
208+
* @description Accessilility label for the button that shows the walkthrough when there are no widgets in the walkthrough.
209+
*/
210+
showThinking: 'Show thinking',
207211
} as const;
208212

209213
export interface Step {
@@ -571,6 +575,14 @@ function renderWalkthroughSidebarButton(
571575
// We only apply the widget styling when loading is complete
572576
'has-widgets': hasOneStepWithWidget && !input.isLoading,
573577
});
578+
579+
let accessibleLabel = title;
580+
if (!isExpanded) {
581+
if (input.isLoading || lastStep.requestApproval) {
582+
accessibleLabel = `${titleForStep(lastStep)} ${i18n.i18n.lockedString(UIStringsNotTranslate.showThinking)}`;
583+
}
584+
}
585+
574586
// clang-format off
575587
return html`
576588
<div class=${toggleContainerClasses}>
@@ -581,6 +593,7 @@ function renderWalkthroughSidebarButton(
581593
.variant=${variant}
582594
.size=${Buttons.Button.Size.SMALL}
583595
.title=${lastStep.isLoading ? titleForStep(lastStep) : title}
596+
.accessibleLabel=${accessibleLabel}
584597
.jslogContext=${walkthrough.isExpanded ? 'ai-hide-walkthrough-sidebar' : 'ai-show-walkthrough-sidebar'}
585598
data-show-walkthrough
586599
@click=${() => {

0 commit comments

Comments
 (0)