fix: guard web search toggle & submit when selected provider is unusable#139
Closed
YizukiAme wants to merge 7 commits into
Closed
fix: guard web search toggle & submit when selected provider is unusable#139YizukiAme wants to merge 7 commits into
YizukiAme wants to merge 7 commits into
Conversation
- Add 'brave' and 'baidu' to WebSearchProviderId union type - Register providers in WEB_SEARCH_PROVIDERS with configs - Create brave.ts: HTML scraping provider (no API key required) - Create baidu.ts: Qianfan REST API provider (Bearer token auth) - Update API route for multi-provider dispatch via 'provider' param - Generalize resolveWebSearchApiKey for provider-agnostic key resolution - Add BRAVE_API_KEY and BAIDU_API_KEY to .env.example - Update settings store with default configs for new providers - Update i18n strings (zh-CN + en-US) to be provider-agnostic - Update web-search-settings UI with conditional API key display - Pass provider param in generation-preview page fetch call
- Fix snippet regex to match 'class=snippet svelte-...' (not exact 'class=snippet')
- Update title extraction to use 'search-snippet-title' class
- Extract descriptions from 'generic-snippet' div (current) with fallback to 'snippet-description' p (legacy)
- Handle relative date prefixes ('2 days ago -')
- Add provider icons (Brave, Baidu, Tavily)
- Update Baidu sub-source toggles to use Switch components
- Fix webSearchAvailable logic to enable search when any provider is available
- Make Brave API key optional in settings UI
# Conflicts: # components/settings/web-search-settings.tsx
- Add shared normalizeWebSearchQuery util (400-char limit) - Apply query normalization to Brave and Baidu providers - Refactor Tavily to use shared normalizer - Add isSelectedProviderUsable check in toolbar toggle - Add pre-submit web search provider validation in page.tsx - Add i18n strings for provider unavailable toast Fixes toolbar allowing web search enable when selected provider has no API key configured, while another provider (Brave) is available without a key.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Superseded — fix was cherry-picked into
feat/brave-baidu-search(PR #42) directly.