Skip to content

Add Brave web search with 5p charge per query#158

Merged
asim merged 2 commits intomainfrom
copilot/implement-brave-search-functionality
Feb 28, 2026
Merged

Add Brave web search with 5p charge per query#158
asim merged 2 commits intomainfrom
copilot/implement-brave-search-functionality

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

Adds a /search endpoint that combines local indexed content with Brave web search results, displayed in parallel sections. Charges 5 credits (5p) per query via the existing wallet quota system.

New: search package

  • Handler runs data.Search (local) and Brave Search API in parallel via goroutines
  • Results rendered in two sections: Local Results / On the Web
  • Requires authentication; quota checked before search, consumed after
  • Gracefully degrades: Brave errors surface as "Web search unavailable" without failing the local results

Wallet

  • New OpWebSearch = "web_search" operation constant
  • CostWebSearch = getEnvInt("CREDIT_COST_SEARCH", 5) — overridable via env var
  • Wired into GetOperationCost; plans page updated to reflect 5p cost

Navigation

  • Search input added to the top of the sidebar nav (submits to /search?q=)
  • CSS added for #nav-search to style the inline input
GET /search?q=bitcoin
→ local: data.Search("bitcoin", 10)          // in parallel
→ web:   Brave API X-Subscription-Token: $BRAVE_API_KEY
→ deduct 5 credits from wallet on success

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: asim <17530+asim@users.noreply.github.com>
Copilot AI changed the title [WIP] Add search functionality using Brave API Add Brave web search with 5p charge per query Feb 28, 2026
@asim asim marked this pull request as ready for review February 28, 2026 08:36
@asim asim merged commit 1ebd945 into main Feb 28, 2026
@asim asim deleted the copilot/implement-brave-search-functionality branch March 2, 2026 21:06
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.

2 participants