Skip to content

fix: skip cooperation UI and network monitor in onlyTransfer mode - #815

Open
pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:agent/bugfix-leader-2-0/2764126fe724
Open

pppanghu77 wants to merge 1 commit into
linuxdeepin:release/v20from
pppanghu77:agent/bugfix-leader-2-0/2764126fe724

Conversation

@pppanghu77

@pppanghu77 pppanghu77 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

修复:onlyTransfer 模式下断网弹出两个网络断开提示框

问题

UOS 向 Windows 投送文件过程中断开 UOS 端网络,Win 端的 dde-cooperation-transfer 弹出两个网络断开提示框,期望只弹一个。必现。

根因

dde-cooperation-transfer 在 Win 端同时加载 cooperation-core 和 data-transfer/core 两个插件,各自启动独立的 1 秒网络监控定时器,均轮询 getFirstIp().size() > 0。断网时两个定时器先后发射 onlineStateChanged(false),分别驱动协同窗口(mainwindow.cpp)和迁移窗口(mainwindow_p_win.cpp)切换到网络断开页面,用户看到两个提示框。

根因点在 CooperaionCorePlugin::start() 中无条件调用 mainWindow()->show() 和 MainController::instance()->start(),未检查 onlyTransfer 属性。

修复方案

在 CooperaionCorePlugin::start() 中增加 onlyTransfer 检查:

  • 当 onlyTransfer=true 时,跳过 mainWindow()->show()(不显示协同窗口)和 MainController::instance()->start()(不启动协同模块网络监控定时器)
  • 保留基础服务(regist()、配置、翻译)
  • 从源头消除重复网络监控,仅保留数据迁移侧的单监控器

改动

  • src/plugins/cooperation/core/cooperationcoreplugin.cpp:start() 函数增加 onlyTransfer 条件检查(+5 行 -2 行)

影响

  • onlyTransfer=true 模式:协同窗口不再显示,协同模块网络监控不启动,断网仅弹一个提示框
  • 正常协同模式(onlyTransfer=false):行为完全不变
  • 基础服务:regist 等基础服务在 onlyTransfer 模式下仍正常执行

PMS: BUG-241813

Summary by Sourcery

Bug Fixes:

  • Prevent duplicate network-disconnection prompts in onlyTransfer mode by disabling the cooperation UI and its redundant network monitoring.

1. Root cause: dde-cooperation-transfer loads both cooperation-core and
   data-transfer/core plugins on Windows, each starting an independent
   1s network monitor timer polling getFirstIp(); both emit
   onlineStateChanged(false) on disconnect, driving two separate UI
   surfaces to show network-disconnected pages
2. Fix: add onlyTransfer check in CooperaionCorePlugin::start() to skip
   mainWindow()->show() and MainController::instance()->start() when
   onlyTransfer is true, eliminating the duplicate network monitor from
   the source while keeping base services (regist, config, translations)
3. Impact: only affects onlyTransfer=true mode; normal cooperation mode
   behavior is unchanged; data-transfer side keeps its single monitor

Log: fix duplicate network-disconnect popup in onlyTransfer mode

Influence:
1. Test file transfer from UOS to Windows with onlyTransfer mode, verify
   only one network-disconnect popup appears when network drops
2. Test normal cooperation mode (non-onlyTransfer), verify both windows
   and network monitoring work as before
3. Verify cooperation module base services (regist, config) still work in
   onlyTransfer mode

fix: onlyTransfer 模式下跳过协同模块 UI 显示和网络监控

1. 根因:dde-cooperation-transfer 在 Win 端同时加载 cooperation-core 和
   data-transfer/core 两个插件,各自启动独立 1s 网络监控定时器轮询
   getFirstIp(),断网时各自发射 onlineStateChanged(false),驱动不同 UI
   表面切换到网络断开页面,产生两个提示框
2. 方案:在 CooperaionCorePlugin::start() 中增加 onlyTransfer 检查,当
   onlyTransfer=true 时跳过 mainWindow()->show() 和
   MainController::instance()->start(),从源头消除重复网络监控,保留
   基础服务(regist、配置、翻译)
3. 影响:仅影响 onlyTransfer=true 模式;正常协同模式行为不变;数据迁移
   侧保持单监控器

Log: 修复 onlyTransfer 模式下断网弹出两个提示框的问题

Influence:
1. 测试 onlyTransfer 模式下 UOS 向 Windows 投送文件,断网后验证仅弹出一个
   网络断开提示框
2. 测试正常协同模式(非 onlyTransfer),验证窗口和网络监控功能无回归
3. 验证 onlyTransfer 模式下协同模块基础服务(regist、配置)仍正常工作

PMS: BUG-241813
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pppanghu77

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Oct 23, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Updates the cooperation core plugin startup path so onlyTransfer mode does not launch the cooperation UI or its duplicate network monitor, leaving the data-transfer monitor as the sole source of network-disconnection prompts while preserving shared registrations and normal-mode behavior.

Sequence diagram for onlyTransfer startup behavior

sequenceDiagram
    participant Plugin as CooperaionCorePlugin
    participant App as qApp
    participant UI as CooperationMainWindow
    participant Controller as MainController
    participant Transfer as DataTransferMonitor

    Plugin->>App: property(onlyTransfer)
    Plugin->>Controller: regist()
    Plugin->>Transfer: regist()
    alt onlyTransfer is false
        Plugin->>UI: show()
        Plugin->>Controller: start()
        Controller-->>Controller: Start cooperation network monitor
    else onlyTransfer is true
        Plugin-->>UI: UI remains hidden
        Plugin-->>Controller: Cooperation monitor remains stopped
        Transfer-->>Transfer: Continue data-transfer network monitor
    end
Loading

File-Level Changes

Change Details Files
Gate cooperation UI startup and network monitoring on the onlyTransfer application property while retaining shared service registration.
  • Read the onlyTransfer flag at startup.
  • Skip showing the cooperation window in transfer-only mode.
  • Skip starting the cooperation controller and its network monitor in transfer-only mode.
  • Continue registering the main, transfer, and cooperation services.
  • Leave normal cooperation-mode behavior unchanged.
src/plugins/cooperation/core/cooperationcoreplugin.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交在 onlyTransfer 模式下跳过协作 UI 显示和 MainController 启动,逻辑清晰、语法正确。 四维度均通过,无安全漏洞,代码质量良好。OCR 建议复用局部变量以提升一致性,属改进建议。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: ['建议将第67行 !qApp->property("onlyTransfer").toBool() 改为 !onlyTransfer,复用已声明的局部变量,提升代码一致性和可维护性']


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

// 建议复用 onlyTransfer 局部变量,将第67行也统一使用该变量: bool CooperaionCorePlugin::start() {
    bool onlyTransfer = qApp->property("onlyTransfer").toBool();
    if (!onlyTransfer)
        CooperationUtil::instance()->mainWindow()->show();
    MainController::instance()->regist();
    TransferHelper::instance()->regist();
    CooperationManager::instance()->regist();
    if (!onlyTransfer)
        MainController::instance()->start();

    if (CommonUitls::isFirstStart() && !onlyTransfer) {  // 复用局部变量
#ifdef linux
        // ...
#endif
    }
    return true;
}

本报告由 AI 代码审查工具自动生成

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