Skip to content

Add OpenRouter summary provider#20

Merged
qyinm merged 3 commits into
mainfrom
qyinm-openrouter-summary-provider
May 5, 2026
Merged

Add OpenRouter summary provider#20
qyinm merged 3 commits into
mainfrom
qyinm-openrouter-summary-provider

Conversation

@qyinm
Copy link
Copy Markdown
Owner

@qyinm qyinm commented May 5, 2026

Summary

Adds OpenRouter as an AI summary provider alongside OpenAI, Ollama, and LM Studio.

Why

Users should be able to use OpenRouter's OpenAI-compatible chat completions API for summary and source-context generation.

Changes

  • Added OpenRouter provider defaults, settings UI option, API key handling, and model-list behavior.
  • Added the LobeHub OpenRouter brand icon to provider controls.
  • Added OpenRouter request headers and structured JSON support for Electron and native source-context calls.
  • Documented the OpenRouter provider setup and added regression coverage for provider normalization and headers.

Validation:

  • npm run desktop:check
  • CARGO_TARGET_DIR=target cargo test
  • git diff --check

Summary by CodeRabbit

  • New Features

    • OpenRouter added as a selectable summary provider.
    • Provider icon updated to include OpenRouter.
  • Bug Fixes / Improvements

    • Provider settings now show API-key input generically for providers that require one.
    • Summary generation uses a consistent structured format for supported providers, improving reliability.
  • Documentation

    • Provider setup docs updated with OpenRouter details and configuration guidance.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Adds OpenRouter as a summary provider across the app: types, defaults, UI options, provider helpers, centralized request headers (including OpenRouter metadata), API-key gating and JSON-schema response-format selection, Rust backend checks and requests, tests, and docs. Test-only exports for two helpers added.

Changes

OpenRouter Provider Support

Layer / File(s) Summary
Type Definitions
apps/desktop/src/types.ts
SummaryProvider union now includes "openrouter".
Configuration & Helpers
apps/desktop/main.cjs
Adds openrouter to SUMMARY_PROVIDER_DEFAULTS; introduces summaryProviderRequiresAPIKey() and summaryProviderDisplayName(); normalizes OpenRouter provider config.
Request Headers
apps/desktop/main.cjs
Adds summaryProviderRequestHeaders(settings, options) to centralize Authorization and include OpenRouter-specific HTTP-Referer and X-Title headers.
Model Listing & Summary Requests
apps/desktop/main.cjs, native/native-host-rust/src/context_packet.rs
Model-listing and chat completion use the centralized headers; API-key requirement checks and error messages use the new helpers; structured JSON-schema response_format is requested for both openai and openrouter.
UI Components & Wiring
apps/desktop/src/components/SettingsPanel.tsx, apps/desktop/src/components/ProviderBrandIcon.tsx
Settings defaults/options include openrouter; provider readiness and API-key input are driven by summaryProviderRequiresAPIKey() and a provider-specific API-key placeholder helper; ProviderBrandIcon renders OpenRouter SVG path.
Public Settings & Test Exports
apps/desktop/main.cjs
publicSummarySettings() computes apiKeyConfigured via summaryProviderRequiresAPIKey(); publicSummarySettings and summaryProviderRequestHeaders are exposed under MIRROR_NOTE_TEST_EXPORTS for tests.
Tests & Documentation
apps/desktop/main/native-launch.node-test.cjs, docs/summary-generation.md, native/native-host-rust/src/context_packet.rs
Node test validates normalization, public masking of API key, and headers (including Authorization, HTTP-Referer, X-Title); docs add OpenRouter entry; Rust adds helpers and unit tests for provider API-key requirements and display names.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A new router hops into the fold with a cheer,
Headers in paw, it greets the API far and near,
Helpers guide keys and names with a wink,
Settings and tests nod, all in sync,
A tiny rabbit dances — new provider is here!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 8.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: adding OpenRouter as a new summary provider. It directly reflects the primary objective stated in the PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch qyinm-openrouter-summary-provider

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces OpenRouter as a summary provider across the desktop application and the Rust-based native host. The changes include updated configuration defaults, new UI icons, centralized header management, and expanded documentation. Feedback focuses on aligning with OpenRouter's documentation by using the X-Title header instead of X-OpenRouter-Title and improving the maintainability of provider display name mappings by explicitly handling all supported providers in both the JavaScript and Rust implementations.

Comment thread apps/desktop/main.cjs Outdated
Comment thread apps/desktop/main.cjs Outdated
Comment thread apps/desktop/main/native-launch.node-test.cjs Outdated
Comment thread native/native-host-rust/src/context_packet.rs Outdated
Comment thread native/native-host-rust/src/context_packet.rs
@qyinm qyinm merged commit d777e8f into main May 5, 2026
1 of 2 checks passed
@qyinm qyinm deleted the qyinm-openrouter-summary-provider branch May 5, 2026 14:38
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