Skip to content

[lens] immediately display loading panel when adding new ES|QL panel#209361

Closed
nreese wants to merge 4 commits intoelastic:mainfrom
nreese:add_esql_lens
Closed

[lens] immediately display loading panel when adding new ES|QL panel#209361
nreese wants to merge 4 commits intoelastic:mainfrom
nreese:add_esql_lens

Conversation

@nreese
Copy link
Copy Markdown
Contributor

@nreese nreese commented Feb 3, 2025

Problem

"Add new ES|QL panel" action awaits several network requests before showing a new panel. This makes Kibana feel clunky as the UI does not immediately respond to user actions. Follow the test instructions on main to see the problem.

Solution

"Add new ES|QL panel" action updated to immediately call parentApi.addNewPanel when "Add new ES|QL panel" action is executed, thus providing immediate user feedback by displaying a loading panel. Network requests to build default ES|QL lens state are moved into buildEmbeddable.

Test instructions

  1. open new dashboard
  2. set network speed to "slow 4g".
  3. Click "Add panel"
  4. Click "ES|QL"
  5. Verify user is given immediate feedback by displaying loading panel before any awaits occur.

cc @stratoula @dej611

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 3, 2025

/ci

@elasticmachine
Copy link
Copy Markdown
Contributor

elasticmachine commented Feb 3, 2025

💔 Build Failed

Failed CI Steps

History

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 3, 2025

/ci

@nreese nreese marked this pull request as ready for review February 3, 2025 21:55
@nreese nreese requested a review from a team as a code owner February 3, 2025 21:55
@nreese nreese added Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels v9.1.0 v8.19.0 labels Feb 3, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

@stratoula
Copy link
Copy Markdown
Contributor

I did a very brief testing and this looks significantly faster. Thanx @nreese for working on this 🙌


const attributes$ = new BehaviorSubject<LensRuntimeState['attributes']>(
initialState.attributes || createEmptyLensState().attributes
await getInitialAttributes()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I agree on the final goal, I think the solution here is not exactly what I was expecting.
I would expect the initializers to be sync code that simply creates all the right things to watch before calling the loader at the end.

In the ES|QL scenario I understand there's some extra async preparation for this, so we're forcefully forwarding the async behaviour into the entire lens embeddable stack and make everything async.
Why not change this into a simpler flow?

  • add new panel const embeddable = addNewPanel(...)
  • call to update the attributes once done: embeddable.updateAttributes(esqlAttributes);
  • call to onEdit: embeddable.onEdit()

Maybe a the loading state until the update call is reached can be communicated in the parentApi somehow, but it would be a bit cleaner to me.
What do you think @nreese ?

Copy link
Copy Markdown
Contributor Author

@nreese nreese Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildEmbeddable is async because initializing an embeddable will likely require async actions. For example, many embeddables load a dataView.

When buildEmbeddable returns, the embeddable is initialized. I don't think it makes sense to add complexity to parentApi to add a work around for this.

For lens, we could keep initializeInternalApi sync and do something like the below. Would that resolve your concerns?

const internalApi = initializeInternalApi(
  initialState: {
    ...initialState,
    attributes: 
      initialState.isNewPanel
      ? await createNewEsqlAttributes(services)
      : initialState.attributes,
  },
  parentApi,
  titleManager,
  services
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is that we could move the await createNewEsqlAttributes(services) into the loader code. No?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not familiar with loader code. Can you provide a file reference and maybe a pointer to where you are thinking. Some sample code would help

@nreese
Copy link
Copy Markdown
Contributor Author

nreese commented Feb 6, 2025

replacing with #210084

@nreese nreese closed this Feb 6, 2025
dej611 added a commit that referenced this pull request Feb 20, 2025
…or edit (#210810)

## Summary

This PR is based on the idea in #209361 and tries to improve perceived
performances for all the scenarios where the `editorFrame` is loaded.

On fast connections this is now perceived very fast:

![esql_fast](https://github.com/user-attachments/assets/efb26416-bf15-449e-912f-a689c689c593)

On Fast 4g is still fast

![esql_fast_4g](https://github.com/user-attachments/assets/acc199be-683d-4a4b-a53c-f37a9117c258)

On Slow 4g is acceptable


![esql_slow_4g](https://github.com/user-attachments/assets/6fed9ec4-dc3f-4557-976c-91d82bddc10f)

Even on 3G connection the feedback is much better now


![esql_3g](https://github.com/user-attachments/assets/27e96c01-9149-4dd1-8a6d-e005202149ff)

As a bonus extra tests have been added for the ES|QL creation flow.

cc @thomasneirynck @nreese 

### Checklist

- [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

---------

Co-authored-by: Nick Partridge <nick.ryan.partridge@gmail.com>
dej611 added a commit that referenced this pull request Mar 3, 2025
…reate or edit (#210810) (#212052)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Lens][Embeddable] Make UI react faster to click actions like create
or edit (#210810)](#210810)

<!--- Backport version: 9.6.4 -->

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

<!--BACKPORT [{"author":{"name":"Marco
Liberati","email":"dej611@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-02-20T17:19:46Z","message":"[Lens][Embeddable]
Make UI react faster to click actions like create or edit
(#210810)\n\n## Summary\n\nThis PR is based on the idea in #209361 and
tries to improve perceived\nperformances for all the scenarios where the
`editorFrame` is loaded.\n\nOn fast connections this is now perceived
very
fast:\n\n![esql_fast](https://github.com/user-attachments/assets/efb26416-bf15-449e-912f-a689c689c593)\n\nOn
Fast 4g is still
fast\n\n![esql_fast_4g](https://github.com/user-attachments/assets/acc199be-683d-4a4b-a53c-f37a9117c258)\n\nOn
Slow 4g is
acceptable\n\n\n![esql_slow_4g](https://github.com/user-attachments/assets/6fed9ec4-dc3f-4557-976c-91d82bddc10f)\n\nEven
on 3G connection the feedback is much better
now\n\n\n![esql_3g](https://github.com/user-attachments/assets/27e96c01-9149-4dd1-8a6d-e005202149ff)\n\nAs
a bonus extra tests have been added for the ES|QL creation flow.\n\ncc
@thomasneirynck @nreese \n\n### Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: Nick Partridge
<nick.ryan.partridge@gmail.com>","sha":"1e92ae8afbec96f437040a7d3147b20e52478833","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:Visualizations","release_note:skip","Feature:Lens","backport:version","v9.1.0","v8.19.0"],"title":"[Lens][Embeddable]
Make UI react faster to click actions like create or
edit","number":210810,"url":"https://github.com/elastic/kibana/pull/210810","mergeCommit":{"message":"[Lens][Embeddable]
Make UI react faster to click actions like create or edit
(#210810)\n\n## Summary\n\nThis PR is based on the idea in #209361 and
tries to improve perceived\nperformances for all the scenarios where the
`editorFrame` is loaded.\n\nOn fast connections this is now perceived
very
fast:\n\n![esql_fast](https://github.com/user-attachments/assets/efb26416-bf15-449e-912f-a689c689c593)\n\nOn
Fast 4g is still
fast\n\n![esql_fast_4g](https://github.com/user-attachments/assets/acc199be-683d-4a4b-a53c-f37a9117c258)\n\nOn
Slow 4g is
acceptable\n\n\n![esql_slow_4g](https://github.com/user-attachments/assets/6fed9ec4-dc3f-4557-976c-91d82bddc10f)\n\nEven
on 3G connection the feedback is much better
now\n\n\n![esql_3g](https://github.com/user-attachments/assets/27e96c01-9149-4dd1-8a6d-e005202149ff)\n\nAs
a bonus extra tests have been added for the ES|QL creation flow.\n\ncc
@thomasneirynck @nreese \n\n### Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: Nick Partridge
<nick.ryan.partridge@gmail.com>","sha":"1e92ae8afbec96f437040a7d3147b20e52478833"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210810","number":210810,"mergeCommit":{"message":"[Lens][Embeddable]
Make UI react faster to click actions like create or edit
(#210810)\n\n## Summary\n\nThis PR is based on the idea in #209361 and
tries to improve perceived\nperformances for all the scenarios where the
`editorFrame` is loaded.\n\nOn fast connections this is now perceived
very
fast:\n\n![esql_fast](https://github.com/user-attachments/assets/efb26416-bf15-449e-912f-a689c689c593)\n\nOn
Fast 4g is still
fast\n\n![esql_fast_4g](https://github.com/user-attachments/assets/acc199be-683d-4a4b-a53c-f37a9117c258)\n\nOn
Slow 4g is
acceptable\n\n\n![esql_slow_4g](https://github.com/user-attachments/assets/6fed9ec4-dc3f-4557-976c-91d82bddc10f)\n\nEven
on 3G connection the feedback is much better
now\n\n\n![esql_3g](https://github.com/user-attachments/assets/27e96c01-9149-4dd1-8a6d-e005202149ff)\n\nAs
a bonus extra tests have been added for the ES|QL creation flow.\n\ncc
@thomasneirynck @nreese \n\n### Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: Nick Partridge
<nick.ryan.partridge@gmail.com>","sha":"1e92ae8afbec96f437040a7d3147b20e52478833"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
SoniaSanzV pushed a commit to SoniaSanzV/kibana that referenced this pull request Mar 4, 2025
…reate or edit (elastic#210810) (elastic#212052)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Lens][Embeddable] Make UI react faster to click actions like create
or edit (elastic#210810)](elastic#210810)

<!--- Backport version: 9.6.4 -->

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

<!--BACKPORT [{"author":{"name":"Marco
Liberati","email":"dej611@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-02-20T17:19:46Z","message":"[Lens][Embeddable]
Make UI react faster to click actions like create or edit
(elastic#210810)\n\n## Summary\n\nThis PR is based on the idea in elastic#209361 and
tries to improve perceived\nperformances for all the scenarios where the
`editorFrame` is loaded.\n\nOn fast connections this is now perceived
very
fast:\n\n![esql_fast](https://github.com/user-attachments/assets/efb26416-bf15-449e-912f-a689c689c593)\n\nOn
Fast 4g is still
fast\n\n![esql_fast_4g](https://github.com/user-attachments/assets/acc199be-683d-4a4b-a53c-f37a9117c258)\n\nOn
Slow 4g is
acceptable\n\n\n![esql_slow_4g](https://github.com/user-attachments/assets/6fed9ec4-dc3f-4557-976c-91d82bddc10f)\n\nEven
on 3G connection the feedback is much better
now\n\n\n![esql_3g](https://github.com/user-attachments/assets/27e96c01-9149-4dd1-8a6d-e005202149ff)\n\nAs
a bonus extra tests have been added for the ES|QL creation flow.\n\ncc
@thomasneirynck @nreese \n\n### Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: Nick Partridge
<nick.ryan.partridge@gmail.com>","sha":"1e92ae8afbec96f437040a7d3147b20e52478833","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:Visualizations","release_note:skip","Feature:Lens","backport:version","v9.1.0","v8.19.0"],"title":"[Lens][Embeddable]
Make UI react faster to click actions like create or
edit","number":210810,"url":"https://github.com/elastic/kibana/pull/210810","mergeCommit":{"message":"[Lens][Embeddable]
Make UI react faster to click actions like create or edit
(elastic#210810)\n\n## Summary\n\nThis PR is based on the idea in elastic#209361 and
tries to improve perceived\nperformances for all the scenarios where the
`editorFrame` is loaded.\n\nOn fast connections this is now perceived
very
fast:\n\n![esql_fast](https://github.com/user-attachments/assets/efb26416-bf15-449e-912f-a689c689c593)\n\nOn
Fast 4g is still
fast\n\n![esql_fast_4g](https://github.com/user-attachments/assets/acc199be-683d-4a4b-a53c-f37a9117c258)\n\nOn
Slow 4g is
acceptable\n\n\n![esql_slow_4g](https://github.com/user-attachments/assets/6fed9ec4-dc3f-4557-976c-91d82bddc10f)\n\nEven
on 3G connection the feedback is much better
now\n\n\n![esql_3g](https://github.com/user-attachments/assets/27e96c01-9149-4dd1-8a6d-e005202149ff)\n\nAs
a bonus extra tests have been added for the ES|QL creation flow.\n\ncc
@thomasneirynck @nreese \n\n### Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: Nick Partridge
<nick.ryan.partridge@gmail.com>","sha":"1e92ae8afbec96f437040a7d3147b20e52478833"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/210810","number":210810,"mergeCommit":{"message":"[Lens][Embeddable]
Make UI react faster to click actions like create or edit
(elastic#210810)\n\n## Summary\n\nThis PR is based on the idea in elastic#209361 and
tries to improve perceived\nperformances for all the scenarios where the
`editorFrame` is loaded.\n\nOn fast connections this is now perceived
very
fast:\n\n![esql_fast](https://github.com/user-attachments/assets/efb26416-bf15-449e-912f-a689c689c593)\n\nOn
Fast 4g is still
fast\n\n![esql_fast_4g](https://github.com/user-attachments/assets/acc199be-683d-4a4b-a53c-f37a9117c258)\n\nOn
Slow 4g is
acceptable\n\n\n![esql_slow_4g](https://github.com/user-attachments/assets/6fed9ec4-dc3f-4557-976c-91d82bddc10f)\n\nEven
on 3G connection the feedback is much better
now\n\n\n![esql_3g](https://github.com/user-attachments/assets/27e96c01-9149-4dd1-8a6d-e005202149ff)\n\nAs
a bonus extra tests have been added for the ES|QL creation flow.\n\ncc
@thomasneirynck @nreese \n\n### Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common
scenarios\n\n---------\n\nCo-authored-by: Nick Partridge
<nick.ryan.partridge@gmail.com>","sha":"1e92ae8afbec96f437040a7d3147b20e52478833"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Mar 22, 2025
…or edit (elastic#210810)

## Summary

This PR is based on the idea in elastic#209361 and tries to improve perceived
performances for all the scenarios where the `editorFrame` is loaded.

On fast connections this is now perceived very fast:

![esql_fast](https://github.com/user-attachments/assets/efb26416-bf15-449e-912f-a689c689c593)

On Fast 4g is still fast

![esql_fast_4g](https://github.com/user-attachments/assets/acc199be-683d-4a4b-a53c-f37a9117c258)

On Slow 4g is acceptable


![esql_slow_4g](https://github.com/user-attachments/assets/6fed9ec4-dc3f-4557-976c-91d82bddc10f)

Even on 3G connection the feedback is much better now


![esql_3g](https://github.com/user-attachments/assets/27e96c01-9149-4dd1-8a6d-e005202149ff)

As a bonus extra tests have been added for the ES|QL creation flow.

cc @thomasneirynck @nreese 

### Checklist

- [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

---------

Co-authored-by: Nick Partridge <nick.ryan.partridge@gmail.com>
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:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v8.19.0 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants