Skip to content

Conversation

@yyhhyyyyyy
Copy link
Collaborator

@yyhhyyyyyy yyhhyyyyyy commented Oct 9, 2025

support reasoning/search objects

Summary by CodeRabbit

  • New Features

    • Enhanced model settings: reasoning now supports a structured option with an optional thinking budget.
    • Added search capability controls: enable/disable search, forced search toggle, and selectable strategy (turbo or max).
    • Configuration and presets now reflect these fields, with sensible defaults for models lacking explicit settings.
  • Tests

    • Updated test coverage to validate thinking budget, search enablement, forced search, and strategy behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 9, 2025

Walkthrough

Expands model metadata schema to include structured reasoning and search capabilities, updates sanitization and presenter logic to derive flags and budgets from these objects, adjusts model configuration derivations accordingly, and updates tests to assert new fields and defaults.

Changes

Cohort / File(s) Summary of changes
Schema + Sanitization
src/shared/types/model-db.ts
Introduces ReasoningSchema and SearchSchema; replaces boolean reasoning with object; adds search field; adds getReasoning/getSearch helpers; updates sanitizeAggregate to use new helpers.
Provider DB Fetch Script
scripts/fetch-provider-db.mjs
Parses incoming model metadata to normalize reasoning (boolean or object) and search (supported/forced_search/search_strategy); pushes sanitized models with new shapes.
Presenter Mapping
src/main/presenter/configPresenter/index.ts, src/main/presenter/configPresenter/modelConfig.ts
Derives reasoning from reasoning?.supported; adds enableSearch, forcedSearch, thinkingBudget, and searchStrategy derivations; keeps other mappings intact.
Tests
test/main/presenter/providerDbModelConfig.test.ts
Updates expectations for reasoning object with budget and new search fields; asserts new cfg properties and defaults.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Provider DB Source
  participant Fetch as fetch-provider-db.mjs
  participant Types as Model Types/Sanitizer
  participant Presenter as configPresenter
  participant Consumer as Model Config Consumer

  Dev->>Fetch: Provide raw model entries (reasoning/search)
  Fetch->>Types: Normalize reasoning/search
  Note over Types: getReasoning / getSearch<br/>- reasoning: supported, budget.default<br/>- search: supported, forced_search, search_strategy
  Types-->>Fetch: Sanitized model objects
  Fetch-->>Presenter: Provider models with reasoning/search objects
  Presenter->>Presenter: Map to flags<br/>enableSearch, forcedSearch,<br/>thinkingBudget, searchStrategy
  Presenter-->>Consumer: Final config (incl. new fields)
  Note over Consumer: Defaults applied when fields absent
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • zerob13

Poem

In burrows of code, I hop and I seek,
Reasoning grows from a toggle to chic.
Search gets a compass—turbo or max,
Budgets of thought in tidy syntax.
Tests nibble carrots, all green and bright—
Configs now sparkle in moonlit byte. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title concisely describes the primary change by indicating a new feature in the provider database: support for reasoning and search objects, which aligns directly with the pull request’s modifications to model metadata schemas and presenter mappings.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/provider-db-reasoning-search

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
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (6)
src/main/presenter/configPresenter/index.ts (1)

656-658: Avoid any; type the provider model and drop casts

Use ProviderModel to access fields; remove (m as any) casts.

Apply within this block:

-      functionCall: Boolean((m as any).tool_call),
-      reasoning: Boolean((m as any).reasoning?.supported),
-      enableSearch: Boolean((m as any).search?.supported),
+      functionCall: Boolean(m.tool_call),
+      reasoning: Boolean(m.reasoning?.supported),
+      enableSearch: Boolean(m.search?.supported),

Outside this range, type the map arg and import ProviderModel:

// add to imports at Line 35
import { ProviderAggregate, ProviderModel } from '@shared/types/model-db'

// type the map arg in getDbProviderModels
return provider.models.map((m: ProviderModel) => ({
  // ...
}))

As per coding guidelines

src/shared/types/model-db.ts (2)

6-24: Schema additions look good; consider narrowing search strategy

Optionally restrict search_strategy to allowed values to catch typos early, e.g., z.enum(['turbo','max']). Keep current if provider may add more.


141-150: Handle boolean search for backward compatibility

Mirror reasoning handling so search: true sanitizes to { supported: true }.

