Add validation support for connections drivers#11582
Conversation
|
E2E Tests 🚀 |
Update generateCode to return {valid, code, errorMessage} for validation.
When project ID is empty, the Connect button is disabled and shows a red
border on the code editor to indicate an error state.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Display validation errors at the bottom of the code editor as an overlay with a grow-up animation. Removed previous box-shadow approach in favor of an absolutely positioned message element. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace { valid: boolean; code: string; errorMessage?: string } with
string | { code: string; errorMessage: string }. A string return indicates
valid code, while the object form indicates validation failure with an error
message. This removes the redundant valid field.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Prevents long error messages from breaking the layout by truncating with ellipsis. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use vscode.l10n.t() for all user-facing error messages. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f7dc530 to
25df4ab
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds validation support for connection drivers, enabling drivers to return validation errors that are displayed inline in the connection modal dialog with an animated error overlay. The implementation extends the generateCode method to optionally return an object containing both code and an error message, which triggers visual feedback and disables the Connect button.
Changes:
- Extended the
generateCodeinterface to support returning validation errors alongside code - Updated UI to display validation errors with an animated overlay and disable the Connect button when errors are present
- Implemented validation for BigQuery drivers to check for required Project ID field
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/services/positronConnections/common/interfaces/positronConnectionsDriver.ts |
Updated generateCode return type to support error messages |
src/vs/workbench/contrib/positronConnections/browser/components/newConnectionModalDialog/createConnectionState.tsx |
Added state management for validation errors, updated button styling and disabled state |
src/vs/workbench/contrib/positronConnections/browser/components/newConnectionModalDialog/createConnectionState.css |
Added error message styling with animation and adjusted footer button layout |
src/vs/workbench/api/common/positron/extHost.positron.protocol.ts |
Updated protocol interface for validation support |
src/positron-dts/positron.d.ts |
Updated public API type definitions |
extensions/positron-connections/src/drivers/bigquery.ts |
Implemented validation for Project ID in both BigQuery drivers |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Daniel Falbel <dfalbel@gmail.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
dhruvisompura
left a comment
There was a problem hiding this comment.
I had a few comments about the code but the changes work as described!
The animation to show the error message is really slick. You could consider adding a similar transition when the error message disappears.
...ib/positronConnections/browser/components/newConnectionModalDialog/createConnectionState.tsx
Outdated
Show resolved
Hide resolved
...ib/positronConnections/browser/components/newConnectionModalDialog/createConnectionState.tsx
Outdated
Show resolved
Hide resolved
...ib/positronConnections/browser/components/newConnectionModalDialog/createConnectionState.tsx
Outdated
Show resolved
Hide resolved
...ib/positronConnections/browser/components/newConnectionModalDialog/createConnectionState.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Dhruvi Sompura <dhruvi.sompura@posit.co> Signed-off-by: Daniel Falbel <dfalbel@gmail.com>
The MainThreadDriverAdapter was using getters for generateCode, connect, etc. which created new function references on every access. This caused React's useEffect to re-run continuously since generateCode was in its dependency array. Changed to create stable function references once in the constructor. Also fixed Form component to: - Pass inputs state instead of metadata.inputs - Use immutable updates instead of mutating input objects Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace keyframe animation with CSS transitions so the error banner animates both on entry and exit. The element is now always in the DOM but hidden via transform/opacity, allowing CSS transitions to handle both directions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
dhruvisompura
left a comment
There was a problem hiding this comment.
This is looking amazing! 🚀
I have one very small nit left but feel free to merge this once that is resolved. It shouldn't need a re-review!
| const editorOptions = useMemo(() => ({ | ||
| const editorOptions: IEditorOptions = { | ||
| readOnly: true, | ||
| cursorBlinking: 'solid' as const |
There was a problem hiding this comment.
small nit: I don't think you need the as const here anymore now that this is typed!
Summary
Adds connection validation support, allowing drivers to return validation errors that are displayed inline in the connection modal with an animated error overlay.
Release Notes
New Features
Bug Fixes
QA Notes
@:connections