Skip to content

fix: remove endsWith(.desktop) heuristic in normalizedDesktopId - #823

Merged
BLumia merged 1 commit into
linuxdeepin:masterfrom
BLumia:agent/pms-bug-bot/c4021041a844
Oct 15, 2026
Merged

BLumia merged 1 commit into
linuxdeepin:masterfrom
BLumia:agent/pms-bug-bot/c4021041a844

Conversation

@BLumia

@BLumia BLumia commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Root Cause Analysis

AppsModel::normalizedDesktopId() used endsWith(".desktop") as a heuristic to skip appending the .desktop suffix. However, the AM DBus always provides appId (the desktop filename without .desktop extension), so for org.telegram.desktop the heuristic returned true and skipped the suffix append. This produced org.telegram.desktop instead of org.telegram.desktop.desktop, causing g_desktop_app_info_new() to return NULL. All downstream operations (uninstall, launch, dock) received an empty path and failed silently.

Fix

Removed the endsWith(".desktop") condition from normalizedDesktopId(). The function now always appends .desktop unless the source is empty or starts with internal/. This aligns with the AM DBus contract: appId is always the desktop filename without the .desktop extension.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • The endsWith(".desktop") check was introduced by commit 322366a (PMS BUG-378253). Removing it does not revert BUG-378253's fix because data(DesktopIdRole) still returns raw source data without going through normalizedDesktopId(). The normalization function is only used internally by indexFromDesktopId() for GIO lookups.
  • Only one condition removed; function signature unchanged; no external callers affected beyond correct behavior.

Business Impact Scope

Affected functional modules:

  • Launcher app uninstall: linyaps apps with .desktop suffix in appId can now be correctly uninstalled
  • Launcher app launch: same normalization path, now works for double-suffix desktop files
  • Dock operations (send to dock / remove from dock): share the same normalizedDesktopId() path

Verification Suggestion

Test uninstalling, launching, and docking linyaps Telegram (org.telegram.desktop). Regression-test normal apps without .desktop suffix in appId.


根因分析

AppsModel::normalizedDesktopId() 使用 endsWith(".desktop") 启发式判断跳过后缀追加。但 AM DBus 提供的 appId 始终是桌面文件名去掉 .desktop 后缀的结果,对 org.telegram.desktop 该判断返回 true 导致不追加后缀,生成 org.telegram.desktop 而非 org.telegram.desktop.desktop,g_desktop_app_info_new() 返回 NULL,下游卸载/启动/驻留操作全链路静默失败。

修复方案

移除 normalizedDesktopId() 中的 endsWith(".desktop") 条件,仅在 source 为空或以 internal/ 开头时跳过后缀追加。这与 AM DBus 契约一致:appId 始终是不含 .desktop 后缀的桌面文件名。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • endsWith(".desktop") 检查由 commit 322366a(PMS BUG-378253)引入。移除该检查不会回退 BUG-378253 的修复,因为 data(DesktopIdRole) 仍返回原始 source data,不经过 normalizedDesktopId()。该归一化函数仅被 indexFromDesktopId() 内部用于 GIO 查找。
  • 仅移除一个条件判断,函数签名不变,无外部调用者受影响。

业务影响范围

受影响功能模块:

  • 启动器应用卸载:appId 含 .desktop 后缀的玲珑应用现在可以正确卸载
  • 启动器应用启动:同一归一化路径,双后缀桌面文件现在可正确查找
  • 驻留栏操作(发送到驻留栏/从驻留栏移除):共享同一 normalizedDesktopId() 路径

验证建议

测试玲珑版 Telegram(org.telegram.desktop)的卸载、启动、驻留操作。回归测试不含 .desktop 后缀的普通应用功能。

Summary by Sourcery

Correct desktop ID normalization to consistently resolve application IDs according to the AM DBus contract.

Bug Fixes:

  • Fix desktop ID normalization for application IDs that themselves end in ".desktop", restoring correct app lookup and downstream launch, uninstall, and dock operations.

