-
Notifications
You must be signed in to change notification settings - Fork 625
fix: resolve Gemini 2.5 thinking budget initialization and sync issues #767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughImplements explicit thinkingBudget handling across presenter and renderer: preserves user-provided values (including 0) in ThreadPresenter.createConversation, adds thinkingBudget state and bindings in NewThread and ChatConfig, and initializes/syncs thinkingBudget in TitleView based on model config. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant ChatConfig as ChatConfig (UI)
participant NewThread as NewThread.vue
participant Store as chatStore
participant Presenter as ThreadPresenter
User->>ChatConfig: Toggle dynamic/explicit thinkingBudget
ChatConfig-->>NewThread: update:thinkingBudget (v-model)
User->>NewThread: Create Thread
NewThread->>Store: createThread({ ..., thinkingBudget })
Store->>Presenter: createConversation(settings)
rect rgba(200,230,255,0.25)
note over Presenter: thinkingBudget defaulting logic (changed)
alt settings.thinkingBudget is undefined
Presenter->>Presenter: Apply model default thinkingBudget
else settings.thinkingBudget is defined (incl. 0)
Presenter->>Presenter: Preserve provided thinkingBudget
end
end
Presenter-->>Store: conversation created
Store-->>NewThread: thread ready
NewThread-->>User: Opens new chat
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 (3)
src/main/presenter/threadPresenter/index.ts (1)
742-752: Guard against overwriting an inherited thinkingBudget with undefined (keep the good fix).Nice fix to preserve explicit user input (including 0). However, if a model’s default config lacks thinkingBudget, this assignment can nullify an inherited value coming from defaultSettings/latest conversation. Add a presence check on the model default before writing.
- if (settings.thinkingBudget === undefined) { - mergedSettings.thinkingBudget = defaultModelsSettings.thinkingBudget - } + // Only apply model default when user hasn't provided a value, + // and the model actually defines a default. + if ( + settings.thinkingBudget === undefined && + defaultModelsSettings.thinkingBudget !== undefined + ) { + mergedSettings.thinkingBudget = defaultModelsSettings.thinkingBudget + }src/renderer/src/components/ChatConfig.vue (1)
258-260: Dynamic vs. “use model default” conflation; and input disabled logic.Using (props.thinkingBudget ?? -1) === -1 treats “undefined” as “dynamic (-1)”, which can misrepresent the actual state when the model default isn’t -1. Recommend binding the switch/disabled strictly to -1 and letting “undefined” mean “use model default”.
- <Switch - :checked="(props.thinkingBudget ?? -1) === -1" - @update:checked="handleDynamicThinkingToggle" - /> + <Switch + :checked="props.thinkingBudget === -1" + @update:checked="handleDynamicThinkingToggle" + />- :disabled="(props.thinkingBudget ?? -1) === -1" + :disabled="props.thinkingBudget === -1"Additionally, the number input can emit null/NaN when the field is cleared or contains invalid text (v-model.number). Normalize in the computed setter so empty/invalid becomes undefined (use model default), and clamp the range.
Add this setter (outside the changed lines) to replace the current displayThinkingBudget setter:
const displayThinkingBudget = computed<number | undefined>({ get: () => (props.thinkingBudget !== undefined ? props.thinkingBudget : undefined), set: (value) => { // Treat empty/invalid as "use model default" if (value === null || value === undefined || Number.isNaN(value as unknown as number)) { emit('update:thinkingBudget', undefined) return } // Preserve -1 for dynamic; otherwise round-and-clamp const n = Math.round(Number(value)) const clamped = n < -1 ? -1 : Math.min(32768, n) emit('update:thinkingBudget', clamped) } })Also applies to: 279-281
src/renderer/src/components/NewThread.vue (1)
93-101: Thinking budget is correctly plumbed end-to-end; tighten types to avoidas any.Wiring v-model, local state, default syncing, and thread creation looks good and should fix initialization/sync issues. Minor nit: the options object passed to createThread is cast to
any, which hides shape errors (including this new field). Prefer updating the options type to includethinkingBudget?: number.I can help propagate the
thinkingBudget?: numberproperty into the relevant types (e.g., the chat store’screateThreadoptions and theCONVERSATION_SETTINGS) so we can dropas any. Want me to open a follow-up diff?Also applies to: 163-166, 184-187, 416-420
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (4)
src/main/presenter/threadPresenter/index.ts(1 hunks)src/renderer/src/components/ChatConfig.vue(2 hunks)src/renderer/src/components/NewThread.vue(4 hunks)src/renderer/src/components/TitleView.vue(1 hunks)
🧰 Additional context used
📓 Path-based instructions (15)
**/*.{ts,tsx,js,jsx,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
Use English for logs and comments
Files:
src/main/presenter/threadPresenter/index.tssrc/renderer/src/components/TitleView.vuesrc/renderer/src/components/ChatConfig.vuesrc/renderer/src/components/NewThread.vue
**/*.{ts,tsx}
📄 CodeRabbit inference engine (CLAUDE.md)
Strict type checking enabled for TypeScript
**/*.{ts,tsx}: 始终使用 try-catch 处理可能的错误
提供有意义的错误信息
记录详细的错误日志
优雅降级处理
日志应包含时间戳、日志级别、错误代码、错误描述、堆栈跟踪(如适用)、相关上下文信息
日志级别应包括 ERROR、WARN、INFO、DEBUG
不要吞掉错误
提供用户友好的错误信息
实现错误重试机制
避免记录敏感信息
使用结构化日志
设置适当的日志级别
Files:
src/main/presenter/threadPresenter/index.ts
src/main/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
Main to Renderer: Use EventBus to broadcast events via mainWindow.webContents.send()
Use Electron's built-in APIs for file system and native dialogs
Files:
src/main/presenter/threadPresenter/index.ts
src/main/presenter/**/*.ts
📄 CodeRabbit inference engine (CLAUDE.md)
One presenter per functional domain
Files:
src/main/presenter/threadPresenter/index.ts
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit inference engine (.cursor/rules/development-setup.mdc)
**/*.{js,jsx,ts,tsx}: 使用 OxLint 进行代码检查
Log和注释使用英文书写
Files:
src/main/presenter/threadPresenter/index.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/threadPresenter/index.ts
src/main/**/*.{ts,js,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
主进程代码放在
src/main
Files:
src/main/presenter/threadPresenter/index.ts
src/renderer/src/**/*.vue
📄 CodeRabbit inference engine (CLAUDE.md)
src/renderer/src/**/*.vue: Use Composition API for all Vue 3 components
Use Tailwind CSS with scoped styles for styling
Organize components by feature in src/renderer/src/
Follow existing component patterns in src/renderer/src/ when creating new UI components
Use Composition API with proper TypeScript typing for new UI components
Implement responsive design with Tailwind CSS for new UI components
Add proper error handling and loading states for new UI componentsUse scoped styles to prevent CSS conflicts between components
Files:
src/renderer/src/components/TitleView.vuesrc/renderer/src/components/ChatConfig.vuesrc/renderer/src/components/NewThread.vue
src/renderer/src/**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (CLAUDE.md)
src/renderer/src/**/*.{ts,tsx,vue}: Use Pinia for frontend state management
Renderer to Main: Use usePresenter.ts composable for direct presenter method calls
Files:
src/renderer/src/components/TitleView.vuesrc/renderer/src/components/ChatConfig.vuesrc/renderer/src/components/NewThread.vue
src/renderer/src/**/*
📄 CodeRabbit inference engine (.cursor/rules/i18n.mdc)
src/renderer/src/**/*: All user-facing strings must use i18n keys (avoid hardcoded user-visible text in code)
Use the 'vue-i18n' framework for all internationalization in the renderer
Ensure all user-visible text in the renderer uses the translation system
Files:
src/renderer/src/components/TitleView.vuesrc/renderer/src/components/ChatConfig.vuesrc/renderer/src/components/NewThread.vue
src/renderer/**/*.{vue,ts,js,tsx,jsx}
📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)
渲染进程代码放在
src/renderer
Files:
src/renderer/src/components/TitleView.vuesrc/renderer/src/components/ChatConfig.vuesrc/renderer/src/components/NewThread.vue
src/renderer/src/**/*.{vue,ts,tsx,js,jsx}
📄 CodeRabbit inference engine (.cursor/rules/vue-best-practices.mdc)
src/renderer/src/**/*.{vue,ts,tsx,js,jsx}: Use the Composition API for better code organization and reusability
Implement proper state management with Pinia
Utilize Vue Router for navigation and route management
Leverage Vue's built-in reactivity system for efficient data handling
Files:
src/renderer/src/components/TitleView.vuesrc/renderer/src/components/ChatConfig.vuesrc/renderer/src/components/NewThread.vue
src/renderer/**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
src/renderer/**/*.{ts,tsx,vue}: Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
Use TypeScript for all code; prefer types over interfaces.
Avoid enums; use const objects instead.
Use arrow functions for methods and computed properties.
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.
Files:
src/renderer/src/components/TitleView.vuesrc/renderer/src/components/ChatConfig.vuesrc/renderer/src/components/NewThread.vue
src/renderer/**/*.{vue,ts}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
Implement lazy loading for routes and components.
Files:
src/renderer/src/components/TitleView.vuesrc/renderer/src/components/ChatConfig.vuesrc/renderer/src/components/NewThread.vue
src/renderer/**/*.{ts,vue}
📄 CodeRabbit inference engine (.cursor/rules/vue-shadcn.mdc)
src/renderer/**/*.{ts,vue}: Use useFetch and useAsyncData for data fetching.
Implement SEO best practices using Nuxt's useHead and useSeoMeta.
Files:
src/renderer/src/components/TitleView.vuesrc/renderer/src/components/ChatConfig.vuesrc/renderer/src/components/NewThread.vue
🧬 Code graph analysis (1)
src/main/presenter/threadPresenter/index.ts (1)
src/main/presenter/configPresenter/modelDefaultSettings.ts (1)
defaultModelsSettings(3-1909)
⏰ 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 (1)
src/renderer/src/components/TitleView.vue (1)
118-124: Initialize thinkingBudget from model defaults only when unset — LGTM.This preserves user overrides and avoids stomping on set values. Good alignment with the PR goal.
resolve Gemini 2.5 thinking budget initialization and sync issues
old:
CleanShot.2025-08-22.at.14.13.17.mp4
new:
CleanShot.2025-08-22.at.14.14.05.mp4
Summary by CodeRabbit
New Features
Bug Fixes