Files
Rahul RaghunathanandRachelElysia f292c7def4 Add sortable 'Added to Fleet' column to hosts table (#50098)
**Related issue:** Resolves #50083

# Screenshot demonstrating the fix

- Hosts page:
<img width="1473" height="335" alt="image"
src="https://github.com/user-attachments/assets/2f88ad6e-a514-4304-ac80-f56678e6be47"
/>

- Edit columns modal:
<img width="798" height="707" alt="image"
src="https://github.com/user-attachments/assets/0a79e8f3-1b21-4f84-bd04-726f44b9a0fa"
/>

## Note on sort direction

The new "Added to Fleet" column renders as a "days ago" duration (same
formatter as Last seen / Last fetched / Last restarted). To keep
behavior consistent across all four time-ago columns on the hosts table,
this PR applies the sort-direction inversion originally introduced for
`last_restarted_at` in #14878 (fix for #13160) to all of them:

- `seen_time` (Last seen)
- `detail_updated_at` (Last fetched)
- `last_restarted_at` (Last restarted) — unchanged behavior
- `last_enrolled_at` (Added to Fleet) — new

Arrow-down on any of these columns now sorts by the visible duration
(biggest "days ago" first / oldest date first), rather than by the raw
underlying timestamp. This is a user-facing behavior change on Last seen
and Last fetched — please re-QA sort order on those two columns
alongside the new one.

# Checklist for submitter

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

- [x] Changes file added for user-visible changes in `changes/`,
`orbit/changes/` or `ee/fleetd-chrome/changes`.
See [Changes
files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files)
for more information.

## Testing

- [x] QA'd all new/changed functionality manually

<!-- Attach: Edit columns modal showing the new "Added to Fleet" column
option, and the Hosts page with the column enabled -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
  * Added an **Added to Fleet** column to the hosts table.
* Displays when each host last enrolled with Fleet, with an explanatory
tooltip.
* The column is hidden by default and can be enabled through table
settings.
  * Supports ascending and descending sorting.

* **Bug Fixes**
* Corrected descending sorting for **Last seen** and **Last fetched** to
reflect the displayed host age.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: RachelElysia <71795832+RachelElysia@users.noreply.github.com>
2026-08-07 13:38:41 -04:00
..
2026-08-04 12:23:34 -07:00