remote-components: component generation reads the dead providers.presets settings section
Summary
Generating or refining a remote component fails with "No AI provider configured. Add a provider in AI Power Ups settings." on any project whose AI was configured through the current settings UI — while that UI plainly shows a working connection and model.
Both use cases read settings.providers.presets[0], and that settings section is legacy. packages/ai-powerups/src/api/features/Connections/legacyProviders.ts states it outright:
providersbundled a credential with a single model. Nothing writes it any more, but an upgraded project still has one and has never saved since, so bothConnectionsandModelRolesderive their first value from it.
So it holds data only for a project that was configured before the connections/roles split and has not saved since. A project configured today has providers.presets: [] permanently, and every reader of it is broken.
Affected
packages/remote-components/src/api/features/generateComponent/GenerateRemoteComponentUseCase.ts:40packages/remote-components/src/api/features/refineComponent/RefineRemoteComponentUseCase.ts:40
Both then decrypt firstProvider.apiKeyEncrypted and derive the SDK name with firstProvider.model.split("/")[0].
Reproduction
On a project with aiPowerups enabled and no pre-existing legacy provider (i.e. anything configured after the connections/roles split):
- Admin → Settings → AI Power-Ups → Connections: add a connection (e.g. Anthropic) with a valid API key.
- Model roles: set
standardandvisionto a model on that connection. - Confirm the settings took:
query { aiPowerUps { getSettings } }shows a populatedconnections.presetsandmodelRoles.roles, and an emptyproviders.presets. - Website Builder → Components → generate a component from a prompt.
Expected: the component is generated on the configured model.
Actual: No AI provider configured. Add a provider in AI Power Ups settings.
Same for refining an existing component.
Anything else still reading providers.presets[0] fails identically; a grep for it across packages/ finds the offenders.
Cause
ResolveAiCapabilityUseCase was introduced as the single place that answers "which model runs this feature", and its own docblock records that it replaced six use cases each reading providers.presets[0]. These two were not migrated with the rest.
Fix
Register an AiCapability beside the feature and resolve through ResolveAiCapabilityUseCase, which applies the precedence rules (pinned model → chosen role → the capability's default role → standard), validates the model against its connection's vendor, and decrypts the key at call time. The capability also gives the feature a row in Settings → AI Power-Ups so it can be pointed at a different model without code.
vision is the right default role for both: they accept reference images via additionalFileIds, which is the normal way to use them.
Because the extension is unregistered entirely when AI Power-Ups is off, the resolver must be taken as [ResolveAiCapabilityUseCase, { optional: true }] and its absence reported.
Note that AiCapability and ResolveAiCapabilityUseCase were not exported from the ai-powerups api barrel, so nothing outside the package could use either; exporting them is part of the fix.
Existing implementation
A working fix for both use cases exists on claude/theme-app in commit 4d6a31e0a8, alongside the equivalent fix for two extraction features on that branch. The remote-components half is self-contained and can be reviewed or cherry-picked on its own:
packages/remote-components/src/api/features/shared/capability.ts(new)- the two use cases above
packages/remote-components/src/api/features/generateComponent/feature.ts(registers the capability)packages/ai-powerups/src/exports/api/ai-powerups.tsandpackages/webiny/src/api/ai-powerups.ts(exports)
Filed separately from that branch because this is a shipped-module bug that affects any project, not part of the work it was found in.
Source: webiny/webiny-js