From fb19bd48b692ec26932fbf58ba4b0e76298635bf Mon Sep 17 00:00:00 2001 From: Nico <32375741+nulmete@users.noreply.github.com> Date: Mon, 27 Apr 2026 14:06:06 -0300 Subject: [PATCH] Fix: Navigating to a a new host displays activity feed for a previously opened host details page (#44218) **Related issue:** Resolves #43591 # Checklist for submitter - [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 ### Before https://github.com/user-attachments/assets/ddd1bfe6-d8f8-426c-8add-71721013e18d ### After https://github.com/user-attachments/assets/86e4f60f-b78e-40cb-835b-a7ea40d54f10 ## Summary by CodeRabbit ## Bug Fixes * Fixed an issue where the host details activity feed could incorrectly display activities from a previously viewed host when navigating between different hosts. The activity data is now properly scoped to ensure the activity feed shows only activities relevant to the currently selected host, preventing stale data from appearing. --- changes/43591-fix-stale-host-activities | 1 + .../details/HostDetailsPage/HostDetailsPage.tsx | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) create mode 100644 changes/43591-fix-stale-host-activities diff --git a/changes/43591-fix-stale-host-activities b/changes/43591-fix-stale-host-activities new file mode 100644 index 0000000000..e42fd87d40 --- /dev/null +++ b/changes/43591-fix-stale-host-activities @@ -0,0 +1 @@ +* Fixed the host details activity feed showing the previously opened host's activities by including the host ID in the activity query cache keys. diff --git a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx index 83ddd8c5b1..bb8a3cb141 100644 --- a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx +++ b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx @@ -485,6 +485,7 @@ const HostDetailsPage = ({ IHostPastActivitiesResponse, Array<{ scope: string; + hostId: number; pageIndex: number; perPage: number; activeTab: "past" | "upcoming"; @@ -493,17 +494,14 @@ const HostDetailsPage = ({ [ { scope: "past-activities", + hostId: hostIdFromURL, pageIndex: activityPage, perPage: DEFAULT_ACTIVITY_PAGE_SIZE, activeTab: activeActivityTab, }, ], - ({ queryKey: [{ pageIndex, perPage }] }) => { - return activitiesAPI.getHostPastActivities( - hostIdFromURL, - pageIndex, - perPage - ); + ({ queryKey: [{ hostId, pageIndex, perPage }] }) => { + return activitiesAPI.getHostPastActivities(hostId, pageIndex, perPage); }, { ...DEFAULT_USE_QUERY_OPTIONS, @@ -524,6 +522,7 @@ const HostDetailsPage = ({ IHostUpcomingActivitiesResponse, Array<{ scope: string; + hostId: number; pageIndex: number; perPage: number; activeTab: "past" | "upcoming"; @@ -532,14 +531,15 @@ const HostDetailsPage = ({ [ { scope: "upcoming-activities", + hostId: hostIdFromURL, pageIndex: activityPage, perPage: DEFAULT_ACTIVITY_PAGE_SIZE, activeTab: activeActivityTab, }, ], - ({ queryKey: [{ pageIndex, perPage }] }) => { + ({ queryKey: [{ hostId, pageIndex, perPage }] }) => { return activitiesAPI.getHostUpcomingActivities( - hostIdFromURL, + hostId, pageIndex, perPage );