Skip to content

Commit 205cd44

Browse files
Lightning00BladeDevtools-frontend LUCI CQ
authored andcommitted
[AI Assistance] Move conversation into single update
Bug: 399377071 Change-Id: I52e8551123d1195b4daf78a86d19afecc34396d7 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6304705 Reviewed-by: Samiya Caur <[email protected]> Commit-Queue: Nikolay Vitkov <[email protected]>
1 parent 34154dd commit 205cd44

File tree

5 files changed

+165
-147
lines changed

5 files changed

+165
-147
lines changed

front_end/panels/ai_assistance/AiAssistancePanel.test.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
445445
});
446446

447447
assert.deepEqual(updatedViewInputAfterNewChat.messages, []);
448-
assert.deepEqual(updatedViewInputAfterNewChat.agentType, AiAssistance.AgentType.STYLING);
448+
assert.deepEqual(updatedViewInputAfterNewChat.conversationType, AiAssistance.ConversationType.STYLING);
449449
});
450450

451451
it('should select the performance insights agent if it is enabled', async () => {
@@ -488,7 +488,8 @@ describeWithMockConnection('AI Assistance Panel', () => {
488488
});
489489

490490
assert.deepEqual(updatedViewInputAfterNewChat.messages, []);
491-
assert.deepEqual(updatedViewInputAfterNewChat.agentType, AiAssistance.AgentType.PERFORMANCE_INSIGHT);
491+
assert.deepEqual(
492+
updatedViewInputAfterNewChat.conversationType, AiAssistance.ConversationType.PERFORMANCE_INSIGHT);
492493
});
493494

494495
it('should select the Dr Jones performance agent if insights are not enabled', async () => {
@@ -531,7 +532,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
531532
});
532533

533534
assert.deepEqual(updatedViewInputAfterNewChat.messages, []);
534-
assert.deepEqual(updatedViewInputAfterNewChat.agentType, AiAssistance.AgentType.PERFORMANCE);
535+
assert.deepEqual(updatedViewInputAfterNewChat.conversationType, AiAssistance.ConversationType.PERFORMANCE);
535536
});
536537

537538
it('should switch agents and restore history', async () => {
@@ -666,7 +667,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
666667
updatedViewInputAfterMessage.onDeleteClick();
667668
});
668669
assert.deepEqual(updatedViewInputAfterDelete.messages, []);
669-
assert.isUndefined(updatedViewInputAfterDelete.agentType);
670+
assert.isUndefined(updatedViewInputAfterDelete.conversationType);
670671
});
671672

672673
it('should select default agent based on open panel after clearing the chat', async () => {
@@ -703,7 +704,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
703704
updatedViewInputAfterMessage.onDeleteClick();
704705
});
705706
assert.deepEqual(updatedViewInputAfterDelete.messages, []);
706-
assert.deepEqual(updatedViewInputAfterDelete.agentType, AiAssistance.AgentType.STYLING);
707+
assert.deepEqual(updatedViewInputAfterDelete.conversationType, AiAssistance.ConversationType.STYLING);
707708
});
708709

709710
it('should have empty state after clear chat history', async () => {
@@ -761,7 +762,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
761762
contextMenu.invokeHandler(clearAll.id());
762763
});
763764
assert.deepEqual(updatedViewInputAfterClearAll.messages, []);
764-
assert.isUndefined(updatedViewInputAfterClearAll.agentType);
765+
assert.isUndefined(updatedViewInputAfterClearAll.conversationType);
765766
contextMenu.discard();
766767

