diff --git a/app/components/chat.tsx b/app/components/chat.tsx
index fc7e04aef79..17f8d3a3496 100644
--- a/app/components/chat.tsx
+++ b/app/components/chat.tsx
@@ -43,6 +43,7 @@ import QualityIcon from "../icons/hd.svg";
import StyleIcon from "../icons/palette.svg";
import PluginIcon from "../icons/plugin.svg";
import ShortcutkeyIcon from "../icons/shortcutkey.svg";
+import ReloadIcon from "../icons/reload.svg";
import {
ChatMessage,
@@ -1541,6 +1542,17 @@ function _Chat() {
+
+ }
+ bordered
+ title={Locale.Chat.Actions.RefreshTitle}
+ onClick={() => {
+ showToast(Locale.Chat.Actions.RefreshToast);
+ chatStore.summarizeSession(true);
+ }}
+ />
+
{!isMobileScreen && (
= SUMMARIZE_MIN_LEN
+ (config.enableAutoGenerateTitle &&
+ session.topic === DEFAULT_TOPIC &&
+ countMessages(messages) >= SUMMARIZE_MIN_LEN) ||
+ refreshTitle
) {
- const topicMessages = messages.concat(
- createMessage({
- role: "user",
- content: Locale.Store.Prompt.Topic,
- }),
+ const startIndex = Math.max(
+ 0,
+ messages.length - modelConfig.historyMessageCount,
);
+ const topicMessages = messages
+ .slice(
+ startIndex < messages.length ? startIndex : messages.length - 1,
+ messages.length,
+ )
+ .concat(
+ createMessage({
+ role: "user",
+ content: Locale.Store.Prompt.Topic,
+ }),
+ );
api.llm.chat({
messages: topicMessages,
config: {