Add copy button to chat messages and improve tool usage guidance#2071
Add copy button to chat messages and improve tool usage guidance#2071gary149 wants to merge 6 commits intohuggingface:mainfrom
Conversation
Add explicit guidance to the system prompt that instructs the model to: - Prefer direct answers over tool calls for simple tasks - Only use tools when genuinely needed - Stop making additional calls when enough info is gathered - Categorize tools (generative vs search) with specific usage rules This addresses the issue where models would make excessive tool calls for simple requests like spelling checks or prompt edits.
Replace complex categorization logic with a single clear instruction: "Only use a tool if you cannot answer without it." This follows Anthropic's recommended approach of using simple, direct instructions rather than elaborate rule systems.
mcpflow prompt adjustment
Adds a copy button to the left of the edit button for user messages. Both buttons have identical styling.
Match the codebase pattern from CopyToClipBoardBtn that handles older/insecure browsers with a textarea fallback.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c1d3f08147
ℹ️ 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".
| onclick={() => { | ||
| navigator.clipboard.writeText(message.content.trim()); | ||
| }} |
There was a problem hiding this comment.
Guard clipboard access to avoid runtime errors
Clicking the new Copy button always calls navigator.clipboard.writeText(...) without checking for availability or handling rejections. In non-secure contexts (e.g., HTTP), older browsers, or locked-down environments where navigator.clipboard is undefined or access is denied, this throws a runtime error or unhandled promise rejection on click, which breaks the UX for those users. Consider checking for navigator.clipboard and handling failures (e.g., fallback to document.execCommand or a user-facing error).
Useful? React with 👍 / 👎.
Summary
This PR enhances the chat interface with a copy-to-clipboard feature for messages and refines the AI's tool usage behavior by providing clearer guidance on when to use available tools.
Key Changes
Chat Message Copy Button: Added a "Copy" button to chat messages that appears on hover, allowing users to easily copy message content to their clipboard. The button uses the Carbon copy icon and matches the styling of existing message action buttons.
Tool Usage Guidance: Updated the tool prompt instructions to:
Implementation Details
navigator.clipboard.writeText()API for copying