From 0eeff74e7752d6692a5042ae56af35b765a534bf Mon Sep 17 00:00:00 2001 From: xiepengfei Date: Mon, 2 Nov 2026 21:19:28 +0800 Subject: [PATCH] fix: implement lazy AI service check in checkValid MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Root cause: StartManager constructor called IflytekAiAssistant::instance()->checkAiExists(), which constructs QDBusInterface and calls copilotInstalled() during startup, triggering D-Bus auto-activation of com.deepin.copilot service 2. Fix: remove checkAiExists() call from constructor; add case Invalid to checkValid() switch so copilotInstalled() runs synchronously on first AI feature invocation, transitioning m_status from Invalid to a valid state (lazy loading); remove now-unused include from startmanager.cpp 3. Impact: deepin-editor autostart no longer activates com.deepin.copilot via D-Bus at boot; AI features (TTS, STT, translation) work normally when first invoked by the user Log: Fix UOS AI window popping up when deepin-editor is set as autostart Influence: 1. Test deepin-editor autostart does not trigger UOS AI window on boot 2. Test AI features (TTS, STT, translation) work on first invocation 3. Verify no regression on normal editor startup behavior fix: 实现 checkValid 懒加载 AI 服务检测 1. 根因:StartManager 构造函数调用 IflytekAiAssistant::instance()->checkAiExists(),该方法在启动阶段 构造 QDBusInterface 并调用 copilotInstalled(),触发 D-Bus 自动 激活 com.deepin.copilot 服务 2. 方案:从构造函数移除 checkAiExists() 调用;在 checkValid() 的 switch 中增加 case Invalid 分支,首次调用 AI 功能时同步执行 copilotInstalled() 检查,将 m_status 从 Invalid 转变为有效状态 (懒加载);移除 startmanager.cpp 中已不再使用的 include 3. 影响:deepin-editor 开机自启不再通过 D-Bus 激活 com.deepin.copilot;AI 功能(TTS、STT、翻译)在用户首次使用时 正常工作 Log: 修复设置文本编辑器开机自启后 UOS AI 窗口弹出的问题 Influence: 1. 测试设置文本编辑器开机自启后,开机不再弹出 UOS AI 窗口 2. 测试在文本编辑器内首次使用 AI 功能时仍可正常工作 3. 验证编辑器正常启动行为无回归 PMS: BUG-368911 --- src/common/iflytek_ai_assistant.cpp | 1 + src/startmanager.cpp | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/common/iflytek_ai_assistant.cpp b/src/common/iflytek_ai_assistant.cpp index fb02d828..4f059e3a 100644 --- a/src/common/iflytek_ai_assistant.cpp +++ b/src/common/iflytek_ai_assistant.cpp @@ -170,6 +170,7 @@ IflytekAiAssistant::CallStatus IflytekAiAssistant::checkValid() { qCDebug(appLog) << "checkValid status:" << m_status; switch (m_status) { + case Invalid: case NotInstalled: m_status = copilotInstalled(m_copilot); if (Enable != m_status) { diff --git a/src/startmanager.cpp b/src/startmanager.cpp index e615c73b..f57022ef 100644 --- a/src/startmanager.cpp +++ b/src/startmanager.cpp @@ -18,7 +18,6 @@ #include #endif -#include "common/iflytek_ai_assistant.h" DWIDGET_USE_NAMESPACE @@ -96,8 +95,6 @@ StartManager::StartManager(QObject *parent) connect(m_pTimer, &QTimer::timeout, this, &StartManager::autoBackupFile); m_pTimer->start(EAutoBackupInterval); - // init flytek backend, check service valid - IflytekAiAssistant::instance()->checkAiExists(); qCInfo(appLog) << "StartManager initialized with backup interval:" << EAutoBackupInterval << "ms"; qCDebug(appLog) << "Exit StartManager constructor"; }