From ac1c7018d87d41707de5ff39296f527f27f5d0c2 Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Thu, 9 Nov 2023 12:33:08 +0700 Subject: [PATCH] Update convo state when user change model --- uikit/src/button/styles.scss | 4 +- uikit/src/command/styles.scss | 2 +- uikit/src/main.scss | 7 --- .../CommandListDownloadedModel/index.tsx | 2 +- web/hooks/useGetConfiguredModels.ts | 1 + web/screens/Chat/HistoryList/index.tsx | 4 +- web/screens/Chat/index.tsx | 53 +++++++++++++++---- .../ExploreModels/ExploreModelList/index.tsx | 2 +- web/screens/MyModels/index.tsx | 3 +- 9 files changed, 54 insertions(+), 24 deletions(-) diff --git a/uikit/src/button/styles.scss b/uikit/src/button/styles.scss index 08b59537f3..17df7381f3 100644 --- a/uikit/src/button/styles.scss +++ b/uikit/src/button/styles.scss @@ -12,7 +12,7 @@ } &-outline { - @apply border-input hover:bg-accent hover:text-accent-foreground border bg-transparent; + @apply border-input hover:bg-primary hover:text-primary-foreground border bg-transparent; } &-secondary { @@ -20,7 +20,7 @@ } &-ghost { - @apply hover:bg-accent hover:text-accent-foreground; + @apply hover:bg-primary hover:text-primary-foreground; } &-sm { diff --git a/uikit/src/command/styles.scss b/uikit/src/command/styles.scss index cbcbbf4d6a..80171ef503 100644 --- a/uikit/src/command/styles.scss +++ b/uikit/src/command/styles.scss @@ -25,7 +25,7 @@ } &-list-item { - @apply text-foreground aria-selected:bg-accent relative flex cursor-pointer select-none items-center rounded-md px-2 py-2 text-sm outline-none; + @apply text-foreground aria-selected:bg-primary relative flex cursor-pointer select-none items-center rounded-md px-2 py-2 text-sm outline-none; } &-empty { diff --git a/uikit/src/main.scss b/uikit/src/main.scss index 9fdca43e19..a176606890 100644 --- a/uikit/src/main.scss +++ b/uikit/src/main.scss @@ -27,7 +27,6 @@ } } - :root { --background: 0 0% 100%; --foreground: 20 14.3% 4.1%; @@ -35,9 +34,6 @@ --muted: 60 4.8% 95.9%; --muted-foreground: 240 3.8% 46.1%; - --accent: 60 4.8% 95.9%; - --accent-foreground: 24 9.8% 10%; - --danger: 346.8 77.2% 49.8%; --danger-foreground: 355.7 100% 97.3%; @@ -77,9 +73,6 @@ --muted: 12 6.5% 15.1%; --muted-foreground: 24 5.4% 63.9%; - --accent: 12 6.5% 15.1%; - --accent-foreground: 60 9.1% 97.8%; - --danger: 346.8 77.2% 49.8%; --danger-foreground: 355.7 100% 97.3%; diff --git a/web/containers/Layout/TopBar/CommandListDownloadedModel/index.tsx b/web/containers/Layout/TopBar/CommandListDownloadedModel/index.tsx index fb135c6f11..108aa8e827 100644 --- a/web/containers/Layout/TopBar/CommandListDownloadedModel/index.tsx +++ b/web/containers/Layout/TopBar/CommandListDownloadedModel/index.tsx @@ -73,7 +73,7 @@ export default function CommandListDownloadedModel() {
{model.name} {activeModel && activeModel._id === model._id && ( - Active + Active )}
diff --git a/web/hooks/useGetConfiguredModels.ts b/web/hooks/useGetConfiguredModels.ts index 84ed5cc637..308d6a2e95 100644 --- a/web/hooks/useGetConfiguredModels.ts +++ b/web/hooks/useGetConfiguredModels.ts @@ -40,6 +40,7 @@ export function useGetConfiguredModels() { // TODO allow user for filter useEffect(() => { fetchModels() + // eslint-disable-next-line react-hooks/exhaustive-deps }, []) return { loading, models } diff --git a/web/screens/Chat/HistoryList/index.tsx b/web/screens/Chat/HistoryList/index.tsx index f5e5f2e7a1..c3c69fa470 100644 --- a/web/screens/Chat/HistoryList/index.tsx +++ b/web/screens/Chat/HistoryList/index.tsx @@ -1,7 +1,7 @@ import { useEffect } from 'react' import { Conversation, Model } from '@janhq/core/lib/types' -import { Button } from '@janhq/uikit' +import { Badge, Button } from '@janhq/uikit' import { motion as m } from 'framer-motion' import { useAtomValue, useSetAtom } from 'jotai' @@ -64,7 +64,7 @@ export default function HistoryList() {
+
+ )} )} @@ -140,7 +171,11 @@ const ChatScreen = () => { className="h-10" onKeyDown={(e) => handleKeyDown(e)} placeholder="Type your message ..." - disabled={!activeModel || stateModel.loading} + disabled={ + !activeModel || + stateModel.loading || + activeModel._id !== currentConvo?.modelId + } value={currentPrompt} onChange={(e) => handleMessageChange(e.target.value)} /> diff --git a/web/screens/ExploreModels/ExploreModelList/index.tsx b/web/screens/ExploreModels/ExploreModelList/index.tsx index f17f62171b..b91c34de5a 100644 --- a/web/screens/ExploreModels/ExploreModelList/index.tsx +++ b/web/screens/ExploreModels/ExploreModelList/index.tsx @@ -10,7 +10,7 @@ export default function ExploreModelList(props: Props) { const { models } = props return (
- {models?.map((item) => )} + {models?.map((item, i) => )}
) } diff --git a/web/screens/MyModels/index.tsx b/web/screens/MyModels/index.tsx index 3f667b6758..cb35904c42 100644 --- a/web/screens/MyModels/index.tsx +++ b/web/screens/MyModels/index.tsx @@ -113,7 +113,8 @@ const MyModelsScreen = () => {