Skip to content

fix(renderer): honor provider-db budget sentinels#1726

Merged
zerob13 merged 3 commits into
devfrom
fix/thinking-budget-sentinels
Jun 2, 2026
Merged

fix(renderer): honor provider-db budget sentinels#1726
zerob13 merged 3 commits into
devfrom
fix/thinking-budget-sentinels

Conversation

@yyhhyyyyyy
Copy link
Copy Markdown
Collaborator

@yyhhyyyyyy yyhhyyyyyy commented Jun 2, 2026

Use reasoningPortrait.budget auto/off values for thinking budget validation instead of checking the Gemini provider id.
Preserve auto/off/unit in renderer capability state and update composable tests.

Summary by CodeRabbit

  • Refactor

    • Unified capability retrieval and simplified model-type detection; removed a provider-specific flag.
    • Redesigned thinking-budget semantics: added auto/off/unit sentinels, normalized/merged ranges, and adaptive input bounds.
  • Tests

    • Updated and expanded tests to cover consolidated capability payloads, budget sentinel behavior, range merging, and adjusted model-type assertions.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 29e61769-15ba-4c90-9d27-f2e2f07d72a1

📥 Commits

Reviewing files that changed from the base of the PR and between 69bf365 and f70ed7f.

📒 Files selected for processing (2)
  • src/renderer/src/composables/useModelCapabilities.ts
  • test/renderer/composables/useModelCapabilities.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/renderer/composables/useModelCapabilities.test.ts
  • src/renderer/src/composables/useModelCapabilities.ts

📝 Walkthrough

Walkthrough

Removes Gemini-specific provider checks, extends thinking-budget types with sentinel fields (auto/off/unit), consolidates capability fetching into a single getCapabilities payload with budget merging, and updates validation, wiring, and tests to use range-driven sentinel logic.

Changes

Thinking Budget Type System and Capabilities Consolidation

Layer / File(s) Summary
Thinking budget types and input bounds
src/renderer/src/composables/useThinkingBudget.ts, src/renderer/src/composables/useChatConfigFields.ts, test/renderer/composables/useChatConfigFields.test.ts
Adds auto, off, and unit to ThinkingBudgetRange; adds getThinkingBudgetInputBounds; changes budgetRange option to `Ref<ThinkingBudgetRange
Thinking budget validation and composable wiring
src/renderer/src/composables/useThinkingBudget.ts, test/renderer/composables/useThinkingBudget.test.ts
Removes isGeminiProvider option; showThinkingBudget treats default/auto/off as configured; validationError accepts sentinel values (range.auto, range.off) as valid values. Tests and imports updated accordingly.
Capabilities API consolidation and budget merging
src/renderer/src/composables/useModelCapabilities.ts, test/renderer/composables/useModelCapabilities.test.ts
Replaces multiple capability calls with a single modelClient.getCapabilities() call; adds normalizeBudgetRange and mergeBudgetRanges to produce a merged ThinkingBudgetRange (including sentinel fields). Temperature-control uses supportsTemperatureControl then falls back to temperatureCapability. Tests mock unified payloads and merged budgets.
Provider detection removal and tests
src/renderer/src/composables/useModelTypeDetection.ts, test/renderer/composables/useModelTypeDetection.test.ts
Removes isGeminiProvider computed from the composable API and implementation; test assertion for isGeminiProvider removed. Remaining model-type flags and reasoning logic unchanged.
ChatConfig integration
src/renderer/src/components/ChatConfig.vue
Stops passing isGeminiProvider: modelTypeDetection.isGeminiProvider into useThinkingBudget; only supportsReasoning: capabilities.supportsReasoning remains.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • ThinkInAIXYZ/deepchat#767: Also changes thinking-budget initialization/wiring and sentinel handling around -1.
  • ThinkInAIXYZ/deepchat#1027: Touches the same composables and tests (capabilities, type detection, thinking budget); overlaps on test updates and API consolidation.
  • ThinkInAIXYZ/deepchat#849: Related ChatConfig.vue thinking-budget logic and provider-specific budgeting changes.

Suggested reviewers

  • deepinfect

Poem

🐰 I hopped through code to prune a gemini thread,

one call now gathers what once many said.
Sentinel carrots guide the budget's span,
ranges lead the rules, validation ran. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.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 PR title 'fix(renderer): honor provider-db budget sentinels' directly summarizes the main objective—using provider database budget sentinel values for validation instead of provider checks.
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 fix/thinking-budget-sentinels

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
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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/composables/useChatConfigFields.ts (1)

130-144: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Make the thinking-budget input sentinel-aware.

Line 130-144 still clamp the native number input to budgetRange.min/max, so valid provider-db sentinels like off: 0 or auto: -1 remain invalid at the UI layer even though useThinkingBudget now accepts them. That means this PR can still block users from entering the very sentinel values it added support for.

Please widen/override the input bounds when sentinels fall outside the numeric range, or omit native min/max for this field in those cases.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/renderer/src/composables/useChatConfigFields.ts` around lines 130 - 144,
The thinking-budget input is currently constrained by min/max using
options.budgetRange.value which prevents entering sentinel values (e.g., off:0,
auto:-1); update the field config around min/max so that when
options.thinkingBudget.value is a sentinel or when known sentinel values lie
outside options.budgetRange.value you either omit the native min/max or expand
them to include those sentinel values before rendering (adjust the object where
min: options.budgetRange.value?.min and max: options.budgetRange.value?.max are
set), keeping getValue/setValue (options.thinkingBudget and
options.emit('update:thinkingBudget')) unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/renderer/src/composables/useModelCapabilities.ts`:
- Around line 91-94: capabilityBudgetRange currently prefers
normalizeBudgetRange(capabilities.reasoningPortrait?.budget) over
normalizeBudgetRange(capabilities.thinkingBudgetRange), which discards legacy
min/max when portrait only provides sentinel metadata; instead create a shallow
merge using capabilities.thinkingBudgetRange as the base and overlay
capabilities.reasoningPortrait?.budget on top, then pass the merged object into
normalizeBudgetRange and assign the result to capabilityBudgetRange.value (fall
back to {} if normalize returns null/undefined). Ensure you reference
capabilityBudgetRange, normalizeBudgetRange,
capabilities.reasoningPortrait?.budget and capabilities.thinkingBudgetRange when
implementing the merge.

---

Outside diff comments:
In `@src/renderer/src/composables/useChatConfigFields.ts`:
- Around line 130-144: The thinking-budget input is currently constrained by
min/max using options.budgetRange.value which prevents entering sentinel values
(e.g., off:0, auto:-1); update the field config around min/max so that when
options.thinkingBudget.value is a sentinel or when known sentinel values lie
outside options.budgetRange.value you either omit the native min/max or expand
them to include those sentinel values before rendering (adjust the object where
min: options.budgetRange.value?.min and max: options.budgetRange.value?.max are
set), keeping getValue/setValue (options.thinkingBudget and
options.emit('update:thinkingBudget')) unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8bbfaa84-60c8-4d81-ab6b-eba93a5003f3

📥 Commits

Reviewing files that changed from the base of the PR and between 898f8fd and 96a9622.

📒 Files selected for processing (8)
  • src/renderer/src/components/ChatConfig.vue
  • src/renderer/src/composables/useChatConfigFields.ts
  • src/renderer/src/composables/useModelCapabilities.ts
  • src/renderer/src/composables/useModelTypeDetection.ts
  • src/renderer/src/composables/useThinkingBudget.ts
  • test/renderer/composables/useModelCapabilities.test.ts
  • test/renderer/composables/useModelTypeDetection.test.ts
  • test/renderer/composables/useThinkingBudget.test.ts
💤 Files with no reviewable changes (2)
  • test/renderer/composables/useModelTypeDetection.test.ts
  • src/renderer/src/composables/useModelTypeDetection.ts

Comment thread src/renderer/src/composables/useModelCapabilities.ts Outdated
Copy link
Copy Markdown
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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/renderer/src/composables/useModelCapabilities.ts`:
- Around line 105-109: The assignment to capabilityBudgetRange.value overrides
mergeBudgetRanges(...)'s null sentinel by using "?? {}", which causes empty
budget ranges to become {} and misleads truthiness checks (e.g.,
!!budgetRange.value in useThinkingBudget.ts); change the assignment to preserve
null from mergeBudgetRanges (remove the "?? {}" fallback) so
capabilityBudgetRange.value stays null when mergeBudgetRanges returns null,
keeping consumers that rely on truthiness correct.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ba3884f6-20de-4db5-a170-337f23397d24

📥 Commits

Reviewing files that changed from the base of the PR and between 96a9622 and 69bf365.

📒 Files selected for processing (4)
  • src/renderer/src/composables/useChatConfigFields.ts
  • src/renderer/src/composables/useModelCapabilities.ts
  • test/renderer/composables/useChatConfigFields.test.ts
  • test/renderer/composables/useModelCapabilities.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/renderer/composables/useModelCapabilities.test.ts

Comment thread src/renderer/src/composables/useModelCapabilities.ts Outdated
@zerob13 zerob13 merged commit c91a002 into dev Jun 2, 2026
3 checks passed
@zhangmo8 zhangmo8 deleted the fix/thinking-budget-sentinels branch June 3, 2026 09:26
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