-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Search Sessions] Improve session restoration back button #87635
[Search Sessions] Improve session restoration back button #87635
Conversation
…store-search-session-back-button # Conflicts: # src/plugins/discover/public/application/angular/discover.js
@elasticmachine merge upstream |
Pinging @elastic/app-search-frontend (Team:AppSearch) |
Pinging @elastic/kibana-app-services (Team:AppServices) |
Sorry for the ping 😢 confused |
@@ -577,18 +575,21 @@ function discoverController($element, $route, $scope, $timeout, Promise, uiCapab | |||
abortController = new AbortController(); | |||
|
|||
const searchSessionId = (() => { | |||
const searchSessionIdFromURL = getSearchSessionIdFromURL(history); | |||
let searchSessionIdFromURL = getSearchSessionIdFromURL(history); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of this entire block being duplicated.
What do you say we add a function called restoreFromUrl(urlHistory)
to the session service?
The function will extract the searchSessionId
from the URL and then apply the logic below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you say we add a function called restoreFromUrl(urlHistory) to the session service?
This part is app-specific. It just happens that Discover and Dashboard do this similar:
It is up to the apps how they restore search sessions. Discover and Dashboard URLs structure are similar (both use searchSessionId
query param inside hash part of the URL.)
- But not every app has a hash in the URL, so they might store
searchSessionId
as a query param in a pathname (before the hash). - They also might have a param named differently or be serialized in rison/json or other structures.
- We will support restoring session without the URL all together: [Search Session] Use new URL Service for session restoration #85126
I'd extract to common place if we'd have a shared place for Discover/Dashboard/Visualize, but as we don't, I think it is fine to leave it as is
I tested the PR Discover.-.Elastic.3.mp4 |
…store-search-session-back-button
Discussed with @lizozom that this is not actually a problem: The back button triggers the previous search which is expected, but Discover doesn't remove old results from the screen in this case, but the Dashboard does. This is not what we want to address in this pr, this is just how Discover / Dashboard error handling works in case of failed requests. Instead, we should focus on is that back button triggers the previous search and on a real-world scenario where the session restoration is successful and we see the new results |
…store-search-session-back-button
ACK, aye, aye, will review |
…store-search-session-back-button
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Presentation team changes LGTM. Was able to test this locally and confirm that the back button restored the invalid search session.
@@ -59,7 +59,7 @@ export function DashboardApp({ | |||
indexPatterns: indexPatternService, | |||
} = useKibana<DashboardAppServices>().services; | |||
|
|||
const [lastReloadTime, setLastReloadTime] = useState(0); | |||
const triggerRefresh$ = useMemo(() => new Subject<{ force?: boolean }>(), []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice improvement. Much better than using a lastReloadTime
to trigger forced resets.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kibana App owned code LGTM, tested locally in Chrome, worked correctly. Every time I look at the change index pattern behavior, it gives me headache. Aspirine will be further deangularization.
…store-search-session-back-button # Conflicts: # x-pack/test/send_search_to_background_integration/tests/apps/dashboard/async_search/send_to_background.ts
@elasticmachine merge upstream |
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
- Tested OSS back behavior
- Tested searchSessionId change in URL is picked up without having to refresh the whole page
- Navigating back to a restored session works
- Navigating back and forth between two restored sessions works
- Refresh button properly cleans the searchSessionId
- Same tests work on Discover and Dashboard 👍
@@ -0,0 +1,60 @@ | |||
/* | |||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add unit tests for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
…y-tests * 'master' of github.com:elastic/kibana: (31 commits) [Discover] Add grid flyout jest test (elastic#89088) [Search Sessions] Improve session restoration back button (elastic#87635) [TSVB] Remove vis_type_timeseries_enhanced plugin (elastic#89274) [Security Solution] Init Osquery plugin (elastic#87109) [Fleet] Do not defined aliases inside datastream template (elastic#89512) skip flaky suite (elastic#86950) chore(NA): bazel machinery installation on kbn bootstrap (elastic#89469) [build/docker] Add support for centos ARM builds (elastic#84831) Convert default_watch.json to a JS object in order to avoid TS complaints (elastic#89488) [CI] Decrease number of Jest workers (elastic#89504) [Maps] remove maps_oss TS project (elastic#89502) Adds migration settings to Docker (elastic#89501) [Lens] Fix crash in transition from unique count to last value (elastic#88916) [kbn-es] Always use bundled JDK when starting Elasticsearch (elastic#89437) unskip getting_started/shakespeare test elasticsearch 64016 (elastic#89346) [Maps] migrate maps, maps_file_upload, and maps_legacy_licensing to TS projects (elastic#89439) skip flaky suite (elastic#89478) skip flaky suite (elastic#89476) skip flaky suite (elastic#89477) skip flaky suite (elastic#89475) ... # Conflicts: # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/cold_phase/cold_phase.tsx
…updates-and-timeline-cleanup * 'master' of github.com:elastic/kibana: (44 commits) [Discover] Add grid flyout jest test (elastic#89088) [Search Sessions] Improve session restoration back button (elastic#87635) [TSVB] Remove vis_type_timeseries_enhanced plugin (elastic#89274) [Security Solution] Init Osquery plugin (elastic#87109) [Fleet] Do not defined aliases inside datastream template (elastic#89512) skip flaky suite (elastic#86950) chore(NA): bazel machinery installation on kbn bootstrap (elastic#89469) [build/docker] Add support for centos ARM builds (elastic#84831) Convert default_watch.json to a JS object in order to avoid TS complaints (elastic#89488) [CI] Decrease number of Jest workers (elastic#89504) [Maps] remove maps_oss TS project (elastic#89502) Adds migration settings to Docker (elastic#89501) [Lens] Fix crash in transition from unique count to last value (elastic#88916) [kbn-es] Always use bundled JDK when starting Elasticsearch (elastic#89437) unskip getting_started/shakespeare test elasticsearch 64016 (elastic#89346) [Maps] migrate maps, maps_file_upload, and maps_legacy_licensing to TS projects (elastic#89439) skip flaky suite (elastic#89478) skip flaky suite (elastic#89476) skip flaky suite (elastic#89477) skip flaky suite (elastic#89475) ... # Conflicts: # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx # x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/lib/absolute_timing_to_relative_timing.ts
Summary
Closes #82419
Improves back button behavior for search session restoration state
Discover and dashboard because this is only apps we have session restoration flow for now
How to test
Full flow will be testable after #81707 is merged, but for now:
searchSessionId
to discover or dashboard URL. Load it. The session should fail to restore in this case. (you can also use a realseaerchSessionId
using inspector)searchSessionId
in the URLdemo-back-button.mov
Both for Discover and Dashboard there are different main cases with this navigation that are different from one another and expected to work:
searchSessionId
in the browser address barDiscover has a very specific code path when changing index patterns. This is another code path that is worth testing and it should work.
Implemintation
I fully exposed underlying
kbnUrlControls
onkbnUrlStorage
. Dashboard needs them to removesearchSessionId
during pending state sync update.There is a known edge case that if you open a Discover or Dashboard URL and then change onlysearchSessionId
then nothing would happen.That is because there is no listener that listens specifically to that query param. Such change is happening in a real-world scenario in case the "refresh" button was hit.@Dosant: Todo: try fixing this, see how difficult this is...This if fixed but made implementation more complicated :(In Dashboard I had to add a denounce on updating dashboard container input to cover the following edge case:
searchSessionId
is removed from the URL.connectToGlobalQueryState
(time) andsearchSessionIdQuery$
will ask for dashboard container update. to avoid double fetch in this cases I added debounce.Notes
Checklist
Delete any items that are not applicable to this PR.
For maintainers