-function getSearch(obj: unknown): ProviderModel['search'] {
-  if (!isRecord(obj)) return undefined
+function getSearch(obj: unknown): ProviderModel['search'] {
+  if (typeof obj === 'boolean') {
+    return { supported: obj }
+  }
+  if (!isRecord(obj)) return undefined
   const supported = getBoolean(obj, 'supported')
   const forced_search = getBoolean(obj, 'forced_search')
   const search_strategy = getString(obj, 'search_strategy')
   if (supported !== undefined || forced_search !== undefined || search_strategy !== undefined) {
     return { supported, forced_search, search_strategy }
   }
   return undefined
 }
test/main/presenter/providerDbModelConfig.test.ts (1)

69-71: Tests align; add coverage for 'max' strategy and forced gating

Consider adding:

  • A model with search: { supported: true, search_strategy: 'max' } to assert 'max' mapping.
  • A model with search: { supported: false, forced_search: true } to assert forcedSearch stays false if unsupported (after gating change below).

Also applies to: 94-97, 107-110, 114-117

src/main/presenter/configPresenter/modelConfig.ts (1)

296-302: Gate forcedSearch by enableSearch

Prevent inconsistent state when supported is false but forced_search is true.

-          enableSearch: Boolean(model.search?.supported),
-          forcedSearch: Boolean(model.search?.forced_search),
+          enableSearch: Boolean(model.search?.supported),
+          forcedSearch: Boolean(model.search?.supported && model.search?.forced_search),
           searchStrategy: model.search?.search_strategy === 'max' ? 'max' : 'turbo',

As per coding guidelines

scripts/fetch-provider-db.mjs (1)

81-90: Also accept boolean search for symmetry with reasoning

Support search: true|false as { supported: <bool> } for older sources.

-      // search (new schema)
+      // search (new schema; accept boolean legacy)
       let search
       const s = m.search
-      if (s && typeof s === 'object') {
+      if (typeof s === 'boolean') {
+        search = { supported: s }
+      } else if (s && typeof s === 'object') {
         const so = {}
         if (typeof s.supported === 'boolean') so.supported = s.supported
         if (typeof s.forced_search === 'boolean') so.forced_search = s.forced_search
         if (typeof s.search_strategy === 'string') so.search_strategy = s.search_strategy
         if (Object.keys(so).length) search = so
       }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6922f29 and d4cf441.

📒 Files selected for processing (5)
  • scripts/fetch-provider-db.mjs (2 hunks)
  • src/main/presenter/configPresenter/index.ts (1 hunks)
  • src/main/presenter/configPresenter/modelConfig.ts (1 hunks)
  • src/shared/types/model-db.ts (4 hunks)
  • test/main/presenter/providerDbModelConfig.test.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (17)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)

**/*.{js,jsx,ts,tsx}: 使用 OxLint 进行代码检查
Log和注释使用英文书写

**/*.{js,jsx,ts,tsx}: Use OxLint for JS/TS code; pre-commit hooks run lint-staged and typecheck
Use camelCase for variables and functions
Use PascalCase for types and classes
Use SCREAMING_SNAKE_CASE for constants

Files:

  • src/main/presenter/configPresenter/modelConfig.ts
  • src/shared/types/model-db.ts
  • src/main/presenter/configPresenter/index.ts
  • test/main/presenter/providerDbModelConfig.test.ts
src/{main,renderer}/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)

src/{main,renderer}/**/*.ts: Use context isolation for improved security
Implement proper inter-process communication (IPC) patterns
Optimize application startup time with lazy loading
Implement proper error handling and logging for debugging

Files:

  • src/main/presenter/configPresenter/modelConfig.ts
  • src/main/presenter/configPresenter/index.ts
src/main/**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/electron-best-practices.mdc)

Use Electron's built-in APIs for file system and native dialogs

Files:

  • src/main/presenter/configPresenter/modelConfig.ts
  • src/main/presenter/configPresenter/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/error-logging.mdc)

**/*.{ts,tsx}: 始终使用 try-catch 处理可能的错误
提供有意义的错误信息
记录详细的错误日志
优雅降级处理
日志应包含时间戳、日志级别、错误代码、错误描述、堆栈跟踪(如适用)、相关上下文信息
日志级别应包括 ERROR、WARN、INFO、DEBUG
不要吞掉错误
提供用户友好的错误信息
实现错误重试机制
避免记录敏感信息
使用结构化日志
设置适当的日志级别

Files:

  • src/main/presenter/configPresenter/modelConfig.ts
  • src/shared/types/model-db.ts
  • src/main/presenter/configPresenter/index.ts
  • test/main/presenter/providerDbModelConfig.test.ts
src/main/**/*.{ts,js,tsx,jsx}

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

主进程代码放在 src/main

Files:

  • src/main/presenter/configPresenter/modelConfig.ts
  • src/main/presenter/configPresenter/index.ts
**/*.{ts,tsx,js,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

Use English for all logs and comments

Files:

  • src/main/presenter/configPresenter/modelConfig.ts
  • src/shared/types/model-db.ts
  • src/main/presenter/configPresenter/index.ts
  • test/main/presenter/providerDbModelConfig.test.ts
**/*.{ts,tsx,vue}

📄 CodeRabbit inference engine (CLAUDE.md)

Enable and adhere to strict TypeScript typing (avoid implicit any, prefer precise types)

Files:

  • src/main/presenter/configPresenter/modelConfig.ts
  • src/shared/types/model-db.ts
  • src/main/presenter/configPresenter/index.ts
  • test/main/presenter/providerDbModelConfig.test.ts
src/main/**

📄 CodeRabbit inference engine (AGENTS.md)

Place all Electron main-process code under src/main/

Files:

  • src/main/presenter/configPresenter/modelConfig.ts
  • src/main/presenter/configPresenter/index.ts
src/main/presenter/**

📄 CodeRabbit inference engine (AGENTS.md)

src/main/presenter/**: Organize main-process presenters under src/main/presenter/ (Window/Tab/Thread/Mcp/Config/LLMProvider)
Follow the Presenter pattern for main-process modules

Files:

  • src/main/presenter/configPresenter/modelConfig.ts
  • src/main/presenter/configPresenter/index.ts
**/*.{js,jsx,ts,tsx,vue}

📄 CodeRabbit inference engine (AGENTS.md)

Apply Prettier formatting: single quotes, no semicolons, max width 100

Files:

  • src/main/presenter/configPresenter/modelConfig.ts
  • src/shared/types/model-db.ts
  • src/main/presenter/configPresenter/index.ts
  • test/main/presenter/providerDbModelConfig.test.ts
scripts/**

📄 CodeRabbit inference engine (AGENTS.md)

Place build/signing/installer/runtime and commit-related scripts in scripts/

Files:

  • scripts/fetch-provider-db.mjs
src/shared/**/*.{ts,tsx,d.ts}

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

共享类型定义放在 shared 目录

Files:

  • src/shared/types/model-db.ts
src/shared/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Place shared types, utilities, constants, and IPC contract definitions under src/shared/

Files:

  • src/shared/types/model-db.ts
src/shared/**

📄 CodeRabbit inference engine (AGENTS.md)

Store shared TypeScript types/utilities in src/shared/

Files:

  • src/shared/types/model-db.ts
test/**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Place unit and integration tests under the test/ directory mirroring project structure

Files:

  • test/main/presenter/providerDbModelConfig.test.ts
test/{main,renderer}/**

📄 CodeRabbit inference engine (AGENTS.md)

Mirror source structure in tests under test/main/** and test/renderer/** (with setup files)

Files:

  • test/main/presenter/providerDbModelConfig.test.ts
test/{main,renderer}/**/*.{test,spec}.ts

📄 CodeRabbit inference engine (AGENTS.md)

test/{main,renderer}/**/*.{test,spec}.ts: Name test files with *.test.ts or *.spec.ts
Write tests with Vitest (jsdom) and Vue Test Utils

Files:

  • test/main/presenter/providerDbModelConfig.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build-check (x64)
🔇 Additional comments (2)
src/shared/types/model-db.ts (2)

125-139: Reasoning parser LGTM

Covers boolean/object and validates budget default nonnegative.


206-208: Switch to helper parsers LGTM

Consistent use of getReasoning/getSearch.

@zerob13
Copy link
Collaborator

zerob13 commented Oct 9, 2025

@codex review

@zerob13 zerob13 merged commit d77f506 into dev Oct 9, 2025
2 checks passed
@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. More of your lovely PRs please.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

zerob13 added a commit that referenced this pull request Oct 9, 2025
* feat(ui): new prompt input and layout wip

* feat(provider-db): support reasoning/search objects (#964)

* chore: sync shadcn components (#963)

* chore(shadcn): sync new ui components

* chore(playground): showcase new shadcn suites

* feat: replace kbg and kb for ShortcutSettings

* feat(ui): prompt input with new chooser

---------

Co-authored-by: yyhhyyyyyy <yyhhyyyyyy8@gmail.com>
@coderabbitai coderabbitai bot mentioned this pull request Oct 19, 2025
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.

3 participants