Skip to content

Fix web search toggle first-time behavior#307

Merged
AnthonyRonning merged 1 commit intomasterfrom
fix-web-search-first-time-toggle
Nov 12, 2025
Merged

Fix web search toggle first-time behavior#307
AnthonyRonning merged 1 commit intomasterfrom
fix-web-search-first-time-toggle

Conversation

@AnthonyRonning
Copy link
Contributor

@AnthonyRonning AnthonyRonning commented Nov 12, 2025

Problem

On the Tauri version (Android/Desktop), the web search first-time popup wasn't working correctly:

  • Clicking the globe icon for the first time didn't set the flag or activate web search
  • Only closing the dialog (any method) would set the flag and activate search
  • This meant the popup could show multiple times and the globe wouldn't be active on first click

Solution

  • Globe icon now enables web search immediately on first click
  • Flag is set on first click to prevent future popups
  • Popup shows after enabling to inform the user
  • Closing popup (via X, backdrop, or "Got it") only dismisses the dialog
  • Subsequent clicks toggle web search on/off normally

Testing

  • Verified build passes with all pre-commit hooks
  • Linting and formatting checks pass

Summary by CodeRabbit

  • Bug Fixes
    • Web search is now enabled immediately when first-time users trigger the web search introduction, improving onboarding.
    • Closing the web search info dialog no longer implicitly enables web search or marks it as seen; those actions occur only at the initial trigger, reducing unexpected behavior.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 12, 2025

Deploying maple with  Cloudflare Pages  Cloudflare Pages

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

View logs

@coderabbitai
Copy link

coderabbitai bot commented Nov 12, 2025

Walkthrough

Refactors first-time web search handling in UnifiedChat.tsx: the code now sets the "hasSeenWebSearchInfo" flag and enables web search immediately during the first-time check, then opens the info dialog; the dialog close handler only updates dialog open state.

Changes

Cohort / File(s) Summary
Web search initialization timing
frontend/src/components/UnifiedChat.tsx
On first-time path, call localStorage.setItem("hasSeenWebSearchInfo","true") and setIsWebSearchEnabled(true) before opening the info dialog (done in two places); simplify WebSearchInfoDialog onOpenChange to only update dialog state and remove side effects.

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
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Localized to one file with two mirrored spots.
  • Verify that enabling web search earlier doesn't interact poorly with downstream logic or assumptions.
  • Check for remaining side-effectful code in onOpenChange and any consumers of the dialog state.

Poem

🐇 I nudged the flag, then leapt away,
The search awoke at start of play,
A tiny hop, a toggle true,
The info pane then sang anew,
Hooray — the web is ready to snoop!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix web search toggle first-time behavior' accurately and specifically describes the main change: fixing the web search toggle behavior on first interaction.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-web-search-first-time-toggle

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b16b970 and 64c6d69.

📒 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 any when 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). (4)
  • GitHub Check: build-linux
  • GitHub Check: build-ios
  • GitHub Check: build-android
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
frontend/src/components/UnifiedChat.tsx (1)

2930-2941: LGTM! Dialog handlers correctly simplified.

The dialog close handlers properly only dismiss the dialog without modifying state, since web search was already enabled when the globe icon was clicked. This aligns perfectly with the PR objective of fixing the first-time behavior.


Comment @coderabbitai help to get the list of available commands and usage tips.

- 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>
@AnthonyRonning AnthonyRonning force-pushed the fix-web-search-first-time-toggle branch from b16b970 to 64c6d69 Compare November 12, 2025 17:12
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1ee4d08 and b16b970.

📒 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 any when 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-apps
Copy link
Contributor

greptile-apps bot commented Nov 12, 2025

Greptile Overview

Greptile Summary

Fixed web search toggle first-time behavior by enabling web search immediately on first click instead of waiting for dialog dismissal.

Key Changes:

  • First-time users now have web search enabled instantly when clicking the globe icon
  • hasSeenWebSearchInfo flag is set immediately on first click to prevent repeat popups
  • Info dialog now serves purely as informational feedback after enabling
  • Dialog dismissal (X button, backdrop, "Got it") no longer triggers state changes
  • Subsequent clicks maintain normal toggle behavior

Impact:

  • Improves UX by making the globe icon functional on first click
  • Prevents confusing behavior where first click appeared non-functional
  • Maintains backward compatibility with existing user flows

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are well-isolated, fix a clear UX bug, and maintain consistency across two identical code paths. The logic is straightforward: moving state updates from dialog dismissal to button click. No new dependencies, no breaking changes, and the fix aligns with user expectations.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
frontend/src/components/UnifiedChat.tsx 5/5 Fixed web search toggle first-time behavior to enable immediately on click instead of on dialog close

Sequence Diagram

sequenceDiagram
    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
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@AnthonyRonning
Copy link
Contributor Author

@TestFlight build

@github-actions
Copy link
Contributor

🚀 TestFlight deployment triggered! Check the Actions tab for progress.

@github-actions
Copy link
Contributor

✅ TestFlight deployment completed successfully!

@AnthonyRonning AnthonyRonning merged commit 94424cb into master Nov 12, 2025
9 checks passed
@AnthonyRonning AnthonyRonning deleted the fix-web-search-first-time-toggle branch November 12, 2025 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant