- {dialog.isEdit ? (
+ {isEditingTitle ? (
{
- setDialog({
- ...dialog,
- title: data.target.value,
- });
+ setTitle(data.target.value);
}}
onBlur={editCompleted}
onKeyDown={(event) => {
@@ -120,7 +123,7 @@ export function ChatItem(props: {
}}
/>
) : (
-
{dialog.title}
+ title
)}
@@ -132,25 +135,14 @@ export function ChatItem(props: {
-
+
setIsEditingTitle(true)}
+ >
);
-
- function editStart() {
- setDialog({
- ...dialog,
- isEdit: true,
- });
- }
- function editCompleted() {
- setDialog({
- ...dialog,
- isEdit: false,
- });
- props.onEdit && props.onEdit(dialog.title);
- }
}
export function ChatList() {
@@ -165,7 +157,7 @@ export function ChatList() {
state.currentSessionIndex,
state.selectSession,
state.removeSession,
- state.editDialogTitle,
+ state.updateSessionTitle,
]);
return (
diff --git a/app/store/app.ts b/app/store/app.ts
index 435f3c018..11d33d8c7 100644
--- a/app/store/app.ts
+++ b/app/store/app.ts
@@ -188,14 +188,13 @@ interface ChatStore {
removeSession: (index: number) => void;
selectSession: (index: number) => void;
newSession: () => void;
- editDialogTitle: (index: number, title: string) => void;
+ updateSessionTitle: (index: number, title: string) => void;
currentSession: () => ChatSession;
onNewMessage: (message: Message) => void;
onUserInput: (content: string) => Promise
;
summarizeSession: () => void;
updateStat: (message: Message) => void;
updateCurrentSession: (updater: (session: ChatSession) => void) => void;
- updateTitle: (title: string) => void;
updateMessage: (
sessionIndex: number,
messageIndex: number,
@@ -270,7 +269,7 @@ export const useChatStore = create()(
});
},
- editDialogTitle(index: number, title: string) {
+ updateSessionTitle(index: number, title: string) {
set((state) => {
const sessions = state.sessions;
sessions[index].topic = title;
@@ -409,10 +408,6 @@ export const useChatStore = create()(
set(() => ({ sessions }));
},
- updateTitle(title: string) {
- get().updateCurrentSession((session) => (session.topic = title));
- },
-
summarizeSession() {
const session = get().currentSession();