Skip to content

feat: support component-bound events in add_event handler#483

Merged
ChiR24 merged 4 commits into
ChiR24:devfrom
mhsm555:feat/component-bound-event-add-event
Jul 7, 2026
Merged

feat: support component-bound events in add_event handler#483
ChiR24 merged 4 commits into
ChiR24:devfrom
mhsm555:feat/component-bound-event-add-event

Conversation

@mhsm555

@mhsm555 mhsm555 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

add_event previously had no path for K2Node_ComponentBoundEvent, so callers asking to wire a component's multicast delegate (e.g. MyCollider.OnComponentBeginOverlap) fell through to the custom-event branch and got an unbound Event_<guid> that never fired. This PR adds a dedicated branch that creates a properly initialized component-bound event node, so per-component overlap / hit / value-changed delegates can be authored over MCP.

Changes

  • Added a component-bound-event branch in HandleBlueprintAddEvent, triggered when the payload supplies componentName plus a delegate eventName (or sets nodeType/eventType to K2Node_ComponentBoundEvent / ComponentBoundEvent).
  • Resolves the SCS component by name and locates the multicast delegate property on its class — accepts both the bare delegate name (OnComponentBeginOverlap) and the engine's generated __DelegateSignature form.
  • Creates a UK2Node_ComponentBoundEvent with ComponentPropertyName, DelegatePropertyName, and DelegateOwnerClass set, so the bound event actually fires on broadcast.
  • Idempotent: a second call for the same component + delegate reuses the existing node instead of duplicating it.
  • Returns clear, distinct error codes for missing or unresolvable inputs: INVALID_ARGUMENT, COMPONENT_NOT_FOUND, COMPONENT_CLASS_UNRESOLVED, DELEGATE_NOT_FOUND.
  • Header include uses the same __has_include fallback pattern already applied to K2Node_DynamicCast / K2Node_CreateWidget, plus an MCP_HAS_K2NODE_COMPONENTBOUNDEVENT guard so the file still compiles cleanly on engine layouts where the header isn't reachable through any of the tried include paths.
  • Added an Added entry under [Unreleased] in CHANGELOG.md; also cleaned up two stray merge labels (fix/dynamiccast-target-class, dev) that were sitting in the changelog as plain text.

Related Issues

Type of Change

  • ✨ New feature (non-breaking change that adds functionality)

Testing

  • Tested with Unreal Engine (version: 5.5)
  • Tested MCP client integration (client: Claude)
  • Added/updated tests

Pre-Merge Checklist

  • Code follows project style guidelines
  • Self-reviewed the code
  • Updated relevant documentation (CHANGELOG entry under [Unreleased])
  • Added/updated tests (if applicable)
  • CI passes

@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: a2c2b568-5717-4c99-971c-63a4596c4343

📥 Commits

Reviewing files that changed from the base of the PR and between 77dbe79 and 770ebfc.

📒 Files selected for processing (1)
  • CHANGELOG.md
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added support for automation “add_event” requests that create component-bound events, using component and event inputs with stronger validation, idempotent reuse of existing bindings, and improved error codes/messages when inputs can’t be resolved.
  • Documentation

    • Updated the [Unreleased] changelog entry to document the new component-bound event behavior and refreshed the prior add_event-related notes.

Walkthrough

Adds a guarded component-bound event path in HandleBlueprintAddEvent, including component and delegate resolution, idempotent UK2Node_ComponentBoundEvent creation or reuse, and a NOT_AVAILABLE path when the node type is unavailable. The changelog now documents the new add_event behavior and error cases.

Changes

Component-Bound Event Handling in add_event

