Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ <h1 class="mat-h1">{{ isEditMode() ? 'Edit panel' : 'Create panel' }}</h1>

@if (!loading()) {
<div class="chart-edit-content">
@if (aiDashboardId()) {
<div class="ai-section" [class.ai-section--collapsed]="!aiExpanded()">
<div class="ai-section-header" (click)="aiExpanded.set(!aiExpanded())">
<div class="ai-section-title">
Expand Down Expand Up @@ -62,7 +61,6 @@ <h1 class="mat-h1">{{ isEditMode() ? 'Edit panel' : 'Create panel' }}</h1>
</div>
}
</div>
}

<!-- Chart preview (always visible when data exists) -->
@if (showResults()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export class ChartEditComponent implements OnInit {
// AI generation
protected aiDescription = signal('');
protected aiGenerating = signal(false);
protected aiDashboardId = signal<string | null>(null);
protected aiExpanded = signal(true);
protected manualExpanded = signal(false);
protected canGenerate = computed(() => !!this.aiDescription().trim() && !this.aiGenerating());
Expand Down Expand Up @@ -383,14 +382,6 @@ export class ChartEditComponent implements OnInit {
const pageTitle = this.isEditMode() ? 'Edit Query' : 'Create Query';
this.title.setTitle(`${pageTitle} | ${title || 'Rocketadmin'}`);
});

// Watch for dashboards to become available for AI feature
effect(() => {
const dashboards = this._dashboards.dashboards();
if (dashboards.length > 0 && !this.aiDashboardId()) {
this.aiDashboardId.set(dashboards[0].id);
}
});
}

ngOnInit(): void {
Expand Down Expand Up @@ -638,13 +629,12 @@ export class ChartEditComponent implements OnInit {
}

async generateWithAi(): Promise<void> {
const dashboardId = this.aiDashboardId();
if (!dashboardId || !this.aiDescription().trim()) return;
if (!this.aiDescription().trim()) return;

this.aiGenerating.set(true);

try {
const result = await this._dashboards.generateWidgetWithAi(dashboardId, this.connectionId(), {
const result = await this._dashboards.generateWidgetWithAi(this.connectionId(), {
Comment on lines 631 to +637
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that AI widget generation no longer depends on a dashboardId (and the aiDashboardId state/effect was removed), the component still calls _loadAiPrerequisites() on init which sets DashboardsService.setActiveConnection() and triggers an unnecessary /dashboards/{connectionId} fetch. Consider removing _loadAiPrerequisites() (and its ngOnInit call) or updating it to only run when the dashboards list is actually needed; also update the stale inline comment that references an effect that no longer exists.

Copilot uses AI. Check for mistakes.
chart_description: this.aiDescription(),
});

Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/models/saved-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,5 @@ export interface GeneratedPanelWithPosition {
position_y: number;
width: number;
height: number;
dashboard_id: string;
};
}
6 changes: 1 addition & 5 deletions frontend/src/app/services/dashboards.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,10 @@ export class DashboardsService {
}

async generateWidgetWithAi(
dashboardId: string,
connectionId: string,
payload: { chart_description: string; name?: string },
): Promise<GeneratedPanelWithPosition | null> {
return this._api.post<GeneratedPanelWithPosition>(
`/dashboard/${dashboardId}/widget/generate/${connectionId}`,
payload,
);
return this._api.post<GeneratedPanelWithPosition>(`/widget/generate/${connectionId}`, payload);
}

async deleteWidget(connectionId: string, dashboardId: string, widgetId: string): Promise<DashboardWidget | null> {
Expand Down
Loading