Skip to content

fix: 修复登录界面FIDO认证提示文案跨两行显示问题 - #91

Closed
mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:agent/pms-bug-bot/07bae51f73f6
Closed

mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:agent/pms-bug-bot/07bae51f73f6

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Root Cause Analysis

In the login interface (lightdm-deepin-greeter), the "Noto Sans CJK SC-Thin" 10.5pt font is explicitly set, which renders Chinese characters wider than the system default font used in the lock screen (dde-lock). The FIDO authentication prompt text (e.g., "请验证安全密钥,触摸或轻扫设备") exceeds the available width (~240px) within the fixed 280px SFAWidget container, and setWordWrap(true) in AuthPasskey::initUI() causes the text to wrap into two lines. The lock screen uses the default font where the same text fits in one line, resulting in inconsistent behavior.

Key evidence: auth_passkey.cpp:40 (setWordWrap(true)), lightdm-deepin-greeter.cpp:57-59 (Thin font setup), sfa_widget.cpp:47 (fixed 280px width).

Fix

Changed m_textLabel->setWordWrap(true) to setWordWrap(false) and added setElideMode(Qt::ElideNone) in AuthPasskey::initUI(). This disables automatic word wrapping and text elision, ensuring the FIDO authentication prompt text displays in a single line, consistent with the lock screen behavior. The actual implementation matches the analysis recommendation exactly.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • The target line setWordWrap(true) was introduced in the original FIDO2 feature commit (b6a1a6e, 2023-10-11), not a prior bug fix — this change does not revert any historical fix.
  • m_textLabel is a private member of AuthPasskey, only accessed within initUI() and setAuthState(). No external callers depend on the word wrap behavior.

Business Impact Scope

The change affects the FIDO/security key authentication prompt text display in both the login interface and lock screen. Specifically, the prompt text label's wrapping behavior is modified. Users will see the authentication prompt in a single line on the login screen, matching the lock screen's behavior.

Verification Suggestion

Verify that the FIDO authentication prompt text displays in a single line on both the login interface and lock screen. Test with Chinese locale to confirm the Thin font rendering no longer causes wrapping.


根因分析

登录界面(lightdm-deepin-greeter)显式设置了 "Noto Sans CJK SC-Thin" 10.5pt 字体,渲染中文字符比锁屏界面(dde-lock)使用的系统默认字体更宽。FIDO 认证提示文案(如"请验证安全密钥,触摸或轻扫设备")在 SFAWidget 固定 280px 容器内超出可用宽度(约 240px),AuthPasskey::initUI() 中的 setWordWrap(true) 导致文本换行为两行。锁屏界面使用默认字体,相同文案宽度足够保持一行,导致登录与锁屏行为不一致。

关键证据:auth_passkey.cpp:40setWordWrap(true))、lightdm-deepin-greeter.cpp:57-59(Thin 字体设置)、sfa_widget.cpp:47(固定 280px 宽度)。

修复方案

AuthPasskey::initUI() 中的 m_textLabel->setWordWrap(true) 改为 setWordWrap(false),并新增 setElideMode(Qt::ElideNone)。禁用自动换行和文本截断,确保 FIDO 认证提示文案以一行展示,与锁屏界面行为一致。实际实现与分析建议完全一致。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 目标代码行 setWordWrap(true) 由 FIDO2 功能初始提交(b6a1a6ef, 2023-10-11)引入,非此前 bug 修复产物——本次修改不会撤销历史修复。
  • m_textLabelAuthPasskey 的私有成员,仅在 initUI()setAuthState() 中使用,无外部调用者依赖换行行为。

业务影响范围

本次改动影响登录界面和锁屏界面的 FIDO/安全密钥认证提示文案显示。具体修改了提示文本标签的换行行为。用户在登录界面将看到认证提示以一行展示,与锁屏界面行为一致。

验证建议

验证登录界面和锁屏界面下 FIDO 认证提示文案均以一行显示。使用中文环境测试,确认 Thin 字体渲染下不再出现换行。

Summary by Sourcery

Keep FIDO authentication prompts on a single line for consistent display across login surfaces.

Bug Fixes:

  • Prevent FIDO authentication prompts from wrapping onto two lines in the login interface.

