Skip to content

Conversation

@tomsonpl
Copy link
Contributor

@tomsonpl tomsonpl commented Jul 10, 2025

Description

Previously, #204965 introduced a string based Selector Component, however the Response Console's framework wasn't adjusted to fully support it:

  • Selector Components Not Restoring State from History:
    When users selected a command from history (e.g., custom script execution), the selector UI (such as script dropdowns) could not restore its value from the previously entered command text. This left the UI out of sync with the command, confusing users and breaking workflows.

  • Broken Paste Functionality:
    Pasting a full command (including arguments meant for selectors) into the console did not populate the selector UI components. As a result, users who pasted commands from documentation or shared snippets would see empty or incorrect selector states, making it difficult to execute or edit those commands.

These issues stemmed from the lack of a unified mechanism for synchronizing between the command text and selector state. Command-specific logic was difficult to maintain and extend.


How was it resolved?

** Added argState Infrastructure:**

  • Enhanced Command interface with argState property to track selector component state
  • Modified command execution pipeline to preserve selector state across history and paste operations

** Smart Paste Processing:**

  • Implemented detectAndPreProcessPastedCommand() function that extracts values from pasted commands like runscript --ScriptName="test.ps1"
  • Separates embedded values into selector state while cleaning the command text for display

** History State Restoration:**

  • Updated InputHistoryItem to include argState property
  • Modified history selection to restore both command text and selector UI state

Additional Architectural Improvements

Based on code review feedback, this PR also addresses architectural concerns with the CustomScriptSelector component:

  • 🔧 Standard React Component:
    Converted from function-returning-component pattern (CustomScriptSelector('agentType')) to standard React component (<CustomScriptSelector />)

  • 🔧 Console Framework Encapsulation:
    Removed direct useConsoleStateDispatch() coupling and replaced with proper callback-based architecture (onChange, requestFocus)

  • 🔧 Command Metadata Integration:
    Agent type now extracted from command.commandDefinition.meta?.agentType instead of function parameters, following console framework patterns

  • 🔧 Enhanced Interface:
    Added command: Command and requestFocus?: () => void props to CommandArgumentValueSelectorProps for better component integration

These changes ensure the console remains a generic, maintainable framework while providing clean interfaces for selector components.


Result

  • Selector UI components now always reflect the correct state when loading from history or after pasting a command (for commands where this is supported).
  • Users can confidently copy, paste, and re-run complex commands with selector arguments.
  • The codebase is more maintainable and ready for future extension.
  • Console framework maintains proper encapsulation with well-defined component interfaces.
Screen.Recording.2025-06-27.at.12.15.47.mov

Closes: #225269
Closes: #225407

@tomsonpl tomsonpl self-assigned this Jul 10, 2025
@tomsonpl
Copy link
Contributor Author

/ci

@tomsonpl
Copy link
Contributor Author

/ci

@tomsonpl
Copy link
Contributor Author

/ci

@tomsonpl tomsonpl added release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution backport:version Backport to applied version labels v9.1.0 v8.19.0 v9.2.0 labels Jul 14, 2025
@tomsonpl tomsonpl marked this pull request as ready for review July 14, 2025 07:44
@tomsonpl tomsonpl requested a review from a team as a code owner July 14, 2025 07:44
@tomsonpl tomsonpl requested review from joeypoon and pzl July 14, 2025 07:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-defend-workflows (Team:Defend Workflows)

@tomsonpl tomsonpl requested review from paul-tavares and szwarckonrad and removed request for joeypoon and pzl July 14, 2025 09:05
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
securitySolution 7611 7612 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 9.8MB 9.8MB +853.0B

History

cc @tomsonpl

@tomsonpl tomsonpl merged commit 5d2008f into elastic:main Aug 1, 2025
13 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.19, 9.1

https://github.com/elastic/kibana/actions/runs/16675548895

@tomsonpl
Copy link
Contributor Author

tomsonpl commented Aug 1, 2025

@ashokaditya I merged this PR before getting review from you because @paul-tavares wanted to have these changes for SentinelOne runscript work.
It would still be nice to have your review on it, I could then address the comments in a follow up PR.

Hope this is fine 👍 Thanks!

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 1, 2025
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 1, 2025
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.19
9.1

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Aug 1, 2025
…230215)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[EDR Workflows] Initialize argument selector value
(#227463)](#227463)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Tomasz
Ciecierski","email":"tomasz.ciecierski@elastic.co"},"sourceCommit":{"committedDate":"2025-08-01T12:51:54Z","message":"[EDR
Workflows] Initialize argument selector value
(#227463)","sha":"5d2008fdfb2f0354d505f0af21c72f04115803aa","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Defend
Workflows","backport:version","v9.2.0","v9.1.1","v8.19.1"],"title":"[EDR
Workflows] Initialize argument selector
value","number":227463,"url":"https://github.com/elastic/kibana/pull/227463","mergeCommit":{"message":"[EDR
Workflows] Initialize argument selector value
(#227463)","sha":"5d2008fdfb2f0354d505f0af21c72f04115803aa"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/227463","number":227463,"mergeCommit":{"message":"[EDR
Workflows] Initialize argument selector value
(#227463)","sha":"5d2008fdfb2f0354d505f0af21c72f04115803aa"}},{"branch":"9.1","label":"v9.1.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Tomasz Ciecierski <tomasz.ciecierski@elastic.co>
szaffarano pushed a commit to szaffarano/kibana that referenced this pull request Aug 5, 2025
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Aug 5, 2025
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @tomsonpl

kibanamachine added a commit that referenced this pull request Aug 5, 2025
…230216)

# Backport

This will backport the following commits from `main` to `9.1`:
- [[EDR Workflows] Initialize argument selector value
(#227463)](#227463)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Tomasz
Ciecierski","email":"tomasz.ciecierski@elastic.co"},"sourceCommit":{"committedDate":"2025-08-01T12:51:54Z","message":"[EDR
Workflows] Initialize argument selector value
(#227463)","sha":"5d2008fdfb2f0354d505f0af21c72f04115803aa","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Defend
Workflows","backport:version","v9.2.0","v9.1.1","v8.19.1"],"title":"[EDR
Workflows] Initialize argument selector
value","number":227463,"url":"https://github.com/elastic/kibana/pull/227463","mergeCommit":{"message":"[EDR
Workflows] Initialize argument selector value
(#227463)","sha":"5d2008fdfb2f0354d505f0af21c72f04115803aa"}},"sourceBranch":"main","suggestedTargetBranches":["9.1","8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/227463","number":227463,"mergeCommit":{"message":"[EDR
Workflows] Initialize argument selector value
(#227463)","sha":"5d2008fdfb2f0354d505f0af21c72f04115803aa"}},{"branch":"9.1","label":"v9.1.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Tomasz Ciecierski <tomasz.ciecierski@elastic.co>
delanni pushed a commit to delanni/kibana that referenced this pull request Aug 5, 2025
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Aug 6, 2025
@wildemat wildemat mentioned this pull request Aug 7, 2025
10 tasks
@mistic mistic added v9.1.2 and removed v9.1.1 labels Aug 7, 2025
NicholasPeretti pushed a commit to NicholasPeretti/kibana that referenced this pull request Aug 18, 2025
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 release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v8.19.1 v9.1.2 v9.2.0

Projects

None yet

5 participants