Supervised field for host details
Resolves #47066
-
[X] Changes file added for user-visible changes in
changes/,orbit/changes/oree/fleetd-chrome/changes. -
[X] Input data is properly validated,
SELECT *is avoided, SQL injection is prevented (using placeholders for values in statements), JS inline code is prevented especially for url redirects, and untrusted data interpolated into shell scripts/commands is validated against shell metacharacters.
Testing
- [X] Added/updated automated tests
- [X] Where appropriate, automated tests simulate multiple hosts and test for host isolation (updates to one hosts's records do not affect another)
- [X] QA'd all new/changed functionality manually
Database migrations
- [X] Checked schema for all modified table for columns that will auto-update timestamps during migration.
- [X] Confirmed that updating the timestamps is acceptable, and will not cause unwanted side effects.
Summary by CodeRabbit
- New Features
- Added a "Supervised" vitals row on Host Details for Apple devices (shows "Yes", "No", or empty when unknown); visible only for Apple hosts.
- Backend / Persistence
- Hosts now persist an optional supervised state; database migration adds a nullable supervised column.
- Tests
- Added coverage for UI display, persistence, migration, and device refetch handling of supervised values.
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
Walkthrough
This PR adds a "Supervised" field to the Host Details page for Apple devices. The change spans the full stack: adding a new nullable boolean field to the Host model, displaying it conditionally in the Vitals card for macOS/iOS/iPadOS hosts, persisting it in the MySQL hosts table via a new migration, implementing read/write operations in the data layer, and wiring it to be populated from Apple MDM DeviceInformation queries. The supervised status is displayed as Yes/No with an empty fallback when not available.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | ⚠️ Warning | Docstring coverage is 50.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 accurately summarizes the main change—adding a 'Supervised' field to the host details page. |
| Description check | ✅ Passed | The PR description covers required sections: linked issue, changes file, security/data validation, testing, and database migrations with all checklist items marked. |
| Linked Issues check | ✅ Passed | The changes implement the supervised field across frontend (UI display), backend (data models), database (migrations), and MDM integration (data collection from Apple devices) as required by issue #47066. |
| Out of Scope Changes check | ✅ Passed | All changes are directly related to implementing the supervised field feature—database schema, API models, frontend display, MDM data collection, and corresponding tests. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ 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.
Comment @coderabbitai help to get the list of available commands and usage tips.
Codecov Report
:x: Patch coverage is 81.25000% with 6 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 67.21%. Comparing base (ef0aed3) to head (cdec5df).
:warning: Report is 1251 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...ions/tables/20260617021010_AddSupervisedToHosts.go | 57.14% | 4 Missing and 2 partials :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #47148 +/- ##
=======================================
Coverage 67.21% 67.21%
=======================================
Files 3630 3631 +1
Lines 229526 229555 +29
Branches 11957 11959 +2
=======================================
+ Hits 154273 154293 +20
- Misses 61389 61397 +8
- Partials 13864 13865 +1
| Flag | Coverage Δ | |
|---|---|---|
| backend | 68.84% <77.77%> (-0.01%) |
:arrow_down: |
| frontend | 58.10% <100.00%> (+<0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Man these migration timestamps are annoying to keep ontop of 🙃
Hi @William-TecNQ thank you for the contribution.
I'm going to mark this as draft, assign @melpike, and notify Mel in Slack as per our community contribution handbook process.
I was looking at #26337 and the pull request related to it #42916, I'm not sure where this change sits in relation to that if it's the preferred solution for all iOS/iPadOS queries.
@William-TecNQ Thanks for that, but it's up to Mel to prioritise this request. I think the scope will also expand to macOS. We will follow up once prioritised and let you know if it expanded to macOS.
@William-TecNQ thanks again for your contribution! We closed out this story since we addressed the issue here: https://github.com/fleetdm/fleet/issues/49173. Up to you to close or leave your PR open.
@melpike Thanks for that, I'll close off this PR, the new PR looks like a good improvement and fetches a lot more data. I just wanted to ask to see if mobile devices are also targeted in the new PR as only macOS is explicitly defined?
I just wanted to ask to see if mobile devices are also targeted in the new PR as only macOS is explicitly defined?
Hey @William-TecNQ! We're actually tracking iOS/iPadOS separately in this issue. Looks like "Supervised" is included :)
@melpike Cheers, thanks for that