Skip to content

fix: 修复启动器无法启动应用名含 .desktop 后缀的应用程序 - #818

Open
BLumia wants to merge 1 commit into
linuxdeepin:masterfrom
BLumia:agent/bot/68e9418cc1d4
Open

BLumia wants to merge 1 commit into
linuxdeepin:masterfrom
BLumia:agent/bot/68e9418cc1d4

Conversation

@BLumia

@BLumia BLumia commented Sep 23, 2026

Copy link
Copy Markdown
Member

Root Cause

applicationObjectPath() in appmgr.cpp unconditionally strips the .desktop suffix from app IDs. For apps like org.telegram.desktop, this produces the wrong DBus path org/telegram instead of org/telegram/desktop, causing the launcher to fail to start such applications.

Changes

  1. src/ddeintegration/appmgr.cpp: Stop stripping .desktop suffix in applicationObjectPath() — pass the raw desktop ID to the DBus path.
  2. src/models/appsmodel.h: Move normalizedDesktopId() to public static so it can be used across modules.
  3. src/models/appsmodel.cpp:
    • data(DesktopIdRole) now returns the raw source ID (no normalization).
    • indexFromDesktopId() normalizes both sides internally for comparison.
    • All internal normalizedDesktopId() calls updated to AppsModel::normalizedDesktopId().
  4. src/models/favoritedproxymodel.cpp: Wrap all desktop ID usages with AppsModel::normalizedDesktopId().
  5. src/models/itemarrangementproxymodel.cpp: Wrap all ID comparisons and lookups with AppsModel::normalizedDesktopId().
  6. src/models/frequentlyusedproxymodel.cpp: Add #include "appsmodel.h", wrap both IDs with AppsModel::normalizedDesktopId().
  7. desktopintegration.cpp: Use raw IDs for AppMgr methods that call applicationObjectPath(), and normalized IDs for AppInfo methods that need .desktop suffix.
  8. tests/searchfilterproxymodeltest.cpp: Update test assertions to expect raw desktop IDs (without .desktop suffix) from data(DesktopIdRole).

Related

Summary by Sourcery

Preserve complete desktop IDs during application launching while normalizing IDs consistently for model and metadata operations.

Bug Fixes:

  • Fix application launching for desktop IDs whose application names end with .desktop by preserving the full ID in DBus object paths.

Enhancements:

  • Separate raw desktop IDs used for launching from normalized IDs used for application metadata, favorites, arrangement, and usage tracking.
  • Expose desktop ID normalization as a shared utility and update model lookups and comparisons to handle both ID forms consistently.

Tests:

  • Update search and shared-model tests to expect raw desktop IDs from the model.

@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: BLumia

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 Sep 23, 2026

Copy link
Copy Markdown

Reviewer's Guide

Fixes launching for applications whose IDs themselves end in .desktop by preserving raw IDs for D-Bus object paths, while exposing shared normalization and applying it consistently across model, proxy, arrangement, and desktop integration code; tests now reflect the raw DesktopIdRole contract.

Sequence diagram for launching applications with desktop-suffixed IDs

sequenceDiagram
    participant DesktopIntegration
    participant AppMgr
    participant DBus
    participant AppInfo

    DesktopIntegration->>AppMgr: launchApp(desktopId, token)
    AppMgr->>DBus: applicationObjectPath(desktopId)
    DBus-->>AppMgr: org/telegram/desktop
    alt AppMgr launch fails
        DesktopIntegration->>AppsModel: normalizedDesktopId(desktopId)
        AppsModel-->>DesktopIntegration: normalized ID
        DesktopIntegration->>AppInfo: launchByDesktopId(normalized ID)
    end
Loading

Flow diagram for raw and normalized desktop ID usage

flowchart LR
    SourceID[Raw desktop ID]
    Normalize[AppsModel.normalizedDesktopId]
    DBusPath[AppMgr.applicationObjectPath]
    AppInfoAPI[AppInfo methods]
    ModelRole[DesktopIdRole returns raw ID]
    ModelCompare[Model and proxy comparisons]

    SourceID --> ModelRole
    SourceID --> DBusPath
    SourceID --> Normalize
    Normalize --> AppInfoAPI
    Normalize --> ModelCompare
Loading

File-Level Changes

Change Details Files
Preserve the complete desktop ID when constructing application D-Bus object paths.
  • Remove unconditional .desktop trimming before escaping the ID into the object path.
  • Use a suffixless launcher ID for the control-center entry point while retaining raw IDs for AppMgr launch calls.
src/ddeintegration/appmgr.cpp
desktopintegration.cpp
Centralize desktop ID normalization while separating public raw IDs from internal comparison and persistence IDs.
  • Expose normalization as a static utility.
  • Return source IDs from DesktopIdRole and normalize both operands in index lookup.
  • Update model and proxy comparisons, favorites, arrangement state, and frequently-used ordering to normalize IDs consistently.
src/models/appsmodel.h
src/models/appsmodel.cpp
src/models/favoritedproxymodel.cpp
src/models/itemarrangementproxymodel.cpp
src/models/frequentlyusedproxymodel.cpp
Align desktop integration API calls with the raw-versus-normalized ID contract.
  • Pass raw IDs to AppMgr methods that resolve D-Bus paths.
  • Normalize IDs for AppInfo, AppStream, dock, desktop-file, and uninstall operations that expect conventional desktop IDs.
desktopintegration.cpp
Update model/search coverage for raw desktop IDs.
  • Change search, sorting, and shared-model adapter expectations to match DesktopIdRole returning IDs without an automatically added .desktop suffix.
tests/searchfilterproxymodeltest.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

@BLumia
BLumia marked this pull request as ready for review September 23, 2026 05:11

@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 ✨

1. Stop stripping .desktop suffix in applicationObjectPath()
2. Return raw desktop ID from AppsModel::data(DesktopIdRole)
3. Add static normalizedDesktopId() for consistent ID normalization
4. Update all proxy models and desktop integration to use normalized IDs
5. Update test assertions to expect raw desktop IDs

Log: Fixed launcher unable to start apps with .desktop suffix in app ID

Influence:
1. Test launching apps with .desktop suffix in app ID (e.g. org.telegram.desktop)
2. Test launching apps without .desktop suffix in app ID
3. Test app search, sort, and favorite functions still work correctly
4. Test app uninstall and dock operations

fix: 修复应用名含 .desktop 后缀的应用无法启动的问题

1. 停止在 applicationObjectPath() 中去除 .desktop 后缀
2. AppsModel::data(DesktopIdRole) 返回原始桌面 ID
3. 新增静态 normalizedDesktopId() 方法统一归一化处理
4. 更新所有代理模型和桌面集成模块使用归一化 ID
5. 更新测试断言以匹配原始桌面 ID

Log: 修复启动器无法启动应用名含 .desktop 后缀的应用程序

Influence:
1. 测试应用名含 .desktop 后缀的应用启动(如 org.telegram.desktop)
2. 测试应用名不含 .desktop 后缀的应用启动
3. 测试应用搜索、排序和收藏功能是否正常
4. 测试应用卸载和驻留栏操作

PMS: BUG-378253
@BLumia
BLumia force-pushed the agent/bot/68e9418cc1d4 branch from a7f1ae0 to 9227e94 Compare September 23, 2026 05:21
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 未发现安全漏洞,代码逻辑正确,修复方案合理,改动一致性好

📋 PR 信息

项目 内容
PR #818
标题 fix: 修复启动器无法启动应用名含 .desktop 后缀的应用程序
作者 BLumia
分支 agent/bot/68e9418cc1d4master
修改文件 8 个文件(+74/-67)
需求来源 PMS Bug: https://pms.uniontech.com/bug-view-378253.html

📝 需求分析

根因分析: appmgr.cpp 中的 applicationObjectPath() 无条件剥离 .desktop 后缀,导致如 org.telegram.desktop 这样的应用 ID 生成错误的 DBus 路径 org/telegram 而非 org/telegram/desktop,致使启动器无法启动此类应用。

修复方案:

  1. 停止在 applicationObjectPath() 中剥离 .desktop 后缀
  2. normalizedDesktopId() 改为 public static 方法供跨模块调用
  3. data(DesktopIdRole) 返回 raw desktop ID(用于启动/DBus 路径)
  4. 所有查找/比较操作统一使用 normalizedDesktopId() 归一化

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

分析:

本次修改语法正确,逻辑清晰。核心修复在 src/ddeintegration/appmgr.cppapplicationObjectPath() 中移除了对 .desktop 后缀的无条件剥离逻辑,这是正确的修复方案。normalizedDesktopId()const 成员方法改为 static 方法是正确的,因为该方法不使用任何实例成员。indexFromDesktopId()match() 改为手动循环是功能等价的,且因为 data(DesktopIdRole) 现在返回 raw ID,使用 match() 已不再适用。边界条件处理完善,包括空字符串和 internal/ 前缀的检查。

各文件分析:

  1. src/ddeintegration/appmgr.cpp - 移除 .desktop 后缀剥离逻辑,核心修复点,逻辑正确
  2. src/models/appsmodel.cpp - data(DesktopIdRole) 改为返回 raw ID,indexFromDesktopId() 重写为手动循环,两侧归一化比较
  3. src/models/appsmodel.h - normalizedDesktopId() 从 private const 移至 public static,声明变更正确
  4. desktopintegration.cpp - AppMgr::launchApp 使用 raw ID,AppInfo 方法使用 normalized ID,分工明确
  5. src/models/favoritedproxymodel.cpp - 所有 desktopId 用法均包装归一化
  6. src/models/frequentlyusedproxymodel.cpp - 两侧 ID 均归一化
  7. src/models/itemarrangementproxymodel.cpp - 所有 ID 查找/比较均归一化,局部变量优化
  8. tests/searchfilterproxymodeltest.cpp - 测试断言同步更新

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

建议:


2. 代码质量 ✅

评价: 优秀 ✅ 通过

分析:

代码结构清晰,改动一致性好。normalizedDesktopId() 改为 public static 是良好的设计决策,允许跨模块复用。在 commitDndOperation() 中创建 normDragId/normDropId 局部变量避免重复调用,在 onSourceModelChanged() 中创建 normalizedId 局部变量,体现了良好的编程习惯。测试用例同步更新,保证测试覆盖。

潜在问题:

  1. src/models/itemarrangementproxymodel.cpp:404 - onSourceModelChanged()findItem(normalizedId) 的返回值未被使用,该调用无实际效果(预存代码,本次修改了该行)

建议:

  1. 可移除 onSourceModelChanged() 中无效的 findItem() 调用以提升代码清晰度
  2. 多处 AppsModel::normalizedDesktopId() 包装调用虽然必要,但可考虑在入口点统一归一化以减少重复

3. 代码性能 ✅

评价: 优秀 ✅ 通过

分析:

性能良好。indexFromDesktopId()match() 改为手动循环,对于典型的应用列表大小(数十到数百项),性能差异可忽略。normalizedDesktopId() 是轻量字符串操作(endsWith/isEmpty/startsWith 检查)。合理使用局部变量 normDragId/normDropId/normalizedId 避免重复归一化调用。

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

建议:


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

安全分析:

存在0个安全漏洞。本次修改不涉及用户输入处理、网络通信、文件系统操作等安全敏感区域。DBus 路径构建使用 DUtil::escapeToObjectPath() 进行转义,确保路径安全。

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个

安全检查项:

  • ✅ 无 SQL 注入风险
  • ✅ 无命令注入风险
  • ✅ 无路径遍历风险
  • ✅ 无硬编码密钥/凭证
  • ✅ 无敏感信息泄露
  • ✅ DBus 路径使用 escapeToObjectPath() 转义

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

建议:


💡 改进建议代码示例

// src/models/itemarrangementproxymodel.cpp - onSourceModelChanged()
// 建议移除无效的 findItem() 调用

// 修改前(当前代码):
if (folder == -1) {
    findItem(normalizedId);  // 返回值未使用,无效调用
    // ... 后续逻辑
}

// 修改后(建议):
if (folder == -1) {
    // 直接进行后续逻辑,无需调用 findItem
    // ... 后续逻辑
}

📊 评分汇总

维度 得分 满分 状态
语法逻辑 25 25 ✅ 通过
代码质量 24 25 ✅ 通过
代码性能 20 20 ✅ 通过
代码安全 30 30 ✅ 通过
总分 99 100 通过

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

审查时间:2026-09-23 13:33:00
OCR 审查状态:失败(LLM 配置问题)
SAST 扫描状态:不可用

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