Fix: Navigating to a a new host displays activity feed for a previously opened host details page (#44218)

<!-- Add the related story/sub-task/bug number, like Resolves #123, or
remove if NA -->
**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



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

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

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Nico
2026-04-27 19:06:06 +02:00
committed by GitHub
parent e44070cb8a
commit fb19bd48b6
2 changed files with 9 additions and 8 deletions
+1
View File
@@ -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.
@@ -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
);