diff --git a/src/home/chat-window/attached/attached-preview.tsx b/src/home/chat-window/attached/attached-preview.tsx index 199d958..a82ce41 100644 --- a/src/home/chat-window/attached/attached-preview.tsx +++ b/src/home/chat-window/attached/attached-preview.tsx @@ -142,7 +142,7 @@ const PromptEditorTitle: React.FC = ({promptProxy}) => { promptProxy.name = e.target.value} /> diff --git a/src/home/chat-window/chat-window.tsx b/src/home/chat-window/chat-window.tsx index fc4ffc0..58c7614 100644 --- a/src/home/chat-window/chat-window.tsx +++ b/src/home/chat-window/chat-window.tsx @@ -47,22 +47,22 @@ export const ChatWindow: React.FC = () => {
- <> -
- +
+ appState.pref.showSidebar = !appState.pref.showSidebar} > -

{chatProxy?.name}

-
layoutState.isPAPinning = true} - > -

P

-
+

{chatProxy?.name}

+
layoutState.isPAPinning = true} + > +

P

- +
+ +
@@ -75,7 +75,7 @@ export const ChatWindow: React.FC = () => { :
}
- +
} diff --git a/src/home/chat-window/prompt/prompt-editor-item.tsx b/src/home/chat-window/prompt/prompt-editor-item.tsx index 4dca452..4321f16 100644 --- a/src/home/chat-window/prompt/prompt-editor-item.tsx +++ b/src/home/chat-window/prompt/prompt-editor-item.tsx @@ -26,7 +26,7 @@ export const PromptEditorItem: React.FC = ({promptProxy, messageProxy, in e.preventDefault() const newIndex = e.shiftKey || e.altKey || e.ctrlKey || e.metaKey ? index : index + 1 // eslint-disable-next-line valtio/state-snapshot-rule - promptProxy.messages.splice(newIndex, 0, {role: "user", content: ""}) + promptProxy.messages.splice(newIndex, 0, {role: "system", content: ""}) }, [index, promptProxy.messages]); return ( diff --git a/src/home/chat-window/prompt/prompt-list.tsx b/src/home/chat-window/prompt/prompt-list.tsx index d0985d4..610b177 100644 --- a/src/home/chat-window/prompt/prompt-list.tsx +++ b/src/home/chat-window/prompt/prompt-list.tsx @@ -1,4 +1,4 @@ -import React, {useEffect, useRef, useState} from "react" +import React, {useCallback, useEffect, useRef, useState} from "react" import {Chat} from "../../../state/app-state.ts" import {useSnapshot} from "valtio/react" import {newPrompt, Prompt, promptState} from "../../../state/promt-state.ts" @@ -45,6 +45,15 @@ export const PromptList: React.FC = ({chatProxy}) => { setFilteredPrompts(ps) }, [searchText, prompts, setFilteredPrompts]) + const scrollToTop = useCallback(() => { + const ref = containerRef.current + ref?.scrollTo({ + left: 0, + top: 0, + behavior: 'instant' + }) + }, []); + // scroll to selected item useEffect(() => { if (isPAPinning && !isSearching && containerRef.current) { @@ -64,16 +73,8 @@ export const PromptList: React.FC = ({chatProxy}) => { } }) } - return () => { - const ref = containerRef.current - ref?.scrollTo({ - left: 0, - top: 0, - behavior: 'instant' - }) - - } - }, [isSearching, isPAPinning,selectedRef,containerRef]) + return scrollToTop + }, [isSearching, isPAPinning, selectedRef, containerRef, scrollToTop]) return (
@@ -130,7 +131,10 @@ export const PromptList: React.FC = ({chatProxy}) => {
{ + newPrompt() + scrollToTop() + }} >
diff --git a/src/state/promt-state.ts b/src/state/promt-state.ts index 8ecddef..8b414f0 100644 --- a/src/state/promt-state.ts +++ b/src/state/promt-state.ts @@ -62,7 +62,7 @@ export const newPrompt = (): string => { const newP: Prompt = { id: randomHash16Char(), name: "New Prompt", - messages: [{role: "user", content: ""}], + messages: [{role: "system", content: ""}], preset: false } promptState.prompts.unshift(newP)