Issue 3551315: add enum option labels to AI context

Summary

  • Add internal enum option resolver + prop metadata normalizer to expose enum_options (label/value pairs) from enum + meta:enum, with x-translation-context support.
  • Wire normalizer into Canvas AI component context for SDC + JS components; JS path pulls meta:enum from component metadata because propSources strips it.
  • Unit coverage for resolver behavior (map/list meta:enum, fallbacks, cache context when translating).

Evidence

  • Example excerpt from getComponentContextForAi output:
    image_position:
      enum_options: [{ label: 'Image on right', value: 'hg:md:flex-row' }, { label: 'Image on left', value: 'hg:md:flex-row-reverse' }]
  • Intent test PASS (AI Explorer): final answer includes “Image on left”; tool payload uses enum value hg:md:flex-row-reverse (stored value).

Tests

  1. ddev xb-phpcs (pass; deprecation warning about SlevomatCodingStandard include config)
  2. ddev xb-phpunit tests/src/Unit/Component/Schema/PropChoiceOptionsResolverTest.php (pass)
  3. ddev xb-phpunit tests/src/Functional/BlockComponentFormTest.php (fails: expected size 0, got 1; known issue 3570699; not addressed here)
  4. ddev exec -- drush ev '\Drupal::service("account_switcher")->switchTo(\Drupal\user\Entity\User::load(1)); $h=\Drupal::service("canvas_ai.page_builder_helper"); print $h->getComponentContextForAi();' > /Users/scott/dev/drupal-contrib/canvas-dev/test_outputs/get_component_context.yaml (warns missing astro-hydration assets)
  5. python3 /Users/scott/.codex/skills/drupal-intent-testing/scripts/intent_test.py /Users/scott/dev/drupal-contrib/worktrees/canvas/issue-3551315-people-friendly-labels/.intent/issue_3551315.yaml --output-dir /Users/scott/dev/drupal-contrib/canvas-dev/test_outputs/intent_3551315_run4 (verdict PASS)

AI disclosure

Drafted with AI assistance; reviewed and tested by a human.

Merge request reports

Loading