Conversation
There was a problem hiding this comment.
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/:connectionIdto/widget/generate/:connectionId. - Removed
dashboardIdfrom the generate-widget input DS and removeddashboard_idfrom 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.
| @Post('/widget/generate/:connectionId') | ||
| async generateWidgetWithAi( | ||
| @SlugUuid('connectionId') connectionId: string, |
There was a problem hiding this comment.
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.
| @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, |
| @Timeout(TimeoutDefaults.AI) | ||
| @Post('/dashboard/:dashboardId/widget/generate/:connectionId') | ||
| @Post('/widget/generate/:connectionId') | ||
| async generateWidgetWithAi( |
There was a problem hiding this comment.
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.
| @@ -13,9 +13,6 @@ export class GeneratedPanelPositionDto { | |||
|
|
|||
| @ApiProperty({ description: 'Panel height in grid units' }) | |||
| height: number; | |||
There was a problem hiding this comment.
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.
| height: number; | |
| height: number; | |
| @ApiPropertyOptional({ description: 'Dashboard ID this panel belongs to' }) | |
| dashboard_id?: string | null; |
No description provided.