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

fix(chat): get rid of redundant models requests, fix duplications from approve required section, fix organization section and folders highlight (Issues #2978, #2183) #3011

Merged
merged 3 commits into from
Jan 24, 2025
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
5 changes: 0 additions & 5 deletions apps/chat-e2e/src/ui/webElements/chatHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from '../selectors';
import { BaseElement } from './baseElement';

import { API } from '@/src/testData';
import { Tags } from '@/src/ui/domData';
import { Locator, Page } from '@playwright/test';

Expand Down Expand Up @@ -61,11 +60,7 @@ export class ChatHeader extends BaseElement {
}

async openConversationSettingsPopup() {
const modelsResponsePromise = this.page.waitForResponse(API.modelsHost);
const addonsResponsePromise = this.page.waitForResponse(API.addonsHost);
await this.conversationSettings.click();
await modelsResponsePromise;
await addonsResponsePromise;
}

public async hoverOverChatModel() {
Expand Down
19 changes: 4 additions & 15 deletions apps/chat/src/components/Chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,15 @@ import {
import { EntityType } from '@/src/types/common';
import { Translation } from '@/src/types/translation';

import {
AddonsActions,
AddonsSelectors,
} from '@/src/store/addons/addons.reducers';
import { AddonsSelectors } from '@/src/store/addons/addons.reducers';
import { ChatActions } from '@/src/store/chat/chat.reducer';
import { ChatSelectors } from '@/src/store/chat/chat.selectors';
import {
ConversationsActions,
ConversationsSelectors,
} from '@/src/store/conversations/conversations.reducers';
import { useAppDispatch, useAppSelector } from '@/src/store/hooks';
import {
ModelsActions,
ModelsSelectors,
} from '@/src/store/models/models.reducers';
import { ModelsSelectors } from '@/src/store/models/models.reducers';
import { PublicationSelectors } from '@/src/store/publication/publication.reducers';
import { SettingsSelectors } from '@/src/store/settings/settings.reducers';
import { UISelectors } from '@/src/store/ui/ui.reducers';
Expand Down Expand Up @@ -199,6 +193,7 @@ export const ChatView = memo(() => {
!modelsMap[conv.assistantModelId])
);
}));

if (isNotAllowedModel) {
setNotAllowedType(EntityType.Model);
} else if (
Expand Down Expand Up @@ -595,13 +590,7 @@ export const ChatView = memo(() => {
!isExternal
}
isShowSettings={isShowChatSettings}
setShowSettings={(isShow) => {
if (isShow) {
dispatch(ModelsActions.getModels());
dispatch(AddonsActions.getAddons());
}
setIsShowChatSettings(isShow);
}}
setShowSettings={setIsShowChatSettings}
selectedConversationIds={
selectedConversationsIds
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function SettingContainer({ children }: SettingContainerProps) {

function EmptySettings() {
const { t } = useTranslation(Translation.Chat);

return (
<SettingContainer>
<FieldContainer>
Expand Down
10 changes: 9 additions & 1 deletion apps/chat/src/components/Chatbar/ChatFolders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,9 @@ export const ChatSection = ({
const [isSectionHighlighted, setIsSectionHighlighted] = useState(false);

const searchTerm = useAppSelector(ConversationsSelectors.selectSearchTerm);
const selectedPublication = useAppSelector(
PublicationSelectors.selectSelectedPublication,
);
const selectFilteredFoldersSelector = useMemo(
() =>
ConversationsSelectors.selectFilteredFolders(
Expand Down Expand Up @@ -405,14 +408,19 @@ export const ChatSection = ({
return null;
}

const isOrganizationAndPublicationSelected =
name === ORGANIZATION_SECTION_NAME && selectedPublication;

return (
<CollapsibleSection
onToggle={handleToggle}
name={name}
openByDefault={openByDefault ?? isExpanded}
isExpanded={isExpanded}
dataQa={dataQa}
isHighlighted={isSectionHighlighted}
isHighlighted={
isOrganizationAndPublicationSelected ? false : isSectionHighlighted
}
>
<div>
{rootFolders.map((folder, index, arr) => {
Expand Down
6 changes: 5 additions & 1 deletion apps/chat/src/components/Folder/Folder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,9 @@ const Folder = <T extends ConversationInfo | PromptInfo | DialFile>({
const iconSize = additionalItemData?.isSidePanelItem ? 24 : 18;
const folderIconStrokeWidth = additionalItemData?.isSidePanelItem ? 1.5 : 2;
const isSidePanelItem = additionalItemData?.isSidePanelItem;
const isInApproveRequiredSectionOrNot =
(selectedPublicationUrl && additionalItemData?.publicationUrl) ||
(!selectedPublicationUrl && !additionalItemData?.publicationUrl);

return (
<div
Expand Down Expand Up @@ -1105,7 +1108,8 @@ const Folder = <T extends ConversationInfo | PromptInfo | DialFile>({
: highlightedFolders?.includes(currentFolder.id) &&
isPartOfSelectedPublication &&
featureType &&
!canSelectFolders
!canSelectFolders &&
isInApproveRequiredSectionOrNot
? 'text-accent-primary'
: 'text-primary',
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ const _PromptSection = ({
const [isSectionHighlighted, setIsSectionHighlighted] = useState(false);

const searchTerm = useAppSelector(PromptsSelectors.selectSearchTerm);
const selectedPublication = useAppSelector(
PublicationSelectors.selectSelectedPublication,
);

const filteredPromptsSelector = useMemo(
() => PromptsSelectors.selectFilteredPrompts(filters, searchTerm),
Expand Down Expand Up @@ -386,14 +389,19 @@ const _PromptSection = ({
return null;
}

const isOrganizationAndPublicationSelected =
name === ORGANIZATION_SECTION_NAME && selectedPublication;

return (
<CollapsibleSection
onToggle={handleToggle}
name={name}
openByDefault={openByDefault ?? isExpanded}
isExpanded={isExpanded}
dataQa={dataQa}
isHighlighted={isSectionHighlighted}
isHighlighted={
isOrganizationAndPublicationSelected ? false : isSectionHighlighted
}
>
<div>
{rootFolders.map((folder, index, arr) => (
Expand Down
1 change: 1 addition & 0 deletions apps/chat/src/store/conversations/conversations.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ const duplicateConversationEpic: AppEpic = (action$, state$) =>
selectedIdToReplaceWithNewOne: conversation.id,
}),
),
of(PublicationActions.selectPublication(null)),
);
}),
);
Expand Down
6 changes: 3 additions & 3 deletions apps/chat/src/store/conversations/conversations.reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,16 +292,16 @@ export const conversationsSlice = createSlice({
selectedIdToReplaceWithNewOne?: string;
}>,
) => {
state.conversations = combineEntities(state.conversations, [
newConversation,
]);
state.selectedConversationsIds =
selectedIdToReplaceWithNewOne &&
state.selectedConversationsIds.length > 1
? state.selectedConversationsIds.map((id) =>
id === selectedIdToReplaceWithNewOne ? newConversation.id : id,
)
: [newConversation.id];
state.conversations = combineEntities(state.conversations, [
newConversation,
]);

state.areSelectedConversationsLoaded = true;
},
Expand Down
Loading