refactor: always preserve marketplace search state in URL#9
Conversation
Greptile OverviewGreptile SummaryRefactored marketplace to always preserve search state in URL by removing conditional logic and the Critical issues found:
Positive changes:
Confidence Score: 1/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Browser
participant Marketplace
participant useSearchPluginText
participant useActivePluginType
participant useFilterPluginTags
participant URL as URL Query Params
participant useMarketplaceSearchMode
participant useMarketplaceData
User->>Browser: Navigate to marketplace
Browser->>Marketplace: Load component
Marketplace->>useSearchPluginText: Call hook
useSearchPluginText->>URL: Read 'q' param via useQueryState
URL-->>useSearchPluginText: Return search text
Marketplace->>useActivePluginType: Call hook
useActivePluginType->>URL: Read 'tab' param via useQueryState
URL-->>useActivePluginType: Return active type
Marketplace->>useFilterPluginTags: Call hook
useFilterPluginTags->>URL: Read 'tags' param via useQueryState
URL-->>useFilterPluginTags: Return tags array
Marketplace->>useMarketplaceSearchMode: Calculate search mode
useMarketplaceSearchMode->>useMarketplaceSearchMode: Check if activePluginType in PLUGIN_CATEGORY_WITH_COLLECTIONS
Note over useMarketplaceSearchMode: BUG: Logic inverted<br/>Now returns true for 'all'/'tool'<br/>instead of 'model'/'agent'
useMarketplaceSearchMode-->>Marketplace: Return isSearchMode
Marketplace->>useMarketplaceData: Fetch data
alt isSearchMode = true
useMarketplaceData->>useMarketplaceData: Use search query
else isSearchMode = false
useMarketplaceData->>useMarketplaceData: Use collections query
end
User->>Marketplace: Change filter/search
Marketplace->>URL: Update query params
Note over URL: All state now persisted in URL<br/>(removed conditional logic)
|
| const isSearchMode = !!searchPluginText | ||
| || filterPluginTags.length > 0 | ||
| || (searchMode ?? (!PLUGIN_CATEGORY_WITH_COLLECTIONS.has(activePluginType))) | ||
| || (searchMode ?? (PLUGIN_CATEGORY_WITH_COLLECTIONS.has(activePluginType))) |
There was a problem hiding this comment.
logic inverted - removed negation operator changes when search mode activates
Before: search mode was true for categories NOT in PLUGIN_CATEGORY_WITH_COLLECTIONS (e.g., 'model', 'agent')
After: search mode is true for categories IN the set (e.g., 'all', 'tool')
This completely reverses which plugin categories trigger search mode vs collection mode
| || (searchMode ?? (PLUGIN_CATEGORY_WITH_COLLECTIONS.has(activePluginType))) | |
| || (searchMode ?? (!PLUGIN_CATEGORY_WITH_COLLECTIONS.has(activePluginType))) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/app/components/plugins/marketplace/atoms.ts
Line: 43:43
Comment:
logic inverted - removed negation operator changes when search mode activates
Before: search mode was `true` for categories NOT in `PLUGIN_CATEGORY_WITH_COLLECTIONS` (e.g., 'model', 'agent')
After: search mode is `true` for categories IN the set (e.g., 'all', 'tool')
This completely reverses which plugin categories trigger search mode vs collection mode
```suggestion
|| (searchMode ?? (!PLUGIN_CATEGORY_WITH_COLLECTIONS.has(activePluginType)))
```
How can I resolve this? If you propose a fix, please make it concise.| } | ||
|
|
||
| export function usePluginPageContext(selector: (value: PluginPageContextValue) => any) { | ||
| export function usePluginPageContext(selector: any) { |
There was a problem hiding this comment.
any type bypasses TypeScript type checking, violating project rule #9
The selector should use a generic type parameter like other contexts in the codebase (e.g., app-context.tsx:48, modal-context.tsx:67)
| export function usePluginPageContext(selector: any) { | |
| export function usePluginPageContext<T>(selector: (value: PluginPageContextValue) => T): T { |
Context Used: Context from dashboard - AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/app/components/plugins/plugin-page/context.tsx
Line: 51:51
Comment:
`any` type bypasses TypeScript type checking, violating project rule #9
The selector should use a generic type parameter like other contexts in the codebase (e.g., `app-context.tsx:48`, `modal-context.tsx:67`)
```suggestion
export function usePluginPageContext<T>(selector: (value: PluginPageContextValue) => T): T {
```
**Context Used:** Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=16b28b0e-8897-4cdb-9b17-0e9c857390af))
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.| const queryState = useQueryState('category', marketplaceSearchParamsParsers.category) | ||
| const atomState = useAtom(activePluginTypeAtom) | ||
| return preserveSearchStateInQuery ? queryState : atomState | ||
| return useQueryState('tab', marketplaceSearchParamsParsers.category) |
There was a problem hiding this comment.
changed query param name from category to tab - this breaks URL compatibility
Users with existing bookmarks or shared links using ?category=tool will lose their filter state. The parser still expects category (marketplaceSearchParamsParsers.category in search-params.ts:6)
Prompt To Fix With AI
This is a comment left during a code review.
Path: web/app/components/plugins/marketplace/atoms.ts
Line: 23:23
Comment:
changed query param name from `category` to `tab` - this breaks URL compatibility
Users with existing bookmarks or shared links using `?category=tool` will lose their filter state. The parser still expects `category` (`marketplaceSearchParamsParsers.category` in `search-params.ts:6`)
How can I resolve this? If you propose a fix, please make it concise.
Benchmark PR from agentic-review-benchmarks#9