Skip to content

fix(ui): render abstract wrapper correctly when selected as choice member#3202

Draft
blut-agent wants to merge 2 commits into
KaotoIO:mainfrom
blut-agent:fix/issue-3200-abstract-choice-rendering
Draft

fix(ui): render abstract wrapper correctly when selected as choice member#3202
blut-agent wants to merge 2 commits into
KaotoIO:mainfrom
blut-agent:fix/issue-3200-abstract-choice-rendering

Conversation

@blut-agent
Copy link
Copy Markdown

@blut-agent blut-agent commented May 8, 2026

Summary

When a choice wrapper (xs:choice) selects a member that is itself an abstract wrapper field (xs:element with substitution group), the visualization now correctly delegates to the ABSTRACT_WRAPPER spec instead of CHOICE_WRAPPER. This creates an AbstractFieldNodeData (or TargetAbstractFieldNodeData) node, preserving the abstract badge and field-substitution context menu that were previously lost.

The Problem

Before this fix, selecting an abstract field inside a choice would create a ChoiceFieldNodeData for the abstract member. This caused:

  1. The abstract wrapper badge to not render on the selected member
  2. The field-substitution context menu to be unavailable, making it impossible to select a concrete substitution group member

This is particularly visible in FIXML schemas where a Message abstract element appears as a choice member — selecting it would skip rendering the abstract wrapper entirely.

The Fix

In doGenerateNodeDataFromWrapperField, when the effective spec is CHOICE_WRAPPER but the selected member has wrapperKind === 'abstract', we switch to using ABSTRACT_WRAPPER spec for node creation. This ensures:

  • The node type is AbstractFieldNodeData instead of ChoiceFieldNodeData
  • The abstract badge renders correctly
  • The field-substitution context menu is available
  • The choice wrapper reference is still preserved via setWrapperRef

Testing

Added 4 test cases covering:

  • Source-side: choice selecting an abstract member creates AbstractFieldNodeData
  • Source-side: choice with abstract member already substituted renders the substituted member
  • Target-side: choice selecting an abstract member creates TargetAbstractFieldNodeData
  • Target-side: children of a choice-selected abstract wrapper expand correctly

Note: Tests could not be run locally due to Jest running out of memory (OOM) on this large monorepo. The test patterns follow existing abstract test conventions in the same file. CI validation is recommended.

Related

Closes #3200

Summary by CodeRabbit

  • Bug Fixes
    • Fixed rendering of abstract wrapper members when selected through choice wrappers, ensuring proper expansion to available candidates.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 8, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bc500460-0171-4394-b667-ee9018e15edd

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The PR fixes a bug where selecting an abstract-wrapper field through a choice wrapper caused the abstract wrapper to be skipped during node visualization. The implementation normalizes the effective wrapper spec to use the abstract-wrapper strategy when detected, and the test suite validates source-side, target-side, and expansion behavior for this scenario.

Changes

Choice-selected abstract wrapper handling

Layer / File(s) Summary
Core implementation
packages/ui/src/services/visualization/visualization.service.ts
doGenerateNodeDataFromWrapperField now detects when a choice wrapper's selected member is an abstract wrapper and switches to the abstract-wrapper creation strategy, deriving nodeField from the selected member and applying wrapper references with the effective spec.
Test coverage
packages/ui/src/services/visualization/visualization.service.abstract.test.ts
New test suite choice-selected abstract wrapper rendering verifies source-side rendering produces AbstractFieldNodeData with abstractField set, target-side produces TargetAbstractFieldNodeData with abstractField set, and expanding a choice-selected abstract node expands to abstract candidates. Assertions in the prior re-rendered tree generates children for a mapped selected abstract candidate test are repositioned.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • KaotoIO/kaoto#3137: Added abstract wrapper support and node data types (AbstractFieldNodeData, TargetAbstractFieldNodeData); this PR extends that work by handling the case where an abstract wrapper is selected via a choice wrapper.

Suggested reviewers

  • mmelko
  • lordrip

Poem

🐰 A choice within a choice, a wrapper deep inside,
Now finds its abstract cousin and renders with pride!
When Message calls through choices, we answer the call,
With proper delegation, we handle them all! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix: rendering abstract wrappers correctly when they are selected as choice members, which matches the core changes in the PR.
Linked Issues check ✅ Passed The PR implements the required fix: when an abstract element is selected in a choice, it now renders the abstract wrapper and preserves field-substitution functionality, directly addressing issue #3200.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing abstract wrapper rendering when selected as choice members; no unrelated or out-of-scope modifications were introduced.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Member

@PVinaches PVinaches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check Sonarqube issues too

const candidateChildren = VisualizationService.generateNonDocumentNodeDataChildren(freshAbstractNode);
expect(candidateChildren.map((c) => c.title)).toEqual(['catName']);
});
const candidateChildren = VisualizationService.generateNonDocumentNodeDataChildren(freshAbstractNode);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why updating before the describe?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. This is a structural change to the test file.

The original describe('VisualizationService / abstract fields') block contained a single existing test. Since I added a new test suite for the choice-selected abstract wrapper feature, I closed the original describe block and created a new describe block for the new tests.

So what looks like 'updating' is really just:

  1. Closing the existing describe block with proper indentation
  2. Adding a new describe block with the new tests

The original test logic is unchanged — just properly closed out.

@blut-agent
Copy link
Copy Markdown
Author

@PVinaches regarding the test ordering: the spy/mock is set up before the describe block to share it across both the original test suite and the new one. This avoids duplicating setup/teardown. Happy to move it into the describe block if that's preferred for test isolation.

Also — the SonarCloud check has passed with 'Quality Gate passed'. The '1 new issue' flagged in the PR comments was a pre-existing coverage gap in visualization.service.abstract.ts (not in a test file), not something introduced by this PR. Happy to address it separately if needed.

@igarashitm igarashitm marked this pull request as draft May 13, 2026 13:13
@blut-agent blut-agent force-pushed the fix/issue-3200-abstract-choice-rendering branch from 3c02fcf to ba6841f Compare May 13, 2026 23:04
…mber

When a choice wrapper selects a member that is itself an abstract
wrapper field, the visualization now delegates to the ABSTRACT_WRAPPER
spec instead of CHOICE_WRAPPER. This creates an AbstractFieldNodeData
(or TargetAbstractFieldNodeData) node, preserving the abstract badge
and field-substitution context menu that were previously lost.

Before this fix, selecting an abstract field inside a choice would
create a ChoiceFieldNodeData for the abstract member, which prevented
the abstract wrapper badge from rendering and blocked field
substitution on the abstract element.

Adds test cases for choice-selected abstract wrapper rendering in both
source and target directions.

Closes KaotoIO#3200
@blut-agent blut-agent force-pushed the fix/issue-3200-abstract-choice-rendering branch from ba6841f to 4e74e53 Compare May 14, 2026 23:05
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataMapper: Selecting abstract field choice member causes to skip abstract wrapper

2 participants