Add AI auto-configure route for new connections#1632
Conversation
Redirect users to /auto-configure/:connection-id after adding a connection, where the frontend calls GET /api/ai/v2/setup/:connection-id to trigger AI-based dashboard configuration. Remove the backend fire-and-forget AI scan from connection creation so configuration is driven by the frontend route. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the AI-based dashboard auto-configuration workflow to be frontend-driven rather than backend fire-and-forget. After a user creates a new database connection, they are now redirected to a dedicated /auto-configure/:connection-id route where the frontend explicitly calls the AI setup endpoint. This provides better user experience through visible loading states and error handling, replacing the previous approach where AI configuration happened silently in the background after connection creation.
Changes:
- Redirects users to a new auto-configure route after successful connection creation
- Adds a new
AutoConfigureComponentthat displays loading state while AI configures the database and handles errors gracefully - Removes the backend fire-and-forget AI scan from the connection creation flow, simplifying the backend logic
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/app/components/connect-db/connect-db.component.ts | Updated navigation to redirect to /auto-configure/:connection-id instead of /dashboard/:connection-id for non-agent connections |
| frontend/src/app/components/auto-configure/auto-configure.component.ts | New standalone component that triggers AI setup via API call and handles success/error states |
| frontend/src/app/components/auto-configure/auto-configure.component.html | Template displaying loading spinner during configuration and error message with fallback navigation |
| frontend/src/app/components/auto-configure/auto-configure.component.css | Styling for centered loading and error states using flexbox layout |
| frontend/src/app/app-routing.module.ts | Added route configuration for auto-configure component with auth guard protection |
| backend/src/entities/connection/use-cases/create-connection.use.case.ts | Removed fire-and-forget AI scan logic, unused imports (Sentry, Encryptor, SharedJobsService), and simplified connection creation flow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private async _configure(connectionId: string): Promise<void> { | ||
| const result = await this._api.get<string>(`/ai/v2/setup/${connectionId}`, { responseType: 'text' }); | ||
|
|
||
| if (result !== null) { | ||
| this._router.navigate([`/dashboard/${connectionId}`]); | ||
| } else { | ||
| this.loading.set(false); | ||
| this.errorMessage.set('Auto-configuration could not be completed. You can still configure your tables manually.'); | ||
| } |
There was a problem hiding this comment.
The error handling logic assumes that a null result always indicates an error, but the API service returns null for any error (including network errors, 401 unauthorized, 404 not found, etc.). This makes it impossible to distinguish between different types of failures or provide more specific error messages to users. Consider checking the specific error type or HTTP status code to provide more contextual error messages, especially for cases like permission denied or connection not found.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Redirect users to /auto-configure/:connection-id after adding a connection, where the frontend calls GET /api/ai/v2/setup/:connection-id to trigger AI-based dashboard configuration. Remove the backend fire-and-forget AI scan from connection creation so configuration is driven by the frontend route.