From 7115eb06986777544269bbede4aa5a200ee94d1d Mon Sep 17 00:00:00 2001 From: Yu <951379969@qq.com> Date: Mon, 15 May 2023 08:39:55 +0800 Subject: [PATCH 1/7] yu modify some app name --- .gitignore | 2 ++ app/components/home.module.scss | 10 +++++++--- app/components/sidebar.tsx | 11 ++++++----- app/layout.tsx | 6 +++--- public/site.webmanifest | 2 +- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 37f6b9029ba..6e8d611c422 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. +/.history + # dependencies /node_modules /.pnp diff --git a/app/components/home.module.scss b/app/components/home.module.scss index 1ce95af8ff4..a3d4f80b52d 100644 --- a/app/components/home.module.scss +++ b/app/components/home.module.scss @@ -134,9 +134,13 @@ } .sidebar-title { - font-size: 20px; - font-weight: bold; - animation: slide-in ease 0.3s; + color: transparent; + font-weight: 800; + background-image: linear-gradient(90deg,#1772e1,#0cf1a5); + -webkit-background-clip: text; + background-clip: text; + font-size: 1.5rem; + margin-right: 0.5rem; } .sidebar-sub-title { diff --git a/app/components/sidebar.tsx b/app/components/sidebar.tsx index 63614ffae54..eb8eb1b05ce 100644 --- a/app/components/sidebar.tsx +++ b/app/components/sidebar.tsx @@ -119,12 +119,13 @@ export function SideBar(props: { className?: string }) { }`} >
-
ChatGPT Next
+
Timo Chat
- Build your own AI assistant. + Chat with your AI assistant.
- + {/* */} +
@@ -173,11 +174,11 @@ export function SideBar(props: { className?: string }) { } shadow /> -
+ {/*
} shadow /> -
+
*/}
Date: Mon, 15 May 2023 09:34:42 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20settings.tsx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/settings.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/components/settings.tsx b/app/components/settings.tsx index eb83d8905f7..fa72fe633ab 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -229,10 +229,10 @@ export function Settings() { "[Update] local version ", new Date(+updateStore.version).toLocaleString(), ); - console.log( - "[Update] remote version ", - new Date(+updateStore.remoteVersion).toLocaleString(), - ); + // console.log( + // "[Update] remote version ", + // new Date(+updateStore.remoteVersion).toLocaleString(), + // ); } const usage = { @@ -288,7 +288,7 @@ export function Settings() { {Locale.Settings.Title}
- {Locale.Settings.SubTitle} + {Locale.Settings.Update.Version(currentVersion ?? "unknown")}
@@ -350,7 +350,7 @@ export function Settings() { - checkUpdate(true)} /> )} - + */} e.currentTarget.select()} + >, + ], + actions: [ + } + text={Locale.Chat.Actions.Copy} + key="copy" + onClick={() => copyToClipboard(res)} + />, + ], + }); setTimeout(() => { window.open(res, "_blank"); }, 800); diff --git a/app/components/home.module.scss b/app/components/home.module.scss index 2076a4f4336..92971b5f1c2 100644 --- a/app/components/home.module.scss +++ b/app/components/home.module.scss @@ -61,24 +61,36 @@ } } } + + &:hover, + &:active { + .sidebar-drag { + background-color: rgba($color: #000000, $alpha: 0.01); + + svg { + opacity: 0.2; + } + } + } } .sidebar-drag { - $width: 10px; + $width: 14px; position: absolute; top: 0; right: 0; height: 100%; width: $width; - background-color: var(--black); + background-color: rgba($color: #000000, $alpha: 0); cursor: ew-resize; - opacity: 0; transition: all ease 0.3s; + display: flex; + align-items: center; - &:hover, - &:active { - opacity: 0.2; + svg { + opacity: 0; + margin-left: -2px; } } diff --git a/app/components/mask.tsx b/app/components/mask.tsx index 091f3cdf40a..b907221349b 100644 --- a/app/components/mask.tsx +++ b/app/components/mask.tsx @@ -11,6 +11,7 @@ import CloseIcon from "../icons/close.svg"; import DeleteIcon from "../icons/delete.svg"; import EyeIcon from "../icons/eye.svg"; import CopyIcon from "../icons/copy.svg"; +import DragIcon from "../icons/drag.svg"; import { DEFAULT_MASK_AVATAR, Mask, useMaskStore } from "../store/mask"; import { @@ -42,6 +43,20 @@ import { ModelConfigList } from "./model-config"; import { FileName, Path } from "../constant"; import { BUILTIN_MASK_STORE } from "../masks"; import { nanoid } from "nanoid"; +import { + DragDropContext, + Droppable, + Draggable, + OnDragEndResponder, +} from "@hello-pangea/dnd"; + +// drag and drop helper function +function reorder(list: T[], startIndex: number, endIndex: number): T[] { + const result = [...list]; + const [removed] = result.splice(startIndex, 1); + result.splice(endIndex, 0, removed); + return result; +} export function MaskAvatar(props: { mask: Mask }) { return props.mask.avatar !== DEFAULT_MASK_AVATAR ? ( @@ -192,6 +207,7 @@ export function MaskConfig(props: { } function ContextPromptItem(props: { + index: number; prompt: ChatMessage; update: (prompt: ChatMessage) => void; remove: () => void; @@ -199,53 +215,67 @@ function ContextPromptItem(props: { const [focusingInput, setFocusingInput] = useState(false); return ( -
- {!focusingInput && ( - - )} - setFocusingInput(true)} - onBlur={() => { - setFocusingInput(false); - // If the selection is not removed when the user loses focus, some - // extensions like "Translate" will always display a floating bar - window?.getSelection()?.removeAllRanges(); - }} - onInput={(e) => - props.update({ - ...props.prompt, - content: e.currentTarget.value as any, - }) - } - /> - {!focusingInput && ( - } - className={chatStyle["context-delete-button"]} - onClick={() => props.remove()} - bordered - /> + {!focusingInput && ( + <> +
+ +
+ + + )} + setFocusingInput(true)} + onBlur={() => { + setFocusingInput(false); + // If the selection is not removed when the user loses focus, some + // extensions like "Translate" will always display a floating bar + window?.getSelection()?.removeAllRanges(); + }} + onInput={(e) => + props.update({ + ...props.prompt, + content: e.currentTarget.value as any, + }) + } + /> + {!focusingInput && ( + } + className={chatStyle["context-delete-button"]} + onClick={() => props.remove()} + bordered + /> + )} +
)} -
+ ); } @@ -267,17 +297,41 @@ export function ContextPrompts(props: { props.updateContext((context) => (context[i] = prompt)); }; + const onDragEnd: OnDragEndResponder = (result) => { + if (!result.destination) { + return; + } + const newContext = reorder( + context, + result.source.index, + result.destination.index, + ); + props.updateContext((context) => { + context.splice(0, context.length, ...newContext); + }); + }; + return ( <>
- {context.map((c, i) => ( - updateContextPrompt(i, prompt)} - remove={() => removeContextPrompt(i)} - /> - ))} + + + {(provided) => ( +
+ {context.map((c, i) => ( + updateContextPrompt(i, prompt)} + remove={() => removeContextPrompt(i)} + /> + ))} + {provided.placeholder} +
+ )} +
+
onDragMouseDown(e as any)} - >
+ > + +
); } diff --git a/app/icons/drag.svg b/app/icons/drag.svg new file mode 100644 index 00000000000..a39157c7eb6 --- /dev/null +++ b/app/icons/drag.svg @@ -0,0 +1 @@ + diff --git a/app/layout.tsx b/app/layout.tsx index 0b49e250690..e0bd0554ae4 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -3,8 +3,9 @@ import "./styles/globals.scss"; import "./styles/markdown.scss"; import "./styles/highlight.scss"; import { getClientConfig } from "./config/client"; +import { type Metadata } from 'next'; -export const metadata = { +export const metadata: Metadata = { title: "Timo Chat", description: "Chat with your AI assistant.", viewport: { diff --git a/app/store/chat.ts b/app/store/chat.ts index 9fc7ebfdb9d..f06c59481da 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -589,7 +589,7 @@ export const useChatStore = create()( }), { name: StoreKey.Chat, - version: 3, + version: 3.1, migrate(persistedState, version) { const state = persistedState as any; const newState = JSON.parse(JSON.stringify(state)) as ChatStore; @@ -617,6 +617,23 @@ export const useChatStore = create()( }); } + // Enable `enableInjectSystemPrompts` attribute for old sessions. + // Resolve issue of old sessions not automatically enabling. + if (version < 3.1) { + newState.sessions.forEach((s) => { + if ( + // Exclude those already set by user + !s.mask.modelConfig.hasOwnProperty("enableInjectSystemPrompts") + ) { + // Because users may have changed this configuration, + // the user's current configuration is used instead of the default + const config = useAppConfig.getState(); + s.mask.modelConfig.enableInjectSystemPrompts = + config.modelConfig.enableInjectSystemPrompts; + } + }); + } + return newState; }, }, diff --git a/next.config.mjs b/next.config.mjs index 01d34271799..c8f17de8c01 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -30,6 +30,9 @@ const nextConfig = { images: { unoptimized: mode === "export", }, + experimental: { + forceSwcTransforms: true, + }, }; if (mode !== "export") { From f89b8032c82047f27bc0eb84eedc4e5fe9647b5a Mon Sep 17 00:00:00 2001 From: Yu <951379969@qq.com> Date: Tue, 31 Oct 2023 17:33:45 +0800 Subject: [PATCH 7/7] modified: app/components/sidebar.tsx --- app/components/sidebar.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/components/sidebar.tsx b/app/components/sidebar.tsx index aec977f22ee..5b90965395d 100644 --- a/app/components/sidebar.tsx +++ b/app/components/sidebar.tsx @@ -205,12 +205,7 @@ export function SideBar(props: { className?: string }) { } shadow /> - -
- - } shadow /> - -
*/} +