Skip to content

Commit fc61ee5

Browse files
OrKoNDevtools-frontend LUCI CQ
authored andcommitted
[AI Assistance] test patch
Bug: 393268664 Change-Id: Ice7a96a004fc066aafe3e7671198056737337a0b Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6281386 Reviewed-by: Ergün Erdoğmuş <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
1 parent 815ca4b commit fc61ee5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

front_end/panels/ai_assistance/AiAssistancePanel.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,11 @@ export class AiAssistancePanel extends UI.Panel.Panel {
550550
if (isAiAssistancePatchingEnabled()) {
551551
this.#workspace.addEventListener(Workspace.Workspace.Events.ProjectAdded, this.#onProjectAddedOrRemoved, this);
552552
this.#workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this.#onProjectAddedOrRemoved, this);
553+
554+
// @ts-expect-error temporary global function for local testing.
555+
window.aiAssistanceTestPatchPrompt = async (changeSummary: string) => {
556+
return await this.#applyPatch(changeSummary);
557+
};
553558
}
554559
}
555560

@@ -1029,6 +1034,16 @@ export class AiAssistancePanel extends UI.Panel.Panel {
10291034
if (!changeSummary) {
10301035
throw new Error('Change summary does not exist');
10311036
}
1037+
1038+
this.#patchSuggestionLoading = true;
1039+
this.requestUpdate();
1040+
const response = await this.#applyPatch(changeSummary);
1041+
this.#patchSuggestion = response?.type === ResponseType.ANSWER ? response.text : 'Could not update files';
1042+
this.#patchSuggestionLoading = false;
1043+
this.requestUpdate();
1044+
}
1045+
1046+
async #applyPatch(changeSummary: string): Promise<ResponseData|undefined> {
10321047
if (!this.#project) {
10331048
throw new Error('Project does not exist');
10341049
}
@@ -1037,13 +1052,8 @@ export class AiAssistancePanel extends UI.Panel.Panel {
10371052
serverSideLoggingEnabled: this.#serverSideLoggingEnabled,
10381053
project: this.#project,
10391054
});
1040-
this.#patchSuggestionLoading = true;
1041-
this.requestUpdate();
10421055
const responses = await Array.fromAsync(agent.applyChanges(changeSummary));
1043-
const response = responses.at(-1);
1044-
this.#patchSuggestion = response?.type === ResponseType.ANSWER ? response.text : 'Could not update files';
1045-
this.#patchSuggestionLoading = false;
1046-
this.requestUpdate();
1056+
return responses.at(-1);
10471057
}
10481058

10491059
async *

0 commit comments

Comments
 (0)