Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ export function FeedbackButtons({ message }: FeedbackButtonsProps) {
const firstInteraction = useRecoilValue(firstUserInteraction);
const { idToResume } = useChatSession();

if (!showFeedbackButtons) {
return null;
}

const handleFeedbackChange = useCallback(
(newFeedback?: number, newComment?: string) => {
if (newFeedback === undefined) {
Expand Down Expand Up @@ -97,6 +93,10 @@ export function FeedbackButtons({ message }: FeedbackButtonsProps) {

const isDisabled = message.streaming || !(firstInteraction || idToResume);

if (!showFeedbackButtons) {
return null;
}

return (
<div className="flex items-center">
<TooltipProvider>
Expand Down
28 changes: 15 additions & 13 deletions frontend/src/components/header/ChatProfiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,29 +41,31 @@ export default function ChatProfiles({ navigate }: Props) {
const [newChatProfile, setNewChatProfile] = useState<string | null>(null);
const [openDialog, setOpenDialog] = useState(false);

// Early return check to prevent unnecessary renders and resource waste
if (!config?.chatProfiles?.length || config.chatProfiles.length <= 1) {
return null;
}
const profiles = config?.chatProfiles;
const hasMultipleProfiles = !!profiles && profiles.length > 1;

// Handle case when no profile is selected
// Auto-select the first profile when none is selected
useEffect(() => {
if (!chatProfile) {
setChatProfile(config.chatProfiles[0].name);
if (hasMultipleProfiles && !chatProfile) {
setChatProfile(profiles![0].name);
}
}, [chatProfile, config.chatProfiles, setChatProfile]);
}, [hasMultipleProfiles, chatProfile, profiles, setChatProfile]);

// Handle case when selected profile becomes invalid
// Reset to first profile when the current selection becomes invalid
useEffect(() => {
if (chatProfile) {
const profileExists = config.chatProfiles.some(
if (hasMultipleProfiles && chatProfile) {
const profileExists = profiles!.some(
(profile) => profile.name === chatProfile
);
if (!profileExists) {
setChatProfile(config.chatProfiles[0].name);
setChatProfile(profiles![0].name);
}
}
}, [chatProfile, config.chatProfiles, setChatProfile]);
}, [hasMultipleProfiles, chatProfile, profiles, setChatProfile]);

if (!hasMultipleProfiles) {
return null;
}

const handleClose = () => {
setOpenDialog(false);
Expand Down