Tests:

  • Update model tests to reflect the AM application ID format without the ".desktop" suffix.

1. Root cause: normalizedDesktopId() used endsWith(".desktop") to
   skip appending the suffix, but AM DBus appId always lacks the
   .desktop extension; for org.telegram.desktop the check returned
   true, so GIO got org.telegram.desktop instead of
   org.telegram.desktop.desktop and returned NULL
2. Fix: remove the endsWith(".desktop") condition; always append
   .desktop unless the source is empty or starts with internal/
3. Impact: apps whose appId ends with .desktop (e.g. Telegram linyaps)
   can now be uninstalled, launched, and docked correctly; no
   regression for normal apps or BUG-378253 fix

Log: Fixed linyaps apps with .desktop suffix in app ID cannot be uninstalled from launcher

Influence:
1. Test uninstalling linyaps apps with .desktop suffix in app ID
2. Test launching linyaps apps with .desktop suffix in app ID
3. Test dock operations for linyaps apps with .desktop suffix
4. Test normal apps without .desktop suffix still work correctly

fix: 移除 normalizedDesktopId 中的 endsWith(.desktop) 启发式判断

1. 根因:normalizedDesktopId() 使用 endsWith(".desktop") 跳过后缀
   追加,但 AM DBus appId 始终不含 .desktop 后缀;对
   org.telegram.desktop 该判断返回 true,导致 GIO 收到
   org.telegram.desktop 而非 org.telegram.desktop.desktop,返回 NULL
2. 方案:移除 endsWith(".desktop") 条件,仅在 source 为空或以
   internal/ 开头时跳过后缀追加
3. 影响:appId 以 .desktop 结尾的玲珑应用(如 Telegram)可正常
   卸载、启动和驻留;对普通应用及 BUG-378253 修复无回归

Log: 修复玲珑应用 appId 含 .desktop 后缀时启动器无法卸载的问题

Influence:
1. 测试 appId 含 .desktop 后缀的玲珑应用卸载功能
2. 测试 appId 含 .desktop 后缀的玲珑应用启动功能
3. 测试 appId 含 .desktop 后缀的玲珑应用驻留操作
4. 测试不含 .desktop 后缀的普通应用功能无回归

PMS: BUG-379545
@sourcery-ai

sourcery-ai Bot commented Oct 14, 2026

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

Reviewer's Guide

Removes the endsWith(".desktop") heuristic so AM-provided app IDs are consistently normalized for GIO lookups, fixing launch, uninstall, and dock operations for IDs such as org.telegram.desktop while updating related tests to match the suffix-free appId contract.

Sequence diagram for corrected desktop ID normalization

sequenceDiagram
    participant Caller
    participant AppsModel
    participant GIO

    Caller->>AppsModel: indexFromDesktopId(appId)
    AppsModel->>AppsModel: normalizedDesktopId(sourceId)
    Note over AppsModel: org.telegram.desktop becomes org.telegram.desktop.desktop
    AppsModel->>GIO: g_desktop_app_info_new(desktopId)
    GIO-->>AppsModel: Desktop app info
    AppsModel-->>Caller: Valid app lookup
Loading

File-Level Changes

Change Details Files
Align desktop ID normalization with the AM DBus appId contract by always adding the .desktop suffix for external applications.
  • Removed the existing suffix-detection heuristic while retaining empty and internal-ID bypasses.
  • Ensured IDs such as org.telegram.desktop resolve to org.telegram.desktop.desktop for GIO lookups.
src/models/appsmodel.cpp
Updated shared-model adapter coverage to treat source app IDs as suffix-free and validate normalized lookup behavior.
  • Changed the suffixed test fixture and lookups to use org.test.suffixed.
  • Updated expected DesktopIdRole values and rename verification accordingly.
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

@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

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 18202781743, 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

@BLumia
BLumia merged commit 541019c into linuxdeepin:master Oct 15, 2026
6 checks passed
@BLumia
BLumia deleted the agent/pms-bug-bot/c4021041a844 branch October 15, 2026 03:38
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.

3 participants