Skip to content

Commit 4ca1a2c

Browse files
Samiya CaurDevtools-frontend LUCI CQ
authored andcommitted
[AiAssistance] Mark existing conversation as readonly before starting new one
Bug: 397184236 Change-Id: Iac114261f57546fa91c646fad9cadc81127eb5cb Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6276246 Reviewed-by: Alex Rudenko <[email protected]> Auto-Submit: Samiya Caur <[email protected]> Commit-Queue: Samiya Caur <[email protected]>
1 parent a2b4cda commit 4ca1a2c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

front_end/panels/ai_assistance/AiAssistancePanel.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ describeWithMockConnection('AI Assistance Panel', () => {
604604
await expectViewUpdate(() => {
605605
contextMenu.invokeHandler(freestylerEntry.id());
606606
});
607+
assert.isTrue(view.lastCall.args[0].isReadOnly);
607608
// Currently history should not store image input
608609
assert.deepEqual(view.lastCall.args[0].messages, [
609610
{

front_end/panels/ai_assistance/AiAssistancePanel.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,7 @@ export class AiAssistancePanel extends UI.Panel.Panel {
463463
this.#messages = [];
464464
this.#isLoading = false;
465465
this.#currentAgent = agent;
466+
this.#currentConversation?.archiveConversation();
466467
if (this.#currentAgent?.type) {
467468
this.#currentConversation =
468469
new Conversation(agentTypeToConversationType(this.#currentAgent.type), [], agent?.id, false);

front_end/panels/ai_assistance/AiHistoryStorage.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@ export class Conversation {
2929
readonly id: string;
3030
readonly history: ResponseData[];
3131
readonly type: ConversationType;
32-
readonly isReadOnly: boolean;
32+
#isReadOnly: boolean;
3333

3434
constructor(type: ConversationType, data: ResponseData[] = [], id: string = crypto.randomUUID(), isReadOnly = true) {
3535
this.type = type;
3636
this.history = data;
3737
this.id = id;
38-
this.isReadOnly = isReadOnly;
38+
this.#isReadOnly = isReadOnly;
39+
}
40+
41+
get isReadOnly(): boolean {
42+
return this.#isReadOnly;
3943
}
4044

4145
get title(): string|undefined {
@@ -51,6 +55,10 @@ export class Conversation {
5155
return this.history.length === 0;
5256
}
5357

58+
archiveConversation(): void {
59+
this.#isReadOnly = true;
60+
}
61+
5462
addHistoryItem(item: ResponseData): void {
5563
if (item.type === ResponseType.USER_QUERY) {
5664
const historyItem = {...item, imageInput: undefined};

0 commit comments

Comments
 (0)