Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 30, 2025

Agent activity flyout displayed "Reassigning agentto Agent policy X" when reassigning agents, missing a space between "agent" and "to".

Changes

  • helpers.tsx: Added leading space to reassignText template literal to match existing upgradeText pattern
  • index.test.tsx: Added test coverage for in-progress policy reassignment message formatting

Code Change

// Before
reassignText: action.type === 'POLICY_REASSIGN' && action.newPolicyId ? `to ${action.newPolicyId}` : '',

// After  
reassignText: action.type === 'POLICY_REASSIGN' && action.newPolicyId ? ` to ${action.newPolicyId}` : '',

The message template concatenates variables without spacing, so each conditional variable must include its own leading punctuation. This follows the pattern already used by upgradeText which includes to version ${version}.

Result: "Reassigning 1 agent to Policy1" ✓

Original prompt

This section details on the original issue you should resolve

<issue_title>[Fleet]: Space is missing in message under Agent activity for Assign to new policy action.</issue_title>
<issue_description>Kibana Build details:


VERSION: 9.3.0-SNAPSHOT
BUILD: 92454
COMMIT: e5f9c58ac8d24a090762509163ef1dcac9e56462

Preconditions:

  1. 9.3.0-SNAPSHOT Kibana cloud environment should be available.
  2. A few agents should be installed

Steps to reproduce:

  1. Navigate to Fleet>Agents.
  2. Assign agent to new policy.
  3. Observe message under Agent activity:
  • Reassigning agentto Agent policy 1

Note:

  • The issue is more noticeable if Assigning to new policy action takes longer time.

Expected Result:
Appropriate space should be added in message under Agent activity for Assign to new policy action.

Screen Capture:

Image Image Image

Comments on the Issue (you are @copilot in this section)

@elasticmachine Pinging @elastic/fleet (Team:Fleet) @amolnater-qasource **Suggestion to address the issue:** **Version:** Copilot- GPT-4.1

Steps to fix the issue:

  1. Identify the source of the message:

    • Search for the string or function in the Fleet plugin responsible for logging or displaying agent policy assignment activities.
    • Likely files will be in the Fleet plugin directory:
      x-pack/plugins/fleet/
  2. Find the message code:

    • Search for code that generates the activity message, especially for agent reassignment.
    • Example search patterns:
      • "Reassigning agentto"
      • Reassigning agent
      • "Assign agent"
    • If not hardcoded, look for template strings or functions handling agent events.
  3. Modify the message string:

    • Update the string to include the missing space:
      Change from:
      `Reassigning agentto Agent policy ${policyName}`
      To:
      `Reassigning agent to Agent policy ${policyName}`
    • If concatenating strings, ensure a space is added between "agent" and "to".

Likely filenames to modify:

  • Message generation (backend):
    x-pack/plugins/fleet/server/services/agent_policy.ts
    or
    x-pack/plugins/fleet/server/services/agent_service.ts
    or
    x-pack/plugins/fleet/server/services/activity_service.ts
  • UI display (frontend):
    x-pack/plugins/fleet/public/applications/fleet/sections/agents/components/agent_activity_log.tsx
    or
    x-pack/plugins/fleet/public/applications/fleet/components/agent_policy_reassign.tsx

Example code change:

Suppose you find this in agent_activity_log.tsx:

// Before
const message = `Reassigning agentto Agent policy ${policyName}`;

// After
const message = `Reassigning agent to Agent policy ${policyName}`;

or if strings are concatenated:

// Before
const message = 'Reassigning agent' + 'to Agent policy ' + policyName;

// After
const message = 'Reassigning agent ' + 'to Agent policy ' + policyName;
@amolnater-qasource @muskangulati-qasource Please review. @muskangulati-qasource Secondary review is Done for this ticket!

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Fix missing space in agent activity message [Fleet] Fix missing space in agent policy reassignment activity message Oct 30, 2025
Copilot AI requested a review from jen-huang October 30, 2025 19:24
Copilot finished work on behalf of jen-huang October 30, 2025 19:24
@jen-huang jen-huang marked this pull request as ready for review October 30, 2025 19:54
@jen-huang jen-huang requested a review from a team as a code owner October 30, 2025 19:54
@jen-huang jen-huang added Team:Fleet Team label for Observability Data Collection Fleet team backport:version Backport to applied version labels v9.3.0 labels Oct 30, 2025
@jen-huang jen-huang added v9.1.7 v9.2.1 release_note:skip Skip the PR/issue when compiling release notes v8.19.7 labels Oct 30, 2025
@jen-huang
Copy link
Contributor

/ci

@jen-huang
Copy link
Contributor

buildkite test this

@elasticmachine
Copy link
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

Test Failures

  • [job] [logs] Jest Tests #3 / AgentActivityFlyout should render agent activity for in progress policy reassign
  • [job] [logs] Jest Tests #3 / AgentActivityFlyout should render agent activity for in progress policy reassign

cc @jen-huang @copilot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels 💝community release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.19.7 v9.1.7 v9.2.1 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fleet]: Space is missing in message under Agent activity for Assign to new policy action.

5 participants