Fix web search toggle first-time behavior#307
Conversation
Deploying maple with
|
| Latest commit: |
64c6d69
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9adda1c2.maple-ca8.pages.dev |
| Branch Preview URL: | https://fix-web-search-first-time-to.maple-ca8.pages.dev |
WalkthroughRefactors first-time web search handling in Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UnifiedChat as Component
participant Storage
participant Dialog
User->>Component: triggers first-time web search info
Component->>Storage: setItem("hasSeenWebSearchInfo","true")
Component->>Component: setIsWebSearchEnabled(true)
Component->>Dialog: open()
User->>Dialog: closes dialog
Dialog->>Component: onOpenChange(isOpen=false)
Component->>Component: update dialog state only
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (1)
Comment |
- Globe icon now enables web search immediately on first click - First-time popup shows after enabling, with flag set to prevent future popups - Closing popup (any method) only dismisses dialog without additional actions - Subsequent globe clicks toggle web search on/off normally Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
b16b970 to
64c6d69
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
frontend/src/components/UnifiedChat.tsx (1)
2497-2532: Consider extracting duplicated web search toggle logic into a shared handler.The web search toggle logic appears identically in two locations (lines 502-532 for centered input and lines 2761-2791 for bottom input). This duplication creates a maintenance risk if the behavior needs to change in the future.
Consider extracting this into a shared handler:
+ // Handler for web search toggle - used in both input areas + const handleWebSearchToggle = useCallback(() => { + // Step 1: Check if user has access (free/starter users see upsell) + if (!canUseWebSearch) { + setUpgradeFeature("websearch"); + setUpgradeDialogOpen(true); + return; + } + + // Step 2: Check if this is their first time (enable web search, set flag, show popup) + const hasSeenWebSearchInfo = + localStorage.getItem("hasSeenWebSearchInfo") === "true"; + if (!hasSeenWebSearchInfo) { + localStorage.setItem("hasSeenWebSearchInfo", "true"); + setIsWebSearchEnabled(true); + setWebSearchInfoDialogOpen(true); + return; + } + + // Step 3: Toggle web search directly + setIsWebSearchEnabled(!isWebSearchEnabled); + }, [canUseWebSearch, isWebSearchEnabled]);Then use
onClick={handleWebSearchToggle}in both Button components.Also applies to: 2756-2791
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/components/UnifiedChat.tsx(3 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.{ts,tsx,js,jsx}: Use 2-space indentation, double quotes, and a 100-character line limit for formatting
Use camelCase for variable and function names
Use try/catch with specific error types for error handling
Files:
frontend/src/components/UnifiedChat.tsx
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Use strict TypeScript typing and avoid
anywhen possible
Files:
frontend/src/components/UnifiedChat.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: build-linux
- GitHub Check: build-macos (universal-apple-darwin)
- GitHub Check: build-android
- GitHub Check: build-ios
- GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
frontend/src/components/UnifiedChat.tsx (2)
510-518: Logic is correct for first-time web search behavior.The implementation correctly enables web search and sets the flag on the first click, then displays the info dialog. This fixes the issue described in the PR where the first click previously didn't activate web search.
However, note that this exact logic is duplicated at lines 2769-2777 for the bottom input area. See my next comment for a refactoring suggestion.
2930-2941: LGTM! Dialog handlers correctly simplified.The dialog close handlers now only dismiss the dialog, which is correct since web search is already enabled when the globe icon is clicked. The comments clearly document this behavior.
Greptile OverviewGreptile SummaryFixed web search toggle first-time behavior by enabling web search immediately on first click instead of waiting for dialog dismissal. Key Changes:
Impact:
Confidence Score: 5/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant GlobeButton
participant LocalStorage
participant State
participant Dialog
Note over User,Dialog: First-time user clicks globe icon (NEW BEHAVIOR)
User->>GlobeButton: Click globe icon
GlobeButton->>LocalStorage: Check hasSeenWebSearchInfo
LocalStorage-->>GlobeButton: false (first time)
GlobeButton->>LocalStorage: Set hasSeenWebSearchInfo = true
GlobeButton->>State: setIsWebSearchEnabled(true)
GlobeButton->>Dialog: Show info dialog
Dialog-->>User: Display info popup
User->>Dialog: Click "Got it" / X / backdrop
Dialog->>Dialog: Close dialog (no state changes)
Note over User,Dialog: Subsequent clicks (toggle behavior)
User->>GlobeButton: Click globe icon again
GlobeButton->>LocalStorage: Check hasSeenWebSearchInfo
LocalStorage-->>GlobeButton: true
GlobeButton->>State: Toggle isWebSearchEnabled
State-->>User: Web search toggled on/off
|
|
@TestFlight build |
|
🚀 TestFlight deployment triggered! Check the Actions tab for progress. |
|
✅ TestFlight deployment completed successfully! |
Problem
On the Tauri version (Android/Desktop), the web search first-time popup wasn't working correctly:
Solution
Testing
Summary by CodeRabbit