-
Notifications
You must be signed in to change notification settings - Fork 18
feat(search): Add support for persisting and sharing query via URL. #173
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
feat(search): Add support for persisting and sharing query via URL. #173
Conversation
WalkthroughThis update introduces new URL hash parameters for search query state (case sensitivity, regex, and query string), synchronizes these parameters between the URL and the application's store, and adds a share button to the SearchTabPanel that copies a permalink containing these search parameters. It also updates relevant type definitions and error messages. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant SearchTabPanel
participant UrlContext
participant Clipboard
User->>SearchTabPanel: Clicks Share Button
SearchTabPanel->>UrlContext: Retrieves queryString, isCaseSensitive, isRegex
SearchTabPanel->>Clipboard: Calls copyPermalinkToClipboard with params
Clipboard-->>User: Permalink with search params copied
sequenceDiagram
participant UrlContext
participant AppController
participant queryStore
UrlContext-->>AppController: Provides queryString, isCaseSensitive, isRegex
AppController->>queryStore: Updates state via setters
AppController->>queryStore: Triggers startQuery if UI state is READY and queryString changes
Possibly related PRs
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
npm warn config production Use 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🧰 Additional context used📓 Path-based instructions (1)`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ` rather than `!`.
🧠 Learnings (1)src/contexts/UrlContextProvider.tsx (1)
🧬 Code Graph Analysis (3)src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx (2)
src/components/AppController.tsx (4)
src/contexts/UrlContextProvider.tsx (1)
🔇 Additional comments (17)
✨ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx (1)
80-86
: Consider omitting the empty object parameter.The empty object passed as
hashParamsUpdates
is unnecessary.const handleShareButtonClick = () => { copyPermalinkToClipboard({ queryString: queryString, isCaseSensitive: getIsCaseSensitive(queryOptions), isRegex: getIsRegex(queryOptions), - }, {}); + }); };src/contexts/StateContextProvider.tsx (1)
459-468
: Simplify the search parameter condition.The condition is complex and could be simplified. Also, consider moving the URL parameter reset to a cleanup function.
useEffect(() => { - if (URL_SEARCH_PARAMS_DEFAULT.queryString !== queryString && URL_SEARCH_PARAMS_DEFAULT.isCaseSensitive !== isCaseSensitive && URL_SEARCH_PARAMS_DEFAULT.isRegex !== isRegex) { + const hasSearchParams = queryString !== URL_SEARCH_PARAMS_DEFAULT.queryString || + isCaseSensitive !== URL_SEARCH_PARAMS_DEFAULT.isCaseSensitive || + isRegex !== URL_SEARCH_PARAMS_DEFAULT.isRegex; + + if (hasSearchParams) { startQuery({queryString, isCaseSensitive, isRegex}); } - updateWindowUrlSearchParams({ - [SEARCH_PARAM_NAMES.QUERY_STRING]: URL_SEARCH_PARAMS_DEFAULT.queryString, - [SEARCH_PARAM_NAMES.IS_CASE_SENSITIVE]: URL_SEARCH_PARAMS_DEFAULT.isCaseSensitive, - [SEARCH_PARAM_NAMES.IS_REGEX]: URL_SEARCH_PARAMS_DEFAULT.isRegex, - }); + + return () => { + updateWindowUrlSearchParams({ + [SEARCH_PARAM_NAMES.QUERY_STRING]: URL_SEARCH_PARAMS_DEFAULT.queryString, + [SEARCH_PARAM_NAMES.IS_CASE_SENSITIVE]: URL_SEARCH_PARAMS_DEFAULT.isCaseSensitive, + [SEARCH_PARAM_NAMES.IS_REGEX]: URL_SEARCH_PARAMS_DEFAULT.isRegex, + }); + }; }, [isFileLoaded]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
(4 hunks)src/contexts/StateContextProvider.tsx
(4 hunks)src/contexts/UrlContextProvider.tsx
(2 hunks)src/typings/url.ts
(2 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
src/contexts/UrlContextProvider.tsx (1)
Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}
: - Prefer false == <expression>
rather than !<expression>
.
src/typings/url.ts (1)
Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}
: - Prefer false == <expression>
rather than !<expression>
.
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx (1)
Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}
: - Prefer false == <expression>
rather than !<expression>
.
src/contexts/StateContextProvider.tsx (1)
Pattern **/*.{cpp,hpp,java,js,jsx,ts,tsx}
: - Prefer false == <expression>
rather than !<expression>
.
🔇 Additional comments (9)
src/typings/url.ts (2)
6-8
: LGTM! The new search parameter names are well-defined.The added enum values follow consistent naming conventions and use appropriate camelCase for URL parameters.
17-19
: LGTM! The interface properties are well-typed.The added properties use appropriate types and maintain type safety through computed property names.
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx (3)
16-16
: LGTM! The imports support the new sharing functionality.The added imports are necessary and well-organized.
Also applies to: 21-24
72-72
: LGTM! The URL context integration is well-implemented.The context usage and state initialization follow React best practices with proper null handling.
Also applies to: 75-75
131-136
: LGTM! The share button UI is well-integrated.The button follows consistent patterns and provides clear user feedback through the tooltip.
src/contexts/UrlContextProvider.tsx (1)
27-29
: LGTM! The default parameters are consistently defined.The new search parameters follow the established pattern and ordering.
src/contexts/StateContextProvider.tsx (3)
249-249
: LGTM! The URL context usage is complete.All necessary search parameters are extracted in a consistent order.
254-255
: LGTM! The file loading state is well-managed.The state is properly initialized and updated in the file info handler.
Also applies to: 309-309
424-425
: LGTM! The query state reset is appropriate.Query results and progress are properly reset when loading a new file.
(no rush; whenever you have time; preferably after your vacation) |
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.
great job. the changes are mostly clean but i think we can make some structural improvements.
please do merge yscope/main
into your branch before making further changes, to avoid more conflicts.
# Conflicts: # src/typings/url.ts
…s after file is loaded
# Conflicts: # src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
…nk with params 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.
Actionable comments posted: 1
🧹 Nitpick comments (3)
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx (3)
53-53
: Consider restructuring to avoid disabling the max-lines-per-function lint rule.
If feasible, reduce the function’s size by extracting logic into smaller helper functions, which can improve maintainability and readability.
118-119
: Adhere to the coding guideline for negation checks.
Replace!queryIsCaseSensitive
withfalse == queryIsCaseSensitive
for consistency.-handleQuerySubmit({queryIsCaseSensitive: !queryIsCaseSensitive}); -setQueryIsCaseSensitive(!queryIsCaseSensitive); +handleQuerySubmit({queryIsCaseSensitive: false == queryIsCaseSensitive}); +setQueryIsCaseSensitive(false == queryIsCaseSensitive);
123-124
: Maintain consistency for the regex negation as well.
Similarly, usefalse == queryIsRegex
instead of!queryIsRegex
.-handleQuerySubmit({queryIsRegex: !queryIsRegex}); -setQueryIsRegex(!queryIsRegex); +handleQuerySubmit({queryIsRegex: false == queryIsRegex}); +setQueryIsRegex(false == queryIsRegex);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
(8 hunks)src/contexts/StateContextProvider.tsx
(4 hunks)src/contexts/UrlContextProvider.tsx
(4 hunks)src/services/LogFileManager/index.ts
(2 hunks)src/typings/query.ts
(1 hunks)src/typings/url.ts
(1 hunks)src/typings/worker.ts
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/contexts/StateContextProvider.tsx
- src/typings/url.ts
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ...
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}
: - Preferfalse == <expression>
rather than!<expression>
.
src/typings/worker.ts
src/typings/query.ts
src/services/LogFileManager/index.ts
src/contexts/UrlContextProvider.tsx
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
🪛 GitHub Check: lint-check
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
[failure] 81-81:
This line has a length of 109. Maximum allowed is 100
[failure] 86-86:
React Hook useEffect has missing dependencies: 'startQuery', 'urlQueryIsCaseSensitive', and 'urlQueryIsRegex'. Either include them or remove the dependency array
🪛 GitHub Actions: lint
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
[warning] 81-81: This line has a length of 109. Maximum allowed is 100 @stylistic/max-len
🔇 Additional comments (22)
src/typings/worker.ts (1)
115-116
: LGTM! Parameter renaming improves code clarity.The renaming of parameters to
queryIsCaseSensitive
andqueryIsRegex
enhances code readability by explicitly indicating these parameters are related to query operations.src/typings/query.ts (1)
3-4
: LGTM! Consistent parameter naming improves maintainability.Renaming these properties to
queryIsCaseSensitive
andqueryIsRegex
aligns with the changes in worker.ts, ensuring consistency across the codebase.src/services/LogFileManager/index.ts (3)
295-296
: LGTM! JSDoc updates match parameter renaming.The JSDoc parameter descriptions have been correctly updated to reflect the renamed parameters.
298-298
: Function signature properly updated to match type changes.The method signature has been updated to use the new parameter names, maintaining consistency with the type changes.
312-317
: LGTM! Variable references updated to match new parameter names.The internal code has been appropriately updated to reference the new parameter names.
src/contexts/UrlContextProvider.tsx (4)
34-36
: LGTM! New default hash parameters added for query sharing.The addition of these parameters to the default object enables the sharing feature for search parameters.
107-107
: LGTM! Condition properly handles false boolean values.The condition now correctly removes parameters when their value is
false
, which aligns with the expected behavior for boolean toggle parameters.
187-190
: Boolean type conversion is required for URL parameters.The
UrlSearchParams
interface may define boolean types, but URLSearchParams stores them as strings. Type conversion is necessary for type safety.
221-235
: LGTM! Proper handling of query parameters from URL hash.The implementation correctly retrieves and type-converts the query parameters from the URL hash. The string to boolean conversion is properly handled using string comparison.
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx (13)
3-3
: No concerns regarding the import ofuseEffect
.
It is properly added and necessary for the upcoming effect logic.
15-15
: The new icon import is a beneficial addition.
ImportingShareIcon
is straightforward and aligns with the sharing feature.
20-25
: Appropriate imports fromUrlContextProvider
.
They are correctly declared and will be useful for URL manipulation and sharing.
30-33
:UI_ELEMENT
andUI_STATE
usage is correct.
These are likely being used in the effect and logic with no apparent issues.
56-60
: DestructuringqueryString
,queryIsCaseSensitive
,queryIsRegex
is implemented correctly.
No concerns here; it cleanly retrieves values from theUrlContext
.
63-64
: State initialization for case sensitivity and regex flags is clear.
Setting both tofalse
by default is logical.
94-101
:handleShareButtonClick
function is straightforward.
Copying the permalink to the clipboard appears well-implemented for sharing the link.
105-106
:handleQuerySubmit
integration looks correct.
Referencing the new case-sensitivity and regex state flags aligns with the updated logic.
130-130
: No concerns with the updated panel container line.
The panel’s setup remains intact.
134-151
: New share button in the panel UI is well integrated.
It complements the existing collapse/expand button, enhancing user experience for link sharing.
161-161
: Binding the textarea’s value toqueryString
is correct.
Ensures the component reflects the current search input accurately.
170-171
:isChecked={queryIsCaseSensitive}
logic is fine.
No issues flagged by the new approach for toggling case-sensitivity.
182-183
:isChecked={queryIsRegex}
logic is also good.
The toggle correctly binds to the updated state for regex mode.
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
Outdated
Show resolved
Hide resolved
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.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx (1)
78-103
: Follow coding guidelines for conditional checks.According to the coding guidelines,
false == <expression>
should be preferred over!<expression>
.- if (null !== urlQueryString) { + if (null !== urlQueryString) {While this particular line already follows the guidelines, ensure all conditional checks throughout the component maintain this style.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
(8 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}`: - Prefer `false == ...
**/*.{cpp,hpp,java,js,jsx,tpp,ts,tsx}
: - Preferfalse == <expression>
rather than!<expression>
.
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
🔇 Additional comments (5)
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx (5)
108-115
: Good implementation of sharing functionality.The
handleShareButtonClick
method correctly captures the current search state and usescopyPermalinkToClipboard
to share it.
70-76
: Good use of refs to track URL context values.Using refs to track the URL context values helps prevent unnecessary re-renders while still keeping the component responsive to URL changes.
91-96
: Good formatting for line length compliance.The multi-line formatting for the hash parameters object effectively prevents line length issues that were flagged in previous reviews.
148-165
: Well-structured UI addition for share button.The share button is implemented consistently with the existing UI patterns, using the same component structure as the collapse/expand button.
99-103
: Properly handled useEffect dependencies.The useEffect now correctly includes
startQuery
in the dependency array, addressing the issue raised in the previous review.
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
Outdated
Show resolved
Hide resolved
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
Outdated
Show resolved
Hide resolved
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.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/components/AppController.tsx (1)
179-207
: Query parameter synchronization is correctly implemented.The three
useEffect
hooks properly synchronize URL query parameters with the query store. While the pattern is repetitive, this is acceptable given the specific synchronization requirements for each parameter type.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
src/components/AppController.tsx
(3 hunks)src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
(2 hunks)src/contexts/UrlContextProvider.tsx
(5 hunks)src/services/LogFileManager/index.ts
(1 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>
.
src/services/LogFileManager/index.ts
src/components/AppController.tsx
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
src/contexts/UrlContextProvider.tsx
🧠 Learnings (1)
src/contexts/UrlContextProvider.tsx (1)
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#173
File: src/contexts/UrlContextProvider.tsx:1-1
Timestamp: 2025-05-27T18:09:39.997Z
Learning: The UrlContextProvider in src/contexts/UrlContextProvider.tsx is planned to be eventually replaced and deleted, so refactoring efforts to reduce its file size should be avoided despite it being large enough to require eslint-disable max-lines.
🧬 Code Graph Analysis (2)
src/components/AppController.tsx (4)
src/contexts/UrlContextProvider.tsx (1)
UrlContext
(305-305)src/typings/states.ts (1)
UI_STATE
(106-106)src/services/LogFileManagerProxy.ts (1)
startQuery
(65-68)src/services/LogFileManager/index.ts (1)
startQuery
(356-386)
src/contexts/UrlContextProvider.tsx (1)
src/typings/url.ts (2)
HASH_PARAM_NAMES
(43-43)UrlSearchParams
(50-50)
🪛 GitHub Check: lint-check
src/components/AppController.tsx
[failure] 82-82:
Missing JSDoc @return declaration
[failure] 82-82:
Missing JSDoc block description
🪛 GitHub Actions: lint
src/components/AppController.tsx
[warning] 82-82: ESLint: Missing JSDoc block description (jsdoc/require-description)
🔇 Additional comments (7)
src/services/LogFileManager/index.ts (1)
366-368
: Excellent improvement to query lifecycle management!Moving the
#queryId
increment and#queryCount
reset after the early return condition is a logical improvement. This ensures that the query ID is only incremented when an actual query will be processed, while still properly resetting the UI state with empty results for invalid queries.src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx (2)
42-58
: Well-implemented share functionality with proper callback optimization.The share button implementation correctly:
- Uses
useCallback
for performance optimization with appropriate dependencies- Converts empty query string to
null
for clean URL parameters- Includes all necessary query parameters (
queryIsCaseSensitive
,queryIsRegex
,queryString
)- Follows the existing pattern with
handleCollapseAllButtonClick
66-82
: Share button UI integration looks good.The share button is properly integrated alongside the existing collapse/expand button with appropriate tooltips and icons.
src/contexts/UrlContextProvider.tsx (4)
36-39
: New hash parameter defaults are correctly defined.The addition of the three new query-related hash parameters with appropriate default values (
false
for booleans,null
for string) is consistent with the existing pattern.
109-109
: Improved hash parameter removal logic.Extending the removal condition to include
false
values in addition tonull
is logical for boolean hash parameters, ensuring clean URLs by removing default boolean values.
189-192
: More robust search parameter handling.The change from handling only predefined keys to iterating over all URL search parameters makes the implementation more flexible and future-proof.
228-242
: Query parameter parsing is correctly implemented.The parsing logic for the new query parameters correctly:
- Handles
queryString
as a direct string assignment- Converts boolean strings to actual boolean values for
queryIsCaseSensitive
andqueryIsRegex
- Uses consistent boolean parsing pattern with existing code
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.
looks very good now. please see my last batch of nitpicking comments
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
Show resolved
Hide resolved
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.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (4)
src/components/AppController.tsx
(4 hunks)src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
(2 hunks)src/contexts/UrlContextProvider.tsx
(5 hunks)src/services/LogFileManager/index.ts
(1 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>
.
src/components/AppController.tsx
src/services/LogFileManager/index.ts
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
src/contexts/UrlContextProvider.tsx
🧠 Learnings (1)
src/contexts/UrlContextProvider.tsx (1)
Learnt from: Henry8192
PR: y-scope/yscope-log-viewer#173
File: src/contexts/UrlContextProvider.tsx:1-1
Timestamp: 2025-05-27T18:09:39.997Z
Learning: The UrlContextProvider in src/contexts/UrlContextProvider.tsx is planned to be eventually replaced and deleted, so refactoring efforts to reduce its file size should be avoided despite it being large enough to require eslint-disable max-lines.
🧬 Code Graph Analysis (2)
src/components/AppController.tsx (4)
src/contexts/UrlContextProvider.tsx (1)
UrlContext
(305-305)src/typings/states.ts (1)
UI_STATE
(106-106)src/services/LogFileManagerProxy.ts (1)
startQuery
(65-68)src/services/LogFileManager/index.ts (1)
startQuery
(356-386)
src/contexts/UrlContextProvider.tsx (1)
src/typings/url.ts (2)
HASH_PARAM_NAMES
(43-43)UrlSearchParams
(50-50)
🔇 Additional comments (13)
src/components/AppController.tsx (2)
17-17
: LGTM: Query store integration.The addition of
useQueryStore
import properly supports the new query parameter synchronization functionality.
82-84
: LGTM: URL context parameter extraction.The extraction of query-related parameters from
UrlContext
correctly follows the established pattern and integrates well with the new URL hash parameter functionality.src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx (6)
2-2
: LGTM: useCallback import addition.The
useCallback
import is properly added to support the memoization of event handlers.
11-11
: LGTM: ShareIcon import.The
ShareIcon
import is correctly added for the new share button functionality.
35-38
: LGTM: Query store parameter extraction.The extraction of query parameters from the store follows the established pattern and provides the necessary data for the share functionality.
42-44
: LGTM: useCallback optimization.Wrapping
handleCollapseAllButtonClick
withuseCallback
is a good optimization that prevents unnecessary re-renders.
46-59
: LGTM: Well-implemented share functionality.The
handleShareButtonClick
callback is well-designed with:
- Proper
useCallback
memoization with correct dependencies- Logical handling of empty query strings (converts to
null
)- Appropriate parameter passing to
copyPermalinkToClipboard
- Clear intent for generating shareable URLs with current search state
66-83
: LGTM: Clean share button integration.The share button is cleanly integrated into the existing title buttons structure with appropriate title text and icon usage.
src/contexts/UrlContextProvider.tsx (5)
1-1
: Acceptable eslint adjustment for temporary file.Given that this file is planned for replacement (as noted in retrieved learnings), the eslint max-lines increase to 350 is acceptable for the current functionality additions.
36-38
: LGTM: Query hash parameters addition.The new query-related hash parameters are properly added with appropriate default values:
queryIsCaseSensitive
:false
(reasonable default)queryIsRegex
:false
(reasonable default)queryString
:null
(indicates no active query)
109-109
: LGTM: Extended parameter removal logic.Extending the condition to remove parameters when their value is
false
makes sense for boolean hash parameters, allowing cleaner URLs when using default values.
189-191
: LGTM: Flexible search parameter handling.Changing to copy all URL search parameters instead of only predefined keys provides more flexibility for handling dynamic parameters.
228-242
: LGTM: Consistent query parameter parsing.The parsing logic for the new query hash parameters is well-implemented:
- String parameters are handled directly
- Boolean parameters use consistent
"true" === value
comparison (matching the existingisPrettified
pattern at line 246)- Proper null checking before assignment
Co-authored-by: Junhao Liao <junhao@junhao.ca>
src/components/CentralContainer/Sidebar/SidebarTabs/SearchTabPanel/index.tsx
Show resolved
Hide resolved
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.
for the PR title, how about:
feat(search): Add support for persisting and sharing query via URL.
@zzxthehappiest please help merging the changes from this PR to #286 🙏 |
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.
when the app loads, we should switch to the "Search" sidebar tab if the query-related parameters are found in the URL
@coderabbitai submit a feature request issue
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.
🧩 Analysis chain
I'll create a feature request issue for automatically switching to the Search sidebar tab when query parameters are present in the URL.
@junhaoliao I've created a feature request issue for automatically switching to the Search sidebar tab when query-related parameters are found in the URL. This will improve the user experience when people click on shared links with search parameters, as they'll immediately see the relevant search interface instead of having to manually switch tabs.
🏁 Script executed:
#!/bin/bash
# Create a GitHub issue for the feature request
gh issue create \
--title "feat: Auto-switch to Search tab when query parameters are present in URL" \
--body "## Feature Request
### Description
When the app loads and query-related parameters are found in the URL (such as \`queryString\`, \`queryIsRegex\`, or \`queryIsCaseSensitive\`), the application should automatically switch to the \"Search\" sidebar tab to provide a better user experience.
### Current Behavior
- Users can share URLs with search parameters (implemented in PR #173)
- When clicking a shared link with search parameters, the app loads with the default sidebar tab
- Users must manually switch to the Search tab to see the search interface
### Expected Behavior
- When the app detects query-related hash parameters in the URL during initialization
- The sidebar should automatically switch to the \"Search\" tab
- This provides immediate context for the shared search query
### Context
This enhancement was requested during the review of PR #173 which introduced URL sharing functionality for search parameters.
### References
- Related PR: https://github.com/y-scope/yscope-log-viewer/pull/173
- Original comment: https://github.com/y-scope/yscope-log-viewer/pull/173#discussion_r2155778816
### Implementation Notes
The query-related parameters to check for include:
- \`queryString\`
- \`queryIsRegex\`
- \`queryIsCaseSensitive\`
Requested by: @junhaoliao" \
--assignee junhaoliao
Length of output: 1450
@junhaoliao Perfect! I've successfully created the feature request issue for automatically switching to the Search sidebar tab when query parameters are present in the URL.
Issue created: #331
The issue includes:
- Clear description of the desired behavior
- Current vs expected behavior comparison
- Implementation notes about which parameters to check for
- References to this PR and your original comment
- Assignment to you for tracking
This enhancement will definitely improve the user experience when people share and access search links, as they'll immediately see the search interface without having to manually switch tabs.
Description
Add support to making queries in the url. Also, a button that generates link to current query is added in
SearchTabPanel
.Validation performed
Summary by CodeRabbit