Skip to content

Commit 4e1e1d4

Browse files
authored
Merge pull request ChatGPTNextWeb#1693 from Yidadaa/bugfix-0522
fix: ChatGPTNextWeb#1668 ChatGPTNextWeb#1681
2 parents bb0c383 + d34676c commit 4e1e1d4

File tree

6 files changed

+45
-15
lines changed

6 files changed

+45
-15
lines changed

app/client/controller.ts

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export const ChatControllerPool = {
2828

2929
remove(sessionIndex: number, messageId: number) {
3030
const key = this.key(sessionIndex, messageId);
31-
this.controllers[key]?.abort();
3231
delete this.controllers[key];
3332
},
3433

app/components/exporter.module.scss

+6-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@
131131
position: absolute;
132132
top: 0px;
133133
left: 0px;
134-
transform: scale(2);
134+
height: 50%;
135+
transform: scale(1.5);
135136
}
136137

137138
.main-title {
@@ -184,6 +185,10 @@
184185
max-width: calc(100% - 104px);
185186
box-shadow: var(--card-shadow);
186187
border: var(--border-in-light);
188+
189+
* {
190+
overflow: hidden;
191+
}
187192
}
188193

189194
&-assistant {

app/components/exporter.tsx

+32-11
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ import { copyToClipboard, downloadAs, useMobileScreen } from "../utils";
77

88
import CopyIcon from "../icons/copy.svg";
99
import LoadingIcon from "../icons/three-dots.svg";
10-
import ChatGptIcon from "../icons/chatgpt.svg";
10+
import ChatGptIcon from "../icons/chatgpt.png";
1111
import ShareIcon from "../icons/share.svg";
12+
import BotIcon from "../icons/bot.png";
1213

1314
import DownloadIcon from "../icons/download.svg";
1415
import { useMemo, useRef, useState } from "react";
1516
import { MessageSelector, useMessageSelector } from "./message-selector";
1617
import { Avatar } from "./emoji";
17-
import { MaskAvatar } from "./mask";
1818
import dynamic from "next/dynamic";
19+
import NextImage from "next/image";
1920

2021
import { toBlob, toPng } from "html-to-image";
22+
import { DEFAULT_MASK_AVATAR } from "../store/mask";
2123

2224
const Markdown = dynamic(async () => (await import("./markdown")).Markdown, {
2325
loading: () => <LoadingIcon />,
@@ -253,6 +255,22 @@ export function PreviewActions(props: {
253255
);
254256
}
255257

258+
function ExportAvatar(props: { avatar: string }) {
259+
if (props.avatar === DEFAULT_MASK_AVATAR) {
260+
return (
261+
<NextImage
262+
src={BotIcon.src}
263+
width={30}
264+
height={30}
265+
alt="bot"
266+
className="user-avatar"
267+
/>
268+
);
269+
}
270+
271+
return <Avatar avatar={props.avatar}></Avatar>;
272+
}
273+
256274
export function ImagePreviewer(props: {
257275
messages: ChatMessage[];
258276
topic: string;
@@ -319,7 +337,12 @@ export function ImagePreviewer(props: {
319337
>
320338
<div className={styles["chat-info"]}>
321339
<div className={styles["logo"] + " no-dark"}>
322-
<ChatGptIcon />
340+
<NextImage
341+
src={ChatGptIcon.src}
342+
alt="logo"
343+
width={50}
344+
height={50}
345+
/>
323346
</div>
324347

325348
<div>
@@ -328,9 +351,9 @@ export function ImagePreviewer(props: {
328351
github.com/Yidadaa/ChatGPT-Next-Web
329352
</div>
330353
<div className={styles["icons"]}>
331-
<Avatar avatar={config.avatar}></Avatar>
354+
<ExportAvatar avatar={config.avatar} />
332355
<span className={styles["icon-space"]}>&</span>
333-
<MaskAvatar mask={session.mask} />
356+
<ExportAvatar avatar={mask.avatar} />
334357
</div>
335358
</div>
336359
<div>
@@ -358,14 +381,12 @@ export function ImagePreviewer(props: {
358381
key={i}
359382
>
360383
<div className={styles["avatar"]}>
361-
{m.role === "user" ? (
362-
<Avatar avatar={config.avatar}></Avatar>
363-
) : (
364-
<MaskAvatar mask={session.mask} />
365-
)}
384+
<ExportAvatar
385+
avatar={m.role === "user" ? config.avatar : mask.avatar}
386+
/>
366387
</div>
367388

368-
<div className={`${styles["body"]} `}>
389+
<div className={styles["body"]}>
369390
<Markdown
370391
content={m.content}
371392
fontSize={config.fontSize}

app/icons/bot.png

7.14 KB
Loading

app/icons/chatgpt.png

9.37 KB
Loading

app/store/chat.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,12 @@ export const useChatStore = create<ChatStore>()(
257257
});
258258

259259
// get recent messages
260-
const systemMessages = [systemInfo];
260+
const systemMessages = [];
261+
// if user define a mask with context prompts, wont send system info
262+
if (session.mask.context.length === 0) {
263+
systemMessages.push(systemInfo);
264+
}
265+
261266
const recentMessages = get().getMessagesWithMemory();
262267
const sendMessages = systemMessages.concat(
263268
recentMessages.concat(userMessage),
@@ -345,7 +350,7 @@ export const useChatStore = create<ChatStore>()(
345350

346351
// wont send cleared context messages
347352
const clearedContextMessages = session.messages.slice(
348-
(session.clearContextIndex ?? 0),
353+
session.clearContextIndex ?? 0,
349354
);
350355
const messages = clearedContextMessages.filter((msg) => !msg.isError);
351356
const n = messages.length;

0 commit comments

Comments
 (0)