Skip to content

feat: AI Selector Widget#1505

Draft
olexii4 wants to merge 2 commits intomainfrom
AI_widget
Draft

feat: AI Selector Widget#1505
olexii4 wants to merge 2 commits intomainfrom
AI_widget

Conversation

@olexii4
Copy link
Copy Markdown
Contributor

@olexii4 olexii4 commented Mar 30, 2026

What does this PR do?

Adds an AI Selector widget to the Create Workspace page, allowing users to pick an AI provider (Google Gemini or Anthropic Claude) and save their API key directly from the dashboard UI.

The widget mirrors the existing Editor Selector design (PatternFly Panel + Accordion + Gallery of provider Cards). Once a user saves an API key, the dashboard stores it as a Kubernetes Opaque Secret in the user's namespace with DevWorkspace Controller auto-mount labels (controller.devfile.io/mount-to-devworkspace: 'true', controller.devfile.io/mount-as: env). The DevWorkspace Controller then automatically injects the key as an environment variable (e.g. GEMINI_API_KEY, ANTHROPIC_API_KEY) into every workspace container — no DevWorkspace spec patching needed.

Changes by layer:

  • packages/commonAiProviderDefinition interface; IServerConfig extended with aiProviders and defaultAiProvider
  • packages/dashboard-backendAiProviderKeyApiService (Kubernetes Secret CRUD using CoreV1API); four new Fastify routes under /dashboard/api/ai-config and /dashboard/api/namespace/:namespace/ai-provider-key; ServerConfigApiService reads aiProviders from CheCluster CR; serverConfig route exposes them
  • packages/dashboard-frontendAiSelector React class component (Panel + Accordion + AiProviderGallery + AiApiKeyField + DocsLink); AiConfig Redux slice (actions, reducer, selectors); aiConfigApi Axios client; GetStarted page renders AiSelector between Editor Selector and Import form; ImportFromGit and SamplesList append ai-provider URL parameter for analytics; AI_PROVIDER_ATTR added to buildFactoryParams

Screenshot/screencast of this PR

Знімок екрана 2026-03-30 о 06 36 18

What issues does this PR fix or reference?

Is it tested? How?

Release Notes

Docs PR

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Mar 30, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Mar 30, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: olexii4

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@che-bot
Copy link
Copy Markdown
Contributor

che-bot commented Mar 30, 2026

Click here to review and test in web IDE: Contribute

@olexii4 olexii4 force-pushed the AI_widget branch 3 times, most recently from 147736e to dd23665 Compare March 30, 2026 01:15
@olexii4 olexii4 force-pushed the AI_widget branch 4 times, most recently from e40ac01 to 6633c64 Compare March 30, 2026 03:15
@github-actions
Copy link
Copy Markdown

Docker image build succeeded: quay.io/eclipse/che-dashboard:pr-1505 (linux/amd64, linux/arm64)

kubectl patch command
kubectl patch -n eclipse-che "checluster/eclipse-che" --type=json -p="[{"op": "replace", "path": "/spec/components/dashboard/deployment", "value": {containers: [{image: "quay.io/eclipse/che-dashboard:pr-1505", name: che-dashboard}]}}]"

Adds an AI Selector widget on the Create Workspace page and
an AI Provider Keys tab in User Preferences for managing
API keys — the same pattern as Personal Access Tokens and
SSH Keys tabs.

AI Selector (Create Workspace):
- Panel+Accordion+Gallery mirroring the Editor Selector
- Saves API key as Kubernetes Secret with DevWorkspace
  Controller auto-mount labels; key becomes an env var
  in all workspace containers without spec patching
- Detects manually-created secrets (demo-repo pattern)
  by matching envVarName data key in mounted secrets

AI Provider Keys tab (User Preferences):
- Add / Update / Delete API keys per configured provider
- Full CRUD modal flow following SshKeys tab pattern
- Empty state when no providers configured or no keys stored

Also fixes:
- AiProviderEntry card onClick restored so Gemini/Claude
  cards respond to user clicks in the Create Workspace widget
- createOrReplace: flat existence-check replaces fragile
  nested try/catch with string-matching re-throw
- handleToggle: early-return on already-active accordion item
- Unsafe as casts replaced with typed selectors
- minLength:1 enforced on apiKey body schema
- Tests: AiApiKeyField, AiProviderEntry, AiSelector null render

Assisted-by: Claude Sonnet 4.5
Signed-off-by: Oleksii Orel <oorel@redhat.com>
@olexii4 olexii4 force-pushed the AI_widget branch 2 times, most recently from 1d13918 to 7a2dae5 Compare March 30, 2026 04:52
Adds an AI Selector widget on the Create Workspace page and
an AI Provider Keys tab in User Preferences for managing
API keys — following the same pattern as SSH Keys tab.

AI Selector (Create Workspace):
- Panel+Accordion+Gallery for selecting the AI provider
- Cards show provider name, description, and a "Key configured"
  badge if a key exists; no key input on cards
- "Manage API keys in User Preferences" link inside the gallery
- Detects manually-created secrets (demo-repo pattern) by
  matching envVarName data key in mounted DevWorkspace secrets

AI Provider Keys tab (User Preferences /user-preferences?tab=AiProviderKeys):
- Add / Update / Delete API keys per configured provider
- Full CRUD modal flow following the SshKeys tab pattern
- Empty state when no providers configured or no keys stored

Backend:
- AiProviderKeyApiService with DevWorkspace Controller
  auto-mount labels (controller.devfile.io/mount-to-devworkspace)
- /api/ai-config and /api/namespace/:ns/ai-provider-key routes
- Dual-source key detection: labeled secrets + envVarName key

Also fixes:
- AiProviderEntry onClick restored for card body clicks
- createOrReplace: flat existence-check pattern
- Unsafe as casts replaced with typed selectors
- minLength:1 enforced on apiKey body schema

Assisted-by: Claude Sonnet 4.5
Signed-off-by: Oleksii Orel <oorel@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants