[lens] immediately display loading panel when adding new ES|QL panel#209361
[lens] immediately display loading panel when adding new ES|QL panel#209361nreese wants to merge 4 commits intoelastic:mainfrom
Conversation
|
/ci |
💔 Build Failed
Failed CI StepsHistory |
|
/ci |
|
Pinging @elastic/kibana-visualizations (Team:Visualizations) |
|
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() |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
);
There was a problem hiding this comment.
What I mean is that we could move the await createNewEsqlAttributes(services) into the loader code. No?
There was a problem hiding this comment.
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
|
replacing with #210084 |
…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:  On Fast 4g is still fast  On Slow 4g is acceptable  Even on 3G connection the feedback is much better now  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>
…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\n\nOn Fast 4g is still fast\n\n\n\nOn Slow 4g is acceptable\n\n\n\n\nEven on 3G connection the feedback is much better now\n\n\n\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\n\nOn Fast 4g is still fast\n\n\n\nOn Slow 4g is acceptable\n\n\n\n\nEven on 3G connection the feedback is much better now\n\n\n\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\n\nOn Fast 4g is still fast\n\n\n\nOn Slow 4g is acceptable\n\n\n\n\nEven on 3G connection the feedback is much better now\n\n\n\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-->
…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\n\nOn Fast 4g is still fast\n\n\n\nOn Slow 4g is acceptable\n\n\n\n\nEven on 3G connection the feedback is much better now\n\n\n\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\n\nOn Fast 4g is still fast\n\n\n\nOn Slow 4g is acceptable\n\n\n\n\nEven on 3G connection the feedback is much better now\n\n\n\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\n\nOn Fast 4g is still fast\n\n\n\nOn Slow 4g is acceptable\n\n\n\n\nEven on 3G connection the feedback is much better now\n\n\n\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-->
…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:  On Fast 4g is still fast  On Slow 4g is acceptable  Even on 3G connection the feedback is much better now  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>
Problem
"Add new ES|QL panel" action
awaitsseveral 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.addNewPanelwhen "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 intobuildEmbeddable.Test instructions
awaitsoccur.cc @stratoula @dej611