feat(webui): Add configurable max results limit to CLP search UI.#2289
feat(webui): Add configurable max results limit to CLP search UI.#2289hoophalab wants to merge 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThis pull request adds a user-facing maximum results selector to the search interface, wiring it through client state, server acceptance, and result-fetch constraints. Users choose result limits from predefined options; the selection flows into query submission, server job creation, and both cursor-based fetching and persisted result capping. ChangesConfigurable Maximum Search Results Selection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Native/SearchResultsVirtualTable/useSearchResults.ts`:
- Line 13: The hook in useSearchResults.ts currently destructures the entire
useSearchStore state with "const {searchJobId, maxNumResults} =
useSearchStore()", causing subscriptions to all state changes; change this to
selective Zustand selectors by calling useSearchStore with a selector function
that returns only searchJobId and maxNumResults (e.g., useSearchStore(s => ({
searchJobId: s.searchJobId, maxNumResults: s.maxNumResults }))) or two separate
calls to subscribe individually, so the component only re-renders when those
specific properties change; update references in the file to use the new
selector-returned values.
In `@components/webui/common/src/schemas/search.ts`:
- Line 18: The schema for maxNumResults currently only specifies
Type.Optional(Type.Integer({minimum: 1})); update the field to enforce an upper
bound of 10000 so callers cannot request unbounded results — e.g. change the
integer constraints to include maximum: 10000 while keeping the field optional
(modify the maxNumResults declaration in
components/webui/common/src/schemas/search.ts to use Type.Integer({minimum: 1,
maximum: 10000})).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: cf3a14e3-ee5a-45fa-88fa-fd46c626a74e
📒 Files selected for processing (16)
components/webui/client/src/components/QueryBox/index.module.csscomponents/webui/client/src/pages/SearchPage/SearchControls/Dataset/index.module.csscomponents/webui/client/src/pages/SearchPage/SearchControls/MaxResultsSelect/index.module.csscomponents/webui/client/src/pages/SearchPage/SearchControls/MaxResultsSelect/index.tsxcomponents/webui/client/src/pages/SearchPage/SearchControls/Native/NativeControls.tsxcomponents/webui/client/src/pages/SearchPage/SearchControls/Native/SearchButton/SubmitButton/index.tsxcomponents/webui/client/src/pages/SearchPage/SearchControls/TimeRangeInput/index.module.csscomponents/webui/client/src/pages/SearchPage/SearchControls/index.module.csscomponents/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Native/SearchResultsVirtualTable/useSearchResults.tscomponents/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTimeline/Native/NativeResultsTimeline.tsxcomponents/webui/client/src/pages/SearchPage/SearchState/index.tsxcomponents/webui/client/src/pages/SearchPage/SearchState/typings.tscomponents/webui/common/src/schemas/search.tscomponents/webui/server/src/routes/api/search/index.tscomponents/webui/server/src/routes/api/search/typings.tscomponents/webui/server/src/routes/api/search/utils.ts
| */ | ||
| const useSearchResults = () => { | ||
| const {searchJobId} = useSearchStore(); | ||
| const {searchJobId, maxNumResults} = useSearchStore(); |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify full-state Zustand subscriptions in SearchPage code.
rg -nP --type=ts --type=tsx 'useSearchStore\s*\(\s*\)' components/webui/client/src/pages/SearchPageRepository: y-scope/clp
Length of output: 83
🏁 Script executed:
# First, let's read the target file to verify the code at line 13
cat -n components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Native/SearchResultsVirtualTable/useSearchResults.ts | head -30Repository: y-scope/clp
Length of output: 1276
🏁 Script executed:
# Search for full-state Zustand subscriptions using correct file type flags
rg -nP --type=ts 'useSearchStore\s*\(\s*\)' components/webui/client/src/pages/SearchPageRepository: y-scope/clp
Length of output: 1376
🏁 Script executed:
# Also search for useSearchStore definition to understand the store structure
fd -e ts -e tsx useSearchStore | head -5Repository: y-scope/clp
Length of output: 37
🏁 Script executed:
# Find the SearchState index file to see useSearchStore definition
cat -n components/webui/client/src/pages/SearchPage/SearchState/index.ts | head -100Repository: y-scope/clp
Length of output: 153
🏁 Script executed:
# Check if there are any examples of selective Zustand subscriptions in the codebase
rg -A2 'useSearchStore\s*\(\s*\(\s*state\s*\)' components/webui/client/src/pages/SearchPageRepository: y-scope/clp
Length of output: 19282
🏁 Script executed:
# Also search broader for state selector patterns
rg '\(\s*state\s*\)\s*=>' components/webui/client/src/pages/SearchPage --type=ts --type=tsx -A1 | head -30Repository: y-scope/clp
Length of output: 83
🏁 Script executed:
# Find the SearchState definition file with different extensions
fd -e js -e jsx -e ts -e tsx SearchState/index components/webui/client/src/pages/SearchPageRepository: y-scope/clp
Length of output: 37
🏁 Script executed:
# Also search for the file in the parent SearchState directory
ls -la components/webui/client/src/pages/SearchPage/SearchState/Repository: y-scope/clp
Length of output: 562
🏁 Script executed:
# Read the SearchState store definition to confirm Zustand usage
cat -n components/webui/client/src/pages/SearchPage/SearchState/index.tsx | head -80Repository: y-scope/clp
Length of output: 2874
Use selective Zustand store subscriptions instead of full-state destructuring.
This hook subscribes to all store property changes when only searchJobId and maxNumResults are needed. Using selector functions limits re-renders to changes in those specific properties, improving performance and following the established pattern throughout the codebase.
Proposed refactor
- const {searchJobId, maxNumResults} = useSearchStore();
+ const searchJobId = useSearchStore((state) => state.searchJobId);
+ const maxNumResults = useSearchStore((state) => state.maxNumResults);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const {searchJobId, maxNumResults} = useSearchStore(); | |
| const searchJobId = useSearchStore((state) => state.searchJobId); | |
| const maxNumResults = useSearchStore((state) => state.maxNumResults); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Native/SearchResultsVirtualTable/useSearchResults.ts`
at line 13, The hook in useSearchResults.ts currently destructures the entire
useSearchStore state with "const {searchJobId, maxNumResults} =
useSearchStore()", causing subscriptions to all state changes; change this to
selective Zustand selectors by calling useSearchStore with a selector function
that returns only searchJobId and maxNumResults (e.g., useSearchStore(s => ({
searchJobId: s.searchJobId, maxNumResults: s.maxNumResults }))) or two separate
calls to subscribe individually, so the component only re-renders when those
specific properties change; update references in the file to use the new
selector-returned values.
| const QueryJobCreationSchema = Type.Object({ | ||
| datasets: Type.Array(Type.String()), | ||
| ignoreCase: Type.Boolean(), | ||
| maxNumResults: Type.Optional(Type.Integer({minimum: 1})), |
There was a problem hiding this comment.
Add an upper bound for maxNumResults in the request schema.
minimum: 1 alone lets callers send unbounded limits (for example via direct API calls), which can drive expensive query and fetch paths. Please enforce the same ceiling used by product behaviour (10,000) at schema level.
Suggested patch
- maxNumResults: Type.Optional(Type.Integer({minimum: 1})),
+ maxNumResults: Type.Optional(Type.Integer({
+ minimum: 1,
+ maximum: 10000,
+ })),📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| maxNumResults: Type.Optional(Type.Integer({minimum: 1})), | |
| maxNumResults: Type.Optional(Type.Integer({ | |
| minimum: 1, | |
| maximum: 10000, | |
| })), |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@components/webui/common/src/schemas/search.ts` at line 18, The schema for
maxNumResults currently only specifies Type.Optional(Type.Integer({minimum:
1})); update the field to enforce an upper bound of 10000 so callers cannot
request unbounded results — e.g. change the integer constraints to include
maximum: 10000 while keeping the field optional (modify the maxNumResults
declaration in components/webui/common/src/schemas/search.ts to use
Type.Integer({minimum: 1, maximum: 10000})).
Description
Checklist
breaking change.
Validation performed
Summary by CodeRabbit
New Features
Style