Răsfoiți Sursa

simple code

Shun Miyazawa 1 an în urmă
părinte
comite
fb0754b587

+ 3 - 1
apps/app/public/static/locales/en_US/translation.json

@@ -154,7 +154,7 @@
   "In-App Notification": "Notifications",
   "AI Assistant": "AI Assistant",
   "Knowledge Assistant": "Knowledge Assistant (Beta)",
-  "Editor Assistant": "Editor Assistant (Beta)",
+  "Editor Assistant": "Editor Assistant ()",
   "original_path": "Original path",
   "new_path": "New path",
   "duplicated_path": "Duplicated path",
@@ -499,6 +499,8 @@
     "instruction_label": "Assistant instructions",
     "reference_pages_label": "Reference pages",
     "placeholder": "Ask me anything.",
+    "knowledge_assistant_placeholder": "Ask me anything.",
+    "editor_assistant_placeholder": "Can I help you with anything?",
     "summary_mode_label": "Summary mode",
     "summary_mode_help": "Concise answer within 2-3 sentences",
     "caution_against_hallucination": "Please verify the information and check the sources.",

+ 2 - 1
apps/app/public/static/locales/fr_FR/translation.json

@@ -493,7 +493,8 @@
   "sidebar_ai_assistant": {
     "instruction_label": "Instructions pour l'assistant",
     "reference_pages_label": "Pages de référence",
-    "placeholder": "Demandez-moi n'importe quoi.",
+    "knowledge_assistant_placeholder": "Demandez-moi n'importe quoi.",
+    "editor_assistant_placeholder": "Puis-je vous aider ?",
     "summary_mode_label": "Mode résumé",
     "summary_mode_help": "Réponse concise en 2-3 phrases",
     "caution_against_hallucination": "Veuillez vérifier les informations et consulter les sources.",

+ 2 - 1
apps/app/public/static/locales/ja_JP/translation.json

@@ -531,7 +531,8 @@
   "sidebar_ai_assistant": {
     "instruction_label": "アシスタントへの指示",
     "reference_pages_label": "参照するページ",
-    "placeholder": "ききたいことを入力してください",
+    "knowledge_assistant_placeholder": "ききたいことを入力してください",
+    "editor_assistant_placeholder": "お手伝いできることはありますか?",
     "summary_mode_label": "要約モード",
     "summary_mode_help": "2~3文以内の簡潔な回答",
     "caution_against_hallucination": "情報が正しいか出典を確認しましょう",

+ 2 - 1
apps/app/public/static/locales/zh_CN/translation.json

@@ -488,7 +488,8 @@
   "sidebar_ai_assistant": {
     "instruction_label": "助手指令",
     "reference_pages_label": "参考页面",
-    "placeholder": "问我任何问题。",
+    "knowledge_assistant_placeholder": "问我任何问题。",
+    "editor_assistant_placeholder": "有什么需要帮忙的吗?",
     "summary_mode_label": "摘要模式",
     "summary_mode_help": "简洁回答在2-3句话内",
     "caution_against_hallucination": "请核实信息并检查来源。",

+ 25 - 10
apps/app/src/features/openai/client/components/AiAssistant/AiAssistantSidebar/AiAssistantSidebar.tsx

@@ -1,6 +1,6 @@
 import type { KeyboardEvent } from 'react';
 import {
-  type FC, memo, useRef, useEffect, useState, useCallback,
+  type FC, memo, useRef, useEffect, useState, useCallback, useMemo,
 } from 'react';
 
 import { useForm, Controller } from 'react-hook-form';
@@ -108,6 +108,27 @@ const AiAssistantSidebarSubstance: React.FC<AiAssistantSidebarSubstanceProps> =
     }
   }, [mutateMessageData, threadData]);
 
+  const headerIcon = useMemo(() => {
+    return isEditorAssistant
+      ? <span className="material-symbols-outlined growi-ai-chat-icon me-3 fs-4">support_agent</span>
+      : <span className="growi-custom-icons growi-ai-chat-icon me-3 fs-4">ai_assistant</span>;
+  }, [isEditorAssistant]);
+
+  const headerText = useMemo(() => {
+    return isEditorAssistant
+      ? <>{t('Editor Assistant')}</>
+      : <>{currentThreadTitle ?? aiAssistantData?.name}</>;
+  }, [isEditorAssistant, currentThreadTitle, aiAssistantData?.name, t]);
+
+  const placeHolder = useMemo(() => {
+    if (form.formState.isSubmitting) {
+      return '';
+    }
+    return t(isEditorAssistant
+      ? 'sidebar_ai_assistant.editor_assistant_placeholder'
+      : 'sidebar_ai_assistant.knowledge_assistant_placeholder');
+  }, [form.formState.isSubmitting, isEditorAssistant, t]);
+
   const isGenerating = generatingAnswerMessage != null;
   const submit = useCallback(async(data: FormData) => {
     // do nothing when the assistant is generating an answer
@@ -283,15 +304,9 @@ const AiAssistantSidebarSubstance: React.FC<AiAssistantSidebarSubstanceProps> =
     <>
       <div className="d-flex flex-column vh-100">
         <div className="d-flex align-items-center p-3 border-bottom position-sticky top-0 bg-body z-1">
-          {isEditorAssistant
-            ? <span className="material-symbols-outlined growi-ai-chat-icon me-3 fs-4">support_agent</span>
-            : <span className="growi-custom-icons growi-ai-chat-icon me-3 fs-4">ai_assistant</span>
-          }
+          {headerIcon}
           <h5 className="mb-0 fw-bold flex-grow-1 text-truncate">
-            {isEditorAssistant
-              ? <>{t('Editor Assistant')}</>
-              : <>{currentThreadTitle ?? aiAssistantData?.name}</>
-            }
+            {headerText}
           </h5>
           <button
             type="button"
@@ -348,7 +363,7 @@ const AiAssistantSidebarSubstance: React.FC<AiAssistantSidebarSubstanceProps> =
                       className="form-control textarea-ask"
                       style={{ resize: 'none' }}
                       rows={1}
-                      placeholder={!form.formState.isSubmitting ? t('sidebar_ai_assistant.placeholder') : ''}
+                      placeholder={placeHolder}
                       onKeyDown={keyDownHandler}
                       disabled={form.formState.isSubmitting}
                     />