767768
contextMenu = getMenu(() => {
@@ -936,34 +937,34 @@ describeWithMockConnection('AI Assistance Panel', () => {
936937
describe('auto agent selection for panels', () => {
937938
const tests: Array<{
938939
panel: {new (...args: any[]): UI.Panel.Panel},
939-
expectedAgentType: AiAssistance.AgentType,
940+
expectedConversationType: AiAssistance.ConversationType,
940941
featureFlagName: string,
941942
}> =
942943
[
943944
{
944945
panel: Elements.ElementsPanel.ElementsPanel,
945-
expectedAgentType: AiAssistance.AgentType.STYLING,
946+
expectedConversationType: AiAssistance.ConversationType.STYLING,
946947
featureFlagName: 'devToolsFreestyler',
947948
},
948949
{
949950
panel: Network.NetworkPanel.NetworkPanel,
950-
expectedAgentType: AiAssistance.AgentType.NETWORK,
951+
expectedConversationType: AiAssistance.ConversationType.NETWORK,
951952
featureFlagName: 'devToolsAiAssistanceNetworkAgent',
952953
},
953954
{
954955
panel: Sources.SourcesPanel.SourcesPanel,
955-
expectedAgentType: AiAssistance.AgentType.FILE,
956+
expectedConversationType: AiAssistance.ConversationType.FILE,
956957
featureFlagName: 'devToolsAiAssistanceFileAgent',
957958
},
958959
{
959960
panel: Timeline.TimelinePanel.TimelinePanel,
960-
expectedAgentType: AiAssistance.AgentType.PERFORMANCE,
961+
expectedConversationType: AiAssistance.ConversationType.PERFORMANCE,
961962
featureFlagName: 'devToolsAiAssistancePerformanceAgent',
962963
}
963964
];
964965

965966
for (const test of tests) {
966-
it(`should select ${test.expectedAgentType} conversation when the panel ${test.panel.name} is opened`,
967+
it(`should select ${test.expectedConversationType} conversation when the panel ${test.panel.name} is opened`,
967968
async () => {
968969
updateHostConfig({
969970
[test.featureFlagName]: {
@@ -976,7 +977,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
976977
aidaClient: mockAidaClient([[{explanation: 'test'}]]),
977978
});
978979

979-
assert.strictEqual(initialViewInput.agentType, test.expectedAgentType);
980+
assert.strictEqual(initialViewInput.conversationType, test.expectedConversationType);
980981
});
981982

982983
it(`should reset the conversation when ${test.panel.name} is closed and no other panels are open`, async () => {
@@ -990,12 +991,12 @@ describeWithMockConnection('AI Assistance Panel', () => {
990991

991992
const {initialViewInput, expectViewUpdate} = await createAiAssistancePanel();
992993

993-
assert.strictEqual(initialViewInput.agentType, test.expectedAgentType);
994+
assert.strictEqual(initialViewInput.conversationType, test.expectedConversationType);
994995

995996
const updatedViewInput = await expectViewUpdate(() => {
996997
UI.Context.Context.instance().setFlavor(test.panel, null);
997998
});
998-
assert.isUndefined(updatedViewInput.agentType);
999+
assert.isUndefined(updatedViewInput.conversationType);
9991000
});
10001001

10011002
it(`should render no conversation state if the ${
@@ -1009,7 +1010,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
10091010
UI.Context.Context.instance().setFlavor(test.panel, sinon.createStubInstance(test.panel));
10101011
const {initialViewInput} = await createAiAssistancePanel();
10111012

1012-
assert.isUndefined(initialViewInput.agentType);
1013+
assert.isUndefined(initialViewInput.conversationType);
10131014
});
10141015
}
10151016

@@ -1026,7 +1027,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
10261027
Timeline.TimelinePanel.TimelinePanel, sinon.createStubInstance(Timeline.TimelinePanel.TimelinePanel));
10271028
const {initialViewInput} = await createAiAssistancePanel();
10281029

1029-
assert.strictEqual(initialViewInput.agentType, AiAssistance.AgentType.PERFORMANCE_INSIGHT);
1030+
assert.strictEqual(initialViewInput.conversationType, AiAssistance.ConversationType.PERFORMANCE_INSIGHT);
10301031
});
10311032
});
10321033
});

0 commit comments

Comments
 (0)