Skip to content

Commit ed5f8a3

Browse files
OrKoNDevtools-frontend LUCI CQ
authored andcommitted
[AI Assistance] Fix temporary project selection
Bug: 393268664 Change-Id: Iea93f795fe2a2d61596c239ebce94369c5a331dc Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6286327 Reviewed-by: Simon Zünd <[email protected]> Commit-Queue: Alex Rudenko <[email protected]>
1 parent 5550f7b commit ed5f8a3

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

front_end/models/persistence/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ devtools_entrypoint("bundle") {
6161
":*",
6262
"../../core/sdk:unittests",
6363
"../../entrypoints/main/*",
64+
"../../panels/ai_assistance/*",
6465
"../../panels/network/*",
6566
"../../panels/recorder/*",
6667
"../../panels/snippets/*",

front_end/panels/ai_assistance/AiAssistancePanel.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import type * as Platform from '../../core/platform/platform.js';
1111
import * as Root from '../../core/root/root.js';
1212
import * as SDK from '../../core/sdk/sdk.js';
1313
import * as Protocol from '../../generated/protocol.js';
14+
import * as Persistence from '../../models/persistence/persistence.js';
1415
import * as Workspace from '../../models/workspace/workspace.js';
1516
import * as Buttons from '../../ui/components/buttons/buttons.js';
1617
import * as UI from '../../ui/legacy/legacy.js';
@@ -351,13 +352,21 @@ export class AiAssistancePanel extends UI.Panel.Panel {
351352

352353
#selectProject(): void {
353354
if (isAiAssistancePatchingEnabled()) {
354-
// TODO: this is temporary code that should be replaced with workflow selection flow.
355-
// For now it picks the first Workspace project that is not Snippets.
356-
const projects =
357-
Workspace.Workspace.WorkspaceImpl.instance().projectsForType(Workspace.Workspace.projectTypes.FileSystem);
355+
// TODO: this is temporary code that should be replaced with
356+
// workflow selection flow. For now it picks the first Workspace
357+
// project that is not Snippets.
358+
const projects = this.#workspace.projectsForType(Workspace.Workspace.projectTypes.FileSystem);
358359
this.#project = undefined;
359360
for (const project of projects) {
360-
if (project.displayName().trim() === '') {
361+
// This is for TypeScript to narrow the types. projectsForType()
362+
// probably only returns instances of
363+
// Persistence.FileSystemWorkspaceBinding.FileSystem.
364+
if (!(project instanceof Persistence.FileSystemWorkspaceBinding.FileSystem)) {
365+
continue;
366+
}
367+
// Workspace projects do not have a type. Only snippets and
368+
// overrides do.
369+
if (project.fileSystem().type()) {
361370
continue;
362371
}
363372
this.#project = project;

front_end/panels/ai_assistance/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ devtools_module("ai_assistance") {
4747
"../../core/root:bundle",
4848
"../../models/bindings:bundle",
4949
"../../models/logs:bundle",
50+
"../../models/persistence:bundle",
5051
"../../models/text_utils:bundle",
5152
"../../models/trace:bundle",
5253
"../../models/workspace:bundle",

0 commit comments

Comments
 (0)