fix: #3612553 Fix page_edit's stale component classifier and add a provider fallback to AiAssistant
Imports two verified fixes found during a live functional pass over all 29 AI Agent tools this module ships (see the Initialize issue context: https://www.drupal.org/project/varbase_ai_figma/issues/3612553).
Problem/Motivation
CanvasPageEdit'spage_edittool (add/swapactions) could not place any vartheme_bs5 theme SDC component ("Unknown component" for e.g.card-icon), even though a full page build viacreate_canvas_pagecould. Itsclassify()/buildInputs()/declaredProps()were a stale copy ofCreateCanvasPage's pre-SDC-support logic.AiAssistant::ask()/askJson()(backingimprove_text,alt_text,meta_description,translate_page,ab_variants) resolved a single AI provider and returned an empty result on any failure, with no fallback. A site whose primary default provider is unhealthy (expired key, outage) fails all 5 tools even when another configured provider is healthy.
Proposed resolution
- Ported
CreateCanvasPage's SDC-aware branch (sdc.id lookup +findSdcComponentId()bare-leaf-name lookup againstComponentconfig entities withsource: sdc) intoCanvasPageEdit::classify(), and the matchingprop_field_definitions-based branches intobuildInputs()/declaredProps(). - Refactored
AiAssistant::resolveDefault()intoresolveCandidates()(every configured default provider, de-duplicated, in priority order) soask()/askJson()try every candidate before giving up.
Both reproduced and re-verified against a live site.
AI-Generated: Yes (implementation drafted and verified with Claude Code).
Checkpoints
- File an issue about this project
- Addition/Change/Update/Fix to this project
- Testing to ensure no regression
- Automated unit/functional testing coverage
- Developer Documentation support on feature change/addition
- User Guide Documentation support on feature change/addition
- UX/UI designer responsibilities
- Accessibility and Readability
- Reviewed by a human
- Code review by maintainers
- Full testing and approval
- Credit contributors
- Review with the product owner
- Update Release Notes
- Release in MRs
Edited by Rajab Natshah