chore: add skill upload fail tip (#38851)

This commit is contained in:
Joel 2026-07-13 15:52:12 +08:00 committed by GitHub
parent 9905e6eceb
commit cb209bc049
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 136 additions and 2 deletions

View File

@ -343,6 +343,60 @@ describe('AgentSkills', () => {
expect(toast.success).toHaveBeenCalled()
})
it('should hide skill package guidance before an upload fails', async () => {
const user = userEvent.setup()
renderAgentSkills({ initialDraft: defaultAgentSoulConfigFormState })
await user.click(
screen.getByRole('button', { name: /agentV2\.agentDetail\.configure\.skills\.add/i }),
)
expect(
screen.queryByText('agentV2.agentDetail.configure.skills.upload.warning.specification'),
).not.toBeInTheDocument()
})
it('should show skill package guidance after failure and hide it when retrying', async () => {
const user = userEvent.setup()
mocks.uploadSkillMutationFn
.mockRejectedValueOnce(new Error('Backend upload error'))
.mockImplementationOnce(() => new Promise<never>(() => undefined))
renderAgentSkills({ initialDraft: defaultAgentSoulConfigFormState })
await user.click(
screen.getByRole('button', { name: /agentV2\.agentDetail\.configure\.skills\.add/i }),
)
const input = await waitFor(() => {
const element = document.querySelector('input[type="file"]')
expect(element).not.toBeNull()
return element as HTMLInputElement
})
await user.upload(
input,
new File(['skill'], 'invoice-helper.skill', { type: 'application/zip' }),
)
const uploadButton = screen.getByRole('button', {
name: /agentDetail\.configure\.skills\.upload\.action/i,
})
await user.click(uploadButton)
expect(
await screen.findByText('agentV2.agentDetail.configure.skills.upload.warning.files'),
).toBeInTheDocument()
expect(
screen.getByText('agentV2.agentDetail.configure.skills.upload.warning.specification'),
).toBeInTheDocument()
await user.click(uploadButton)
await waitFor(() => {
expect(
screen.queryByText('agentV2.agentDetail.configure.skills.upload.warning.files'),
).not.toBeInTheDocument()
})
})
it('should not show the frontend fallback error when skill upload fails', async () => {
const user = userEvent.setup()
mocks.uploadSkillMutationFn.mockRejectedValueOnce(new Error('Backend upload error'))

View File

@ -17,8 +17,9 @@ import {
import { toast } from '@langgenius/dify-ui/toast'
import { useMutation } from '@tanstack/react-query'
import { useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Trans, useTranslation } from 'react-i18next'
import ActionButton from '@/app/components/base/action-button'
import Link from '@/next/link'
import { consoleQuery } from '@/service/client'
import { formatFileSize } from '@/utils/format'
@ -60,9 +61,11 @@ function hasDraggedFiles(event: DragEvent<HTMLDivElement>) {
function AgentSkillPackageUploader({
file,
onChange,
showWarning,
}: {
file?: File
onChange: (file?: File) => void
showWarning: boolean
}) {
const { t } = useTranslation('agentV2')
const fileInputRef = useRef<HTMLInputElement>(null)
@ -183,6 +186,33 @@ function AgentSkillPackageUploader({
</div>
</div>
)}
{showWarning && (
<div className="mt-2 flex items-start gap-2 rounded-lg border-[0.5px] border-components-badge-status-light-warning-halo bg-state-warning-hover px-3 py-2.5">
<span
aria-hidden
className="mt-0.5 i-ri-alert-fill size-4 shrink-0 text-text-warning-secondary"
/>
<ul className="list-disc space-y-1 pl-4 system-xs-regular text-text-warning">
<li>
<Trans
i18nKey={($) => $['agentDetail.configure.skills.upload.warning.specification']}
ns="agentV2"
components={{
specificationLink: (
<Link
href="https://agentskills.io/specification"
target="_blank"
rel="noopener noreferrer"
className="rounded-sm underline outline-hidden focus-visible:ring-2 focus-visible:ring-state-accent-solid"
/>
),
}}
/>
</li>
<li>{t(($) => $['agentDetail.configure.skills.upload.warning.files'])}</li>
</ul>
</div>
)}
</div>
)
}
@ -283,7 +313,11 @@ export function AgentSkillUploadDialog({
<DialogDescription className="mt-1 system-sm-regular text-text-tertiary">
{t(($) => $['agentDetail.configure.skills.upload.description'])}
</DialogDescription>
<AgentSkillPackageUploader file={file} onChange={setFile} />
<AgentSkillPackageUploader
file={file}
onChange={setFile}
showWarning={uploadSkillMutation.isError}
/>
<div className="flex justify-end gap-2 pt-6">
<Button
type="button"

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "قم بتحميل ملف .zip أو .skill.",
"agentDetail.configure.skills.upload.success": "تم تحميل المهارة.",
"agentDetail.configure.skills.upload.title": "تحميل مهارة",
"agentDetail.configure.skills.upload.warning.files": "إذا كنت تحتاج فقط إلى استخدام ملفات Markdown، فحمّلها إلى قسم الملفات وأشر إليها في الموجّه الخاص بك.",
"agentDetail.configure.skills.upload.warning.specification": "يجب أن تتوافق المهارات التي يتم تحميلها مع <specificationLink>مواصفات Agent Skills</specificationLink>.",
"agentDetail.configure.title": "تكوين",
"agentDetail.configure.tools.add": "إضافة أداة",
"agentDetail.configure.tools.addMenu.cliTool.badge": "للمطورين",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Bitte eine .zip- oder .skill-Datei hochladen.",
"agentDetail.configure.skills.upload.success": "Skill hochgeladen.",
"agentDetail.configure.skills.upload.title": "Skill hochladen",
"agentDetail.configure.skills.upload.warning.files": "Wenn du nur Markdown-Dateien verwenden möchtest, lade sie unter „Dateien“ hoch und verweise in deinem Prompt darauf.",
"agentDetail.configure.skills.upload.warning.specification": "Hochgeladene Skills müssen der <specificationLink>Agent-Skills-Spezifikation</specificationLink> entsprechen.",
"agentDetail.configure.title": "Konfigurieren",
"agentDetail.configure.tools.add": "Tool hinzufügen",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Für Entwickler",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Upload a .zip or .skill file.",
"agentDetail.configure.skills.upload.success": "Skill uploaded.",
"agentDetail.configure.skills.upload.title": "Upload skill",
"agentDetail.configure.skills.upload.warning.files": "If you only need to use Markdown files, upload them to Files and reference them in your prompt.",
"agentDetail.configure.skills.upload.warning.specification": "Uploaded skills must follow the <specificationLink>Agent Skills specification</specificationLink>.",
"agentDetail.configure.title": "Configure",
"agentDetail.configure.tools.add": "Add tool",
"agentDetail.configure.tools.addMenu.cliTool.badge": "For developers",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Sube un archivo .zip o .skill.",
"agentDetail.configure.skills.upload.success": "Habilidad subida.",
"agentDetail.configure.skills.upload.title": "Subir habilidad",
"agentDetail.configure.skills.upload.warning.files": "Si solo necesitas usar archivos Markdown, súbelos a Archivos y haz referencia a ellos en tu prompt.",
"agentDetail.configure.skills.upload.warning.specification": "Las habilidades subidas deben cumplir la <specificationLink>especificación de Agent Skills</specificationLink>.",
"agentDetail.configure.title": "Configurar",
"agentDetail.configure.tools.add": "Agregar herramienta",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Para desarrolladores",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "یک فایل .zip یا .skill بارگذاری کنید.",
"agentDetail.configure.skills.upload.success": "مهارت بارگذاری شد.",
"agentDetail.configure.skills.upload.title": "بارگذاری مهارت",
"agentDetail.configure.skills.upload.warning.files": "اگر فقط می‌خواهید از فایل‌های Markdown استفاده کنید، آن‌ها را در بخش فایل‌ها بارگذاری و در پرامپت خود ارجاع دهید.",
"agentDetail.configure.skills.upload.warning.specification": "مهارت‌های بارگذاری‌شده باید از <specificationLink>مشخصات Agent Skills</specificationLink> پیروی کنند.",
"agentDetail.configure.title": "پیکربندی",
"agentDetail.configure.tools.add": "افزودن ابزار",
"agentDetail.configure.tools.addMenu.cliTool.badge": "برای توسعه‌دهندگان",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Téléversez un fichier .zip ou .skill.",
"agentDetail.configure.skills.upload.success": "Compétence téléversée.",
"agentDetail.configure.skills.upload.title": "Téléverser une compétence",
"agentDetail.configure.skills.upload.warning.files": "Si vous souhaitez uniquement utiliser des fichiers Markdown, téléversez-les dans Fichiers et référencez-les dans votre prompt.",
"agentDetail.configure.skills.upload.warning.specification": "Les compétences téléversées doivent respecter la <specificationLink>spécification Agent Skills</specificationLink>.",
"agentDetail.configure.title": "Configurer",
"agentDetail.configure.tools.add": "Ajouter un outil",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Pour les développeurs",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "एक .zip या .skill फ़ाइल अपलोड करें।",
"agentDetail.configure.skills.upload.success": "कौशल अपलोड हो गया।",
"agentDetail.configure.skills.upload.title": "कौशल अपलोड करें",
"agentDetail.configure.skills.upload.warning.files": "यदि आपको केवल Markdown फ़ाइलों का उपयोग करना है, तो उन्हें फ़ाइलें में अपलोड करें और अपने प्रॉम्प्ट में उनका संदर्भ दें।",
"agentDetail.configure.skills.upload.warning.specification": "अपलोड किए गए कौशल को <specificationLink>Agent Skills विनिर्देश</specificationLink> का पालन करना चाहिए।",
"agentDetail.configure.title": "कॉन्फ़िगर करें",
"agentDetail.configure.tools.add": "उपकरण जोड़ें",
"agentDetail.configure.tools.addMenu.cliTool.badge": "डेवलपर्स के लिए",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Unggah file .zip atau .skill.",
"agentDetail.configure.skills.upload.success": "Keterampilan diunggah.",
"agentDetail.configure.skills.upload.title": "Unggah keterampilan",
"agentDetail.configure.skills.upload.warning.files": "Jika Anda hanya perlu menggunakan file Markdown, unggah ke File dan rujuk file tersebut dalam prompt Anda.",
"agentDetail.configure.skills.upload.warning.specification": "Keterampilan yang diunggah harus mengikuti <specificationLink>spesifikasi Agent Skills</specificationLink>.",
"agentDetail.configure.title": "Konfigurasi",
"agentDetail.configure.tools.add": "Tambahkan alat",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Untuk pengembang",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Carica un file .zip o .skill.",
"agentDetail.configure.skills.upload.success": "Abilità caricata.",
"agentDetail.configure.skills.upload.title": "Carica abilità",
"agentDetail.configure.skills.upload.warning.files": "Se devi usare solo file Markdown, caricali in File e richiamali nel tuo prompt.",
"agentDetail.configure.skills.upload.warning.specification": "Le abilità caricate devono rispettare la <specificationLink>specifica Agent Skills</specificationLink>.",
"agentDetail.configure.title": "Configura",
"agentDetail.configure.tools.add": "Aggiungi strumento",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Per sviluppatori",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": ".zip または .skill ファイルをアップロードしてください。",
"agentDetail.configure.skills.upload.success": "スキルをアップロードしました。",
"agentDetail.configure.skills.upload.title": "スキルをアップロード",
"agentDetail.configure.skills.upload.warning.files": "Markdown ファイルのみを使用する場合は、「ファイル」にアップロードし、プロンプト内で参照してください。",
"agentDetail.configure.skills.upload.warning.specification": "アップロードするスキルは <specificationLink>Agent Skills 仕様</specificationLink>に準拠する必要があります。",
"agentDetail.configure.title": "設定",
"agentDetail.configure.tools.add": "ツールを追加",
"agentDetail.configure.tools.addMenu.cliTool.badge": "開発者向け",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": ".zip 또는 .skill 파일을 업로드하세요.",
"agentDetail.configure.skills.upload.success": "스킬을 업로드했습니다.",
"agentDetail.configure.skills.upload.title": "스킬 업로드",
"agentDetail.configure.skills.upload.warning.files": "Markdown 파일만 사용하려면 파일에 업로드하고 프롬프트에서 참조하세요.",
"agentDetail.configure.skills.upload.warning.specification": "업로드한 스킬은 <specificationLink>Agent Skills 사양</specificationLink>을 준수해야 합니다.",
"agentDetail.configure.title": "구성",
"agentDetail.configure.tools.add": "도구 추가",
"agentDetail.configure.tools.addMenu.cliTool.badge": "개발자용",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Upload een .zip- of .skill-bestand.",
"agentDetail.configure.skills.upload.success": "Skill geüpload.",
"agentDetail.configure.skills.upload.title": "Skill uploaden",
"agentDetail.configure.skills.upload.warning.files": "Als je alleen Markdown-bestanden wilt gebruiken, upload ze dan naar Bestanden en verwijs ernaar in je prompt.",
"agentDetail.configure.skills.upload.warning.specification": "Geüploade skills moeten voldoen aan de <specificationLink>Agent Skills-specificatie</specificationLink>.",
"agentDetail.configure.title": "Configureren",
"agentDetail.configure.tools.add": "Tool toevoegen",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Voor ontwikkelaars",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Prześlij plik .zip lub .skill.",
"agentDetail.configure.skills.upload.success": "Umiejętność przesłana.",
"agentDetail.configure.skills.upload.title": "Prześlij umiejętność",
"agentDetail.configure.skills.upload.warning.files": "Jeśli chcesz używać tylko plików Markdown, prześlij je do sekcji Pliki i odwołaj się do nich w swoim prompcie.",
"agentDetail.configure.skills.upload.warning.specification": "Przesyłane umiejętności muszą być zgodne ze <specificationLink>specyfikacją Agent Skills</specificationLink>.",
"agentDetail.configure.title": "Konfiguruj",
"agentDetail.configure.tools.add": "Dodaj narzędzie",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Dla deweloperów",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Envie um arquivo .zip ou .skill.",
"agentDetail.configure.skills.upload.success": "Habilidade enviada.",
"agentDetail.configure.skills.upload.title": "Enviar habilidade",
"agentDetail.configure.skills.upload.warning.files": "Se você só precisa usar arquivos Markdown, envie-os para Arquivos e faça referência a eles no seu prompt.",
"agentDetail.configure.skills.upload.warning.specification": "As habilidades enviadas devem seguir a <specificationLink>especificação Agent Skills</specificationLink>.",
"agentDetail.configure.title": "Configurar",
"agentDetail.configure.tools.add": "Adicionar ferramenta",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Para desenvolvedores",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Încărcați un fișier .zip sau .skill.",
"agentDetail.configure.skills.upload.success": "Abilitate încărcată.",
"agentDetail.configure.skills.upload.title": "Încarcă abilitate",
"agentDetail.configure.skills.upload.warning.files": "Dacă trebuie doar să folosești fișiere Markdown, încarcă-le în Fișiere și menționează-le în promptul tău.",
"agentDetail.configure.skills.upload.warning.specification": "Abilitățile încărcate trebuie să respecte <specificationLink>specificația Agent Skills</specificationLink>.",
"agentDetail.configure.title": "Configurare",
"agentDetail.configure.tools.add": "Adaugă instrument",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Pentru dezvoltatori",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Загрузите файл .zip или .skill.",
"agentDetail.configure.skills.upload.success": "Навык загружен.",
"agentDetail.configure.skills.upload.title": "Загрузить навык",
"agentDetail.configure.skills.upload.warning.files": "Если вам нужно использовать только файлы Markdown, загрузите их в раздел «Файлы» и укажите ссылки на них в своем промпте.",
"agentDetail.configure.skills.upload.warning.specification": "Загружаемые навыки должны соответствовать <specificationLink>спецификации Agent Skills</specificationLink>.",
"agentDetail.configure.title": "Настроить",
"agentDetail.configure.tools.add": "Добавить инструмент",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Для разработчиков",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Naložite datoteko .zip ali .skill.",
"agentDetail.configure.skills.upload.success": "Veščina naložena.",
"agentDetail.configure.skills.upload.title": "Naloži veščino",
"agentDetail.configure.skills.upload.warning.files": "Če želite uporabljati samo datoteke Markdown, jih naložite v razdelek Datoteke in se nanje sklicujte v svojem pozivu.",
"agentDetail.configure.skills.upload.warning.specification": "Naložene veščine morajo upoštevati <specificationLink>specifikacijo Agent Skills</specificationLink>.",
"agentDetail.configure.title": "Konfiguriraj",
"agentDetail.configure.tools.add": "Dodaj orodje",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Za razvijalce",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "อัปโหลดไฟล์ .zip หรือ .skill",
"agentDetail.configure.skills.upload.success": "อัปโหลดทักษะแล้ว",
"agentDetail.configure.skills.upload.title": "อัปโหลดทักษะ",
"agentDetail.configure.skills.upload.warning.files": "หากต้องการใช้เฉพาะไฟล์ Markdown ให้อัปโหลดไปยังส่วนไฟล์และอ้างอิงไฟล์เหล่านั้นในพรอมต์ของคุณ",
"agentDetail.configure.skills.upload.warning.specification": "ทักษะที่อัปโหลดต้องเป็นไปตาม<specificationLink>ข้อกำหนด Agent Skills</specificationLink>",
"agentDetail.configure.title": "กำหนดค่า",
"agentDetail.configure.tools.add": "เพิ่มเครื่องมือ",
"agentDetail.configure.tools.addMenu.cliTool.badge": "สำหรับนักพัฒนา",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Bir .zip veya .skill dosyası yükleyin.",
"agentDetail.configure.skills.upload.success": "Beceri yüklendi.",
"agentDetail.configure.skills.upload.title": "Beceri yükle",
"agentDetail.configure.skills.upload.warning.files": "Yalnızca Markdown dosyalarını kullanmanız gerekiyorsa bunları Dosyalar bölümüne yükleyin ve isteminizde referans verin.",
"agentDetail.configure.skills.upload.warning.specification": "Yüklenen beceriler <specificationLink>Agent Skills spesifikasyonuna</specificationLink> uygun olmalıdır.",
"agentDetail.configure.title": "Yapılandır",
"agentDetail.configure.tools.add": "Araç ekle",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Geliştiriciler için",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Завантажте файл .zip або .skill.",
"agentDetail.configure.skills.upload.success": "Навичку завантажено.",
"agentDetail.configure.skills.upload.title": "Завантажити навичку",
"agentDetail.configure.skills.upload.warning.files": "Якщо потрібно використовувати лише файли Markdown, завантажте їх у розділ «Файли» та посилайтеся на них у своєму промпті.",
"agentDetail.configure.skills.upload.warning.specification": "Завантажувані навички мають відповідати <specificationLink>специфікації Agent Skills</specificationLink>.",
"agentDetail.configure.title": "Налаштувати",
"agentDetail.configure.tools.add": "Додати інструмент",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Для розробників",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "Tải lên một tệp .zip hoặc .skill.",
"agentDetail.configure.skills.upload.success": "Đã tải lên kỹ năng.",
"agentDetail.configure.skills.upload.title": "Tải lên kỹ năng",
"agentDetail.configure.skills.upload.warning.files": "Nếu bạn chỉ cần sử dụng tệp Markdown, hãy tải chúng lên Tệp và tham chiếu chúng trong prompt của bạn.",
"agentDetail.configure.skills.upload.warning.specification": "Kỹ năng được tải lên phải tuân theo <specificationLink>đặc tả Agent Skills</specificationLink>.",
"agentDetail.configure.title": "Cấu hình",
"agentDetail.configure.tools.add": "Thêm công cụ",
"agentDetail.configure.tools.addMenu.cliTool.badge": "Dành cho nhà phát triển",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "请上传 .zip 或 .skill 文件。",
"agentDetail.configure.skills.upload.success": "Skill 已上传。",
"agentDetail.configure.skills.upload.title": "上传 Skill",
"agentDetail.configure.skills.upload.warning.files": "如果只需要使用 Markdown 文件,请将它们上传到「文件」,并在你的提示词中引用。",
"agentDetail.configure.skills.upload.warning.specification": "上传的 Skill 需遵循 <specificationLink>Agent Skills 规范</specificationLink>。",
"agentDetail.configure.title": "配置",
"agentDetail.configure.tools.add": "添加工具",
"agentDetail.configure.tools.addMenu.cliTool.badge": "开发者适用",

View File

@ -218,6 +218,8 @@
"agentDetail.configure.skills.upload.invalidFile": "請上傳 .zip 或 .skill 檔案。",
"agentDetail.configure.skills.upload.success": "Skill 已上傳。",
"agentDetail.configure.skills.upload.title": "上傳 Skill",
"agentDetail.configure.skills.upload.warning.files": "如果只需要使用 Markdown 檔案,請將它們上傳到「檔案」,並在你的提示詞中引用。",
"agentDetail.configure.skills.upload.warning.specification": "上傳的 Skill 需遵循 <specificationLink>Agent Skills 規範</specificationLink>。",
"agentDetail.configure.title": "設定",
"agentDetail.configure.tools.add": "新增工具",
"agentDetail.configure.tools.addMenu.cliTool.badge": "開發者適用",