Skip to content

fix(windows): 补齐 QA helper-window 的原生交互语义#184

Closed
Cooper-X-Oak wants to merge 3 commits into
Open-Less:mainfrom
Cooper-X-Oak:codex/issue-153-native-drag-repro
Closed

fix(windows): 补齐 QA helper-window 的原生交互语义#184
Cooper-X-Oak wants to merge 3 commits into
Open-Less:mainfrom
Cooper-X-Oak:codex/issue-153-native-drag-repro

Conversation

@Cooper-X-Oak
Copy link
Copy Markdown
Contributor

@Cooper-X-Oak Cooper-X-Oak commented May 2, 2026

摘要

Closes #153

这张 PR 是从 upstream 干净基线 重新切出来的代码修复分支,目标只做一件事:

补齐 Windows 上 QA helper-window 的原生交互语义。

这里说的交互语义,主要是:

  • 热键打开正常
  • 关闭按钮可点
  • QA 浮窗顶部区域可拖动
  • 不把问题扩散到主窗口 UI 外观线

这张 PR 不再继续尝试共享拖动承载,而是改成 Windows 原生消息层 的拖动实现。

这张 PR 解决什么

当前我们已经把问题范围收得很小了:

  • Ctrl+Shift+; 正常
  • 关闭按钮正常
  • 连续追问链路正常
  • 剩下唯一核心缺口是:
    • Windows 上 QA 浮窗不可拖动

所以这张 PR 不再是“大而全 QA 修复”,而是聚焦在:

Windows native drag semantics for QA helper-window

修复内容

这次实际改动主要有三类:

  1. 收紧 Windows 的热键 ownership
  • Windows 下 dictation / QA lifecycle 由 backend low-level hook 单独拥有
  • 不再依赖前台窗口额外共驱动状态机
  1. 保留 QA helper-window 的原有产品目标
  • 不抢上下文
  • 可点关闭
  • 可继续追问
  1. 改成 Windows 原生拖动承载
  • 不再依赖共享拖动补丁
  • 改为在 Windows 原生消息层把 QA 浮窗顶部区域映射成可拖动区域
  • 方向是:WM_NCHITTEST -> HTCAPTION

为什么要这样做

这次已经验证出来:

  • 同一个产品目标可以保留
  • 但不同 OS 需要不同承载手段
  • macOS 上自然成立的 helper-window 拖动语义,不能直接假设 Windows 也能靠同一实现承载

所以这张 PR 的核心不是“改一段前端拖动代码”,而是:

按 Windows 的原生交互规范,补齐同一个产品目标。

范围边界

这张 PR 不包含

也就是说,这张 PR 只属于:

  • QA / selection ask / helper-window 这条 feature family

验证情况

已完成:

  • npm run build
  • cargo build
  • 从 upstream 基线确认:旧版 QaPanel.tsx 没有拖动承载实现
  • 修复版启动后,hotkey listener 和 QA hotkey listener 正常安装
  • Ctrl 热键正常
  • 关闭按钮可点
  • 运行日志确认已安装 Windows 原生 drag hit-test
  • 自动化窗口位置测量确认:QA 窗口在拖动路径下发生位移

仍建议 reviewer 再做一次 Windows 实机确认:

  • 打开 QA panel
  • 拖动顶部区域
  • 点击关闭
  • 确认多轮追问不受影响

关联关系

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Sorry @Cooper-X-Oak, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@Cooper-X-Oak Cooper-X-Oak marked this pull request as ready for review May 2, 2026 06:24
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Sorry @Cooper-X-Oak, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac51f719ef

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +668 to +670
let toolbar_height = 32;
let right_controls_width = 76;
let draggable_right = (rect.right - right_controls_width).max(0);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Scale hit-test bounds with monitor DPI

WM_NCHITTEST coordinates and GetClientRect are in physical pixels, but the drag thresholds here (toolbar_height = 32, right_controls_width = 76) are hard-coded as if they were CSS/logical pixels. On Windows displays using 125%/150% scaling, the non-draggable controls area becomes too small and the draggable caption zone intrudes into the pin/close buttons, so clicks on controls can be interpreted as drag starts. Please derive these bounds from the current DPI (or from runtime window scale factor) before comparing against hit-test coordinates.

Useful? React with 👍 / 👎.

@H-Chris233
Copy link
Copy Markdown
Collaborator

Codex:P1
请解决

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.

[windows] QA 浮窗生命周期语义未与 macOS 对齐,存在 linger / focus / screenshot 风险

2 participants