fix(renderer): exclude system control buttons from AI interactive click handling - #218
Merged
lioensky merged 1 commit intoSep 30, 2026
Conversation
… prevent event hijacking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
动机与背景
在聊天消息渲染中,工具结果气泡右上方提供的“从上下文中删除此工具结果”按钮(
.vcp-tool-result-delete-btn)点击无响应,控制台输出[ContentProcessor] Button has no text to send。根因分析
contentProcessor.js的processInteractiveButtons使用宽泛选择器contentDiv.querySelectorAll('button'),将系统内建的工具栏控制按钮误识别为 AI 交互按钮;handleAIButtonClick在入口未做语义校验前无差别调用了event.stopImmediatePropagation(),导致底层 messageRenderer 上的全局删除委托无法捕获事件;由于系统按钮内仅包含图标 SVG 而无文本,直接抛警告返回,阻断了整个两段式确认与删除流程。解决方案(双保险设计)
processInteractiveButtons中加入系统按钮特征检测,明确排除.vcp-tool-result-delete-btn、.code-copy-btn、.mermaid-viewer-btn及处于系统工具栏内的按钮,不挂载 AI 交互监听器;handleAIButtonClick,在判定按钮不存在有效发送内容时,静默让出事件处理权,不阻止事件冒泡。测试验证
node --test tests/content-processor-owner.test.mjs,5/5 项单测全部通过;