Skip to content

Commit 6714cbc

Browse files
Piotr PaulskiDevtools-frontend LUCI CQ
authored andcommitted
Fix AI Assistance panel not updating state after move to top/bottom
When moved, panel is being hidden and shown in new location. Event about other panels being revealed and or hidden as a result of the move are sent in between. Ai Assistance panel is unsubscribed from the events while hidden, so it is needed to force update when it is shown again. Fixed: 434160934 Change-Id: I3521b5e414e4ef944fdb06af3d219930069c14b0 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6812254 Auto-Submit: Piotr Paulski <piotrpaulski@chromium.org> Reviewed-by: Ergün Erdoğmuş <ergunsh@chromium.org> Commit-Queue: Ergün Erdoğmuş <ergunsh@chromium.org>
1 parent 073bdfe commit 6714cbc

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

front_end/panels/ai_assistance/AiAssistancePanel.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,25 @@ describeWithMockConnection('AI Assistance Panel', () => {
12531253
});
12541254
}
12551255

1256+
it('should refresh its state when moved', async () => {
1257+
updateHostConfig({
1258+
devToolsFreestyler: {
1259+
enabled: true,
1260+
},
1261+
});
1262+
viewManagerIsViewVisibleStub.callsFake(viewName => viewName === 'elements');
1263+
const {panel, view} = await createAiAssistancePanel();
1264+
1265+
assert.strictEqual(view.input.conversationType, AiAssistanceModel.ConversationType.STYLING);
1266+
1267+
// Simulate ViewManager.moveView() that hides panel, updates locations and other panel visibility, then shows moved view
1268+
panel.willHide();
1269+
viewManagerIsViewVisibleStub.callsFake(viewName => viewName === 'console');
1270+
panel.wasShown();
1271+
1272+
assert.isUndefined((await view.nextInput).conversationType);
1273+
});
1274+
12561275
describe('Performance Insight agent', () => {
12571276
it('should select the PERFORMANCE_INSIGHT agent when the performance panel is open and insights are enabled and an insight is expanded',
12581277
async () => {

front_end/panels/ai_assistance/AiAssistancePanel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
743743
UI.Context.Context.instance().addFlavorChangeListener(
744744
TimelinePanel.TimelinePanel.TimelinePanel, this.#bindTimelineTraceListener, this);
745745
this.#bindTimelineTraceListener();
746+
this.#selectDefaultAgentIfNeeded();
746747

747748
Host.userMetrics.actionTaken(Host.UserMetrics.Action.AiAssistancePanelOpened);
748749
}

0 commit comments

Comments
 (0)