Skip to content

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

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

feat(composer): add delete button to QuoteChip for draft quote removal#3200
Battleplus wants to merge 23 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 中移除不需要的引用。

变更类型

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

范围

UI 变化

  • 引用的设计规范:不涉及:仅在现有 QuoteChip 组件上添加功能按钮,遵循已有组件交互模式(group hover / keyboard focus 可见),无新的视觉/交互/文案规范需求。删除按钮样式复用现有 icon button 模式。

怎么验证的

自动验证

pnpm --filter maker-core test
结果:42/42 pass

pnpm --filter maker-shared test
结果:54/54 pass

手工验证

  • QuoteChip: hover / focus 时删除按钮可见,click 触发回调
  • ComposerQuoteNode: 删除 quote 后 undo 可恢复
  • onRemove 时不显示按钮
  • 已发送消息中的 QuoteChip 不受影响

未执行的验证

风险

风险分类

  • 无已知风险
  • SQLite / migration
  • system prompt
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 存量插件兼容
  • 原生层 / fingerprint / OTA
  • 跨平台差异
  • 其他:

影响与回滚

  • 影响范围:仅 composer QuoteChip 组件的渲染和 atom 删除逻辑
  • 回滚 / 降级方式:git revert 即可,无持久化状态变更

提交前检查

  • 已 review 完整 diff
  • 每个 commit 都带 DCO 签名
  • UI 改动已在「UI 变化」注明引用的设计规范章节
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档
  • 已确认测试结果或说明未执行原因

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

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
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.tsregisterColor 列表里没有)。没有 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
@Battleplus

Copy link
Copy Markdown
Contributor Author

已在 head b081b0d 修复本轮审查的 3 个 P1(基于上一 head 2f721d0):

1. 共享 Tip + 真实 <button>(DESIGN.md §14.6)
ComposerQuoteNode 的删除控件改为真实 <button type="button">,用 @/components/ui/tooltipTip 包裹,textaria-label 同用已有 key chat.quote.remove,未使用 native title

2. 外层补 relative
NodeViewWrapper 加上 relativeabsolute -right-0.5 -top-0.5 的 × 现在锚定在本颗胶囊上,多条引用不会叠到同一处。

3. 死 API 删除 + 交互测试(讨论 #3203 第 3、4 项)

  • 删除全仓无调用方的 removeQuoteFromComposerDocument() / removeQuoteFromDraft() 及其 import;UI 删除统一走 NodeView 的 getPos() + deleteRange
  • composerChipPresentation.test.tsx:展示契约改为「仅 composerQuote 允许 close control(真实 button)」,其余 atom 仍断言无 button,不再用 span 绕过旧断言。
  • 新增用例覆盖:hover/focus 显隐与 relative 定位契约、click 只删被点那颗(含两条相同属性场景)、Enter/Space 删除且 keydown 不冒泡(document 监听断言)、undo/redo 恢复、编辑器锁定(setEditable(false))时删除无效;已发送 QuoteChip 无关闭按钮由既有 quoteChip.test.tsx 覆盖。

验证

  • vitest run composerChipPresentation.test.tsx quoteChip.test.tsx:13/13 通过
  • vitest run composerDraftStore.test.ts:37/37 通过
  • 改动文件 eslint 无告警;renderer 相关 tsc 无新增错误

@MagicLizi
MagicLizi dismissed their stale review September 6, 2026 03:43

这些问题已在当前 head 的后续 commit 中修复(格式门/安全门已通过),自动 dismiss 旧的 CHANGES_REQUESTED 以解除合并阻塞。

Battleplus and others added 2 commits September 6, 2026 04:30
…remove APIs

Address the 2026-09-06 changes-requested review on makecindy#3200:

- ComposerQuoteNode: render the remove control as a real <button type="button">
  wrapped in the shared Tip (text and aria-label both use chat.quote.remove),
  per DESIGN.md §14.6; no native title.
- ComposerQuoteNode: add `relative` to the NodeViewWrapper so the absolutely
  positioned × anchors to its own chip instead of an outer containing block.
- ComposerQuoteNode: no-op removal while the editor is locked
  (editor.setEditable(false)) so frozen drafts can't be mutated.
- composerDraftStore / composerQuoteDocument: remove the unwired
  removeQuoteFromDraft() / removeQuoteFromComposerDocument() APIs and imports
  (discussion makecindy#3203 item 3).
- composerChipPresentation.test.tsx: allow the close control only on the
  composer quote atom; add coverage for hover/focus visibility contract,
  click/Enter/Space removing only the clicked quote (identical attrs included),
  undo/redo restore, keydown not bubbling toward send, sent-message QuoteChip
  keeping no close button, and locked-editor no-op.

Signed-off-by: Battleplus <3559424769@qq.com>
@MagicLizi MagicLizi added the awaiting-discussion 等待维护者讨论(review-pr) label Sep 6, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

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

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

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

@MagicLizi MagicLizi added touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示) and removed status:awaiting-author 等作者修改(review-pr 自动维护,仅展示) labels Sep 6, 2026
@Battleplus

Copy link
Copy Markdown
Contributor Author

CI 补充说明(head 4d8a5d1):与本改动相关的检查已全部通过——Windows unit tests (2/2)、Linux unit tests (1/2)(2/2)、verify-checks、Desktop Git integration、DCO、check:pr-design-basis 均为 success;此前两轮的失败项(design-inventory 台账过期、composerChipPresentation undo 用例在 jsdom 的 Range 几何闪红)已分别以 36823164d8a5d1 修复,本地连跑 3 次稳定全绿。

当前仅剩 Windows unit tests (1/2) 失败:packages/maker-core/src/memory/manager.scope.test.ts 的 owner scope guard 用例 5192ms 超过 5000ms 限时(纯超时,非断言失败)。该文件本 PR 未触及,同一提交上 Linux 对应分片为绿,属 Windows runner 计时敏感闪红——我没有权限 re-run 该 job,麻烦有权限的同学重跑一下,或等待下一轮 CI。

…control change

The orca-workflow surface token/radius counts changed with the real
<button> + Tip remove control in ComposerQuoteNode, so the GENERATED
block no longer matched a fresh scan. Regenerated via
node scripts/design-inventory.mjs on the branch merged with upstream
main; --check and design-inventory.test.mjs pass.

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

jsdom lacks Range.getClientRects/getBoundingClientRect; ProseMirror's
focus/scrollIntoView coordsAtPos path hits them depending on rAF timing,
which made the undo/redo case flake red on CI. Provide a minimal
single-zero-rect implementation so scroll targeting takes the fallback
path in tests.

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

Copy link
Copy Markdown
Contributor

@Battleplus 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

3 similar comments
@MagicLizi

Copy link
Copy Markdown
Contributor

@Battleplus 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

@MagicLizi

Copy link
Copy Markdown
Contributor

@Battleplus 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

@MagicLizi

Copy link
Copy Markdown
Contributor

@Battleplus 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

…-button

Only conflict is docs/design-rules/design-inventory.md (regenerated on
main); the doc is refreshed against the merged tree in the next commit.

Signed-off-by: Battleplus <3559424769@qq.com>
The ledger conflicted with main because both sides regenerated the
GENERATED block; re-ran node scripts/design-inventory.mjs on the branch
merged with latest main (--check passes).

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

Only conflict is docs/design-rules/design-inventory.md (regenerated on
main again); the doc is refreshed against the merged tree in the next
commit.

Signed-off-by: Battleplus <3559424769@qq.com>
Re-ran node scripts/design-inventory.mjs on the branch merged with the
latest main (--check passes).

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

Only conflict is docs/design-rules/design-inventory.md (regenerated on
main); the doc is refreshed against the merged tree in the next commit.

Signed-off-by: Battleplus <3559424769@qq.com>
Re-ran node scripts/design-inventory.mjs on the branch merged with the
latest main (--check passes).

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

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

Signed-off-by: Battleplus <3559424769@qq.com>
Re-ran node scripts/design-inventory.mjs on the branch merged with the
latest main (--check passes).

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

Copy link
Copy Markdown
Contributor

@Battleplus 👋 这个 PR 目前与 main 有合并冲突,auto-review 因此暂时跳过、没法继续审查 / 合并。

请在本地 merge 最新的 origin/main 解决冲突后推送;冲突解除后,下一轮 auto-review 会自动重新处理这个 PR。

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

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

Signed-off-by: Battleplus <3559424769@qq.com>
Re-ran node scripts/design-inventory.mjs on the branch merged with the
latest main (--check passes).

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

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

Signed-off-by: Battleplus <3559424769@qq.com>
Re-ran node scripts/design-inventory.mjs on the branch merged with the
latest main (--check passes).

Signed-off-by: Battleplus <3559424769@qq.com>
@MagicLizi MagicLizi added the touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示) label Sep 8, 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:product-ui 改动碰到产品 / UI 面(review-pr 自动维护,仅展示) touches:rules 改动碰到规则 / 规范文档(review-pr 自动维护,仅展示)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants