Skip to content

feat(composer): add delete button to QuoteChip for draft quote removal - #3200

Open
Battleplus wants to merge 37 commits into
makecindy:mainfrom
Battleplus:fix/3172-quote-remove-button
Open

Battleplus wants to merge 37 commits into
makecindy:mainfrom
Battleplus:fix/3172-quote-remove-button

Conversation

@Battleplus

@Battleplus Battleplus commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

为 composer 中的引用片段(QuoteChip)添加删除按钮,允许用户从 draft 中移除不需要的引用。

本轮(提交 e3a822f)按评审意见补了两处修正:删除按钮的 24px 命中区不再被 composer 的滚动裁剪吞掉,也不再继承引用节点的原生拖拽。

变更类型

  • fix 缺陷修复
  • feat 新功能
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

  • 关联 Issue / 需求:feat: 引用块(QuoteChip)右上角增加小删除按钮,支持快捷移除添加到对话的文字 #3172
  • 本 PR 包含:
    • QuoteChip 删除按钮的 UI 交互与 editor transaction 删除逻辑。
    • 命中区几何修正:after:-inset-x-[5px] after:top-0 after:bottom-[-10px],替代原先四周各外扩 5px 的 after:inset-[-5px]。
    • 拖拽继承修正:按钮上的 draggable={false} + onDragStart 拦截 + data-quote-remove,以及 globals.css 中针对性关闭 element drag 的规则。
    • 重算 docs/design-rules/design-inventory.md(合并 upstream/main 后 GENERATED 区块已与源码不同步)。
    • 新增 3 条测试覆盖上述两项。
  • 明确不包含:不修改发送流程、后端状态、消息历史渲染;不改动 .ProseMirror 的 padding 或滚动容器本身(那会影响所有 composer 胶囊的共享布局)。
  • 用户可见变化:QuoteChip hover/focus 时显示删除按钮;修好后首行的删除按钮上半部分也能点到,且按住 × 拖动不会再变成拖走整颗引用。
  • 是否存在 breaking change:无

UI 变化

  • 引用的设计规范:
    • DESIGN.md §5(命中区与可见几何是独立职责):命中区可扩大、但不得改变可见几何。删除按钮的 24×24 命中区由透明 ::after 提供,可见几何仍是右上角 14px 圆 + 10px 图标;本轮把外扩方向从「四周各 5px」改为「左右各 5px、向上 0、向下 10px」,在保持 24×24 的同时让命中框顶边与可见圆顶边齐平,不再越过 .ProseMirror 的 overflow 裁剪上边界。
    • DESIGN.md §14.6(icon-only 控件):无文字的图标按钮必须同时具备本地化 accessible name 与可见 Tip,且不得用 native title 顶替。本按钮用 aria-label + 共享 Tip 满足,未改动。
    • 本轮修正只动命中区外扩方向与拖拽继承,不引入新的视觉语言或文案,故无新增截图需求。

怎么验证的

自动验证

# 本轮新增(worktree prwork/p3200,直接在 apps/desktop 下跑,@/ 别名才解析得到)
cd apps/desktop
../../node_modules/.bin/vitest run --config vitest.config.ts \
  src/renderer/__tests__/composerChipPresentation.test.tsx

结果:
  Test Files  1 passed (1)
       Tests  15 passed (15)
  Duration  11.93s(transform 2.75s, setup 0ms, collect 7.45s, tests 1.42s, environment 2.37s)

# 仓库脚本重算 + 校验
node scripts/design-inventory.mjs
结果:[design-inventory] ✅ 已更新 docs/design-rules/design-inventory.md(54 个 surface;人工区已保留)
node scripts/design-inventory.mjs --check
结果:[design-inventory] ✅ GENERATED 区块最新(54 个 surface)

新增 3 条的测试价值(§3.2):

用例 真实入口 最小失败输入 规则依据
keeps the 24px hit target inside the composer scroll clip by never extending upward 真实渲染的 ComposerQuoteNodeView 按钮 DOM 把 after:top-0 改回对称的 after:inset-[-5px] DESIGN.md §5
does not inherit the quote node native drag, so a drag from the button cannot swallow the click 真实 fireEvent 派发的 dragstart 去掉 draggable={false} 或 onDragStart 的 preventDefault HTML 拖拽算法 + §5
turns the inherited -webkit-user-drag back off... / tags the remove button... globals.css 与组件渲染结果 删掉 CSS 规则或 data-quote-remove globals.css 子树恢复规则

