Repository navigation
Conversation
1. Root cause: m_status initialized to Invalid(-1), checkAiExists() uses async detection so m_status stays Invalid before detection completes; checkValid() switch had no case Invalid, falling to default:break and returning Invalid, causing speechToText() to abort early 2. Fix: add case Invalid with Q_FALLTHROUGH() to checkValid() so it proceeds to copilotInstalled check like NotInstalled, and to errorString() for explicit handling 3. Impact: right-click menu can now invoke speech-to-text when async detection has not yet completed; no behavior change for other status values Log: fix speech-to-text unavailable via right-click menu in text editor Influence: 1. Test speech-to-text via right-click menu immediately after launch 2. Test speech-to-text after uos-ai detection completes 3. Verify no regression on TTS and translation features fix: 修复文本编辑器右键菜单无法唤醒语音听写的问题 1. 根因:m_status 初始值为 Invalid(-1),checkAiExists() 异步检测 完成前 m_status 保持 Invalid,checkValid() 的 switch 无 case Invalid 分支,走 default:break 返回 Invalid,导致 speechToText() 提前返回 2. 方案:在 checkValid() 和 errorString() 的 switch 中增加 case Invalid: Q_FALLTHROUGH(),使 Invalid 状态如 NotInstalled 一样 进入检测流程 3. 影响:右键菜单在异步检测完成前可正常唤醒语音听写,对其余 状态无行为变化 Log: 修复文本编辑器右键菜单无法唤醒语音听写的问题 Influence: 1. 测试启动后立即通过右键菜单使用语音听写 2. 测试 uos-ai 检测完成后使用语音听写 3. 验证语音朗读和翻译功能无回归 PMS: BUG-375785
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe fix handles the assistant’s initial Invalid status by reusing the existing detection flow, allowing dictation, text-to-speech, and translation actions to reach DBus immediately after editor startup while retaining existing behavior for other statuses. Sequence diagram for initial AI assistant action validationsequenceDiagram
actor User
participant Editor
participant Assistant as IflytekAiAssistant
participant Copilot as uos_ai
participant DBus
User->>Editor: Select AI feature
Editor->>Assistant: speechToText() / textToSpeech() / textToTranslate()
Assistant->>Assistant: checkValid()
alt m_status == Invalid
Assistant->>Copilot: copilotInstalled()
Assistant->>Copilot: isCopilotEnabled()
end
Assistant->>DBus: Invoke selected AI action
DBus->>Copilot: Execute request
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, pengfeixx The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Root Cause Analysis
In
src/common/iflytek_ai_assistant.cpp, thecheckValid()method uses aswitch(m_status)statement that only handlescase NotInstalled:andcase NoUserAgreement:. Whenm_statusisInvalid(-1)— its initial value beforecheckAiExists()async detection completes — the switch falls through todefault: break;, returningInvalidwithout performing any detection. This causesspeechToText(),textToSpeech(), andtextToTranslate()to abort early viaif (Enable != checkValid()), so the right-click menu actions never reach the DBus call to invoke voice dictation.Key evidence:
iflytek_ai_assistant.cpp:169-198(switch missingcase Invalid:),iflytek_ai_assistant.h:73(m_statusinitialized toInvalid), minimal demo reproduction confirmsdbusCalled=0before fix anddbusCalled=1after fix.Fix Approach
Added
case Invalid: Q_FALLTHROUGH();to bothcheckValid()anderrorString()switch statements, so that whenm_status == Invalid, it proceeds to the same detection logic ascase NotInstalled:(callingcopilotInstalled()andisCopilotEnabled()). This is a 4-line addition across 2 locations in a single file.Change Safety Assessment
Code Safety
case Invalid:fallthrough tocase NotInstalled:does not change existing detection flow for other status values; it only extends the entry condition for theNotInstalleddetection path to also coverInvalidspeechToText,textToSpeech,textToTranslate) use the samecheckValid()guard, behavior is consistent across all three right-click menu AI featuresBusiness Impact Scope
Affected functional modules: right-click context menu AI features in text editor — voice dictation (语音听写), text-to-speech (语音朗读), and translation (翻译). User scenario: immediately after launching the text editor, right-clicking and selecting any AI assistant feature would silently fail. After the fix, these features will properly trigger detection and invoke the DBus interface.
Verification Suggestion
根因分析
在
src/common/iflytek_ai_assistant.cpp中,checkValid()方法的switch(m_status)语句仅有case NotInstalled:和case NoUserAgreement:分支。当m_status为Invalid(-1)(异步检测checkAiExists()完成前的初始值)时,switch 走default: break;,直接返回Invalid而不执行任何检测。导致speechToText()、textToSpeech()和textToTranslate()因if (Enable != checkValid())提前返回,右键菜单动作无法到达 DBus 调用。关键证据:
iflytek_ai_assistant.cpp:169-198(switch 缺少case Invalid:),iflytek_ai_assistant.h:73(m_status初始化为Invalid),最小 demo 复现确认改前dbusCalled=0、改后dbusCalled=1。修复方案
在
checkValid()和errorString()的 switch 语句中增加case Invalid: Q_FALLTHROUGH();,使m_status == Invalid时进入与case NotInstalled:相同的检测逻辑(调用copilotInstalled()和isCopilotEnabled())。单文件 2 处共 4 行新增。改动安全评估
代码安全评估
case Invalid:fallthrough 到case NotInstalled:不改变其他状态值的现有检测流程,仅扩展了NotInstalled检测路径的入口条件speechToText、textToSpeech、textToTranslate)均使用相同的checkValid()守卫,行为一致业务影响范围
受影响功能模块:文本编辑器右键菜单 AI 功能 — 语音听写、语音朗读、翻译。用户场景:启动文本编辑器后立即右键选择任意 AI 助手功能会静默失败。修复后这些功能将正确触发检测并调用 DBus 接口。
验证建议
PMS: BUG-375785
Summary by Sourcery
Bug Fixes: