45641 Display ran_custom_mdm_command activities in host and global activity feeds#47897
45641 Display ran_custom_mdm_command activities in host and global activity feeds#47897andymFleet wants to merge 18 commits into
Conversation
…mdm-command-activity-feed-ui
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_commandactivities 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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR adds frontend support for the Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (15)
changes/45640-apple-windows-mdm-command-activitiesfrontend/interfaces/activity.tsfrontend/pages/DashboardPage/cards/ActivityFeed/ActivityFeed.tsxfrontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tsxfrontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsxfrontend/pages/hosts/components/CommandDetailsModal/index.tsfrontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsxfrontend/pages/hosts/details/cards/Activity/ActivityConfig.tsxfrontend/pages/hosts/details/cards/Activity/ActivityItems/RanCustomMdmCommandActivityItem/RanCustomMdmCommandActivityItem.tsxfrontend/pages/hosts/details/cards/Activity/ActivityItems/RanCustomMdmCommandActivityItem/index.tsfrontend/utilities/helpers.tsxserver/fleet/activities.goserver/service/integration_mdm_test.goserver/service/mdm.goserver/service/mdm_test.go
Codecov Report❌ Patch coverage is 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
frontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tests.tsx (1)
24-38: ⚡ Quick winAdd explicit boundary tests for Windows status ranges.
Please add checks for
199and399so 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
📒 Files selected for processing (7)
frontend/pages/DashboardPage/cards/ActivityFeed/ActivityFeed.tsxfrontend/pages/DashboardPage/cards/ActivityFeed/GlobalActivityItem/GlobalActivityItem.tests.tsxfrontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tests.tsxfrontend/pages/hosts/components/CommandDetailsModal/CommandDetailsModal.tsxfrontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsxfrontend/utilities/helpers.tests.tsxfrontend/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
Related issue: Resolves #45641
If some of the following don't apply, delete the relevant line.
changes/,orbit/changes/oree/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