Skip to content

Feature/web search#27

Merged
Louis-7 merged 5 commits intomainfrom
feature/web-search
Apr 8, 2026
Merged

Feature/web search#27
Louis-7 merged 5 commits intomainfrom
feature/web-search

Conversation

@Louis-7
Copy link
Copy Markdown
Contributor

@Louis-7 Louis-7 commented Apr 8, 2026

Pull Request Template

Description

Enabled web search feature for Google and OpenAI models

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor
  • Other

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Louis-7 added 2 commits April 8, 2026 14:36
- 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.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 webSearchEnabled chat setting + UI toggles, and plumb webSearch/onWebSources through AIService → 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.

Comment thread src/pages/ChatPopup/ChatPopup.tsx
Comment thread src/services/providers/parsers/extractWebSources.ts
Louis-7 added 3 commits April 8, 2026 16:09
…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.
@Louis-7 Louis-7 merged commit ccaa728 into main Apr 8, 2026
4 checks passed
@Louis-7 Louis-7 deleted the feature/web-search branch April 8, 2026 08:32
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