Skip to content
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

style(weave): restyle carousel view #3205

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions weave-js/src/assets/icons/icon-visible.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions weave-js/src/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ import {ReactComponent as ImportVersionsLayers} from '../../assets/icons/icon-ve
import {ReactComponent as ImportVertexGCP} from '../../assets/icons/icon-vertex-gcp.svg';
import {ReactComponent as ImportVideoPlay} from '../../assets/icons/icon-video-play.svg';
import {ReactComponent as ImportViewGlasses} from '../../assets/icons/icon-view-glasses.svg';
import {ReactComponent as ImportVisible} from '../../assets/icons/icon-visible.svg';
import {ReactComponent as ImportWandb} from '../../assets/icons/icon-wandb.svg';
import {ReactComponent as ImportWarning} from '../../assets/icons/icon-warning.svg';
import {ReactComponent as ImportWarningAlt} from '../../assets/icons/icon-warning-alt.svg';
Expand Down Expand Up @@ -1048,6 +1049,9 @@ export const IconVideoPlay = (props: SVGIconProps) => (
export const IconViewGlasses = (props: SVGIconProps) => (
<ImportViewGlasses {...updateIconProps(props)} />
);
export const IconVisible = (props: SVGIconProps) => (
<ImportVisible {...updateIconProps(props)} />
);
export const IconWandb = (props: SVGIconProps) => (
<ImportWandb {...updateIconProps(props)} />
);
Expand Down Expand Up @@ -1336,6 +1340,7 @@ const ICON_NAME_TO_ICON: Record<IconName, ElementType> = {
'vertex-gcp': IconVertexGCP,
'video-play': IconVideoPlay,
'view-glasses': IconViewGlasses,
visible: IconVisible,
wandb: IconWandb,
warning: IconWarning,
'warning-alt': IconWarningAlt,
Expand Down
1 change: 1 addition & 0 deletions weave-js/src/components/Icon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export {
IconVertexGCP,
IconVideoPlay,
IconViewGlasses,
IconVisible,
IconWandb,
IconWarning,
IconWarningAlt,
Expand Down
1 change: 1 addition & 0 deletions weave-js/src/components/Icon/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ export const IconNames = {
VertexGCP: 'vertex-gcp',
VideoPlay: 'video-play',
ViewGlasses: 'view-glasses',
Visible: 'visible',
Wandb: 'wandb',
Warning: 'warning',
WarningAlt: 'warning-alt',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ type ChoiceViewProps = {
isStructuredOutput?: boolean;
isNested?: boolean;
choiceIndex?: number;
messageHeader?: React.ReactNode;
};

export const ChoiceView = ({
choice,
isStructuredOutput,
isNested,
choiceIndex,
messageHeader,
}: ChoiceViewProps) => {
const {message} = choice;
return (
Expand All @@ -24,6 +26,7 @@ export const ChoiceView = ({
isStructuredOutput={isStructuredOutput}
isNested={isNested}
choiceIndex={choiceIndex}
messageHeader={messageHeader}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,39 @@ export const ChoicesViewCarousel = ({
};

return (
<>
<ChoiceView
choice={choices[selectedChoiceIndex]}
isStructuredOutput={isStructuredOutput}
choiceIndex={selectedChoiceIndex}
/>
<div className="flex items-center">
<div className="flex-auto">
<ChoiceView
choice={choices[selectedChoiceIndex]}
isStructuredOutput={isStructuredOutput}
choiceIndex={selectedChoiceIndex}
messageHeader={
<div className="mb-8 flex items-center gap-4">
<div className="flex items-center gap-12">
<Button
variant="ghost"
icon="chevron-back"
size="small"
onClick={onBack}
/>
<span className="text-sm text-moon-500">
{selectedChoiceIndex + 1} of {choices.length}
</span>
<Button
variant="ghost"
icon="chevron-next"
size="small"
onClick={onNext}
/>
</div>
<Button
size="small"
variant="quiet"
icon="expand-uncollapse"
icon="visible"
onClick={() => setIsDrawerOpen(true)}
tooltip="Switch to linear view"
/>
tooltip="Switch to linear view">
Review
</Button>
</div>
<div className="flex items-center gap-12">
<Button
variant="ghost"
icon="chevron-back"
size="small"
onClick={onBack}
/>
{selectedChoiceIndex + 1} of {choices.length}
<Button
variant="ghost"
icon="chevron-next"
size="small"
onClick={onNext}
/>
</div>
</div>
</>
}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type MessagePanelProps = {
choiceIndex?: number;
isNested?: boolean;
pendingToolResponseId?: string;
messageHeader?: React.ReactNode;
};

export const MessagePanel = ({
Expand All @@ -30,6 +31,7 @@ export const MessagePanel = ({
// If the tool call response is pending, the editor will be shown automatically
// and on save the tool call response will be updated and sent to the LLM
pendingToolResponseId,
messageHeader,
}: MessagePanelProps) => {
const [isShowingMore, setIsShowingMore] = useState(false);
const [isOverflowing, setIsOverflowing] = useState(false);
Expand Down Expand Up @@ -116,6 +118,7 @@ export const MessagePanel = ({
'max-h-[400px]': !isShowingMore,
'max-h-full': isShowingMore,
})}>
{messageHeader}
{isPlayground && editorHeight ? (
<PlaygroundMessagePanelEditor
message={message}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const PlaygroundChat = ({
setSettingsTab,
settingsTab,
}: PlaygroundChatProps) => {
console.log('playgroundStates', playgroundStates);
const [chatText, setChatText] = useState('');
const [isLoading, setIsLoading] = useState(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export const useChatFunctions = (
messageIndex: number,
newMessage: Message
) => {
console.log('editMessage', callIndex, messageIndex, newMessage);

setPlaygroundStateField(callIndex, 'traceCall', prevTraceCall => {
const newTraceCall = clearTraceCall(
cloneDeep(prevTraceCall as OptionalTraceCallSchema)
Expand Down Expand Up @@ -106,6 +108,7 @@ export const useChatFunctions = (
choiceIndex: number,
newChoice: Message
) => {
console.log('editChoice', callIndex, choiceIndex, newChoice);
setPlaygroundStateField(callIndex, 'traceCall', prevTraceCall => {
const newTraceCall = clearTraceCall(
cloneDeep(prevTraceCall as OptionalTraceCallSchema)
Expand Down
Loading