Преглед на файлове

feat: #5422 快捷键清除上下文

DDMeaqua преди 1 година
родител
ревизия
4c63ee23cd
променени са 4 файла, в които са добавени 23 реда и са изтрити 0 реда
  1. 20 0
      app/components/chat.tsx
  2. 1 0
      app/locales/cn.ts
  3. 1 0
      app/locales/en.ts
  4. 1 0
      app/locales/tw.ts

+ 20 - 0
app/components/chat.tsx

@@ -874,6 +874,10 @@ export function ShortcutKeyModal(props: { onClose: () => void }) {
       title: Locale.Chat.ShortcutKey.showShortcutKey,
       keys: isMac ? ["⌘", "/"] : ["Ctrl", "/"],
     },
+    {
+      title: Locale.Chat.ShortcutKey.clearContext,
+      keys: isMac ? ["⌘", "Shift", "Delete"] : ["Ctrl", "Shift", "Delete"],
+    },
   ];
   return (
     <div className="modal-mask">
@@ -1560,6 +1564,22 @@ function _Chat() {
         event.preventDefault();
         setShowShortcutKeyModal(true);
       }
+      // 清除上下文 command + shift + delete
+      else if (
+        (event.metaKey || event.ctrlKey) &&
+        event.shiftKey &&
+        event.key.toLowerCase() === "delete"
+      ) {
+        event.preventDefault();
+        chatStore.updateCurrentSession((session) => {
+          if (session.clearContextIndex === session.messages.length) {
+            session.clearContextIndex = undefined;
+          } else {
+            session.clearContextIndex = session.messages.length;
+            session.memoryPrompt = ""; // will clear memory
+          }
+        });
+      }
     };
 
     window.addEventListener("keydown", handleKeyDown);

+ 1 - 0
app/locales/cn.ts

@@ -95,6 +95,7 @@ const cn = {
       copyLastMessage: "复制最后一个回复",
       copyLastCode: "复制最后一个代码块",
       showShortcutKey: "显示快捷方式",
+      clearContext: "清除上下文",
     },
   },
   Export: {

+ 1 - 0
app/locales/en.ts

@@ -97,6 +97,7 @@ const en: LocaleType = {
       copyLastMessage: "Copy Last Reply",
       copyLastCode: "Copy Last Code Block",
       showShortcutKey: "Show Shortcuts",
+      clearContext: "Clear Context",
     },
   },
   Export: {

+ 1 - 0
app/locales/tw.ts

@@ -90,6 +90,7 @@ const tw = {
       copyLastMessage: "複製最後一個回覆",
       copyLastCode: "複製最後一個代碼塊",
       showShortcutKey: "顯示快捷方式",
+      clearContext: "清除上下文",
     },
   },
   Export: {