Skip to content

Commit

Permalink
chore(ui): Playground: add copy button, tooltip on toggles (#3218)
Browse files Browse the repository at this point in the history
* Added tooltip to Settings Tabs

* Added copy control for messages

* Added playground cost data

* Use TraceCostStats - updated finish reason

* Lint

* Wrestling types

* Lint fix

* Casting

* Revert changes to call stats
  • Loading branch information
m-rgba authored Dec 16, 2024
1 parent d33d87e commit dbfb7a7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {toast} from '@wandb/weave/common/components/elements/Toast';
import {Button} from '@wandb/weave/components/Button';
import React from 'react';

Expand Down Expand Up @@ -26,8 +27,28 @@ export const PlaygroundMessagePanelButtons: React.FC<
}) => {
const {deleteMessage, deleteChoice, retry} = usePlaygroundContext();

const handleCopy = async () => {
if (contentRef.current?.textContent) {
try {
await navigator.clipboard.writeText(contentRef.current.textContent);
toast('Message copied to clipboard');
} catch (error) {
toast('Failed to copy message');
}
}
};

return (
<div className="ml-auto flex gap-4 rounded-lg pt-[8px]">
<Button
variant="quiet"
size="small"
startIcon="copy"
onClick={handleCopy}
tooltip={!hasContent ? 'No content to copy' : 'Copy message'}
disabled={!hasContent}>
Copy
</Button>
<Button
variant="quiet"
size="small"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Box from '@mui/material/Box';
import Tooltip from '@mui/material/Tooltip';
import {MOON_250} from '@wandb/weave/common/css/color.styles';
import {Switch} from '@wandb/weave/components';
import * as Tabs from '@wandb/weave/components/Tabs';
Expand Down Expand Up @@ -46,7 +47,9 @@ export const PlaygroundSettings: React.FC<PlaygroundSettingsProps> = ({
onClick={() => setSettingsTab(idx)}
className="max-w-[120px]">
{playgroundStates.length > 1 && <Tag label={`${idx + 1}`} />}
<span className="truncate">{state.model}</span>
<Tooltip title={state.model}>
<span className="truncate">{state.model}</span>
</Tooltip>
</Tabs.Trigger>
))}
</Tabs.List>
Expand Down

0 comments on commit dbfb7a7

Please sign in to comment.