Conversation
- Introduced `webSearchEnabled` setting in `settings.default.json` and updated relevant interfaces. - Added `WebSearchToggle` component to manage web search settings in `ChatPopup` and `SettingsChat`. - Updated localization files to include web search descriptions in English, Simplified Chinese, and Traditional Chinese. - Enhanced `AIService` and request builders to support web search options for OpenAI and Google providers. - Added tests to verify web search functionality in provider tests.
- Added `shell:open-external` IPC handler to safely open external URLs in the default browser. - Introduced `MessageWebSources` component to display web sources in chat messages. - Updated `ChatMessage` to conditionally render web sources if available. - Enhanced localization files to include new "sources" key in English and Chinese. - Modified AI service and provider parsers to support extraction and handling of web sources. - Added tests for web source extraction functionality in various providers.
There was a problem hiding this comment.
Pull request overview
Adds provider-native “web search” support (OpenAI search-capable models + Google Gemini grounding), including capturing citation sources from responses and displaying them in the chat UI. This integrates into the existing provider adapter architecture (request builders/response parsers), settings system, and Electron IPC surface.
Changes:
- Add a
webSearchEnabledchat setting + UI toggles, and plumbwebSearch/onWebSourcesthroughAIService→ providers. - Implement provider-specific source extraction (OpenAI annotations, Gemini groundingMetadata) and render sources in chat messages.
- Add a safe Electron IPC bridge to open external http/https source URLs in the system browser.
Reviewed changes
Copilot reviewed 25 out of 29 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types/setting.d.ts | Adds webSearchEnabled to chat settings type. |
| src/types/providers.d.ts | Extends provider options and parser interfaces to support web search + sources callbacks. |
| src/types/index.d.ts | Adds openExternalUrl to the renderer Electron API typings. |
| src/types/chat.d.ts | Adds ChatSource and optional sources on messages. |
| src/services/providers/UnifiedProvider.ts | Threads onWebSources into streaming/non-streaming parsing flow. |
| src/services/providers/parsers/openaiResponseParser.ts | Collects OpenAI citation sources during streaming and from non-streaming responses. |
| src/services/providers/parsers/ollamaResponseParser.ts | Updates parser signature to accept (unused) web sources callback. |
| src/services/providers/parsers/googleResponseParser.ts | Collects Gemini grounding sources during streaming and from non-streaming responses. |
| src/services/providers/parsers/extractWebSources.ts | New unified extraction + dedupe helpers for OpenAI/Gemini sources. |
| src/services/providers/parsers/anthropicResponseParser.ts | Updates parser signature to accept (unused) web sources callback. |
| src/services/providers/adapters/openaiRequestBuilder.ts | Adds OpenAI-only web_search_options when web search is enabled. |
| src/services/providers/adapters/googleRequestBuilder.ts | Adds Gemini tools: [{ google_search: {} }] when web search is enabled. |
| src/services/providers/tests/OpenAIProvider.test.ts | Tests OpenAI web search request shape + sources callbacks (streaming + non-streaming). |
| src/services/providers/tests/GoogleProvider.test.ts | Tests Gemini grounding tools + sources callbacks (streaming + non-streaming). |
| src/services/providers/tests/extractWebSources.test.ts | New unit tests for extraction and deduplication helpers. |
| src/services/providers/tests/DeepSeekProvider.test.ts | Verifies web_search_options is not added for non-OpenAI providers. |
| src/services/AIService.ts | Adds webSearch + onWebSources plumbing based on settings / call overrides. |
| src/pages/Settings/SettingsChat.tsx | Adds web search setting toggle to Settings UI. |
| src/pages/ChatPopup/ChatPopup.tsx | Adds web search toggle and updates assistant message with emitted sources. |
| src/pages/ChatMessage/ChatMessage.tsx | Renders web sources UI for assistant messages with sources. |
| src/i18n/locales/zh-hant.json | Adds localized strings for web search + “Sources”. |
| src/i18n/locales/zh-hans.json | Adds localized strings for web search + “Sources”. |
| src/i18n/locales/en.json | Adds localized strings for web search + “Sources”. |
| src/components/WebSearchToggle.tsx | New compact toggle button (globe icon) for chat popup. |
| src/components/MessageWebSources.tsx | New sources pill + drawer UI and link opening behavior. |
| src/components/Icon.tsx | Adds globe icon support. |
| settings.default.json | Adds default chat.webSearchEnabled: false. |
| preload.ts | Exposes openExternalUrl via IPC to main process. |
| main.ts | Adds shell:open-external IPC handler with http/https-only validation. |
…sponses - Modified `googleRequestBuilder` and `openaiRequestBuilder` to remove output token limits when web search is enabled, ensuring responses are not truncated. - Updated tests for `GoogleProvider` and `OpenAIProvider` to assert that token limits are undefined when web search is active.
…unction - Updated documentation in `extractWebSources.ts` to specify that annotations appear in `choices[0].delta.annotations` for streaming responses.
- Added tests to verify behavior of the `think` field based on reasoning settings in `OllamaProvider`. - Implemented logic in `ollamaRequestBuilder` to conditionally include the `think` field based on the model and reasoning status. - Updated `ollamaResponseParser` to handle streaming responses with thinking traces, encapsulating them in `<think>` tags.
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.
Pull Request Template
Description
Enabled web search feature for Google and OpenAI models
Type of Change
Checklist