Enhancements:

  • Align FIDO prompt text display behavior between the login and lock-screen interfaces.

原因:登录界面使用Thin字体渲染中文更宽,在SFAWidget固定280px容器内
提示文案超出可用宽度,setWordWrap(true)导致文本换行为两行,与锁屏
界面行为不一致。
方法:将m_textLabel的setWordWrap改为false并设置setElideMode(Qt::ElideNone),
禁用自动换行,使提示文案以一行展示。

Log: 修复登录界面FIDO认证提示文案换行问题
Bug: https://pms.uniontech.com/bug-view-370733.html
Influence: 登录界面和锁屏界面的安全密钥FIDO认证提示文案显示
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mhduiy

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 14, 2026

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

Reviewer's Guide

The PR updates the FIDO prompt label configuration to display authentication text on a single line, resolving wrapping caused by the login greeter’s wider Thin font within the fixed-width widget and aligning its behavior with the lock screen.

Flow diagram for single-line FIDO prompt rendering

flowchart LR
    A["FIDO authentication prompt"] --> B["AuthPasskey::initUI()"]
    B --> C["setWordWrap(false)"]
    B --> D["setElideMode(Qt::ElideNone)"]
    C --> E["Single-line prompt in fixed-width SFAWidget"]
    D --> E
    E --> F["Login greeter behavior matches lock screen"]
Loading

File-Level Changes

Change Details Files
Prevent the FIDO authentication prompt from wrapping onto multiple lines.
  • Disable automatic word wrapping on the prompt label.
  • Disable text elision so the prompt remains fully visible rather than being truncated.
src/session-widgets/auth_passkey.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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/session-widgets/auth_passkey.cpp" line_range="40-41" />
<code_context>
     /* 文案提示 */
     m_textLabel->setText(tr("Please plug in the security key"));
-    m_textLabel->setWordWrap(true);
+    m_textLabel->setWordWrap(false);
+    m_textLabel->setElideMode(Qt::ElideNone);

     /* 旋转提示和文案提示布局 */
</code_context>
<issue_to_address>
**issue (bug_risk):** When the translated prompt is wider than the fixed authentication row, disabling word wrapping leaves the label constrained to one line, and `Qt::ElideNone` prevents any indication of omitted text; the right side of the FIDO instruction is clipped instead of being displayed in full.

**Triggers:** When using the Chinese locale and the prompt exceeds the available label width, as described in the change rationale.

**Suggested fix:** Increase the available width or reduce the font size; otherwise use an elision mode such as `Qt::ElideRight` and ensure the full instruction is available through accessibility or another UI element.

```suggestion
    m_textLabel->setWordWrap(false);
    m_textLabel->setElideMode(Qt::ElideRight);
```
</issue_to_address>

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

Comment on lines +40 to +41
m_textLabel->setWordWrap(false);
m_textLabel->setElideMode(Qt::ElideNone);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (bug_risk): When the translated prompt is wider than the fixed authentication row, disabling word wrapping leaves the label constrained to one line, and Qt::ElideNone prevents any indication of omitted text; the right side of the FIDO instruction is clipped instead of being displayed in full.

Triggers: When using the Chinese locale and the prompt exceeds the available label width, as described in the change rationale.

Suggested fix: Increase the available width or reduce the font size; otherwise use an elision mode such as Qt::ElideRight and ensure the full instruction is available through accessibility or another UI element.

Suggested change
m_textLabel->setWordWrap(false);
m_textLabel->setElideMode(Qt::ElideNone);
m_textLabel->setWordWrap(false);
m_textLabel->setElideMode(Qt::ElideRight);

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 代码变更简单明确,将setWordWrap改为false并设置setElideMode(Qt::ElideNone)以修复FIDO认证提示文案跨两行显示问题。变更与commit message目的一致,无安全漏洞,各维度均通过。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: []


2. 代码质量 ✅

评价: 优秀 ✅ 通过

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

建议: []


3. 代码性能 ✅

评价: 优秀 ✅ 通过

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

建议: []


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例

// 修复已正确无需额外修复代码

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

@mhduiy

mhduiy commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

在这里跟踪,此PR关闭:#78

@mhduiy mhduiy closed this Sep 18, 2026
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