From 62a38577ae31aa3d755a0d024326c2ecb95fea92 Mon Sep 17 00:00:00 2001 From: GotoFox Date: Thu, 13 Apr 2023 13:56:49 +0800 Subject: [PATCH] feat:add Stop Responding --- app/components/chat.tsx | 23 +++++++++++++++++++++++ app/icons/stop.svg | 1 + app/locales/cn.ts | 1 + app/locales/en.ts | 1 + app/locales/es.ts | 1 + app/locales/it.ts | 1 + app/locales/jp.ts | 1 + app/locales/tr.ts | 1 + app/locales/tw.ts | 1 + 9 files changed, 31 insertions(+) create mode 100644 app/icons/stop.svg diff --git a/app/components/chat.tsx b/app/components/chat.tsx index b9ae13926..aa46063b1 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -3,6 +3,7 @@ import { memo, useState, useRef, useEffect, useLayoutEffect } from "react"; import SendWhiteIcon from "../icons/send-white.svg"; import BrainIcon from "../icons/brain.svg"; +import StopIcon from "../icons/stop.svg"; import ExportIcon from "../icons/share.svg"; import ReturnIcon from "../icons/return.svg"; import CopyIcon from "../icons/copy.svg"; @@ -767,6 +768,28 @@ export function Chat(props: { })} +
+ {session.messages.length > 0 && + session.messages[session.messages.length - 1].streaming && ( +
{ + const lastMessage = + session.messages[session.messages.length - 1]; + if (lastMessage?.id) { + onUserStop(lastMessage.id); + } + }} + > + + + {Locale.Chat.Actions.stopResponding} + +
+ )} +
+
diff --git a/app/icons/stop.svg b/app/icons/stop.svg new file mode 100644 index 000000000..e4870ddb3 --- /dev/null +++ b/app/icons/stop.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 9973a3c68..7738e944b 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -17,6 +17,7 @@ const cn = { Copy: "复制", Stop: "停止", Retry: "重试", + stopResponding: "停止响应", }, Rename: "重命名对话", Typing: "正在输入…", diff --git a/app/locales/en.ts b/app/locales/en.ts index bd417aa84..87d3f1280 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -19,6 +19,7 @@ const en: LocaleType = { Copy: "Copy", Stop: "Stop", Retry: "Retry", + stopResponding: "Stop Responding", }, Rename: "Rename Chat", Typing: "Typing…", diff --git a/app/locales/es.ts b/app/locales/es.ts index 88bcd2012..393200cda 100644 --- a/app/locales/es.ts +++ b/app/locales/es.ts @@ -19,6 +19,7 @@ const es: LocaleType = { Copy: "Copiar", Stop: "Detener", Retry: "Reintentar", + stopResponding: "Deja de responder", }, Rename: "Renombrar chat", Typing: "Escribiendo...", diff --git a/app/locales/it.ts b/app/locales/it.ts index 3cd768fed..0d61ff9ab 100644 --- a/app/locales/it.ts +++ b/app/locales/it.ts @@ -19,6 +19,7 @@ const it: LocaleType = { Copy: "Copia", Stop: "Stop", Retry: "Riprova", + stopResponding: "cessa di rispondere", }, Rename: "Rinomina Chat", Typing: "Typing…", diff --git a/app/locales/jp.ts b/app/locales/jp.ts index 50ac21609..4390ac029 100644 --- a/app/locales/jp.ts +++ b/app/locales/jp.ts @@ -18,6 +18,7 @@ const jp = { Copy: "コピー", Stop: "停止", Retry: "リトライ", + stopResponding: "応答を停止する", }, Rename: "チャットの名前を変更", Typing: "入力中…", diff --git a/app/locales/tr.ts b/app/locales/tr.ts index 708d2d7d5..b004d69ae 100644 --- a/app/locales/tr.ts +++ b/app/locales/tr.ts @@ -19,6 +19,7 @@ const tr: LocaleType = { Copy: "Kopyala", Stop: "Durdur", Retry: "Tekrar Dene", + stopResponding: "yanıt vermemeyi durdur", }, Rename: "Sohbeti Yeniden Adlandır", Typing: "Yazıyor…", diff --git a/app/locales/tw.ts b/app/locales/tw.ts index 77975b896..219138b5a 100644 --- a/app/locales/tw.ts +++ b/app/locales/tw.ts @@ -18,6 +18,7 @@ const tw: LocaleType = { Copy: "複製", Stop: "停止", Retry: "重試", + stopResponding: "停止响应", }, Rename: "重命名對話", Typing: "正在輸入…",