Skip to content

feat: 增加渠道级 LLM 思考模式开关#404

Merged
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:fix/issue-402-llm-thinking-toggle
May 11, 2026
Merged

feat: 增加渠道级 LLM 思考模式开关#404
H-Chris233 merged 1 commit into
Open-Less:betafrom
H-Chris233:fix/issue-402-llm-thinking-toggle

Conversation

@H-Chris233
Copy link
Copy Markdown
Collaborator

@H-Chris233 H-Chris233 commented May 11, 2026

User description

概要

Closes #402

本 PR 在 LLM 设置里补齐“思考模式”开关,并把开关贯通到所有 LLM 调用路径:润色、翻译、QA 流式回答和设置页连接验证。

实现方式

  • 新增 llmThinkingEnabled 用户偏好,并通过前端设置页切换保存。
  • OpenAI-compatible 路径统一在请求体中按“渠道”下发官方思考字段,不再维护单模型适配表:
    • OpenAI / Coding Plan X:reasoning_effort
    • OpenRouter:reasoning.effort
    • Alibaba Coding:enable_thinking
    • DeepSeek:thinking.type
  • Gemini 原生路径继续走 generateContent / streamGenerateContent,用原生 thinkingConfig 做渠道级控制。
  • 新增的 Codex OAuth provider 走 Responses 风格端口,因此同样按 Responses 请求体使用 reasoning.effort
  • 明确撤销 prompt 注入方案:不向 system/user prompt 追加“开启/关闭思考”的文字。

文档核对

验证

  • cargo test --manifest-path openless-all/app/src-tauri/Cargo.toml --lib openai_chat_body -- --nocapture
  • cd openless-all/app && cargo test --manifest-path src-tauri/Cargo.toml --lib codex_oauth -- --nocapture
  • cd openless-all/app && cargo test --manifest-path src-tauri/Cargo.toml --lib disabled_thinking_config -- --nocapture
  • cd openless-all/app && cargo test --manifest-path src-tauri/Cargo.toml --lib build_generate_body -- --nocapture
  • cd openless-all/app && cargo check --manifest-path src-tauri/Cargo.toml
  • cd openless-all/app && npm run build
  • git diff --check

备注:Rust 与 Vite 输出均只剩仓库既有 warning。


PR Type

Enhancement, Tests


Description

  • Add channel-level LLM thinking toggle in settings

  • Pass thinking flag to polish, translate, QA, and validation

  • Inject provider‑specific thinking fields (OpenAI, DeepSeek, Alibaba, Gemini, OpenRouter, Codex)

  • Simplify Gemini thinking to channel‑level budget config, dropping per‑model table


Diagram Walkthrough

flowchart LR
  Settings["Settings: Toggle thinking mode"] -- "saves" --> Prefs["UserPreferences.llm_thinking_enabled"]
  Prefs -- "passed to" --> Dispatch["Polish / Translate / QA / Validate"]
  Dispatch -- "openai/codingPlanX" --> OpenAI["OpenAI‑compatible providers"]
  Dispatch -- "gemini" --> Gemini["Gemini native"]
  Dispatch -- "codex" --> Codex["Codex OAuth"]
  OpenAI -- "applies" --> Fields["reasoning_effort / enable_thinking / reasoning.effort / thinking.type"]
  Gemini -- "applies" --> GemConfig["thinkingConfig: budget=0 (off) or omitted (on)"]
  Codex -- "applies" --> CodexField["reasoning.effort: medium/low"]
Loading

File Walkthrough

Relevant files
Enhancement
8 files
commands.rs
Read thinking preference and pass to provider configs       
+21/-9   
coordinator.rs
Thread thinking flag through polish/translate/QA paths     
+39/-18 
dictation.rs
Pass thinking preference to dictation session handling     
+3/-0     
llm_gemini.rs
Simplify Gemini thinking control to channel‑level budget 
+50/-115
polish.rs
Add channel‑specific thinking control fields for OpenAI‑compatible
+208/-20
types.rs
Add llm_thinking_enabled field to UserPreferences               
+10/-0   
types.ts
Add llmThinkingEnabled to frontend UserPreferences type   
+2/-0     
Settings.tsx
Add thinking toggle UI component in settings                         
+45/-5   
Documentation
5 files
en.ts
Add English translations for thinking mode toggle               
+4/-0     
ja.ts
Add Japanese translations for thinking mode                           
+4/-0     
ko.ts
Add Korean translations for thinking mode                               
+4/-0     
zh-CN.ts
Add Chinese translations for thinking mode                             
+4/-0     
zh-TW.ts
Add Traditional Chinese translations                                         
+4/-0     
Tests
2 files
ipc.ts
Add llmThinkingEnabled to mock settings                                   
+1/-0     
stylePrefs.test.ts
Include thinking field in test preferences                             
+1/-0     

Issue Open-Less#402 needs a Settings toggle that applies to every LLM runtime path without changing prompt behavior. The implementation keeps the preference in user settings, threads it through polish, translate, QA, and validation, and sends only provider-channel request fields documented by each backend instead of prompt instructions or model-name heuristics.

Constraint: Thinking controls are provider-specific request fields, not a portable prompt convention

Rejected: Prompt-level thinking instructions | changes model-facing prompts and cannot guarantee provider thinking mode

Rejected: Per-model allow/deny lists | user requested channel-level behavior and provider-side handling for unsupported models

Confidence: medium

Scope-risk: moderate

Directive: Do not add prompt injection or model-name thinking adapters for Open-Less#402 without a new explicit product decision

Tested: cargo test --manifest-path openless-all/app/src-tauri/Cargo.toml --lib openai_chat_body -- --nocapture

Tested: cd openless-all/app && cargo test --manifest-path src-tauri/Cargo.toml --lib disabled_thinking_config -- --nocapture

Tested: cd openless-all/app && cargo test --manifest-path src-tauri/Cargo.toml --lib build_generate_body -- --nocapture

Tested: cd openless-all/app && cargo check --manifest-path src-tauri/Cargo.toml

Tested: cd openless-all/app && npm run build

Tested: git diff --check

Related: Open-Less#402
@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

402 - PR Code Verified

Compliant requirements:

  • 已在 LLM 设置页新增思考模式开关
  • 已将开关状态持久化到用户偏好
  • 已贯通到润色、翻译、QA 流式回答和连接验证等调用路径

Requires further human verification:

  • 需要在实际 UI 中确认开关布局、文案和交互是否符合预期
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@H-Chris233 H-Chris233 merged commit 69978a3 into Open-Less:beta May 11, 2026
4 checks passed
@H-Chris233 H-Chris233 deleted the fix/issue-402-llm-thinking-toggle branch May 11, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

增加思考模式开关

1 participant