Skip to content

Commit

Permalink
fix(chat): fix new conversations model selection (Issue #2684) (#2770)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Kezik authored Dec 11, 2024
1 parent 2ceae5a commit 975437b
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 215 deletions.
5 changes: 1 addition & 4 deletions apps/chat/src/components/Chatbar/Chatbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ const ChatActionsBlock = () => {
const messageIsStreaming = useAppSelector(
ConversationsSelectors.selectIsConversationsStreaming,
);
const isActiveNewConversationRequest = useAppSelector(
ConversationsSelectors.selectIsActiveNewConversationRequest,
);
const isNewConversationDisabled = useAppSelector((state) =>
SettingsSelectors.isFeatureEnabled(state, Feature.HideNewConversation),
);
Expand All @@ -57,7 +54,7 @@ const ChatActionsBlock = () => {
className="flex shrink-0 grow cursor-pointer select-none items-center gap-3 rounded px-3 py-[5px] transition-colors duration-200 hover:bg-accent-primary-alpha disabled:cursor-not-allowed hover:disabled:bg-transparent"
onClick={() => router.push('/marketplace')}
data-qa="link-to-marketplace"
disabled={messageIsStreaming || isActiveNewConversationRequest}
disabled={messageIsStreaming}
>
<Tooltip tooltip={t('DIAL Marketplace')}>
<IconApps className="text-secondary" width={24} height={24} />
Expand Down
6 changes: 1 addition & 5 deletions apps/chat/src/components/Chatbar/ChatbarSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ export const ChatbarSettings = () => {
const maximumAttachmentsAmount = useAppSelector(
ConversationsSelectors.selectMaximumAttachmentsAmount,
);
const isActiveNewConversationRequest = useAppSelector(
ConversationsSelectors.selectIsActiveNewConversationRequest,
);
const isMyItemsExist = useAppSelector(
ConversationsSelectors.selectDoesAnyMyItemExist,
);
Expand Down Expand Up @@ -184,7 +181,7 @@ export const ChatbarSettings = () => {
name: t('Compare mode'),
dataQa: 'compare',
Icon: IconScale,
disabled: isStreaming || isActiveNewConversationRequest,
disabled: isStreaming,
onClick: () => {
handleToggleCompare();
},
Expand All @@ -208,7 +205,6 @@ export const ChatbarSettings = () => {
isStreaming,
isSelectMode,
deleteTerm,
isActiveNewConversationRequest,
enabledFeatures,
dispatch,
collapsedSections,
Expand Down
9 changes: 3 additions & 6 deletions apps/chat/src/components/Header/CreateNewConversation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ export const CreateNewConversation = ({ iconSize }: Props) => {
const areConversationsLoaded = useAppSelector(
ConversationsSelectors.areConversationsUploaded,
);
const isActiveNewConversationRequest = useAppSelector(
ConversationsSelectors.selectIsActiveNewConversationRequest,
);
const messageIsStreaming = useAppSelector(
ConversationsSelectors.selectIsConversationsStreaming,
);
Expand All @@ -41,18 +38,18 @@ export const CreateNewConversation = ({ iconSize }: Props) => {
<button
className="flex h-full items-center justify-center border-r border-tertiary px-[9px] disabled:cursor-not-allowed"
onClick={() => {
if (!areConversationsLoaded || isActiveNewConversationRequest) return;
if (!areConversationsLoaded) return;
dispatch(
ConversationsActions.createNewConversations({
names: [DEFAULT_CONVERSATION_NAME],
}),
);
dispatch(ConversationsActions.resetSearch());
}}
disabled={messageIsStreaming || isActiveNewConversationRequest}
disabled={messageIsStreaming}
data-qa="new-entity"
>
{!areConversationsLoaded || isActiveNewConversationRequest ? (
{!areConversationsLoaded ? (
<Spinner
size={iconSize + 6}
className="cursor-pointer text-secondary md:mx-2"
Expand Down
5 changes: 1 addition & 4 deletions apps/chat/src/components/Header/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ export const Logo = () => {
const areConversationsLoaded = useAppSelector(
ConversationsSelectors.areConversationsUploaded,
);
const isActiveNewConversationRequest = useAppSelector(
ConversationsSelectors.selectIsActiveNewConversationRequest,
);
const customLogo = useAppSelector(UISelectors.selectCustomLogo);
const isCustomLogoFeatureEnabled = useAppSelector((state) =>
SettingsSelectors.isFeatureEnabled(state, Feature.CustomLogo),
Expand All @@ -40,7 +37,7 @@ export const Logo = () => {
`/api/${ApiUtils.encodeApiUrl(customLogo)}`;

const createNewConversation = () => {
if (!areConversationsLoaded || isActiveNewConversationRequest) return;
if (!areConversationsLoaded) return;
dispatch(
ConversationsActions.createNewConversations({
names: [DEFAULT_CONVERSATION_NAME],
Expand Down
Loading

0 comments on commit 975437b

Please sign in to comment.