Repository navigation
fix(remote-components): resolve the model through an AI capability - #5805
Conversation
Component generation and refinement still read the model from settings.providers.presets[0], the path #5691 replaced with connections, model roles and capabilities. The `as any` on the settings kept the compiler from saying so. It kept working only for projects configured before #5691, because the legacy providers section still round-trips through storage; a project set up the new way got "No AI provider configured" with a model configured. Both use cases now resolve wb.generateComponent through ResolveAiCapabilityUseCase, the way the admin assistant and entry generation do. That also puts component generation on the model roles screen, so a project can choose its model and append instructions like any other AI feature, and the connection and API key come resolved instead of being decrypted here. One capability covers generate and refine. They do the same job against the same output contract, and two settings rows would only invite them to drift. It declares no guidance: each use case builds its own prompt and passes it to withAdditionalInstructions. The default role is standard, matching entry generation, which also takes optional image attachments. The resolver is an optional dependency, as the ai-powerups extension asks of external callers, since nothing in AI Power-Ups is registered when it is off. The use cases say so instead of failing at DI resolution. A resolver failure is passed through unchanged because it already names the setting to fix. Tests cover the model and connection coming from the capability, the project's instructions reaching the system prompt, resolver failures passing through, and the AI Power-Ups-absent path, for both use cases. The prompt test was checked by reverting the composed prompt and watching it fail. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
🚓 Slop Cop ✅ Nothing worth flagging. The diff looks consistent with the PR's stated intent and the code-style rules. Focused, coherent PR: switches two use cases from the legacy settings shape to the new AI capability resolver, matching the stated fix; no footprint mismatch, no secrets/debug leftovers, and no style-rule violations found in the added/changed lines. Automated, non-blocking heads-up from an LLM. It can be wrong — use your judgment. Regenerates on every push. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review. 📝 WalkthroughWalkthroughThe extension registers a component-generation AI capability. The generation and refinement use cases resolve that capability for their model and connection, and include capability instructions in their prompts. Tests cover successful resolution and cases where the resolver is unavailable or returns an error. ChangesRemote component AI
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant Remote component use case
participant ResolveAiCapabilityUseCase
participant AI
Remote component use case->>ResolveAiCapabilityUseCase: resolve REMOTE_COMPONENT_CAPABILITY
ResolveAiCapabilityUseCase-->>Remote component use case: model, connection, and additional instructions
Remote component use case->>AI: send prompt with resolved model and connection
Merge Risk: ⚪ Minimal · up to Component generation and refinement use the configured capability, with a defined response when AI Power-Ups is disabled. No issue identified here prevents merging after normal checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change moves credential selection behind configuration checks rather than adding a caller-selected credential. Component content can now go to a different configured model. Authorization and file ownership could not be fully verified, so the risk is not assessed as minimal. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Hardening Proposals
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Problem
Component generation and refinement read their model from
settings.providers.presets[0], which is the settings shape #5691 replaced with connections, model roles and capabilities. Theas anyon the settings object is why the compiler never flagged it.The feature kept working only for projects configured before #5691, because the legacy
providerssection still round-trips through storage. A project set up the new way got "No AI provider configured" even with a model configured.Change
Both use cases now resolve a new
wb.generateComponentcapability throughResolveAiCapabilityUseCase, the same way the admin assistant and entry generation do. That brings three things:Some choices a reviewer may want to question:
parseGeneratedSourcereads. Two settings rows would only let them drift apart.guidance. Each use case builds its own prompt and passes it towithAdditionalInstructions, the same approach entry generation uses.standard. This matches entry generation, which also takes optional image attachments. Writing working component code is where small models struggle.Testing
packages/remote-components/__tests__/componentCapability.test.tshas six tests. They cover the model and connection coming from the capability, the project's instructions reaching the system prompt, resolver failures passing through, and the path with AI Power-Ups off, for both generate and refine. The fake AI returns a response the parser accepts, so a request assertion can't pass while the use case fails afterwards.adioare clean. 16 tests pass in the package.Not verified in a browser. Remote components aren't mounted in the monorepo's local
webiny.config.tsx: the project never renders<RemoteComponents />, and itsremoteComponents: truesits at the top level instead of underaiPowerups, where the schema ignores it. That config is unrelated to this change and I left it alone.Workspace: wby-next1 · ✨ AI CHAT
🤖 Generated with Claude Code
Summary by CodeRabbit