diff --git a/app/components/exporter.tsx b/app/components/exporter.tsx
index 0a885d87463..435e24953e6 100644
--- a/app/components/exporter.tsx
+++ b/app/components/exporter.tsx
@@ -27,7 +27,7 @@ import { Avatar } from "./emoji";
import dynamic from "next/dynamic";
import NextImage from "next/image";
-import { toBlob, toJpeg, toPng } from "html-to-image";
+import { toBlob, toPng } from "html-to-image";
import { DEFAULT_MASK_AVATAR } from "../store/mask";
import { api } from "../client/api";
import { prettyObject } from "../utils/format";
@@ -41,7 +41,22 @@ const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
export function ExportMessageModal(props: { onClose: () => void }) {
return (
-
+
+ 只有清除上下文之后的消息会被展示
+
+ }
+ >
@@ -149,7 +164,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,
@@ -437,13 +452,13 @@ export function ImagePreviewer(props: {
showToast(Locale.Export.Image.Toast);
const dom = previewRef.current;
if (!dom) return;
-
+
const isApp = getClientConfig()?.isApp;
-
+
try {
const blob = await toPng(dom);
if (!blob) return;
-
+
if (isMobile || (isApp && window.__TAURI__)) {
if (isApp && window.__TAURI__) {
const result = await window.__TAURI__.dialog.save({
@@ -459,7 +474,7 @@ export function ImagePreviewer(props: {
},
],
});
-
+
if (result !== null) {
const response = await fetch(blob);
const buffer = await response.arrayBuffer();
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 cadf52e643e..3d2321d0962 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) => (