fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Supervised field for host details

Open William-TecNQ opened this issue 5 months ago • 6 comments

Resolves #47066

  • [X] Changes file added for user-visible changes in changes/, orbit/changes/ or ee/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

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.

William-TecNQ avatar Jun 09 '26 01:06 William-TecNQ

Review Change Stack

[!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_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Jun 09 '26 01:06 coderabbitai[bot]

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.

codecov[bot] avatar Jun 09 '26 23:06 codecov[bot]

Man these migration timestamps are annoying to keep ontop of 🙃

William-TecNQ avatar Jun 10 '26 05:06 William-TecNQ

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.

MagnusHJensen avatar Jun 10 '26 14:06 MagnusHJensen

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 avatar Jun 17 '26 03:06 William-TecNQ

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

MagnusHJensen avatar Jun 17 '26 10:06 MagnusHJensen

@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 avatar Aug 05 '26 13:08 melpike

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

William-TecNQ avatar Aug 11 '26 01:08 William-TecNQ

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 avatar Aug 11 '26 13:08 melpike

@melpike Cheers, thanks for that

William-TecNQ avatar Aug 11 '26 22:08 William-TecNQ