Skip to content

feat(bridge): expose the in-flight automation action for external monitoring#503

Open
SoloGorilla wants to merge 2 commits into
ChiR24:devfrom
SoloGorilla:fix/b11-k2b-inflight-action
Open

feat(bridge): expose the in-flight automation action for external monitoring#503
SoloGorilla wants to merge 2 commits into
ChiR24:devfrom
SoloGorilla:fix/b11-k2b-inflight-action

Conversation

@SoloGorilla

Copy link
Copy Markdown
Contributor

What

Adds a thread-safe accessor, McpAutomationBridge::GetInFlightAction(), that reports which automation action ProcessAutomationRequest is currently executing.

Why

Automation handlers run synchronously on the game thread. If a handler blocks it (a modal, or a long synchronous editor op), external tooling — e.g. an off-thread watchdog — can detect that the game thread stalled, but has no way to know which tool caused it. This accessor closes that gap: it lets a stall be attributed to the specific in-flight action.

How

The action is stored in a namespace-scoped FString guarded by an FCriticalSection. It is set right before dispatch and cleared on every exit path (including early returns and exceptions). The lock is held only for the brief set/get, never during the handler, so a reader can observe the action off-thread even while a handler is blocking the game thread — which is exactly when attribution matters most.

The getter is exported (MCPAUTOMATIONBRIDGE_API) for cross-module use. No behavior changes for existing callers; the setter/getter are additive.

Verification

Built against UE 5.8 (Result: Succeeded, 0 errors) and smoke-tested live: an off-thread watchdog reading GetInFlightAction() correctly named the in-flight tool while a handler was deliberately blocking the game thread.

…itoring

Adds a thread-safe accessor, McpAutomationBridge::GetInFlightAction(), that reports which
automation action ProcessAutomationRequest is currently executing. It is set around the
handler dispatch and cleared on every exit path; the guarding lock is held only for the brief
set/get, never during the handler, so an external observer (e.g. an off-thread watchdog) can
read the in-flight action even while a handler blocks the game thread — which is exactly when
attribution is most useful (it lets a stall be blamed on the specific tool that caused it).

The getter is exported (MCPAUTOMATIONBRIDGE_API) for cross-module use; no behavior changes for
existing callers.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

No new commits to review since the last review.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1c286688-de8a-4acb-aff1-fec19e632bf6

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

This change adds a thread-safe in-flight automation action tracker in McpAutomationBridge and exposes it through GetInFlightAction(). ProcessAutomationRequest records the current action at start and clears it on every exit path.

Changes

In-flight Action Tracking

Layer / File(s) Summary
Tracker and lifecycle wiring
plugins/McpAutomationBridge/Source/McpAutomationBridge/Public/McpAutomationBridgeSubsystem.h, plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Core/Requests/McpAutomationBridge_ProcessRequest.cpp
Adds the exported GetInFlightAction() API plus the static tracker implementation, then sets the tracked action when request processing begins and clears it via ON_SCOPE_EXIT.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Poem

A bunny keeps one action in sight,
With a lock so tiny and neat and light.
It hops in, sets, then hops away,
And leaves the tracker empty at day’s end.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers What/Why/How/Verification, but it omits required template sections like Related Issues, Type of Change, and the checklist. Reformat it to the repo template and add Related Issues, Type of Change, explicit Testing items, and the Pre-Merge Checklist.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed Clear and specific; it accurately summarizes the new in-flight action accessor for external monitoring.
✨ 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: 1

🤖 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
`@plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Core/Requests/McpAutomationBridge_ProcessRequest.cpp`:
- Around line 12-31: `GetInFlightAction()` is only defined in the .cpp, so other
modules still can’t call it despite the export macro. Add a public declaration
for `McpAutomationBridge::GetInFlightAction()` in the appropriate header used by
external modules, and keep the existing `.cpp` definition in
`McpAutomationBridge_ProcessRequest` aligned with that declaration so
cross-module access works.
🪄 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: 35839912-70c1-4f9b-8733-4e6d62aa96df

📥 Commits

Reviewing files that changed from the base of the PR and between d49b158 and 340f1d4.

📒 Files selected for processing (1)
  • plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Core/Requests/McpAutomationBridge_ProcessRequest.cpp

Comment on lines +12 to +31
// Publish the currently-executing automation action so external tooling (e.g. an off-thread watchdog) can attribute
// a game-thread stall to the tool that was in flight. The lock is held ONLY for the brief set/get — never during
// the handler — so a reader can observe the action off-thread even while a handler blocks the game thread. The
// getter is exported so another module can link it.
namespace McpAutomationBridge
{
static FCriticalSection GInFlightActionCS;
static FString GInFlightAction;
static void SetInFlightAction(const FString& InAction)
{
FScopeLock Lock(&GInFlightActionCS);
GInFlightAction = InAction;
}
MCPAUTOMATIONBRIDGE_API FString GetInFlightAction()
{
FScopeLock Lock(&GInFlightActionCS);
return GInFlightAction;
}
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Check whether GetInFlightAction is declared in a header.
rg -n "GetInFlightAction" --type=cpp --type=h -g '*.h'

Repository: ChiR24/Unreal_mcp

Length of output: 155


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Files mentioning InFlightAction =="
rg -n "InFlightAction|GetInFlightAction|SetInFlightAction" .

echo
echo "== Relevant headers under the plugin =="
git ls-files 'plugins/McpAutomationBridge/**/*.h'

echo
echo "== Public API declarations for this symbol =="
rg -n "MCPAUTOMATIONBRIDGE_API.*GetInFlightAction|GetInFlightAction" plugins/McpAutomationBridge --glob '*.h'

echo
echo "== Current file context =="
sed -n '1,180p' plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Core/Requests/McpAutomationBridge_ProcessRequest.cpp

Repository: ChiR24/Unreal_mcp

Length of output: 27512


Expose GetInFlightAction() in a public header
MCPAUTOMATIONBRIDGE_API on the .cpp definition isn’t enough for other modules to call it; add a public declaration if cross-module access is intended.

🤖 Prompt for 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.

In
`@plugins/McpAutomationBridge/Source/McpAutomationBridge/Private/Core/Requests/McpAutomationBridge_ProcessRequest.cpp`
around lines 12 - 31, `GetInFlightAction()` is only defined in the .cpp, so
other modules still can’t call it despite the export macro. Add a public
declaration for `McpAutomationBridge::GetInFlightAction()` in the appropriate
header used by external modules, and keep the existing `.cpp` definition in
`McpAutomationBridge_ProcessRequest` aligned with that declaration so
cross-module access works.

Review follow-up: MCPAUTOMATIONBRIDGE_API on the .cpp definition alone
is not callable from other modules without a matching declaration.
Declare McpAutomationBridge::GetInFlightAction() in the public
McpAutomationBridgeSubsystem.h so external consumers link against it
without re-declaring the extern themselves.
@github-actions github-actions Bot added the size/s label Jul 6, 2026
@SoloGorilla

Copy link
Copy Markdown
Contributor Author

Addressed: GetInFlightAction() is now declared in the public McpAutomationBridgeSubsystem.h (next to the existing McpProcessRequestDispatch declaration), so external modules can call it without re-declaring the extern themselves. Verified in a UE 5.8 editor build with a second module (our watchdog) consuming the function through the header — compiles and links cleanly.

@SoloGorilla

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

1 participant