Skip to content

Remove dashboardId references from panel position generation and related tests#1640

Merged
Artuomka merged 2 commits intomainfrom
backend_remove_dashboard_id_from_generate_panel_position
Feb 27, 2026
Merged

Remove dashboardId references from panel position generation and related tests#1640
Artuomka merged 2 commits intomainfrom
backend_remove_dashboard_id_from_generate_panel_position

Conversation

@Artuomka
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings February 26, 2026 15:57
@Artuomka Artuomka enabled auto-merge February 26, 2026 15:58
@Artuomka Artuomka disabled auto-merge February 26, 2026 15:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR removes dashboardId coupling from the “generate widget with AI” flow by updating the API route, input data structure, and output DTO so AI-generated panel positioning is dashboard-agnostic, and aligns the SaaS e2e tests with the new contract.

Changes:

  • Changed the AI widget generation endpoint from /dashboard/:dashboardId/widget/generate/:connectionId to /widget/generate/:connectionId.
  • Removed dashboardId from the generate-widget input DS and removed dashboard_id from the generated panel position DTO/output mapping.
  • Updated SaaS e2e tests to hit the new endpoint and removed the obsolete “non-existent dashboard” test.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
backend/test/ava-tests/saas-tests/dashboard-ai-widget-e2e.test.ts Updates e2e tests for the new AI widget generation route and response shape.
backend/src/entities/visualizations/panel-position/use-cases/generate-table-dashboard-with-ai.use.case.ts Removes dashboard_id from generated (in-memory) panel position DTO objects.
backend/src/entities/visualizations/panel-position/use-cases/generate-panel-position-with-ai.use.case.ts Removes dashboard lookup/validation and stops returning dashboard_id in generated panel position.
backend/src/entities/visualizations/panel-position/panel-position.controller.ts Moves the AI generation endpoint out of the dashboard-scoped route and updates params accordingly.
backend/src/entities/visualizations/panel-position/dto/generated-panel-with-position.dto.ts Removes dashboard_id from GeneratedPanelPositionDto response contract.
backend/src/entities/visualizations/panel-position/data-structures/generate-panel-position-with-ai.ds.ts Removes dashboardId from the use-case input data structure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +170 to 172
@Post('/widget/generate/:connectionId')
async generateWidgetWithAi(
@SlugUuid('connectionId') connectionId: string,
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

The AI widget generation route was changed to POST /widget/generate/:connectionId, but PanelPositionModule.configure() still registers AuthMiddleware for the old path (/dashboard/:dashboardId/widget/generate/:connectionId). As a result, this endpoint may bypass AuthMiddleware and ConnectionEditGuard will likely crash because request.decoded is missing. Update the module's forRoutes list (or apply AuthMiddleware more broadly) to cover the new route.

Suggested change
@Post('/widget/generate/:connectionId')
async generateWidgetWithAi(
@SlugUuid('connectionId') connectionId: string,
@Post('/dashboard/:dashboardId/widget/generate/:connectionId')
async generateWidgetWithAi(
@SlugUuid('connectionId') connectionId: string,
@Param('dashboardId') dashboardId: string,

Copilot uses AI. Check for mistakes.
Comment on lines 169 to 171
@Timeout(TimeoutDefaults.AI)
@Post('/dashboard/:dashboardId/widget/generate/:connectionId')
@Post('/widget/generate/:connectionId')
async generateWidgetWithAi(
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

This endpoint path change is not reflected in existing consumers: frontend/src/app/services/dashboards.service.ts still calls /dashboard/${dashboardId}/widget/generate/${connectionId}. Without updating callers (or keeping a backwards-compatible alias route), the frontend will break at runtime. Please update the client(s) or add a deprecated route that forwards to the new handler.

Copilot uses AI. Check for mistakes.
@@ -13,9 +13,6 @@ export class GeneratedPanelPositionDto {

@ApiProperty({ description: 'Panel height in grid units' })
height: number;
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

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

Removing dashboard_id from GeneratedPanelPositionDto changes the response contract for generateWidgetWithAi. The frontend model GeneratedPanelWithPosition.panel_position.dashboard_id (see frontend/src/app/models/saved-query.ts) will no longer match the API and can cause type/runtime issues. Update downstream DTOs/models accordingly, or keep dashboard_id (possibly as optional) until consumers are migrated.

Suggested change
height: number;
height: number;
@ApiPropertyOptional({ description: 'Dashboard ID this panel belongs to' })
dashboard_id?: string | null;

Copilot uses AI. Check for mistakes.
@Artuomka Artuomka enabled auto-merge February 27, 2026 07:59
@Artuomka Artuomka merged commit 2064027 into main Feb 27, 2026
17 of 19 checks passed
@Artuomka Artuomka deleted the backend_remove_dashboard_id_from_generate_panel_position branch February 27, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants