Skip to content

[PoC] Discover profile state (local)#13

Closed
davismcphee wants to merge 6 commits into
discover-context-awareness-toolkitfrom
poc-profile-state
Closed

[PoC] Discover profile state (local)#13
davismcphee wants to merge 6 commits into
discover-context-awareness-toolkitfrom
poc-profile-state

Conversation

@davismcphee
Copy link
Copy Markdown
Owner

@davismcphee davismcphee commented May 26, 2026

Superseded by PR against main branch: elastic#271164.

@davismcphee davismcphee self-assigned this May 26, 2026
davismcphee pushed a commit that referenced this pull request May 26, 2026
## Summary

Set `connect.timeout = 60s` on the undici `Agent` used by
`KbnClientRequester` (https path only).

## Why

elastic#268531 migrated `KbnClient` from axios to native fetch but did not
override undici's 10s `connect.timeout` default. Axios had no equivalent
cutoff, so FTR callers talking to a busy local Kibana started failing
once that PR landed.

The `kibana-streams-performance` weekly pipeline went red in builds #9,
#11, #12, and #13 with:

```
ConnectTimeoutError: Connect Timeout Error (attempted address: localhost:5620, timeout: 10000ms)
```

The `10000ms` is undici's default. Bisect: build #8 last green
(2026-05-11) → #9 first red (2026-05-18), with elastic#268531 in the window.

## What changed


`src/platform/packages/shared/kbn-kbn-client/src/kbn_client/kbn_client_requester.ts`:
one constant, one option on the https `Agent`. http branch unchanged.

## Related

Regression introduced in elastic#268531. Companion streams perf PR: elastic#270636.

## Validation

https://buildkite.com/elastic/kibana-streams-performance/builds/14
davismcphee and others added 6 commits May 30, 2026 03:45
## Summary

This PR introduces a context awareness toolkit that gives profile
extension points a centralized way to trigger actions in the host
context (add filters, open tabs, update queries, etc.):
```mermaid
flowchart LR
    subgraph Hosts["Host creates toolkit"]
        MA["Main App"]
        EM["Embeddable"]
        CP["Context Page"]
    end

    Hosts --> TK["Toolkit<br/><code>addFilter, openInNewTab,<br/>updateESQLQuery, setExpandedDoc, ...</code>"]

    TK --> SPM["ScopedProfilesManager"]

    SPM -->|"{ context, toolkit }"| Prof["Profile Accessors<br/><i>cell renderers, chart section,<br/>doc viewer, cell actions, ...</i>"]

    Prof -->|"toolkit.actions.*"| Hosts
```

### Why

Profile extension points need to trigger actions in the host app, but
there was no central way to do this. Each host (Discover, embeddable,
surrounding docs) passed actions down through extension point params,
resulting in a lot of duplication and no consistent interface.

### How it works

The toolkit gets injected into profile accessors alongside the existing
`context` param, so extensions receive `(prev, { context, toolkit })`
and can call things like `toolkit.actions.addFilter(...)` directly.

Each host constructs its own toolkit implementation:
- **Main app** — actions dispatch to tab-scoped Redux thunks
- **Embeddable** — actions use dashboard triggers and local state
- **Context page** — actions use the filter manager and React state

This decouples what profiles can do from how each host implements it,
and makes adding new host contexts straightforward. It also lays the
foundation for extensible state management for profiles, which can also
be centralized and exposed via the toolkit.

### Cleanup

- Removes duplicate action implementations across Discover, the
embeddable, and surrounding docs
- Unifies filter handling into a single thunk that supports both
KQL/Lucene and ES|QL WHERE clauses
- Simplifies `DiscoverLayout` by moving filter action code out of the
component

Prep work related to elastic#242987.

### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [x] This was checked for breaking HTTP API changes, and any breaking
changes have been approved by the breaking-change committee. The
`release_note:breaking` label should be applied in these situations.
- [ ] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@davismcphee
Copy link
Copy Markdown
Owner Author

Superseded by PR against main branch: elastic#271164.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant