Skip to content

Commit

Permalink
feat(chat): allow settings in Isolated view (Issue #2807) (#2809)
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaBondar authored Dec 12, 2024
1 parent f04ee77 commit beb4d0e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion apps/chat-e2e/src/tests/isolatedView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ dialTest(
await chatBar.waitForState({ state: 'hidden' });
await promptBar.waitForState({ state: 'hidden' });
await chatHeader.openConversationSettings.waitForState({
state: 'hidden',
state: 'visible',
});
},
);
Expand Down
12 changes: 4 additions & 8 deletions apps/chat/src/components/Chat/ChatHeader/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export const ChatHeader = ({
const isSelectMode = useAppSelector(
ConversationsSelectors.selectIsSelectMode,
);
const isIsolatedView = useAppSelector(SettingsSelectors.selectIsIsolatedView);
const isChatbarEnabled = useAppSelector((state) =>
SettingsSelectors.isFeatureEnabled(state, Feature.ConversationsSection),
);
Expand Down Expand Up @@ -120,10 +119,7 @@ export const ChatHeader = ({
);

const isContextMenuVisible =
!isIsolatedView &&
isChatbarEnabled &&
!isSelectMode &&
!isTopContextMenuHidden;
isChatbarEnabled && !isSelectMode && !isTopContextMenuHidden;

const selectedAddons = useMemo(
() => getSelectedAddons(conversation.selectedAddons, addonsMap, model),
Expand Down Expand Up @@ -223,13 +219,13 @@ export const ChatHeader = ({
<button
className={classNames(
isMessageStreaming &&
!isIsolatedView &&
!isChangeAgentDisallowed &&
'cursor-not-allowed',
)}
disabled={
isIsolatedView ||
isMessageStreaming ||
isChangeAgentDisallowed
isChangeAgentDisallowed ||
isExternal
}
onClick={() => onModelClick(conversation.id)}
>
Expand Down
19 changes: 10 additions & 9 deletions apps/chat/src/components/Chat/EmptyChatDescription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const EmptyChatDescriptionView = ({
ModelsSelectors.selectInstalledModelIds,
);
const models = useAppSelector(ModelsSelectors.selectModels);
const isIsolatedView = useAppSelector(SettingsSelectors.selectIsIsolatedView);
const isEmptyChatChangeAgentHidden = useAppSelector((state) =>
SettingsSelectors.isFeatureEnabled(state, Feature.HideEmptyChatChangeAgent),
);
Expand Down Expand Up @@ -159,15 +158,17 @@ const EmptyChatDescriptionView = ({
)}
</div>
</div>
{!isExternal && !isIsolatedView && !isEmptyChatChangeAgentHidden && (
{!isExternal && (
<div className="flex gap-3 divide-x divide-primary leading-4">
<button
className="text-left text-accent-primary"
data-qa="change-agent"
onClick={handleOpenChangeModel}
>
{t('Change agent')}
</button>
{!isEmptyChatChangeAgentHidden && (
<button
className="text-left text-accent-primary"
data-qa="change-agent"
onClick={handleOpenChangeModel}
>
{t('Change agent')}
</button>
)}
{!conversation.replay?.replayAsIs &&
!conversation.playback?.isPlayback &&
isEmptyChatSettingsEnabled && (
Expand Down
15 changes: 10 additions & 5 deletions apps/chat/src/utils/server/get-common-page-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,18 @@ import packageJSON from '../../../../../package.json';
import { Feature } from '@epam/ai-dial-shared';
import { URL, URLSearchParams } from 'url';

const hiddenFeaturesForIsolatedView = new Set([
const disabledFeaturesForIsolatedView = new Set([
Feature.ConversationsSection,
Feature.PromptsSection,
Feature.EmptyChatSettings,
Feature.TopChatModelSettings,
]);

const hiddenFeaturesForIsolatedView = [
Feature.HideNewConversation,
Feature.HideEmptyChatChangeAgent,
Feature.DisallowChangeAgent,
Feature.HideTopContextMenu,
];

export const getCommonPageProps: GetServerSideProps = async ({
locale,
req,
Expand Down Expand Up @@ -104,12 +109,12 @@ export const getCommonPageProps: GetServerSideProps = async ({
)
.filter((feature) =>
params?.has(ISOLATED_MODEL_QUERY_PARAM)
? !hiddenFeaturesForIsolatedView.has(feature)
? !disabledFeaturesForIsolatedView.has(feature)
: true,
)
.concat(
params?.has(ISOLATED_MODEL_QUERY_PARAM)
? Feature.HideNewConversation
? hiddenFeaturesForIsolatedView
: [],
),
publicationFilters: (
Expand Down

0 comments on commit beb4d0e

Please sign in to comment.