Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
仙 境 ᰔᩚ authored and 仙 境 ᰔᩚ committed Mar 29, 2023
1 parent 8a05f84 commit 9ad0e9a
Show file tree
Hide file tree
Showing 3 changed files with 19,230 additions and 7,680 deletions.
70 changes: 36 additions & 34 deletions app/components/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { IconButton } from "./button";
import styles from "./home.module.scss";

import SettingsIcon from "../icons/settings.svg";
import GithubIcon from "../icons/github.svg";
import ChatGptIcon from "../icons/chatgpt.svg";
import SendWhiteIcon from "../icons/send-white.svg";
import BrainIcon from "../icons/brain.svg";
Expand Down Expand Up @@ -102,7 +101,7 @@ export function ChatList() {
state.currentSessionIndex,
state.selectSession,
state.removeSession,
]
],
);

return (
Expand Down Expand Up @@ -170,7 +169,10 @@ export function PromptHints(props: {
);
}

export function Chat(props: { showSideBar?: () => void, sideBarShowing?: boolean }) {
export function Chat(props: {
showSideBar?: () => void;
sideBarShowing?: boolean;
}) {
type RenderMessage = Message & { preview?: boolean };

const chatStore = useChatStore();
Expand All @@ -194,7 +196,7 @@ export function Chat(props: { showSideBar?: () => void, sideBarShowing?: boolean
setPromptHints(promptStore.search(text));
},
100,
{ leading: true, trailing: true }
{ leading: true, trailing: true },
);

const onPromptSelect = (prompt: Prompt) => {
Expand Down Expand Up @@ -280,7 +282,7 @@ export function Chat(props: { showSideBar?: () => void, sideBarShowing?: boolean
preview: true,
},
]
: []
: [],
)
.concat(
userInput.length > 0
Expand All @@ -292,7 +294,7 @@ export function Chat(props: { showSideBar?: () => void, sideBarShowing?: boolean
preview: true,
},
]
: []
: [],
);

// auto scroll
Expand Down Expand Up @@ -375,32 +377,33 @@ export function Chat(props: { showSideBar?: () => void, sideBarShowing?: boolean
</div>
)}
<div className={styles["chat-message-item"]}>
{(!isUser && !(message.preview || message.content.length === 0)) && (
<div className={styles["chat-message-top-actions"]}>
{message.streaming ? (
<div
className={styles["chat-message-top-action"]}
onClick={() => onUserStop(i)}
>
{Locale.Chat.Actions.Stop}
</div>
) : (
{!isUser &&
!(message.preview || message.content.length === 0) && (
<div className={styles["chat-message-top-actions"]}>
{message.streaming ? (
<div
className={styles["chat-message-top-action"]}
onClick={() => onUserStop(i)}
>
{Locale.Chat.Actions.Stop}
</div>
) : (
<div
className={styles["chat-message-top-action"]}
onClick={() => onResend(i)}
>
{Locale.Chat.Actions.Retry}
</div>
)}

<div
className={styles["chat-message-top-action"]}
onClick={() => onResend(i)}
onClick={() => copyToClipboard(message.content)}
>
{Locale.Chat.Actions.Retry}
{Locale.Chat.Actions.Copy}
</div>
)}

<div
className={styles["chat-message-top-action"]}
onClick={() => copyToClipboard(message.content)}
>
{Locale.Chat.Actions.Copy}
</div>
</div>
)}
)}
{(message.preview || message.content.length === 0) &&
!isUser ? (
<LoadingIcon />
Expand Down Expand Up @@ -555,7 +558,7 @@ export function Home() {
state.newSession,
state.currentSessionIndex,
state.removeSession,
]
],
);
const loading = !useHasHydrated();
const [showSideBar, setShowSideBar] = useState(true);
Expand Down Expand Up @@ -620,11 +623,6 @@ export function Home() {
}}
/>
</div>
<div className={styles["sidebar-action"]}>
<a href={REPO_URL} target="_blank">
<IconButton icon={<GithubIcon />} />
</a>
</div>
</div>
<div>
<IconButton
Expand All @@ -648,7 +646,11 @@ export function Home() {
}}
/>
) : (
<Chat key="chat" showSideBar={() => setShowSideBar(true)} sideBarShowing={showSideBar} />
<Chat
key="chat"
showSideBar={() => setShowSideBar(true)}
sideBarShowing={showSideBar}
/>
)}
</div>
</div>
Expand Down
Loading

0 comments on commit 9ad0e9a

Please sign in to comment.