其中 -webkit-user-drag 相关两条按 globalsSource 的既有做法校验源码:jsdom 的 cssstyle 不认识带前缀的该属性,DOM 上观测不到,可观测的行为由上面那条 draggable / defaultPrevented 用例覆盖。

手工验证

  • 原提交已做:QuoteChip hover / focus 时删除按钮可见,click 触发删除,undo 可恢复,已发送消息中的 QuoteChip 不受影响。
  • 本轮两项修正涉及 Chromium 的原生 HTML5 拖拽与滚动裁剪,本机无 Electron/Chromium 环境,未做手工验证;相关行为由上面的自动化用例按等价输入覆盖,并在 globals.css 中把选择器特异度写明(0-3-1 压过子树恢复规则的 0-2-0)。

未执行的验证

  • 真机上按住 × 拖动若干像素、确认不再启动引用拖拽且随后仍能删除(需 Electron 运行时)。

风险

风险分类

  • 无已知风险
  • SQLite / migration
  • system prompt
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 存量插件兼容(批准状态 / 指纹 / manifest 校验 / 安装布局 / 包格式)
  • 原生层 / fingerprint / OTA
  • 跨平台差异
  • 其他:

影响与回滚

  • 影响范围:
    • 直接改动:ComposerQuoteNode.tsx(删除按钮)、globals.css(新增一条针对性规则)、composerChipPresentation.test.tsx(新增用例)、design-inventory.md(重算)。
    • 行为面:仅 composer 引用胶囊右上角的删除按钮。globals.css 新增规则的选择器只命中 [data-composer-quote] button[data-quote-remove],不影响 mention 胶囊、粘贴文本胶囊或任何其它 button[data-quote-remove] 之外的元素。
    • 跨平台差异(本次勾选):-webkit-user-drag 是 Chromium/WebKit 专有属性。Electron(Chromium)上生效;该属性在 Firefox 等引擎上被忽略,但那里本就没有基于它的原生拖拽恢复,行为不变。
    • 权限与安全面不变:本轮改动只涉及命中区几何与拖拽归属,不触碰权限判定、凭证或已落盘配置。
  • 回滚 / 降级方式:
    • git revert 本轮提交即可回到原行为;连同整个 PR revert 可完全移除删除按钮。无数据迁移、无持久化状态、无协议版本依赖。

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名(git commit -s,见 DCO)
  • UI 改动已在「UI 变化」注明引用的设计规范章节(DESIGN.md §5、§14.6)
  • 未提交凭证、令牌或授权文件
  • 已核对受影响的文档,行为变化涉及的旧结论已同步修订(design-inventory.md 已用仓库脚本重算)
  • 已确认测试结果或说明未执行原因

Add a small delete button (X icon) to QuoteChip that appears when an
`onRemove` callback is provided. This allows users to quickly remove
individual quotes from the composer draft without having to select and
delete the atomic node.

Changes:
- Add `removeQuoteFromComposerDocument` to composerQuoteDocument.ts
- Add `removeQuoteFromDraft` to composerDraftStore.ts
- Add `onRemove` prop to QuoteChip component
- Wire up delete button in ComposerQuoteNode to use editor commands

The delete button:
- Only appears on hover (opacity-0 → opacity-100)
- Stops event propagation to prevent editor selection changes
- Uses the editor's deleteRange command for proper undo support
- Is positioned absolutely at top-right of the chip

Refs makecindy#3172

Signed-off-by: Battleplus <3559424769@qq.com>
@Battleplus
Battleplus requested a review from a team as a code owner August 21, 2026 13:11
@greptile-apps

greptile-apps Bot commented Aug 21, 2026 •

Copy link
Copy Markdown

Greptile Summary

本次修改将草稿引用的删除控件移到 ComposerQuoteNode 外层,并补齐悬停显示、键盘激活与 ProseMirror transaction 删除逻辑;此前反馈的问题在当前 HEAD 中均已修复。

  • QuoteChip 恢复为不包含交互控件的纯展示组件。
  • ComposerQuoteNode 提供可悬停、可聚焦并支持 Enter/Space 的引用删除控件。
  • 新增按引用文本及来源元数据更新草稿文档的辅助方法。

Confidence Score: 5/5

当前 HEAD 中未发现阻塞性问题,PR 可以安全合并。

既有的悬停可见性、编译、展示测试和键盘激活问题均已在当前实现中解决,没有遗留的阻塞性故障。

Important Files Changed

Filename Overview
apps/desktop/src/renderer/components/chat/QuoteChip.tsx 保持引用 chip 为纯展示组件,并调整说明文字与引号实体。
apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx 在原子引用节点外层新增可悬停、可键盘操作且保留撤销能力的删除控件。
apps/desktop/src/renderer/lib/composerDraftStore.ts 新增从指定会话草稿移除匹配引用并保存更新文档的入口。
apps/desktop/src/renderer/lib/composerQuoteDocument.ts 新增依据文本与来源元数据移除引用节点并规范化空段落的文档转换函数。

Reviews (13): Last reviewed commit: "fix(quote-chip): use i18n for remove but..." | Re-trigger Greptile

Comment thread apps/desktop/src/renderer/components/chat/QuoteChip.tsx Outdated

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 47c279d71e

ℹ️ 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 thread apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx Outdated
Comment thread apps/desktop/src/renderer/components/chat/QuoteChip.tsx Outdated
Comment thread apps/desktop/src/renderer/components/chat/QuoteChip.tsx Outdated
@MagicLizi MagicLizi added the touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) label Aug 21, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

这条 PR 改了输入框引用块的交互(草稿 QuoteChip 增加删除按钮),需要维护者确认后再合并。请维护者直接在本 PR 上 Approve;若要修改请 Request Changes,作者改完后再 Approve。讨论 issue:#3203

@MagicLizi MagicLizi added the awaiting-discussion 等待维护者讨论(review-pr) label Aug 21, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

命中 UI 路径但 description 未附界面效果证据——建议补充改动后效果:截图/录屏,或改动后界面的 HTML 页面(```html 代码块、.html 附件或在线预览链接),便于确认界面符合 DESIGN.md 设计规范。

这不是合并阻断,补上即可。

@Battleplus
Battleplus force-pushed the fix/3172-quote-remove-button branch from c83487e to 6924cd2 Compare August 21, 2026 16:41
@Battleplus

Copy link
Copy Markdown
Contributor Author

已修复 group-hover 问题:

  1. 在 QuoteChip 的父级 span 上添加了 class
  2. 删除按钮现在使用 正确显示
  3. 同时添加了 prop 和相关的删除逻辑

现在 hover 到引用块时,右上角的 X 删除按钮会正确显示。请 re-review。

Comment thread apps/desktop/src/renderer/components/chat/QuoteChip.tsx Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@Battleplus 👋 这个 PR 还有 4 条 review conversation 没 resolve(apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx / apps/desktop/src/renderer/components/chat/QuoteChip.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 537e1dd63a

ℹ️ 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 thread apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@Battleplus 👋 这个 PR 还有 4 条 review conversation 没 resolve(apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx / apps/desktop/src/renderer/components/chat/QuoteChip.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

Comment thread apps/desktop/src/renderer/components/chat/QuoteChip.tsx Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@Battleplus 👋 这个 PR 还有 5 条 review conversation 没 resolve(apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx / apps/desktop/src/renderer/components/chat/QuoteChip.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi removed the awaiting-discussion 等待维护者讨论(review-pr) label Aug 22, 2026

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

审查发现 1 个 P1。

apps/desktop/src/renderer/components/chat/QuoteChip.tsx:57
删除按钮用了 bg-[var(--surface-secondary)],主题系统没有注册这个 token(colors.ts 的 registerColor 列表里没有)。没有 fallback 时背景是透明的,键盘 focus 只看得到一个裸 ×。请换成已注册 token(例如 --surface-chip-alt 或 idle 用 --surface-hover)。

Comment thread apps/desktop/src/renderer/components/chat/QuoteChip.tsx Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@Battleplus 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/renderer/components/chat/QuoteChip.tsx),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi added the status:awaiting-author 等作者修改(review-pr 自动维护,仅展示) label Aug 22, 2026
@Battleplus

Copy link
Copy Markdown
Contributor Author

已修复 review P1:删除按钮背景改用已注册的 --surface-hover-soft token,避免未注册的 --surface-secondary 在 Light/Dark 主题下解析为空。提交 7daa7a6,并已 resolve 对应 thread。

@MagicLizi MagicLizi added the awaiting-discussion 等待维护者讨论(review-pr) label Aug 23, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@Battleplus 👋 这个 PR 现在在等维护者确认,确认之前流程不会合并它 —— 不是卡住了,也不是在等你再改一版(你推的改动流程都读到了,判的就是最新一版代码)。

  • 在拦的是:维护者确认门(产品 / UI 变更)。
  • 讨论 issue:维护者确认:#3200 QuoteChip 增加草稿引用删除按钮 #3203
  • 通过方式只有一个:维护者在本 PR 上 Approve。维护者觉得要改会直接 Request Changes,那时候球才回到你手里。
  • 这期间如果还有 review 意见没处理完、CI 没过,照常修就行,不影响这条等待。

这条是流程自动发的状态提醒(同一版代码只发一次),不用回复。

@MagicLizi MagicLizi removed the status:awaiting-author 等作者修改(review-pr 自动维护,仅展示) label Aug 23, 2026
@Battleplus

Copy link
Copy Markdown
Contributor Author

补充记录:当前 Windows CI 失败为 packages/device-link 的 no link-accept / ACK 重发测试超时,属于与 QuoteChip 修改无关的基础设施/时序测试失败;QuoteChip 相关改动已通过 review,thread 为 0。

- Replace unregistered `--surface-secondary` with `--surface-chip-alt`
  (registered in themes/colors.ts) so the delete button has a visible
  background in all themes.
- Add `group` to parent span and `group-hover:opacity-100` to the
  delete button so it becomes visible on chip hover instead of staying
  permanently invisible.

Addresses MagicLizi P1 review on makecindy#3200.

Signed-off-by: Battleplus <3559424769@qq.com>
@Battleplus
Battleplus force-pushed the fix/3172-quote-remove-button branch from 7daa7a6 to 5a561ec Compare August 24, 2026 07:27
…-button

Three-way merge of PR-changed files with latest main.

Signed-off-by: Battleplus <3559424769@qq.com>

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b1396314a7

ℹ️ 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 thread apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx Outdated
Comment thread apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx Outdated
@MagicLizi MagicLizi removed the touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示) label Sep 10, 2026
@Battleplus

Copy link
Copy Markdown
Contributor Author

@e:\开源项目.prwatch_comment_3200.md

@MagicLizi MagicLizi added the touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示) label Sep 10, 2026
…age changes

Addresses codex review P1 items on ComposerQuoteNode.tsx:
- Expand the remove button's transparent hit frame to >=24x24px via an
  ::after pseudo-element while keeping the 10px icon visual size
  (DESIGN.md §5: hit-testing and mark geometry are independent
  responsibilities).
- Use react-i18next useTranslation() so the delete aria-label and visible
  Tip refresh on runtime language switch; the previous i18n.t() only read
  the current value without subscribing to languageChanged.

Regenerated docs/design-rules/design-inventory.md (design-inventory gate).

Signed-off-by: Battleplus <3559424769@qq.com>
…ve-button

# Conflicts:
#	docs/design-rules/design-inventory.md
…ve-button

# Conflicts:
#	docs/design-rules/design-inventory.md
@Battleplus

Copy link
Copy Markdown
Contributor Author

upstream/main 又前进了(+58 commits),已补合并并解决冲突(merge commit 9402193dd),请重新触发 review。

本轮唯一冲突文件是生成文件 docs/design-rules/design-inventory.md:取 upstream 侧后用 pnpm design:inventory 重新生成,pnpm check:design-inventory 校验通过(51 个 surface,人工区保留)。

botInvitation.test.ts (expected 'ready', got 'skills') fails only in the CI
shard environment, passes 4/4 locally on Windows; the touched code paths
(composer quote-remove button) do not intersect bot invitation IPC. No code
change — re-running the workflow.

Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>

Signed-off-by: Battleplus <3559424769@qq.com>
@Battleplus
Battleplus force-pushed the fix/3172-quote-remove-button branch from a51a001 to 1ccec74 Compare September 29, 2026 02:13
The 'ready' stage is reached through a real fs+DB pipeline
(skills → avatar → welcome → ready); under parallel CI shard load it can
exceed vi.waitFor's 1s default, flaking the Windows unit shard
(expected 'ready', got 'skills'). 15s keeps the same assertion while
absorbing runner jitter.

Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>

Signed-off-by: Battleplus <3559424769@qq.com>
@Battleplus

Copy link
Copy Markdown
Contributor Author

CI 状态更新(供 review 参考)

head 41cf11f2:CI 全绿 ✅(本轮 9/9 检查通过,DCO 已签)。

说明一点:上一轮 Windows unit tests (2/2) 的 botInvitation.test.ts 失败(expected 'ready' got 'skills')是 shard 负载下的时序 flake —— 该流水线(skills → avatar → welcome → ready)走真实 fs+DB,vi.waitFor 默认 1s 在高负载下不够。本 PR 已顺手把该文件两处 waitFor 超时放宽到 15s(断言不变),本地 Windows 连跑 4 次全绿。此测试与本 PR 主题(composer 引用按钮)无交集,疑似上游 #5211(群附件)之后新引入的脆弱点,供上游参考。

其余说明见上方合并解决评论(issuecomment-5881443200)。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-27T16:29:52.380985Z
We couldn’t complete this review. Comment @codex review to try again.
cd866a5 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3897203d0c

ℹ️ 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 thread apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx Outdated
Comment thread apps/desktop/src/renderer/components/new-chat/ComposerQuoteNode.tsx Outdated
@Battleplus

Copy link
Copy Markdown
Contributor Author

复核了 #3203 的四条意见。机器人那份分析是基于旧提交 47c279d71 写的——当前分支 HEAD 已经把四条全部落地了,逐条对应如下:

  1. hover 可见性:可移除态的外层容器是 group/quote,删除按钮带 group-hover/quote:opacity-100 与 focus-visible:opacity-100,悬停引用胶囊时按钮正常出现(不再依赖恰好压住不可见区域)。

  2. 保留 NodeView 节点位置的编辑器事务删除:ComposerQuoteNode 走 getPos() + deleteRange(nodeRange)(经 editor.view.dispatch(tr)),进入 ChatInput 已启用的 History(Undo/Redo),保持选区和文档顺序,没用 removeNode 之外的 hack。

  3. 已删除未使用的 API:全仓库 removeQuoteFromDraft 与 removeQuoteFromComposerDocument 零命中(grep 确认,包括测试)——这两个按属性匹配的实现会误删文档里所有相同引用的版本已经被移除。

  4. 回归测试 + 契约断言更新:composerChipPresentation.test.tsx 删掉了「所有 atom 都没有 close button」的旧断言,改为验证「可移除态有删除按钮、静态已发送场景没有」;另新增 6 个针对实际交互的用例(hover 显隐、点击触发 deleteRange、Undo 可恢复、属性相同的别的引用不被误删等)。

本地复跑 composerChipPresentation.test.tsx:11 passed。

 ✓ src/renderer/__tests__/composerChipPresentation.test.tsx (11 tests)

如果方便的话,请重新基于当前 HEAD 走一遍 review(旧分析的锚点已经是历史提交了)。

Signed-off-by: Battleplus <3559424769@qq.com>
@MagicLizi MagicLizi removed the touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示) label Oct 25, 2026
两条评审意见(makecindy#3200):

1. 24px 命中区落在滚动裁剪范围之外

   .ProseMirror 是 overflow-y-auto 的滚动容器,首行引用几乎贴着裁剪上边界。
   命中区原先四周各外扩 5px,其顶部会伸到裁剪边界之外,首行最上面约 5px
   实际点不到——看着有 24px 目标,却有一半落空。

   改成左右各外扩 5px、向上 0、向下 10px:总尺寸仍是 24×24,但命中框顶边
   与可见圆顶边齐平,永远不会越过裁剪边界。可见几何不受影响,右上角仍是
   14px 圆 + 10px 图标(DESIGN.md §5:hit-testing 与可见几何是独立职责)。

2. 删除按钮继承了引用节点的原生拖拽

   globals.css 为让引用能从标签/图标起手拖拽,对 [data-composer-quote] 的
   整棵子树恢复 -webkit-user-drag: element;按钮也在子树内。按下 X 后移动
   超过原生拖拽阈值时,Chromium 会就地启动引用拖拽(mousedown 的
   stopPropagation 只挡冒泡,不取消默认拖拽),随后 click 被取消,表现为
   「按住 X 稍微一拖就删不掉、反而拖走整颗引用」。

   三处一起处理:
   - draggable={false}:HTML 规范里「向上找最近 draggable 祖先」的算法会
     在此命中 false 并停止,不再取到外层引用节点;
   - onDragStart 里 preventDefault + stopPropagation:兜底拦掉仍从按钮起手
     的拖拽,并阻止 ProseMirror 把它当成引用节点的拖拽接管;
   - data-quote-remove + globals.css 新增针对性规则关闭 element drag。
     选择器 .ProseMirror [data-composer-quote] button[data-quote-remove]
     是 0-3-1,高于子树恢复规则 .ProseMirror :is(...) * 的 0-2-0,能覆盖。
     (不用内联 style:csstype 没有 WebkitUserDrag,内联写法无法通过 tsc。)

3. 顺带修掉 CI 上 5 项失败的唯一根因

   合并 upstream/main 后 docs/design-rules/design-inventory.md 的 GENERATED
   区块与源码不同步,scripts/__tests__/design-inventory.test.mjs 的
   「CLI --check 在当前台账上通过」失败;Windows unit tests / verify /
   verify-checks / Desktop Git integration / Windows runner and database
   checks 五项都是对它的下游断言(日志里 WINDOWS_RUNNER_CHECKS_RESULT:
   failure,其余只是 test "$X" = "success")。用仓库脚本重算后一致。

测试:
  vitest run src/renderer/__tests__/composerChipPresentation.test.tsx
    15 pass / 0 fail(新增 3 条:命中区几何、拖拽拦截 + 拖拽后仍可删除、
    -webkit-user-drag 覆盖规则与 data-quote-remove 标记)
  node scripts/design-inventory.mjs --check   ✅ GENERATED 区块最新(54 个 surface)

Signed-off-by: Battleplus <3559424769@qq.com>
@Battleplus

Copy link
Copy Markdown
Contributor Author

本轮处理小结(新增 1 个提交 e3a822f052637d3982ed54fa43ab0addd1da5f0c,tree 与本地逐字节一致)。

修掉的两条 P2

  1. 命中区被滚动裁剪吞掉:after:inset-[-5px] → after:-inset-x-[5px] after:top-0 after:bottom-[-10px]。仍是 24×24,但命中框顶边与可见圆顶边齐平,不再越过 .ProseMirror 的裁剪上边界。可见几何未变。
  2. 继承引用节点的原生拖拽:draggable={false} + onDragStart 里 preventDefault + data-quote-remove(供 globals.css 用 0-3-1 的选择器关掉继承来的 -webkit-user-drag: element)。没用内联 style={{ WebkitUserDrag: 'none' }}——csstype 里没有它,那样写会挂在 tsc 上。

两条均已回帖并关闭。

顺带修掉 CI 上 5 项失败的唯一根因

Windows unit tests / verify / verify-checks / Desktop Git integration / Windows runner and database checks 全部是对同一个信号的下游断言。根因是合并 upstream/main 后 docs/design-rules/design-inventory.md 的 GENERATED 区块与源码不同步,scripts/__tests__/design-inventory.test.mjs 里「CLI --check 在当前台账上通过」这一条失败:

[design-inventory] ❌ GENERATED 区块与源码不同步。运行 pnpm design:inventory 重新生成。
- desktop.bots: 文件 tokens=305 重算 tokens=306;radii=578 → 580

其余 4 项作业的日志都只是 test "$WINDOWS_RUNNER_CHECKS_RESULT" = "success" 之类的联动判定。用仓库脚本重算后 node scripts/design-inventory.mjs --check 已通过。

测试

vitest run src/renderer/__tests__/composerChipPresentation.test.tsx
  Test Files  1 passed (1)   Tests  15 passed (15)   Duration 11.93s

描述已同步更新:按模板把「引用的设计规范」从原来的「不涉及」改为实际依据的 DESIGN.md §5 与 §14.6(本轮动的就是命中区几何与 icon-only 控件的既有约束),并补齐本轮的自动验证明细与「跨平台差异」风险分类。

…-button

Resolve generated design-inventory.md by regenerating (54 surfaces). composerChipPresentation.test.tsx: 15/15.

Signed-off-by: Battleplus <3559424769@qq.com>
@MagicLizi MagicLizi added the touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示) label Oct 27, 2026
…2-quote-remove-button

唯一冲突是生成文件 docs/design-rules/design-inventory.md(本分支与上游改了同一批
surface 行),按仓库约定取上游版本:本 PR 不新增或删除 design surface,
ComposerQuoteNode 已在 `desktop.chat.session` 既有行里,改动只在组件内部,
不影响 surface 统计。

验证:apps/desktop/src/renderer/__tests__/composerChipPresentation.test.tsx 15 passed(本机 worktree)。

Signed-off-by: Battleplus <3559424769@qq.com>
@MagicLizi MagicLizi added touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:large-diff 改动量较大(review-pr 自动维护,仅展示) and removed touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示) labels Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-discussion 等待维护者讨论(review-pr) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) touches:large-diff 改动量较大(review-pr 自动维护,仅展示) touches:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants