Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lens] searchSessionId is reset when opening a Lens config panel in Discover #162496

Closed
mbondyra opened this issue Jul 25, 2023 · 1 comment · Fixed by #162498
Closed

[Lens] searchSessionId is reset when opening a Lens config panel in Discover #162496

mbondyra opened this issue Jul 25, 2023 · 1 comment · Fixed by #162498
Labels
bug Fixes for quality problems that affect the customer experience Feature:Lens impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. Team:Visualizations Visualization editors, elastic-charts and infrastructure

Comments

@mbondyra
Copy link
Contributor

mbondyra commented Jul 25, 2023

Kibana version:
main

Might not be worth to fix as hopefully we'll do overall fix first (#121543) but let's keep an eye on it as it can cause some problems.

A specific bug:

  1. Open Discover in text based mode with a few columns chosen
  2. In your code, track searchSessionId somewhere (you can for example add a console.log data.search.session.getSessionId() in src/plugins/unified_histogram/public/container/container.tsx as it is ran on every searchSessionId.
  3. Open the Lens config panel and see that the searchSessionId changes when it's open.

Explanation

This is caused by the fact that we initialise searchSessionId for the existing document like this (x-pack/plugins/lens/public/state_management/init_middleware/load_initial.ts):

 const currentSessionId = data.search.session.getSessionId();
store.dispatch(
  initExisting({
    isSaveable: true,
    sharingSavedObjectProps,
    filters: data.query.filterManager.getFilters(),
    query: doc.state.query,
    searchSessionId:
      dashboardFeatureFlag.allowByValueEmbeddables &&
      Boolean(embeddableEditorIncomingState?.originatingApp) &&
      !(initialInput as LensByReferenceInput)?.savedObjectId &&
      currentSessionId
        ? currentSessionId
        : data.search.session.start(),

I would assume it would be safe to just do instead searchSessionId: currentSessionId ? currentSessionId : data.search.session.start(), but there were a lot of bugs in the past with searchSessionId management so it's important to investigate it if we have to fix it. This code should be thoroughly tested and we should also update our test suite because at the moment it's misses few pieces and we cannot fully count on it.

Some cases to pay attention to:

Lens editor initialisation:

  1. Opening empty document
  2. Opening existing document
  3. Opening existing document from the search bar on top of the page
  4. When coming from Dashboard -> preserve the searchSessionId from the dashboard
  5. When coming from Discover -> preserve the searchSessionId
    Lend editor leaving:
  6. Session is kept when coming back to dashboard when saving visualization
  7. Session is kept when coming back to dashboard after canceling editing (we have a bug on cancel right now)
  8. Session is kept when coming back to discover

Inside Lens workflow:
searchSessionId is changed when:

  • changing filters
  • changing query
  • changing autorefresh interval
  • we change something about visualization that doesn’t affect the data but too much time passed (2% of the timerange)
  1. Coming from TSVB (not sure what to do here)
  2. Autoapply off behavior
  3. Sharink link feature
@mbondyra mbondyra added bug Fixes for quality problems that affect the customer experience Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens labels Jul 25, 2023
@elasticmachine
Copy link
Contributor

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

@mbondyra mbondyra added the impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. label Jul 25, 2023
mbondyra added a commit that referenced this issue Jul 26, 2023
## Summary

Fixes #162496

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
ThomThomson pushed a commit to ThomThomson/kibana that referenced this issue Aug 1, 2023
## Summary

Fixes elastic#162496

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Lens impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. Team:Visualizations Visualization editors, elastic-charts and infrastructure
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants