From 4ce6adc463304ab5d153d222c56cc4d165dce248 Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 18 Aug 2025 17:11:06 +0000 Subject: [PATCH 1/3] latest --- .../SearchPage/SearchQueryStatus/Results.tsx | 11 ++++++---- .../SearchPage/SearchQueryStatus/index.tsx | 2 +- .../pages/SearchPage/SearchState/index.tsx | 10 +++++++++ .../SearchState/useUpdateStateWithMetadata.ts | 21 ++++++++++++------- .../client/src/pages/SearchPage/index.tsx | 4 ++-- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/components/webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx b/components/webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx index b67283fcfc..334c8ae1bc 100644 --- a/components/webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx @@ -19,16 +19,19 @@ type TextTypes = GetProps["type"]; * @return */ const Results = () => { + const numSearchResultsMetadata = useSearchStore((state) => state.numSearchResultsMetadata); const numSearchResultsTimeline = useSearchStore((state) => state.numSearchResultsTimeline); const numSearchResultsTable = useSearchStore((state) => state.numSearchResultsTable); const searchUiState = useSearchStore((state) => state.searchUiState); - // Number of results is the maximum of the number of results in the timeline and table. The - // timeline may have more results since the table results are capped. Having two sources may - // provide more timely updates to the user. + // Number of results is the maximum from timeline, table, and server metadata sources. + // Multiple sources provide more timely updates. Source behavior differs by query engine: + // - clp/clp-s: table and server metadata counts are capped + // - presto: table count is capped, no timeline available const numResults = useMemo( - () => Math.max(numSearchResultsTimeline, numSearchResultsTable), + () => Math.max(numSearchResultsMetadata, numSearchResultsTimeline, numSearchResultsTable), [ + numSearchResultsMetadata, numSearchResultsTimeline, numSearchResultsTable, ] diff --git a/components/webui/client/src/pages/SearchPage/SearchQueryStatus/index.tsx b/components/webui/client/src/pages/SearchPage/SearchQueryStatus/index.tsx index ee152f39fc..ea76d91479 100644 --- a/components/webui/client/src/pages/SearchPage/SearchQueryStatus/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchQueryStatus/index.tsx @@ -24,7 +24,7 @@ const SearchQueryStatus = () => { {(searchUiState === SEARCH_UI_STATE.QUERYING || searchUiState === SEARCH_UI_STATE.DONE) && ( - Search job # + Search job id: {searchJobId} {" "} found diff --git a/components/webui/client/src/pages/SearchPage/SearchState/index.tsx b/components/webui/client/src/pages/SearchPage/SearchState/index.tsx index 8189bcced0..d26fd9d273 100644 --- a/components/webui/client/src/pages/SearchPage/SearchState/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchState/index.tsx @@ -18,6 +18,7 @@ import {SEARCH_UI_STATE} from "./typings"; const SEARCH_STATE_DEFAULT = Object.freeze({ aggregationJobId: null, cachedDataset: null, + numSearchResultsMetadata: 0, numSearchResultsTable: 0, numSearchResultsTimeline: 0, queryIsCaseSensitive: false, @@ -43,6 +44,11 @@ interface SearchState { */ cachedDataset: Nullable; + /** + * The number of search results from metadata (total results when search is complete). + */ + numSearchResultsMetadata: number; + /** * The number of search table results. */ @@ -97,6 +103,7 @@ interface SearchState { updateAggregationJobId: (id: string | null) => void; updateCachedDataset: (dataset: string) => void; + updateNumSearchResultsMetadata: (num: number) => void; updateNumSearchResultsTable: (num: number) => void; updateNumSearchResultsTimeline: (num: number) => void; updateQueryIsCaseSensitive: (newValue: boolean) => void; @@ -117,6 +124,9 @@ const useSearchStore = create((set) => ({ updateCachedDataset: (dataset) => { set({cachedDataset: dataset}); }, + updateNumSearchResultsMetadata: (num) => { + set({numSearchResultsMetadata: num}); + }, updateNumSearchResultsTable: (num) => { set({numSearchResultsTable: num}); }, diff --git a/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts b/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts index 284c03c8f7..81f93c396d 100644 --- a/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts +++ b/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts @@ -10,20 +10,26 @@ import useSearchStore from "./index"; import {SEARCH_UI_STATE} from "./typings"; import {useResultsMetadata} from "./useResultsMetadata"; - /** - * Custom hook to update the UI state to `DONE` when the results metadata signal indicates - * that the query is complete, or `FAILED` if the query fails. If there is an error, it will - * also display a notification with the error message. + * Custom hook to update the client state based on results metadata from the server. + * - Sets the UI state to `DONE` when the results metadata signal indicates that the query is + * complete, or `FAILED` if the query fails. + * - If there is an error, it will display a notification with the error message. + * - Updates the number of search results from the metadata. */ -const useUiUpdateOnDoneSignal = () => { - const {updateSearchUiState} = useSearchStore(); +const useUpdateStateWithMetadata = () => { + const {updateSearchUiState, updateNumSearchResultsMetadata} = useSearchStore(); const resultsMetadata = useResultsMetadata(); + useEffect(() => { if (null === resultsMetadata) { return; } + if ("undefined" !== typeof resultsMetadata.numTotalResults) { + updateNumSearchResultsMetadata(resultsMetadata.numTotalResults); + } + switch (resultsMetadata.lastSignal) { case SEARCH_SIGNAL.RESP_DONE: case PRESTO_SEARCH_SIGNAL.FINISHED: @@ -47,7 +53,8 @@ const useUiUpdateOnDoneSignal = () => { }, [ resultsMetadata, updateSearchUiState, + updateNumSearchResultsMetadata, ]); }; -export {useUiUpdateOnDoneSignal}; +export {useUpdateStateWithMetadata}; diff --git a/components/webui/client/src/pages/SearchPage/index.tsx b/components/webui/client/src/pages/SearchPage/index.tsx index d49a358801..ef78f1a068 100644 --- a/components/webui/client/src/pages/SearchPage/index.tsx +++ b/components/webui/client/src/pages/SearchPage/index.tsx @@ -8,7 +8,7 @@ import SearchControls from "./SearchControls"; import SearchQueryStatus from "./SearchQueryStatus"; import SearchResultsTable from "./SearchResults/SearchResultsTable"; import SearchResultsTimeline from "./SearchResults/SearchResultsTimeline"; -import {useUiUpdateOnDoneSignal} from "./SearchState/useUpdateStateWithMetadata"; +import {useUpdateStateWithMetadata} from "./SearchState/useUpdateStateWithMetadata"; /** @@ -17,7 +17,7 @@ import {useUiUpdateOnDoneSignal} from "./SearchState/useUpdateStateWithMetadata" * @return */ const SearchPage = () => { - useUiUpdateOnDoneSignal(); + useUpdateStateWithMetadata(); return ( <> From 6b9cb77958a14c3e0ad305408587d802904f651a Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 19 Aug 2025 18:00:51 +0000 Subject: [PATCH 2/3] latest --- .../src/pages/SearchPage/SearchQueryStatus/Results.tsx | 2 +- .../webui/client/src/pages/SearchPage/SearchState/index.tsx | 2 +- .../SearchPage/SearchState/useUpdateStateWithMetadata.ts | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx b/components/webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx index 334c8ae1bc..4e810c4982 100644 --- a/components/webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx @@ -27,7 +27,7 @@ const Results = () => { // Number of results is the maximum from timeline, table, and server metadata sources. // Multiple sources provide more timely updates. Source behavior differs by query engine: // - clp/clp-s: table and server metadata counts are capped - // - presto: table count is capped, no timeline available + // - presto: table count is capped, no timeline count available const numResults = useMemo( () => Math.max(numSearchResultsMetadata, numSearchResultsTimeline, numSearchResultsTable), [ diff --git a/components/webui/client/src/pages/SearchPage/SearchState/index.tsx b/components/webui/client/src/pages/SearchPage/SearchState/index.tsx index d26fd9d273..8fc97841bf 100644 --- a/components/webui/client/src/pages/SearchPage/SearchState/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchState/index.tsx @@ -45,7 +45,7 @@ interface SearchState { cachedDataset: Nullable; /** - * The number of search results from metadata (total results when search is complete). + * The number of search results from server metadata. */ numSearchResultsMetadata: number; diff --git a/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts b/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts index 81f93c396d..8e79f64994 100644 --- a/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts +++ b/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts @@ -10,11 +10,12 @@ import useSearchStore from "./index"; import {SEARCH_UI_STATE} from "./typings"; import {useResultsMetadata} from "./useResultsMetadata"; + /** * Custom hook to update the client state based on results metadata from the server. * - Sets the UI state to `DONE` when the results metadata signal indicates that the query is - * complete, or `FAILED` if the query fails. - * - If there is an error, it will display a notification with the error message. + * complete, or `FAILED` if the query fails. If there is an error, it will display a notification + * with the error message. * - Updates the number of search results from the metadata. */ const useUpdateStateWithMetadata = () => { From 5afa51a1601609feae5de730a16e37074ceb75a7 Mon Sep 17 00:00:00 2001 From: davemarco <83603688+davemarco@users.noreply.github.com> Date: Fri, 22 Aug 2025 11:06:55 -0400 Subject: [PATCH 3/3] Update components/webui/client/src/pages/SearchPage/SearchQueryStatus/index.tsx Co-authored-by: hoophalab <200652805+hoophalab@users.noreply.github.com> --- .../client/src/pages/SearchPage/SearchQueryStatus/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/webui/client/src/pages/SearchPage/SearchQueryStatus/index.tsx b/components/webui/client/src/pages/SearchPage/SearchQueryStatus/index.tsx index ea76d91479..f65bb13f43 100644 --- a/components/webui/client/src/pages/SearchPage/SearchQueryStatus/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchQueryStatus/index.tsx @@ -24,7 +24,8 @@ const SearchQueryStatus = () => { {(searchUiState === SEARCH_UI_STATE.QUERYING || searchUiState === SEARCH_UI_STATE.DONE) && ( - Search job id: + Search job + {" "} {searchJobId} {" "} found