fix(webui): Respect case sensitivity setting in search queries (fixes #1060); refactor Zustand usages.#1063
Conversation
|
""" WalkthroughThe changes refactor how state is accessed from the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SubmitButton
participant useSearchStore
participant handleQuerySubmit
User->>SubmitButton: Click "Submit"
SubmitButton->>useSearchStore: Get searchUiState, timeRange, queryString, queryIsCaseSensitive
SubmitButton->>handleQuerySubmit: Submit query (ignoreCase = !queryIsCaseSensitive)
Possibly related issues
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (1)`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.
⚙️ Source: CodeRabbit Configuration File List of files the instruction was applied to:
🧠 Learnings (3)📓 Common learningscomponents/webui/client/src/pages/SearchPage/SearchControls/QueryInput/index.tsx (4)components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTimeline/index.tsx (7)⏰ Context from checks skipped due to timeout of 90000ms (2)
🔇 Additional comments (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/SubmitButton.tsx (1)
43-45: Add missing dependency to useCallback.The
queryIsCaseSensitivestate is used in the callback but missing from the dependency array.Apply this diff to fix the dependencies:
}, [queryString, updateTimelineConfig, - timeRange]); + timeRange, + queryIsCaseSensitive]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/SubmitButton.tsx(2 hunks)components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTimeline/index.tsx(2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}: - Preferfalse == <expression>rather than!<expression>.
⚙️ Source: CodeRabbit Configuration File
List of files the instruction was applied to:
components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/SubmitButton.tsxcomponents/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTimeline/index.tsx
🧠 Learnings (3)
📓 Common learnings
Learnt from: junhaoliao
PR: y-scope/clp#962
File: components/log-viewer-webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx:22-26
Timestamp: 2025-06-09T17:15:30.309Z
Learning: When using Zustand stores in React components, always use specific selectors (e.g., `useStore(state => state.property)`) instead of destructuring the entire state object to prevent unnecessary re-renders. This is especially important as state stores grow in complexity.
Learnt from: junhaoliao
PR: y-scope/clp#962
File: components/log-viewer-webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx:22-26
Timestamp: 2025-06-09T17:15:30.309Z
Learning: When using Zustand stores in React components, always use specific selectors (e.g., `useStore(state => state.property)`) instead of destructuring the entire state object to prevent unnecessary re-renders. This is especially important as state stores grow in complexity.
Learnt from: LinZhihao-723
PR: y-scope/clp#873
File: components/core/src/clp/ffi/ir_stream/search/QueryHandlerImpl.hpp:320-324
Timestamp: 2025-05-05T01:12:18.561Z
Learning: In the CLP codebase, the `m_case_sensitive_search` flag is used only for actual string value comparisons during query evaluation, not for schema key name matching. Schema keys are always compared case-sensitively regardless of this flag's setting.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/SubmitButton.tsx (3)
Learnt from: junhaoliao
PR: y-scope/clp#962
File: components/log-viewer-webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx:22-26
Timestamp: 2025-06-09T17:15:30.309Z
Learning: When using Zustand stores in React components, always use specific selectors (e.g., `useStore(state => state.property)`) instead of destructuring the entire state object to prevent unnecessary re-renders. This is especially important as state stores grow in complexity.
Learnt from: junhaoliao
PR: y-scope/clp#962
File: components/log-viewer-webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx:22-26
Timestamp: 2025-06-09T17:15:30.309Z
Learning: When using Zustand stores in React components, always use specific selectors (e.g., `useStore(state => state.property)`) instead of destructuring the entire state object to prevent unnecessary re-renders. This is especially important as state stores grow in complexity.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTimeline/index.tsx (4)
Learnt from: junhaoliao
PR: y-scope/clp#962
File: components/log-viewer-webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx:22-26
Timestamp: 2025-06-09T17:15:30.309Z
Learning: When using Zustand stores in React components, always use specific selectors (e.g., `useStore(state => state.property)`) instead of destructuring the entire state object to prevent unnecessary re-renders. This is especially important as state stores grow in complexity.
Learnt from: junhaoliao
PR: y-scope/clp#962
File: components/log-viewer-webui/client/src/pages/SearchPage/SearchQueryStatus/Results.tsx:22-26
Timestamp: 2025-06-09T17:15:30.309Z
Learning: When using Zustand stores in React components, always use specific selectors (e.g., `useStore(state => state.property)`) instead of destructuring the entire state object to prevent unnecessary re-renders. This is especially important as state stores grow in complexity.
Learnt from: junhaoliao
PR: y-scope/clp#596
File: components/log-viewer-webui/client/src/api/query.js:16-23
Timestamp: 2024-11-21T15:51:33.203Z
Learning: In `components/log-viewer-webui/client/src/api/query.js`, the `ExtractJsonResp` type definition is accurate as-is and does not require modification. When suggesting changes to type definitions, ensure they align with the server-side definitions, referencing the source code if necessary.
Learnt from: junhaoliao
PR: y-scope/clp#937
File: components/log-viewer-webui/client/src/AntdApp.tsx:16-24
Timestamp: 2025-05-29T20:33:40.653Z
Learning: In components/log-viewer-webui React codebase: Return type annotations (like `: JSX.Element`) are unnecessary and not preferred for React components in JSX/TSX files.
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: lint-check (ubuntu-latest)
- GitHub Check: lint-check (macos-latest)
- GitHub Check: build (macos-latest)
🔇 Additional comments (2)
components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/SubmitButton.tsx (1)
22-26: Excellent refactoring to individual selectors.This change aligns perfectly with the retrieved learning about using specific selectors instead of destructuring the entire state object to prevent unnecessary re-renders.
components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTimeline/index.tsx (1)
22-31: Excellent refactoring to individual selectors.This change follows the same beneficial pattern as the SubmitButton component, using specific selectors to prevent unnecessary re-renders.
junhaoliao
left a comment
There was a problem hiding this comment.
for the PR title, how about:
fix(webui): Respect case sensitivity setting in search queries (fixes #1060); refactor Zustand usages.
| const queryString = useSearchStore((state) => state.queryString); | ||
| const queryIsCaseSensitive = useSearchStore((state) => state.queryIsCaseSensitive); | ||
| const updateQueryString = useSearchStore((state) => state.updateQueryString); | ||
| const updateQueryIsCaseSensitive = useSearchStore((state) => state.updateQueryIsCaseSensitive); | ||
| const searchUiState = useSearchStore((state) => state.searchUiState); |
There was a problem hiding this comment.
- let's try to alphabetize the state retreivals
- for actions whose definitions usually won't change, let's retrieve them non-reactively
| const queryString = useSearchStore((state) => state.queryString); | |
| const queryIsCaseSensitive = useSearchStore((state) => state.queryIsCaseSensitive); | |
| const updateQueryString = useSearchStore((state) => state.updateQueryString); | |
| const updateQueryIsCaseSensitive = useSearchStore((state) => state.updateQueryIsCaseSensitive); | |
| const searchUiState = useSearchStore((state) => state.searchUiState); | |
| const queryIsCaseSensitive = useSearchStore((state) => state.queryIsCaseSensitive); | |
| const queryString = useSearchStore((state) => state.queryString); | |
| const searchUiState = useSearchStore((state) => state.searchUiState); | |
...
const handleCaseSensitiveChange = useCallback((newValue: boolean) => {
const {updateQueryIsCaseSensitive} = useSearchStore.getState();
updateQueryIsCaseSensitive(newValue);
}, []);
const handleChange = useCallback((ev: ChangeEvent<HTMLInputElement>) => {
const {updateQueryString} = useSearchStore.getState();
updateQueryString(ev.target.value);
}, []);
<QueryBox
isCaseSensitive={queryIsCaseSensitive}
placeholder={"Enter your query"}
progress={pseudoProgress}
size={"large"}
value={queryString}
disabled={
searchUiState === SEARCH_UI_STATE.QUERY_ID_PENDING ||
searchUiState === SEARCH_UI_STATE.QUERYING
}
onCaseSensitiveChange={handleCaseSensitiveChange}
onChange={handleChange}/>
| const searchUiState = useSearchStore((state) => state.searchUiState); | ||
| const timeRange = useSearchStore((state) => state.timeRange); | ||
| const queryString = useSearchStore((state) => state.queryString); | ||
| const updateTimelineConfig = useSearchStore((state) => state.updateTimelineConfig); | ||
| const queryIsCaseSensitive = useSearchStore((state) => state.queryIsCaseSensitive); |
There was a problem hiding this comment.
- ditto: order
- ditto: action retrieval
| const searchUiState = useSearchStore((state) => state.searchUiState); | |
| const timeRange = useSearchStore((state) => state.timeRange); | |
| const queryString = useSearchStore((state) => state.queryString); | |
| const updateTimelineConfig = useSearchStore((state) => state.updateTimelineConfig); | |
| const queryIsCaseSensitive = useSearchStore((state) => state.queryIsCaseSensitive); | |
| const queryIsCaseSensitive = useSearchStore((state) => state.queryIsCaseSensitive); | |
| const queryString = useSearchStore((state) => state.queryString); | |
| const searchUiState = useSearchStore((state) => state.searchUiState); | |
| const timelineConfig = useSearchStore((state) => state.timelineConfig); |
...
const handleTimelineZoom = useCallback((newTimeRange: [Dayjs, Dayjs]) => {
const newTimelineConfig: TimelineConfig = computeTimelineConfig(newTimeRange);
// Update range picker selection to match zoomed range.
const {
updateTimeRange, updateTimeRangeOption, updateTimelineConfig,
} = useSearchStore.getState();
updateTimeRange(newTimeRange);
updateTimeRangeOption(TIME_RANGE_OPTION.CUSTOM);
updateTimelineConfig(newTimelineConfig);
const isQueryStringEmpty = queryString === SEARCH_STATE_DEFAULT.queryString;
if (isQueryStringEmpty) {
return;
}
handleQuerySubmit({
ignoreCase: false === queryIsCaseSensitive,
queryString: queryString,
timeRangeBucketSizeMillis: newTimelineConfig.bucketDuration.asMilliseconds(),
timestampBegin: newTimeRange[0].valueOf(),
timestampEnd: newTimeRange[1].valueOf(),
});
}, [
queryIsCaseSensitive,
queryString,
]);
(also move handleTimelineZoom to show up before the useEffect() block)
| const queryString = useSearchStore((state) => state.queryString); | ||
| const updateTimeRange = useSearchStore((state) => state.updateTimeRange); | ||
| const updateTimeRangeOption = useSearchStore((state) => state.updateTimeRangeOption); | ||
| const timelineConfig = useSearchStore((state) => state.timelineConfig); | ||
| const searchUiState = useSearchStore((state) => state.searchUiState); | ||
| const updateTimelineConfig = useSearchStore((state) => state.updateTimelineConfig); | ||
| const updateNumSearchResultsTimeline = useSearchStore( | ||
| (state) => state.updateNumSearchResultsTimeline | ||
| ); | ||
| const queryIsCaseSensitive = useSearchStore((state) => state.queryIsCaseSensitive); |
There was a problem hiding this comment.
| const queryString = useSearchStore((state) => state.queryString); | |
| const updateTimeRange = useSearchStore((state) => state.updateTimeRange); | |
| const updateTimeRangeOption = useSearchStore((state) => state.updateTimeRangeOption); | |
| const timelineConfig = useSearchStore((state) => state.timelineConfig); | |
| const searchUiState = useSearchStore((state) => state.searchUiState); | |
| const updateTimelineConfig = useSearchStore((state) => state.updateTimelineConfig); | |
| const updateNumSearchResultsTimeline = useSearchStore( | |
| (state) => state.updateNumSearchResultsTimeline | |
| ); | |
| const queryIsCaseSensitive = useSearchStore((state) => state.queryIsCaseSensitive); | |
| const queryString = useSearchStore((state) => state.queryString); | |
| const queryIsCaseSensitive = useSearchStore((state) => state.queryIsCaseSensitive); | |
| const searchUiState = useSearchStore((state) => state.searchUiState); | |
| const timeRange = useSearchStore((state) => state.timeRange); |
...
const handleSubmitButtonClick = useCallback(() => {
// Update timeline to match range picker selection.
const newTimelineConfig = computeTimelineConfig(timeRange);
const {updateTimelineConfig} = useSearchStore.getState();
updateTimelineConfig(newTimelineConfig);
handleQuerySubmit({
ignoreCase: false === queryIsCaseSensitive,
queryString: queryString,
timeRangeBucketSizeMillis: newTimelineConfig.bucketDuration.asMilliseconds(),
timestampBegin: timeRange[0].valueOf(),
timestampEnd: timeRange[1].valueOf(),
});
}, [
queryString,
queryIsCaseSensitive,
timeRange,
]);
…-scope#1060); refactor Zustand usages. (y-scope#1063) Co-authored-by: Marco <david.marcovitch@yscope.com>
…-scope#1060); refactor Zustand usages. (y-scope#1063) Co-authored-by: Marco <david.marcovitch@yscope.com>
Description
Case sensitivity option was submitted as part of query, this PR adds missing option.
I also did some minor refactoring per new zustand guidelines in affected files
Checklist
breaking change.
Validation performed
Tested case sensitivity toggle works
Summary by CodeRabbit