Skip to content

Commit 385f781

Browse files
committed
sync 00d6cb2
1 parent aba2581 commit 385f781

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

app/components/chat-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import { ChatSession, useChatStore } from "../store";
1313

1414
import Locale from "../locales";
15-
import { Link, useLocation, useNavigate } from "react-router-dom";
15+
import { useLocation, useNavigate } from "react-router-dom";
1616
import { Path } from "../constant";
1717
import { MaskAvatar } from "./mask";
1818
import { Mask } from "../store/mask";

app/components/chat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ function _Chat() {
16071607
title={Locale.Chat.Actions.RefreshTitle}
16081608
onClick={() => {
16091609
showToast(Locale.Chat.Actions.RefreshToast);
1610-
chatStore.summarizeSession(true);
1610+
chatStore.summarizeSession(true, session);
16111611
}}
16121612
/>
16131613
</div>

app/store/chat.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,13 @@ export const useChatStore = createPersistStore(
352352
return session;
353353
},
354354

355-
onNewMessage(message: ChatMessage) {
356-
get().updateCurrentSession((session) => {
355+
onNewMessage(message: ChatMessage, targetSession: ChatSession) {
356+
get().updateTargetSession(targetSession, (session) => {
357357
session.messages = session.messages.concat();
358358
session.lastUpdate = Date.now();
359359
});
360360
get().updateStat(message);
361-
get().summarizeSession();
361+
get().summarizeSession(false, targetSession);
362362
},
363363

364364
async onUserInput(content: string, attachImages?: string[]) {
@@ -428,7 +428,7 @@ export const useChatStore = createPersistStore(
428428
botMessage.streaming = false;
429429
if (message) {
430430
botMessage.content = message;
431-
get().onNewMessage(botMessage);
431+
get().onNewMessage(botMessage, session);
432432
}
433433
ChatControllerPool.remove(session.id, botMessage.id);
434434
},
@@ -598,9 +598,12 @@ export const useChatStore = createPersistStore(
598598
});
599599
},
600600

601-
summarizeSession(refreshTitle: boolean = false) {
601+
summarizeSession(
602+
refreshTitle: boolean = false,
603+
targetSession: ChatSession,
604+
) {
602605
const config = useAppConfig.getState();
603-
const session = get().currentSession();
606+
const session = targetSession;
604607
const modelConfig = session.mask.modelConfig;
605608
// skip summarize when using dalle3?
606609
if (isDalle3(modelConfig.model)) {
@@ -651,7 +654,8 @@ export const useChatStore = createPersistStore(
651654
},
652655
onFinish(message, responseRes) {
653656
if (responseRes?.status === 200) {
654-
get().updateCurrentSession(
657+
get().updateTargetSession(
658+
session,
655659
(session) =>
656660
(session.topic =
657661
message.length > 0 ? trimTopic(message) : DEFAULT_TOPIC),
@@ -719,7 +723,7 @@ export const useChatStore = createPersistStore(
719723
onFinish(message, responseRes) {
720724
if (responseRes?.status === 200) {
721725
console.log("[Memory] ", message);
722-
get().updateCurrentSession((session) => {
726+
get().updateTargetSession(session, (session) => {
723727
session.lastSummarizeIndex = lastSummarizeIndex;
724728
session.memoryPrompt = message; // Update the memory prompt for stored it in local storage
725729
});
@@ -745,6 +749,16 @@ export const useChatStore = createPersistStore(
745749
updater(sessions[index]);
746750
set(() => ({ sessions }));
747751
},
752+
updateTargetSession(
753+
targetSession: ChatSession,
754+
updater: (session: ChatSession) => void,
755+
) {
756+
const sessions = get().sessions;
757+
const index = sessions.findIndex((s) => s.id === targetSession.id);
758+
if (index < 0) return;
759+
updater(sessions[index]);
760+
set(() => ({ sessions }));
761+
},
748762

749763
clearChatData() {
750764
set(() => ({

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
},
1010
"package": {
1111
"productName": "NextChat",
12-
"version": "2.15.6"
12+
"version": "2.15.7"
1313
},
1414
"tauri": {
1515
"allowlist": {

0 commit comments

Comments
 (0)