Repository navigation
Fix #24: add a copy-answer button to assistant replies - #34
Open
xiaoyao-666-coder wants to merge 2 commits into
Open
xiaoyao-666-coder wants to merge 2 commits into
xiaoyao-666-coder wants to merge 2 commits into
Conversation
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.
问题
助手回答下方只有“这条回答有帮助吗?”点赞/点踩,没有复制按钮,长回答只能手动选中复制。
修复
frontend/src/copy-text.ts(纯函数、可单测):先试navigator.clipboard.writeText,失败(权限被拒等)则走document.execCommand("copy")兜底(临时 textarea 选中复制);两者都没有返回unavailable,兜底也失败返回denied。navigator/document都做了typeof守卫,Node 下 import 安全。.message-feedback行内(点赞/点踩之后)加复制按钮,32px(小屏 36px),与现有反馈按钮同一尺寸与间距;欢迎消息沿用原有排除逻辑,没有复制按钮。message.content的原文:回答气泡就是把content按换行分段渲染的纯文本,引用、响应耗时、“查看参考资料”都是独立 UI,所以复制结果只有回答正文,不含引用标记与界面文案。copied样式,跟点赞选中态同款青色),同时 toast 提示“回答已复制到剪贴板。”,3 秒后自动消失。按钮的aria-label会在“复制回答/已复制回答”之间切换,toast 本身是role="status",读屏用户可感知。formatHttpError):“当前浏览器不支持复制,请手动选中回答内容复制。”(无可用途径)/“复制失败,请检查浏览器剪贴板权限后重试。”(权限被拒/兜底失败)。验证
npm test16 pass / 0 fail(基线 10 + 新增 6),npm run build正常。新增测试覆盖:Clipboard API 被调用且原文原样写入、不调兜底;clipboard 被拒走兜底成功;无 Clipboard API 直接走兜底;clipboard 被拒且兜底失败报denied;两者皆无报unavailable;空文本不调用写入。MEDGUIDE_MODE=test python -m pytest -q backend/tests521 passed(基线,无后端改动)。已知遗留
Closes #24