Skip to content

45641 Display ran_custom_mdm_command activities in host and global activity feeds#47897

Open
andymFleet wants to merge 18 commits into
mainfrom
45641-mdm-command-activity-feed-ui
Open

45641 Display ran_custom_mdm_command activities in host and global activity feeds#47897
andymFleet wants to merge 18 commits into
mainfrom
45641-mdm-command-activity-feed-ui

Conversation

@andymFleet

@andymFleet andymFleet commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Related issue: Resolves #45641

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information. In other subtask.

Testing

  • Added/updated automated tests

  • QA'd all new/changed functionality manually

Summary by CodeRabbit

Release Notes

  • New Features
    • Added support for tracking and displaying “ran custom MDM command” activities across dashboard and host activity feeds.
    • Added custom MDM command detail modals with status-aware messaging, actor attribution, target host, and relative “time ago” updates.
    • Improved command name rendering by shortening long request types for cleaner display.
  • Bug Fixes
    • Enhanced command status handling for additional Apple and Windows status formats so icons and verbs display correctly.
  • Tests
    • Added coverage for custom MDM command rendering and command-status helper behavior.

Copilot AI review requested due to automatic review settings June 19, 2026 09:49
@andymFleet andymFleet requested review from a team as code owners June 19, 2026 09:49

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Copilot AI 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.

Warning

  • Copilot's review of this pull request may be incomplete because some of the changed files are excluded by your Copilot content exclusion settings. See Excluding content from Copilot for details.

Pull request overview

This PR adds a new ran_custom_mdm_command activity type on the backend when a custom MDM command is enqueued, and updates the frontend to render these activities in both host and global activity feeds (including a details modal backed by the command results API).

Changes:

  • Backend: create ran_custom_mdm_command activities for successfully enqueued hosts (skipping enqueue failures).
  • Frontend: display the new activity type in host/global feeds and show command-results details in a modal.
  • Tests: add unit + integration coverage to ensure activities are created and rendered as expected.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
server/service/mdm.go Logs ran_custom_mdm_command activities after successful enqueue; skips failed UUIDs.
server/service/mdm_test.go Adds unit tests for activity creation and skipping failed hosts.
server/service/integration_mdm_test.go Extends integration test to assert the new activity payload.
server/fleet/activities.go Defines new ActivityTypeRanCustomMDMCommand activity details.
frontend/interfaces/activity.ts Adds RanCustomMdmCommand to enums/types and request_type to details.
frontend/utilities/helpers.tsx Adds formatting helpers for displaying MDM command request types in activity copy.
frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx Adds host activity “show details” handling + command results modal copy for this activity.
frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx Wires the new activity type to its host activity item component.
frontend/pages/hosts/details/cards/Activity/ActivityItems/RanCustomMdmCommandActivityItem/RanCustomMdmCommandActivityItem.tsx New host activity item rendering for custom MDM commands.
frontend/pages/hosts/details/cards/Activity/ActivityItems/RanCustomMdmCommandActivityItem/index.ts Barrel export for the new activity item.
frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx Adds global-feed rendering for ran_custom_mdm_command.
frontend/pages/DashboardPage/cards/ActivityFeed/ActivityFeed.tsx Adds global activity “show details” handling + modal copy for this activity.
frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx Extends status icon mapping (Apple + Windows) and exports a status-to-verb helper.
frontend/pages/hosts/components/CommandDetailsModal/index.ts Re-exports the new getVerbForCommandStatus helper.
changes/45640-apple-windows-mdm-command-activities User-visible change entry (content excluded from review).
Files excluded by content exclusion policy (1)
  • changes/45640-apple-windows-mdm-command-activities

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread frontend/utilities/helpers.tsx
Comment thread frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx
Comment thread frontend/pages/DashboardPage/cards/ActivityFeed/ActivityFeed.tsx
@coderabbitai

coderabbitai Bot commented Jun 19, 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 63a29200-fbd0-48ce-bc23-6239f128767d

📥 Commits

Reviewing files that changed from the base of the PR and between ecca0a9 and dd452f1.

📒 Files selected for processing (1)
  • frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tests.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tests.tsx

Walkthrough

This PR adds frontend support for the ran_custom_mdm_command activity type. ActivityType gains a new RanCustomMdmCommand enum value, IActivityDetails gains an optional request_type field, and ACTIVITY_TYPE_TO_FILTER_LABEL gains a display label. Two new utility functions — getMdmCommandDisplayName and formatMdmCommandNameForActivityItem — format MDM command request types for display. GetIconName is expanded to handle additional Apple and numeric Windows OMA-DM statuses, and a new getVerbForCommandStatus helper derives display verbs. A new RanCustomMdmCommandActivityItem component is registered for the host past activity feed, and both the dashboard ActivityFeed and HostDetailsPage gain state management and modal rendering for this activity type.

Possibly related issues

Possibly related PRs

  • fleetdm/fleet#47743: This is the backend counterpart that creates ActivityTypeRanCustomMDMCommand activities in RunMDMCommand, which the current PR's frontend consumes to display activity items and modal details.
🚥 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 summarizes the main change: displaying ran_custom_mdm_command activities in both host and global activity feeds.
Description check ✅ Passed The description includes the related issue and completed key checklist items, but lacks comprehensive detail about implementation and testing specifics.
Linked Issues check ✅ Passed The PR implements all key requirements: displays MDM command activities on host and global feeds [#45641], handles failed command lookups by showing Request Type [#45641], and manages both pending and deleted command states [#45641].
Out of Scope Changes check ✅ Passed All changes are directly related to displaying ran_custom_mdm_command activities in activity feeds as specified in issue #45641; no out-of-scope modifications detected.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 45641-mdm-command-activity-feed-ui

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.

@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: 4

🤖 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 `@frontend/pages/DashboardPage/cards/ActivityFeed/ActivityFeed.tsx`:
- Around line 159-163: Make the host_uuid field required in the
mdmCommandActivityDetails state type definition by removing the optional marker,
changing host_uuid from host_uuid?: string to host_uuid: string. Then ensure all
locations where mdmCommandActivityDetails is being set (referenced at lines
332-337 and 508-511) always provide a valid host_uuid value before opening the
modal. This prevents unscoped command-results fetches that could return multiple
results and cause the modal to fail.

In `@frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx`:
- Around line 49-51: The getVerbForCommandStatus function currently returns
"ran" as a default for any status that doesn't produce an "error" icon, which
causes unknown or warning statuses to be labeled as successful. Instead of using
a ternary operator that defaults to "ran", explicitly check the icon name
returned by GetIconName and return appropriate verb strings for each specific
status type (such as "ran" for success icons, "failed to run" for error icons,
and handle warning or other unmapped statuses appropriately rather than
defaulting to success messaging).

In `@frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx`:
- Around line 297-301: Make the host_uuid field required in the
activityCommandDetails state object by removing the optional marker from
host_uuid?: string and changing it to host_uuid: string. Since this
HostDetailsPage has access to host?.uuid, ensure that whenever
activityCommandDetails is set throughout the component (including in the
locations at lines 910-915 and 1881-1884), the host_uuid is always provided as a
value. This will ensure command-results queries are properly scoped to the
current host and remain deterministic.

In `@frontend/utilities/helpers.tsx`:
- Around line 457-460: The function that splits requestType by "/" and returns a
truncated label does not account for trailing slashes, which results in an empty
last segment causing the display to show only "..." instead of a meaningful
label. Before splitting requestType by "/" and accessing
segments[segments.length - 1], either remove the trailing slash from requestType
or filter out empty strings from the segments array, then pick the last
non-empty segment for display to ensure meaningful command labels are shown even
for paths like "./Vendor/MSFT/".
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 532caca5-e9fc-4358-ab24-3ea4a7de8b6e

📥 Commits

Reviewing files that changed from the base of the PR and between 97f28d6 and fb1f40e.

📒 Files selected for processing (15)
  • changes/45640-apple-windows-mdm-command-activities
  • frontend/interfaces/activity.ts
  • frontend/pages/DashboardPage/cards/ActivityFeed/ActivityFeed.tsx
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsx
  • frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx
  • frontend/pages/hosts/components/CommandDetailsModal/index.ts
  • frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx
  • frontend/pages/hosts/details/cards/Activity/ActivityConfig.tsx
  • frontend/pages/hosts/details/cards/Activity/ActivityItems/RanCustomMdmCommandActivityItem/RanCustomMdmCommandActivityItem.tsx
  • frontend/pages/hosts/details/cards/Activity/ActivityItems/RanCustomMdmCommandActivityItem/index.ts
  • frontend/utilities/helpers.tsx
  • server/fleet/activities.go
  • server/service/integration_mdm_test.go
  • server/service/mdm.go
  • server/service/mdm_test.go

Comment thread frontend/pages/DashboardPage/cards/ActivityFeed/ActivityFeed.tsx
Comment thread frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx
Comment thread frontend/utilities/helpers.tsx Outdated
@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 43.01075% with 53 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.26%. Comparing base (ad4847b) to head (76f3bef).

Files with missing lines Patch % Lines
.../hosts/details/HostDetailsPage/HostDetailsPage.tsx 0.00% 29 Missing ⚠️
.../DashboardPage/cards/ActivityFeed/ActivityFeed.tsx 8.33% 22 Missing ⚠️
...ndActivityItem/RanCustomMdmCommandActivityItem.tsx 50.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #47897   +/-   ##
=======================================
  Coverage   67.25%   67.26%           
=======================================
  Files        3641     3642    +1     
  Lines      230237   230254   +17     
  Branches    11988    11889   -99     
=======================================
+ Hits       154856   154870   +14     
- Misses      61464    61475   +11     
+ Partials    13917    13909    -8     
Flag Coverage Δ
frontend 58.21% <43.01%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@andymFleet andymFleet marked this pull request as ready for review June 19, 2026 13:15

@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.

🧹 Nitpick comments (1)
frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tests.tsx (1)

24-38: ⚡ Quick win

Add explicit boundary tests for Windows status ranges.

Please add checks for 199 and 399 so the threshold behavior is locked and regressions are caught.

Proposed test additions
   it("returns pending-outline for Windows 101 status", () => {
     expect(GetIconName("101")).toEqual("pending-outline");
   });
+
+  it("returns pending-outline for Windows 199 status (upper pending boundary)", () => {
+    expect(GetIconName("199")).toEqual("pending-outline");
+  });
+
+  it("returns success for Windows 399 status (upper success boundary)", () => {
+    expect(GetIconName("399")).toEqual("success");
+  });
🤖 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
`@frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tests.tsx`
around lines 24 - 38, Add two additional boundary test cases in the test suite
for the GetIconName function to check the threshold behavior at the edges of
status code ranges. Add a test case for status code "199" (just below the
success boundary of 200) and a test case for status code "399" (just below the
error boundary of 400) to ensure the function returns the correct icon names for
these boundary values and prevent regressions in the status code logic.
🤖 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.

Nitpick comments:
In
`@frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tests.tsx`:
- Around line 24-38: Add two additional boundary test cases in the test suite
for the GetIconName function to check the threshold behavior at the edges of
status code ranges. Add a test case for status code "199" (just below the
success boundary of 200) and a test case for status code "399" (just below the
error boundary of 400) to ensure the function returns the correct icon names for
these boundary values and prevent regressions in the status code logic.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a306de44-bc30-4322-b7e0-9a896e6a7e6d

📥 Commits

Reviewing files that changed from the base of the PR and between fb1f40e and ecca0a9.

📒 Files selected for processing (7)
  • frontend/pages/DashboardPage/cards/ActivityFeed/ActivityFeed.tsx
  • frontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsx
  • frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tests.tsx
  • frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsx
  • frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx
  • frontend/utilities/helpers.tests.tsx
  • frontend/utilities/helpers.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • frontend/utilities/helpers.tsx
  • frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx
  • frontend/pages/DashboardPage/cards/ActivityFeed/ActivityFeed.tsx

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.

MCA: Frontend: Display MDM command activities

2 participants