Layer / File(s) Summary
Conditional header inclusion and compile flag
plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/Blueprint/Events/McpAutomationBridge_BlueprintHandlersAddEvent.cpp
Adds __has_include-guarded inclusion of K2Node_ComponentBoundEvent.h across multiple Unreal Engine header layouts and defines the MCP_HAS_K2NODE_COMPONENTBOUNDEVENT compile-time macro.
Component-bound event resolution and node creation
plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/Blueprint/Events/McpAutomationBridge_BlueprintHandlersAddEvent.cpp
Adds the component-bound event branch inside HandleBlueprintAddEvent: detects the request via componentName/eventName and node-type hints, validates inputs, locates the SCS component, resolves the multicast delegate property, idempotently creates or reuses a UK2Node_ComponentBoundEvent node, sets binding and position fields, compiles and saves the blueprint, and emits a NOT_AVAILABLE error when the node type is unavailable.
Changelog entry for add_event support
CHANGELOG.md
Replaces the unreleased changelog entry with documentation for component-bound add_event support and its error handling.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • ChiR24/Unreal_mcp#454: Also creates or reuses UK2Node_ComponentBoundEvent nodes by resolving a component's multicast delegate.

Suggested reviewers: ChiR24

Poem

🐰 I hopped through nodes with careful grace,
A bound event found its proper place.
A delegate named, a component sought,
And changelog lines recorded what was wrought.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding component-bound event support to add_event.
Description check ✅ Passed The description matches the template and covers summary, changes, type, testing, and checklist with concrete details.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Around line 22-28: The CHANGELOG.md file contains unresolved git merge
conflict markers (<<<<<<< Updated upstream, =======, and >>>>>>> Stashed
changes) between lines 22-28 that must be removed before shipping. Resolve this
conflict by reviewing both versions separated by the markers, deciding which
changelog entries to keep or combining them if both are valuable, then remove
all three conflict markers along with the separator lines so the changelog
contains only the final resolved content without any git markers.

In
`@plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/Blueprint/Events/McpAutomationBridge_BlueprintHandlersAddEvent.cpp`:
- Around line 175-179: The bIsComponentBoundRequest detection in
McpAutomationBridge_BlueprintHandlersAddEvent.cpp currently requires
ComponentName to be non-empty, allowing explicit ComponentBoundEvent hints
without a componentName to bypass validation and fall into incorrect branches.
Refactor the logic to first detect explicit component-bound intent by checking
if NodeTypeLower or EventTypeLower contains "componentboundevent" as a separate
condition that indicates component-bound intent regardless of ComponentName
presence, then separately validate that required fields like ComponentName and
event names are provided, returning INVALID_ARGUMENT when they are missing
instead of allowing the request to proceed into unrelated event handling
branches.
- Around line 181-299: When MCP_HAS_K2NODE_COMPONENTBOUNDEVENT is 0,
component-bound event requests currently fall through to non-component logic
without notifying the caller that the feature is unavailable. Add an explicit
else branch after the endif for MCP_HAS_K2NODE_COMPONENTBOUNDEVENT that checks
if bIsComponentBoundRequest is true, and if so, calls Bridge.SendAutomationError
with a clear message indicating that component-bound event handling is not
available in this build configuration, using TEXT("FEATURE_NOT_AVAILABLE") as
the error code. This ensures that when the component-bound feature is compiled
out, callers receive an explicit failure message instead of misleading behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 95adc9a6-58b2-4bc7-bf88-792330d23172

📥 Commits

Reviewing files that changed from the base of the PR and between e1ceb64 and e033a78.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Domains/Blueprint/Events/McpAutomationBridge_BlueprintHandlersAddEvent.cpp

Comment thread CHANGELOG.md Outdated
mhsm555 added 2 commits June 18, 2026 00:29
- resolve CHANGELOG stash-pop conflict; scope the Unreleased entry to
  this PR (component-bound events) and drop the leftover Fixed bullets
  that belong to other PRs
- detect an explicit ComponentBoundEvent hint (nodeType/eventType)
  independently of field presence, and validate componentName and
  eventName separately inside the branch, so an explicit request with a
  missing field returns INVALID_ARGUMENT instead of silently becoming a
  dead custom event
- add an #else NOT_AVAILABLE path: when MCP_HAS_K2NODE_COMPONENTBOUNDEVENT
  is 0, a component-bound request now errors clearly instead of falling
  through to the custom-event branch
@github-actions github-actions Bot added size/l and removed size/m labels Jun 29, 2026
@ChiR24
ChiR24 merged commit 265f272 into ChiR24:dev Jul 7, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants