-
-
Notifications
You must be signed in to change notification settings - Fork 807
Add AI Response Feedback + Copy Buttons #2457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
83dcb0c
split up big aimessage.tsx file, implement feedback/copy buttons UI.
sawka 83452da
add feedback telemetry
sawka 5ecc7c2
update this message to avoid saying what the cap is explicitly
sawka bc30c5d
minor, don't show copy button if no text. use \n\n as separator for …
sawka f87e68c
small tweak to change "//" => "/" for OSC 7
sawka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| // Copyright 2025, Command Line Inc. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| import { RpcApi } from "@/app/store/wshclientapi"; | ||
| import { TabRpcClient } from "@/app/store/wshrpcutil"; | ||
| import { cn, makeIconClass } from "@/util/util"; | ||
| import { memo, useState } from "react"; | ||
|
|
||
| interface AIFeedbackButtonsProps { | ||
| messageText: string; | ||
| } | ||
|
|
||
| export const AIFeedbackButtons = memo(({ messageText }: AIFeedbackButtonsProps) => { | ||
| const [thumbsUpClicked, setThumbsUpClicked] = useState(false); | ||
| const [thumbsDownClicked, setThumbsDownClicked] = useState(false); | ||
| const [copied, setCopied] = useState(false); | ||
|
|
||
| const handleThumbsUp = () => { | ||
| setThumbsUpClicked(!thumbsUpClicked); | ||
| if (thumbsDownClicked) { | ||
| setThumbsDownClicked(false); | ||
| } | ||
| if (!thumbsUpClicked) { | ||
| RpcApi.RecordTEventCommand(TabRpcClient, { | ||
| event: "waveai:feedback", | ||
| props: { | ||
| "waveai:feedback": "good", | ||
| }, | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| const handleThumbsDown = () => { | ||
| setThumbsDownClicked(!thumbsDownClicked); | ||
| if (thumbsUpClicked) { | ||
| setThumbsUpClicked(false); | ||
| } | ||
| if (!thumbsDownClicked) { | ||
| RpcApi.RecordTEventCommand(TabRpcClient, { | ||
| event: "waveai:feedback", | ||
| props: { | ||
| "waveai:feedback": "bad", | ||
| }, | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| const handleCopy = () => { | ||
| navigator.clipboard.writeText(messageText); | ||
| setCopied(true); | ||
| setTimeout(() => setCopied(false), 2000); | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="flex items-center gap-0.5 mt-2"> | ||
| <button | ||
| onClick={handleThumbsUp} | ||
| className={cn( | ||
| "p-1.5 rounded cursor-pointer transition-colors", | ||
| thumbsUpClicked | ||
| ? "text-accent" | ||
| : "text-secondary hover:bg-gray-700 hover:text-primary" | ||
| )} | ||
| title="Good Response" | ||
| > | ||
| <i className={makeIconClass(thumbsUpClicked ? "solid@thumbs-up" : "regular@thumbs-up", false)} /> | ||
| </button> | ||
| <button | ||
| onClick={handleThumbsDown} | ||
| className={cn( | ||
| "p-1.5 rounded cursor-pointer transition-colors", | ||
| thumbsDownClicked | ||
| ? "text-accent" | ||
| : "text-secondary hover:bg-gray-700 hover:text-primary" | ||
| )} | ||
| title="Bad Response" | ||
| > | ||
| <i className={makeIconClass(thumbsDownClicked ? "solid@thumbs-down" : "regular@thumbs-down", false)} /> | ||
| </button> | ||
| {messageText?.trim() && ( | ||
| <button | ||
| onClick={handleCopy} | ||
| className={cn( | ||
| "p-1.5 rounded cursor-pointer transition-colors", | ||
| copied | ||
| ? "text-success" | ||
| : "text-secondary hover:bg-gray-700 hover:text-primary" | ||
| )} | ||
| title="Copy Message" | ||
| > | ||
| <i className={makeIconClass(copied ? "solid@check" : "regular@copy", false)} /> | ||
| </button> | ||
| )} | ||
| </div> | ||
| ); | ||
| }); | ||
|
|
||
| AIFeedbackButtons.displayName = "AIFeedbackButtons"; | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling and timeout cleanup.
The clipboard API can fail (e.g., permission denied, insecure context), and the timeout is not cleaned up if the component unmounts during the 2-second window.
Apply this diff to add error handling and cleanup: