diff --git a/app/components/exporter.tsx b/app/components/exporter.tsx
index 381ff71d643..0c92272515b 100644
--- a/app/components/exporter.tsx
+++ b/app/components/exporter.tsx
@@ -46,7 +46,22 @@ const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
export function ExportMessageModal(props: { onClose: () => void }) {
return (
-
+
+ 只有清除上下文之后的消息会被展示
+
+ }
+ >
@@ -154,7 +169,7 @@ export function MessageExporter() {
if (exportConfig.includeContext) {
ret.push(...session.mask.context);
}
- ret.push(...session.messages.filter((m, i) => selection.has(m.id)));
+ ret.push(...session.messages.filter((m) => selection.has(m.id)));
return ret;
}, [
exportConfig.includeContext,
diff --git a/app/components/message-selector.module.scss b/app/components/message-selector.module.scss
index b4ba1a1412a..c8defb6b027 100644
--- a/app/components/message-selector.module.scss
+++ b/app/components/message-selector.module.scss
@@ -58,8 +58,8 @@
}
.body {
- flex-grow: 1;
- max-width: calc(100% - 40px);
+ flex: 1;
+ max-width: calc(100% - 80px);
.date {
font-size: 12px;
@@ -71,6 +71,12 @@
font-size: 12px;
}
}
+
+ .checkbox {
+ display: flex;
+ justify-content: flex-end;
+ flex: 1;
+ }
}
}
}
diff --git a/app/components/message-selector.tsx b/app/components/message-selector.tsx
index 5b25dcd5696..d4ebe0d7bfe 100644
--- a/app/components/message-selector.tsx
+++ b/app/components/message-selector.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useState } from "react";
import { ChatMessage, useAppConfig, useChatStore } from "../store";
import { Updater } from "../typing";
import { IconButton } from "./button";
@@ -73,11 +73,23 @@ export function MessageSelector(props: {
const chatStore = useChatStore();
const session = chatStore.currentSession();
const isValid = (m: ChatMessage) => m.content && !m.isError && !m.streaming;
- const messages = session.messages.filter(
- (m, i) =>
- m.id && // message must have id
- isValid(m) &&
- (i >= session.messages.length - 1 || isValid(session.messages[i + 1])),
+ const allMessages = useMemo(() => {
+ let startIndex = Math.max(0, session.clearContextIndex ?? 0);
+ if (startIndex === session.messages.length - 1) {
+ startIndex = 0;
+ }
+ return session.messages.slice(startIndex);
+ }, [session.messages, session.clearContextIndex]);
+
+ const messages = useMemo(
+ () =>
+ allMessages.filter(
+ (m, i) =>
+ m.id && // message must have id
+ isValid(m) &&
+ (i >= allMessages.length - 1 || isValid(allMessages[i + 1])),
+ ),
+ [allMessages],
);
const messageCount = messages.length;
const config = useAppConfig();
@@ -176,6 +188,8 @@ export function MessageSelector(props: {
{messages.map((m, i) => {
if (!isInSearchResult(m.id!)) return null;
+ const id = m.id ?? i;
+ const isSelected = props.selection.has(id);
return (
{
props.updateSelection((selection) => {
- const id = m.id ?? i;
selection.has(id) ? selection.delete(id) : selection.add(id);
});
onClickIndex(i);
@@ -206,6 +219,10 @@ export function MessageSelector(props: {
{m.content}
+
+
+
+
);
})}
diff --git a/app/components/ui-lib.tsx b/app/components/ui-lib.tsx
index 0c927728a4e..f7e326fd318 100644
--- a/app/components/ui-lib.tsx
+++ b/app/components/ui-lib.tsx
@@ -97,8 +97,9 @@ export function Loading() {
interface ModalProps {
title: string;
children?: any;
- actions?: JSX.Element[];
+ actions?: React.ReactNode[];
defaultMax?: boolean;
+ footer?: React.ReactNode;
onClose?: () => void;
}
export function Modal(props: ModalProps) {
@@ -147,6 +148,7 @@ export function Modal(props: ModalProps) {
{props.children}
+ {props.footer}
{props.actions?.map((action, i) => (