Skip to content

Commit 5692e5e

Browse files
Samiya CaurDevtools-frontend LUCI CQ
authored andcommitted
Allow multiline completion in Console
Also add a temporary fix for b/441221870 by prepending a newline for each prefix. Fixed: 441912057 Change-Id: Ic20f1df8388fd1df5630e0e07e20be503a7742fb Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6895839 Auto-Submit: Samiya Caur <samiyac@chromium.org> Commit-Queue: Ergün Erdoğmuş <ergunsh@chromium.org> Reviewed-by: Ergün Erdoğmuş <ergunsh@chromium.org>
1 parent ff0f155 commit 5692e5e

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

front_end/models/ai_code_completion/AiCodeCompletion.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describeWithEnvironment('AiCodeCompletion', () => {
4747
sinon.assert.calledOnce(mockAidaClient.completeCode);
4848
const request = mockAidaClient.completeCode.firstCall.args[0];
4949
assert.strictEqual(request.client, 'CHROME_DEVTOOLS');
50-
assert.strictEqual(request.prefix, 'prefix');
50+
assert.strictEqual(request.prefix, '\nprefix');
5151
assert.strictEqual(request.suffix, 'suffix');
5252
assert.deepEqual(request.options, {
5353
temperature: 0.5,
@@ -133,7 +133,7 @@ describeWithEnvironment('AiCodeCompletion', () => {
133133

134134
await clock.tickAsync(AiCodeCompletion.AIDA_REQUEST_DEBOUNCE_TIMEOUT_MS + 1);
135135
sinon.assert.calledOnce(mockAidaClient.completeCode);
136-
assert.strictEqual(mockAidaClient.completeCode.firstCall.args[0].prefix, 'pre');
136+
assert.strictEqual(mockAidaClient.completeCode.firstCall.args[0].prefix, '\npre');
137137
});
138138

139139
it('does not dispatch suggestion or citation if recitation action is BLOCK', async () => {

front_end/models/ai_code_completion/AiCodeCompletion.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ export class AiCodeCompletion extends Common.ObjectWrapper.ObjectWrapper<EventTy
172172
function validTemperature(temperature: number|undefined): number|undefined {
173173
return typeof temperature === 'number' && temperature >= 0 ? temperature : undefined;
174174
}
175+
// As a temporary fix for b/441221870 we are prepending a newline for each prefix.
176+
prefix = '\n' + prefix;
175177

176178
const additionalFiles = this.#panel === Panel.CONSOLE ? [{
177179
path: 'devtools-console-context.js',

front_end/panels/console/ConsolePrompt.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,8 @@ export class ConsolePrompt extends Common.ObjectWrapper.eventMixin<EventTypes, t
512512
this.detachAiCodeCompletionTeaser();
513513
this.teaser = undefined;
514514
}
515-
// We are prioritizing single line suggestions in Console panel to reduce noise.
516515
this.aiCodeCompletion = new AiCodeCompletion.AiCodeCompletion.AiCodeCompletion(
517-
{aidaClient: this.aidaClient}, this.editor, AiCodeCompletion.AiCodeCompletion.Panel.CONSOLE, ['\n']);
516+
{aidaClient: this.aidaClient}, this.editor, AiCodeCompletion.AiCodeCompletion.Panel.CONSOLE);
518517
this.aiCodeCompletion.addEventListener(AiCodeCompletion.AiCodeCompletion.Events.RESPONSE_RECEIVED, event => {
519518
this.aiCodeCompletionCitations = event.data.citations;
520519
this.dispatchEventToListeners(Events.AI_CODE_COMPLETION_RESPONSE_RECEIVED, event.data);

0 commit comments

Comments
 (0)