-
Notifications
You must be signed in to change notification settings - Fork 61k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #378 from Yidadaa/prompt-edit
feat: add context prompt edit
- Loading branch information
Showing
25 changed files
with
1,087 additions
and
737 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { useState, useRef, useEffect, useLayoutEffect } from "react"; | ||
import DeleteIcon from "../icons/delete.svg"; | ||
import styles from "./home.module.scss"; | ||
|
||
import { | ||
Message, | ||
SubmitKey, | ||
useChatStore, | ||
ChatSession, | ||
BOT_HELLO, | ||
} from "../store"; | ||
|
||
import Locale from "../locales"; | ||
import { isMobileScreen } from "../utils"; | ||
|
||
export function ChatItem(props: { | ||
onClick?: () => void; | ||
onDelete?: () => void; | ||
title: string; | ||
count: number; | ||
time: string; | ||
selected: boolean; | ||
}) { | ||
return ( | ||
<div | ||
className={`${styles["chat-item"]} ${ | ||
props.selected && styles["chat-item-selected"] | ||
}`} | ||
onClick={props.onClick} | ||
> | ||
<div className={styles["chat-item-title"]}>{props.title}</div> | ||
<div className={styles["chat-item-info"]}> | ||
<div className={styles["chat-item-count"]}> | ||
{Locale.ChatItem.ChatItemCount(props.count)} | ||
</div> | ||
<div className={styles["chat-item-date"]}>{props.time}</div> | ||
</div> | ||
<div className={styles["chat-item-delete"]} onClick={props.onDelete}> | ||
<DeleteIcon /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export function ChatList() { | ||
const [sessions, selectedIndex, selectSession, removeSession] = useChatStore( | ||
(state) => [ | ||
state.sessions, | ||
state.currentSessionIndex, | ||
state.selectSession, | ||
state.removeSession, | ||
], | ||
); | ||
|
||
return ( | ||
<div className={styles["chat-list"]}> | ||
{sessions.map((item, i) => ( | ||
<ChatItem | ||
title={item.topic} | ||
time={item.lastUpdate} | ||
count={item.messages.length} | ||
key={i} | ||
selected={i === selectedIndex} | ||
onClick={() => selectSession(i)} | ||
onDelete={() => | ||
(!isMobileScreen() || confirm(Locale.Home.DeleteChat)) && | ||
removeSession(i) | ||
} | ||
/> | ||
))} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
.prompt-toast { | ||
position: absolute; | ||
bottom: -50px; | ||
z-index: 999; | ||
display: flex; | ||
justify-content: center; | ||
width: calc(100% - 40px); | ||
|
||
.prompt-toast-inner { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
font-size: 12px; | ||
background-color: var(--white); | ||
color: var(--black); | ||
|
||
border: var(--border-in-light); | ||
box-shadow: var(--card-shadow); | ||
padding: 10px 20px; | ||
border-radius: 100px; | ||
|
||
.prompt-toast-content { | ||
margin-left: 10px; | ||
} | ||
} | ||
} | ||
|
||
.context-prompt { | ||
.context-prompt-row { | ||
display: flex; | ||
justify-content: center; | ||
width: 100%; | ||
margin-bottom: 10px; | ||
|
||
.context-role { | ||
margin-right: 10px; | ||
} | ||
|
||
.context-content { | ||
flex: 1; | ||
max-width: 100%; | ||
text-align: left; | ||
} | ||
|
||
.context-delete-button { | ||
margin-left: 10px; | ||
} | ||
} | ||
|
||
.context-prompt-button { | ||
flex: 1; | ||
} | ||
} | ||
|
||
.memory-prompt { | ||
margin-top: 20px; | ||
|
||
.memory-prompt-title { | ||
font-size: 12px; | ||
font-weight: bold; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.memory-prompt-content { | ||
background-color: var(--gray); | ||
border-radius: 6px; | ||
padding: 10px; | ||
font-size: 12px; | ||
user-select: text; | ||
} | ||
} |
Oops, something went wrong.
e8dd391
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
chat-gpt-next-web – ./
chat-gpt-next-web-git-main-yidadaa.vercel.app
chat-gpt-next-web-yidadaa.vercel.app
chat-gpt-next-web.vercel.app
chat.simplenaive.cn