HemanthTempalli commited on
Commit
8969194
·
1 Parent(s): 6fffc51

feat: add copied tooltip for assistant messages

Browse files
frontend/src/components/chat/MessageBubble.tsx CHANGED
@@ -64,7 +64,7 @@ export default function MessageBubble({ message }: Props) {
64
  await navigator.clipboard.writeText(message.content);
65
  setCopied(true);
66
  if (copiedTimeoutRef.current) clearTimeout(copiedTimeoutRef.current);
67
- copiedTimeoutRef.current = setTimeout(() => setCopied(false), 2000);
68
  } catch {
69
  setCopied(false);
70
  }
@@ -158,6 +158,15 @@ export default function MessageBubble({ message }: Props) {
158
  <Copy className="w-3.5 h-3.5" />
159
  )}
160
  </Button>
 
 
 
 
 
 
 
 
 
161
  </>
162
  )}
163
  <div className={`prose-chat text-sm ${message.content ? "pr-14" : ""}`}>
 
64
  await navigator.clipboard.writeText(message.content);
65
  setCopied(true);
66
  if (copiedTimeoutRef.current) clearTimeout(copiedTimeoutRef.current);
67
+ copiedTimeoutRef.current = setTimeout(() => setCopied(false), 1500);
68
  } catch {
69
  setCopied(false);
70
  }
 
158
  <Copy className="w-3.5 h-3.5" />
159
  )}
160
  </Button>
161
+ {copied && (
162
+ <div
163
+ className="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-zinc-800 text-white text-xs rounded-md whitespace-nowrap opacity-100 transition-opacity pointer-events-none"
164
+ role="status"
165
+ aria-live="polite"
166
+ >
167
+ Copied!
168
+ </div>
169
+ )}
170
  </>
171
  )}
172
  <div className={`prose-chat text-sm ${message.content ? "pr-14" : ""}`}>