Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix(skills): fix import, tags, duplication, model selection, and TXT icons (#42653)

zxhlyh863ce1d70d82
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/file-icon.spec.ts b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/file-icon.spec.ts
index cf7058c331b..b0c5084fc2b 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/file-icon.spec.ts
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/__tests__/file-icon.spec.ts
@@ -39,4 +39,17 @@ describe('agent file icon helpers', () => {
expect(getFileIconType('archive.zip')).toBe('archive')
expect(getFileIconType('script.ts')).toBe('code')
})
+
+ it.each([
+ ['references/notes.txt', undefined],
+ ['references/NOTES.TXT', undefined],
+ ['references/notes.txt', 'text/plain'],
+ ['references/notes.txt', 'application/octet-stream'],
+ ])('should identify %s as text regardless of MIME metadata (%s)', (fileName, mimeType) => {
+ expect(getFileIconType(fileName, mimeType)).toBe('text')
+ })
+
+ it('should keep unrecognized binary files as generic files', () => {
+ expect(getFileIconType('data.bin', 'application/octet-stream')).toBe('file')
+ })
})
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/file-icon.ts b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/file-icon.ts
index 653b33393d1..104cc2b8e9c 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/file-icon.ts
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/file-icon.ts
@@ -63,7 +63,7 @@ export function getFileIconType(fileName: string, mimeType?: string | null): Fil
if (tableFileExtensions.has(extension)) return 'table'
if (archiveFileExtensions.has(extension)) return 'archive'
if (codeFileExtensions.has(extension)) return 'code'
- if (mimeType?.startsWith('text/')) return 'text'
+ if (extension === 'txt' || mimeType?.startsWith('text/')) return 'text'
return 'file'
}
diff --git a/web/features/skills/__tests__/detail-page-builder.spec.tsx b/web/features/skills/__tests__/detail-page-builder.spec.tsx
index fbeb3586b5e..e918eb75d17 100644
--- a/web/features/skills/__tests__/detail-page-builder.spec.tsx
+++ b/web/features/skills/__tests__/detail-page-builder.spec.tsx
@@ -1,5 +1,5 @@
import type { SkillDetailResponse } from '@dify/contracts/api/console/workspaces/types.gen'
-import { act, fireEvent, screen, waitFor } from '@testing-library/react'
+import { act, fireEvent, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import {
@@ -447,6 +447,213 @@ describe('SkillDetailPage builder', () => {
expect(sendButton).toBeDisabled()
}, 15000)
+ it('uses an available model instead of a default model that no longer exists', async () => {
+ const user = userEvent.setup()
+ mocks.defaultTextGenerationModel = {
+ provider: { provider: 'langgenius/openai/openai' },
+ model: 'gpt-5-chat-latest',
+ }
+
+ renderSkillDetailPage()
+
+ const promptInput = await screen.findByPlaceholderText(
+ 'skill.skillManagement.detail.builder.modifyPlaceholder',
+ )
+ await user.type(promptInput, 'Update the skill{Enter}')
+
+ expect(mocks.sendSkillAssistMessage).toHaveBeenCalledWith(
+ expect.objectContaining({
+ model: expect.objectContaining({
+ provider: 'langgenius/openai/openai',
+ model: 'gpt-5.5',
+ }),
+ }),
+ )
+ expect(mocks.modelParameterRulesFetch).toHaveBeenCalled()
+ const requestedModels = mocks.modelParameterRulesFetch.mock.calls.map(([input]) => {
+ const url = input instanceof Request ? input.url : String(input)
+ return new URL(url).searchParams.get('model')
+ })
+ expect(requestedModels).toEqual(['gpt-5.5'])
+ })
+
+ it('does not request parameters or send with an unavailable default and no usable model', async () => {
+ const user = userEvent.setup()
+ mocks.defaultTextGenerationModel = {
+ provider: { provider: 'langgenius/openai/openai' },
+ model: 'gpt-5-chat-latest',
+ }
+ mocks.textGenerationModelList = []
+ mocks.skillDetail = createDefaultSkillDraftDetail()
+
+ renderSkillDetailPage()
+
+ const promptInput = await screen.findByPlaceholderText(
+ 'skill.skillManagement.detail.builder.placeholder',
+ )
+ expect(
+ screen.getByRole('button', {
+ name: 'skill.skillManagement.detail.builder.send',
+ }),
+ ).toBeDisabled()
+ expect(
+ screen.getByRole('button', {
+ name: 'skill.skillManagement.detail.builder.exampleIssueTriage',
+ }),
+ ).toBeDisabled()
+ await user.type(promptInput, 'Create a skill{Enter}')
+
+ expect(mocks.sendSkillAssistMessage).not.toHaveBeenCalled()
+ expect(mocks.modelParameterRulesFetch).not.toHaveBeenCalled()
+ })
+
+ it('keeps an available default model instead of replacing it with the first model', async () => {
+ const user = userEvent.setup()
+ mocks.textGenerationModelList[0]!.models.unshift({
+ model: 'gpt-4.1',
+ status: 'active',
+ })
+
+ renderSkillDetailPage()
+ const promptInput = await screen.findByPlaceholderText(
+ 'skill.skillManagement.detail.builder.modifyPlaceholder',
+ )
+ await user.type(promptInput, 'Update the skill{Enter}')
+
+ expect(mocks.sendSkillAssistMessage).toHaveBeenCalledWith(
+ expect.objectContaining({
+ model: expect.objectContaining({ model: 'gpt-5.5' }),
+ }),
+ )
+ expect(mocks.toastError).not.toHaveBeenCalled()
+ })
+
+ it.each([
+ { target: 'provider', status: 'disabled' },
+ { target: 'model', status: 'disabled' },
+ { target: 'model', status: 'credential-removed' },
+ ])('does not use a default whose $target has status $status', async ({ target, status }) => {
+ const user = userEvent.setup()
+ const defaultProvider = mocks.textGenerationModelList[0]!
+ if (target === 'provider') defaultProvider.status = status
+ else defaultProvider.models[0]!.status = status
+ mocks.textGenerationModelList.push({
+ provider: 'langgenius/anthropic/anthropic',
+ status: 'active',
+ models: [{ model: 'claude-sonnet-4-6', status: 'active' }],
+ })
+
+ renderSkillDetailPage()
+ const promptInput = await screen.findByPlaceholderText(
+ 'skill.skillManagement.detail.builder.modifyPlaceholder',
+ )
+ await user.type(promptInput, 'Update the skill{Enter}')
+
+ expect(mocks.sendSkillAssistMessage).toHaveBeenCalledWith(
+ expect.objectContaining({
+ model: expect.objectContaining({
+ provider: 'langgenius/anthropic/anthropic',
+ model: 'claude-sonnet-4-6',
+ }),
+ }),
+ )
+ expect(mocks.modelParameterRulesFetch).toHaveBeenCalledTimes(1)
+ const request = mocks.modelParameterRulesFetch.mock.calls[0]![0]
+ const url = new URL(request instanceof Request ? request.url : String(request))
+ expect(url.pathname).toContain('/model-providers/langgenius/anthropic/anthropic/')
+ expect(url.searchParams.get('model')).toBe('claude-sonnet-4-6')
+ })
+
+ it('waits for available models before requesting parameters or allowing Builder sends', async () => {
+ const user = userEvent.setup()
+ let resolveModels: (response: { data: typeof mocks.textGenerationModelList }) => void = () => {}
+ const modelListResponse = new Promise<{ data: typeof mocks.textGenerationModelList }>(
+ (resolve) => {
+ resolveModels = resolve
+ },
+ )
+ mocks.textGenerationModelListGet.mockReturnValue(modelListResponse)
+ mocks.skillDetail = createDefaultSkillDraftDetail()
+
+ renderSkillDetailPage()
+ const promptInput = await screen.findByPlaceholderText(
+ 'skill.skillManagement.detail.builder.placeholder',
+ )
+ const sendButton = screen.getByRole('button', {
+ name: 'skill.skillManagement.detail.builder.send',
+ })
+ const suggestion = screen.getByRole('button', {
+ name: 'skill.skillManagement.detail.builder.exampleIssueTriage',
+ })
+ await user.type(promptInput, 'Create a skill{Enter}')
+
+ expect(sendButton).toBeDisabled()
+ expect(suggestion).toBeDisabled()
+ expect(mocks.sendSkillAssistMessage).not.toHaveBeenCalled()
+ expect(mocks.modelParameterRulesFetch).not.toHaveBeenCalled()
+
+ await act(async () => {
+ resolveModels({ data: mocks.textGenerationModelList })
+ await modelListResponse
+ })
+ await waitFor(() => expect(sendButton).toBeEnabled())
+ expect(suggestion).toBeEnabled()
+ await user.keyboard('{Enter}')
+
+ expect(mocks.sendSkillAssistMessage).toHaveBeenCalledWith(
+ expect.objectContaining({ model: expect.objectContaining({ model: 'gpt-5.5' }) }),
+ )
+ expect(mocks.modelParameterRulesFetch).toHaveBeenCalledTimes(1)
+ })
+
+ it('preserves user-edited parameters for an available Builder model', async () => {
+ const user = userEvent.setup()
+ mocks.modelParameterRulesFetch.mockImplementation(async () =>
+ Response.json({
+ data: [
+ {
+ name: 'temperature',
+ label: { en_US: 'Temperature' },
+ help: { en_US: 'Control randomness' },
+ type: 'float',
+ min: 0,
+ max: 2,
+ default: 0.7,
+ precision: 1,
+ },
+ ],
+ }),
+ )
+
+ renderSkillDetailPage()
+ await user.click(
+ await screen.findByRole('button', {
+ name: 'common.modelProvider.modelSettings',
+ }),
+ )
+ const dialog = await screen.findByRole('dialog', {
+ name: 'common.modelProvider.modelSettings',
+ })
+ const temperature = await within(dialog).findByRole('spinbutton', { name: 'Temperature' })
+ await user.clear(temperature)
+ await user.type(temperature, '1.2')
+ await user.click(within(dialog).getByRole('button', { name: 'common.operation.close' }))
+ await user.type(
+ screen.getByPlaceholderText('skill.skillManagement.detail.builder.modifyPlaceholder'),
+ 'Update the skill{Enter}',
+ )
+
+ expect(mocks.sendSkillAssistMessage).toHaveBeenCalledWith(
+ expect.objectContaining({
+ model: {
+ provider: 'langgenius/openai/openai',
+ model: 'gpt-5.5',
+ model_settings: { temperature: 1.2 },
+ },
+ }),
+ )
+ })
+
it('uploads image attachments in Skill Builder', async () => {
const user = userEvent.setup({ applyAccept: false })
mocks.uploadSkillFile.mockResolvedValue({
diff --git a/web/features/skills/__tests__/detail-page-metadata.spec.tsx b/web/features/skills/__tests__/detail-page-metadata.spec.tsx
index 2c2b2602b54..77fbc1ab5ee 100644
--- a/web/features/skills/__tests__/detail-page-metadata.spec.tsx
+++ b/web/features/skills/__tests__/detail-page-metadata.spec.tsx
@@ -41,7 +41,7 @@ describe('SkillDetailPage metadata', () => {
).not.toBeInTheDocument()
})
- it('saves selected workspace tags when the selector closes', async () => {
+ it('previews selected workspace tags immediately and saves once when the selector closes', async () => {
const user = userEvent.setup()
renderSkillDetailPage()
@@ -51,6 +51,21 @@ describe('SkillDetailPage metadata', () => {
}),
)
await user.click(await screen.findByRole('option', { name: 'Search' }))
+
+ expect(
+ within(screen.getByRole('region', { name: /skillManagement\.detail\.fileCount/ })).getByText(
+ 'Search',
+ ),
+ ).toBeInTheDocument()
+ expect(screen.getByRole('listbox')).toBeVisible()
+ expect(screen.getByRole('option', { name: 'Search' })).toHaveAttribute('aria-selected', 'true')
+ expect(
+ screen.getByRole('button', {
+ name: 'skill.skillManagement.detail.removeTag:{"tag":"Search"}',
+ }),
+ ).toBeDisabled()
+ expect(mocks.skillMetadataMutationFn).not.toHaveBeenCalled()
+
await user.click(screen.getByTestId('skill-detail-sidebar-header'))
await waitFor(() => {
@@ -64,9 +79,10 @@ describe('SkillDetailPage metadata', () => {
expect.anything(),
)
})
+ expect(mocks.skillMetadataMutationFn).toHaveBeenCalledTimes(1)
})
- it('removes a selected tag when it is unchecked and the selector closes', async () => {
+ it('previews unchecked tags immediately and saves once when the selector closes', async () => {
const user = userEvent.setup()
mocks.skillDetail = createSkillDetail({
tags: ['Search', 'Productivity'],
@@ -79,6 +95,16 @@ describe('SkillDetailPage metadata', () => {
}),
)
await user.click(await screen.findByRole('option', { name: 'Search' }))
+
+ const sidebar = within(
+ screen.getByRole('region', { name: /skillManagement\.detail\.fileCount/ }),
+ )
+ expect(sidebar.queryByText('Search')).not.toBeInTheDocument()
+ expect(sidebar.getByText('Productivity')).toBeInTheDocument()
+ expect(screen.getByRole('listbox')).toBeVisible()
+ expect(screen.getByRole('option', { name: 'Search' })).toHaveAttribute('aria-selected', 'false')
+ expect(mocks.skillMetadataMutationFn).not.toHaveBeenCalled()
+
await user.click(screen.getByTestId('skill-detail-sidebar-header'))
await waitFor(() => {
@@ -91,6 +117,7 @@ describe('SkillDetailPage metadata', () => {
expect.anything(),
)
})
+ expect(mocks.skillMetadataMutationFn).toHaveBeenCalledTimes(1)
})
it('renders an unmatched search as a create action instead of a tag checkbox', async () => {
@@ -117,7 +144,7 @@ describe('SkillDetailPage metadata', () => {
expect(screen.queryByRole('option', { name: 'BrandNew' })).not.toBeInTheDocument()
})
- it('creates and binds an unmatched tag when the create action is selected', async () => {
+ it('previews a newly created tag immediately and binds it when the selector closes', async () => {
const user = userEvent.setup()
renderSkillDetailPage()
@@ -137,6 +164,19 @@ describe('SkillDetailPage metadata', () => {
name: "common.tag.create 'BrandNew'",
}),
)
+
+ expect(
+ within(screen.getByRole('region', { name: /skillManagement\.detail\.fileCount/ })).getByText(
+ 'BrandNew',
+ ),
+ ).toBeInTheDocument()
+ expect(screen.getByRole('listbox')).toBeVisible()
+ expect(screen.getByRole('option', { name: 'BrandNew' })).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ )
+ expect(mocks.skillMetadataMutationFn).not.toHaveBeenCalled()
+
await user.click(screen.getByTestId('skill-detail-sidebar-header'))
await waitFor(() => {
@@ -149,9 +189,10 @@ describe('SkillDetailPage metadata', () => {
expect.anything(),
)
})
+ expect(mocks.skillMetadataMutationFn).toHaveBeenCalledTimes(1)
})
- it('shows an added tag only after the metadata request finishes', async () => {
+ it('keeps selected tags visible and prevents reopening while the metadata request is pending', async () => {
const user = userEvent.setup()
let resolveMutation: ((detail: SkillDetailResponse) => void) | undefined
mocks.skillDetailKey.mockReturnValue(['skill-detail'])
@@ -175,7 +216,23 @@ describe('SkillDetailPage metadata', () => {
await user.click(await screen.findByRole('option', { name: 'Search' }))
await user.click(screen.getByTestId('skill-detail-sidebar-header'))
- expect(screen.queryByText('Search')).not.toBeInTheDocument()
+ expect(
+ within(screen.getByRole('region', { name: /skillManagement\.detail\.fileCount/ })).getByText(
+ 'Search',
+ ),
+ ).toBeInTheDocument()
+ const addTagButton = screen.getByRole('combobox', {
+ name: 'skill.skillManagement.detail.addTag',
+ })
+ expect(addTagButton).toBeDisabled()
+ expect(
+ screen.getByRole('button', {
+ name: 'skill.skillManagement.detail.removeTag:{"tag":"Search"}',
+ }),
+ ).toBeDisabled()
+ await user.click(addTagButton)
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument()
+ expect(mocks.skillMetadataMutationFn).toHaveBeenCalledTimes(1)
await act(async () => {
const nextDetail = createSkillDetail({
@@ -187,6 +244,61 @@ describe('SkillDetailPage metadata', () => {
})
expect(await screen.findByText('Search')).toBeInTheDocument()
+ expect(addTagButton).toBeEnabled()
+ })
+
+ it('restores persisted tags when saving the visible selection fails', async () => {
+ const user = userEvent.setup()
+ let rejectMutation: ((error: Error) => void) | undefined
+ mocks.skillDetailKey.mockReturnValue(['skill-detail'])
+ mocks.skillDetailQueryOptions.mockImplementation(() => ({
+ queryKey: ['skill-detail'],
+ queryFn: async () => mocks.skillDetail,
+ }))
+ mocks.skillDetail = createSkillDetail({ tags: ['Search'] })
+ mocks.skillMetadataMutationFn.mockImplementation(
+ () =>
+ new Promise<SkillDetailResponse>((_resolve, reject) => {
+ rejectMutation = reject
+ }),
+ )
+ renderSkillDetailPage()
+
+ await user.click(
+ await screen.findByRole('combobox', {
+ name: 'skill.skillManagement.detail.addTag',
+ }),
+ )
+ await user.click(await screen.findByRole('option', { name: 'Search' }))
+ await user.click(screen.getByRole('option', { name: 'Productivity' }))
+ await user.click(screen.getByTestId('skill-detail-sidebar-header'))
+
+ const sidebar = within(
+ screen.getByRole('region', { name: /skillManagement\.detail\.fileCount/ }),
+ )
+ expect(sidebar.queryByText('Search')).not.toBeInTheDocument()
+ expect(sidebar.getByText('Productivity')).toBeInTheDocument()
+
+ await act(async () => {
+ rejectMutation?.(new Error('Saving tags failed'))
+ })
+
+ expect(await sidebar.findByText('Search')).toBeInTheDocument()
+ expect(sidebar.queryByText('Productivity')).not.toBeInTheDocument()
+ expect(mocks.toastError).toHaveBeenCalledWith('skill.skillManagement.detail.updateTagsFailed')
+ await user.click(
+ screen.getByRole('combobox', {
+ name: 'skill.skillManagement.detail.addTag',
+ }),
+ )
+ expect(await screen.findByRole('option', { name: 'Search' })).toHaveAttribute(
+ 'aria-selected',
+ 'true',
+ )
+ expect(screen.getByRole('option', { name: 'Productivity' })).toHaveAttribute(
+ 'aria-selected',
+ 'false',
+ )
})
it('opens tag management from the selector', async () => {
@@ -342,13 +454,11 @@ describe('SkillDetailPage metadata', () => {
})
it.each(['version-1', null])(
- 'duplicates and exports the current skill with published version %s from the sidebar More menu',
+ 'opens the returned duplicate for inline rename with published version %s from the sidebar More menu',
async (publishedVersionId) => {
const user = userEvent.setup()
- const archive = new Blob(['archive'], { type: 'application/zip' })
+ mocks.duplicateSkillMutationFn.mockResolvedValue(createSkillDetail({ id: 'copied-skill' }))
mocks.skillDetail = createSkillDetail({ latest_published_version_id: publishedVersionId })
- mocks.duplicateSkillMutationFn.mockResolvedValue({})
- mocks.fetchSkillArchiveBlob.mockResolvedValue(archive)
renderSkillDetailPage()
const moreButton = await screen.findByRole('button', {
@@ -364,8 +474,45 @@ describe('SkillDetailPage metadata', () => {
)
})
expect(mocks.toastSuccess).toHaveBeenCalledWith('skill.skillManagement.duplicateSuccess')
+ expect(mocks.routerPush).toHaveBeenCalledWith('/skills/copied-skill?rename=true')
+ },
+ )
- await user.click(moreButton)
+ it('stays on the original detail when duplication fails', async () => {
+ const user = userEvent.setup()
+ mocks.duplicateSkillMutationFn.mockRejectedValue(new Error('Duplicate failed'))
+ renderSkillDetailPage()
+
+ await user.click(
+ await screen.findByRole('button', {
+ name: 'skill.skillManagement.moreActions:{"name":"Untitled skill"}',
+ }),
+ )
+ await user.click(screen.getByRole('menuitem', { name: 'common.operation.duplicate' }))
+
+ await waitFor(() => {
+ expect(mocks.toastError).toHaveBeenCalledWith('skill.skillManagement.duplicateFailed')
+ })
+ expect(mocks.routerPush).not.toHaveBeenCalled()
+ expect(screen.getByRole('button', { name: 'common.operation.rename' })).toHaveTextContent(
+ 'Untitled skill',
+ )
+ })
+
+ it.each(['version-1', null])(
+ 'exports the current skill with published version %s from the sidebar More menu',
+ async (publishedVersionId) => {
+ const user = userEvent.setup()
+ const archive = new Blob(['archive'], { type: 'application/zip' })
+ mocks.fetchSkillArchiveBlob.mockResolvedValue(archive)
+ mocks.skillDetail = createSkillDetail({ latest_published_version_id: publishedVersionId })
+ renderSkillDetailPage()
+
+ await user.click(
+ await screen.findByRole('button', {
+ name: 'skill.skillManagement.moreActions:{"name":"Untitled skill"}',
+ }),
+ )
await user.click(screen.getByRole('menuitem', { name: 'common.operation.export' }))
await waitFor(() => {
@@ -378,6 +525,84 @@ describe('SkillDetailPage metadata', () => {
},
)
+ it('does not start inline rename on an ordinary detail visit', async () => {
+ const { onUrlUpdate } = renderSkillDetailPage()
+
+ expect(
+ await screen.findByRole('button', { name: 'common.operation.rename' }),
+ ).toHaveTextContent('Untitled skill')
+ expect(
+ screen.queryByRole('textbox', { name: 'common.operation.rename' }),
+ ).not.toBeInTheDocument()
+ expect(onUrlUpdate).not.toHaveBeenCalled()
+ })
+
+ it('starts inline rename after the copied detail loads and consumes the request once', async () => {
+ const user = userEvent.setup()
+ let resolveDetail: (detail: SkillDetailResponse) => void = () => {}
+ const detailPromise = new Promise<SkillDetailResponse>((resolve) => {
+ resolveDetail = resolve
+ })
+ mocks.skillDetailQueryOptions.mockImplementation((options) => ({
+ queryKey: ['skill-detail', options],
+ queryFn: () => detailPromise,
+ }))
+ const { onUrlUpdate, queryClient } = renderSkillDetailPage({
+ searchParams: '?rename=true&source=list',
+ strict: true,
+ })
+
+ expect(
+ screen.queryByRole('textbox', { name: 'common.operation.rename' }),
+ ).not.toBeInTheDocument()
+ expect(onUrlUpdate).not.toHaveBeenCalled()
+ await act(async () => resolveDetail(createSkillDetail()))
+
+ const renameInput = await screen.findByRole('textbox', { name: 'common.operation.rename' })
+ expect(renameInput).toHaveFocus()
+ expect(renameInput).toHaveValue('Untitled skill')
+ expect(renameInput).toHaveProperty('selectionStart', 0)
+ expect(renameInput).toHaveProperty('selectionEnd', 'Untitled skill'.length)
+ await waitFor(() => expect(onUrlUpdate).toHaveBeenCalled())
+ expect(onUrlUpdate.mock.lastCall?.[0].searchParams.has('rename')).toBe(false)
+ expect(onUrlUpdate.mock.lastCall?.[0].searchParams.get('source')).toBe('list')
+
+ await user.keyboard('{Escape}')
+ expect(screen.getByRole('button', { name: 'common.operation.rename' })).toBeInTheDocument()
+ await act(async () => queryClient.invalidateQueries())
+ expect(
+ screen.queryByRole('textbox', { name: 'common.operation.rename' }),
+ ).not.toBeInTheDocument()
+ expect(mocks.skillMetadataMutationFn).not.toHaveBeenCalled()
+ })
+
+ it('saves the automatically activated name editor without activating it again', async () => {
+ const user = userEvent.setup()
+ const { onUrlUpdate, queryClient } = renderSkillDetailPage({ searchParams: '?rename=true' })
+ const renameInput = await screen.findByRole('textbox', { name: 'common.operation.rename' })
+
+ await user.clear(renameInput)
+ await user.type(renameInput, 'Renamed duplicate{Enter}')
+
+ await waitFor(() => {
+ expect(screen.getByRole('button', { name: 'common.operation.rename' })).toHaveTextContent(
+ 'Renamed duplicate',
+ )
+ })
+ expect(mocks.skillMetadataMutationFn).toHaveBeenCalledWith(
+ expect.objectContaining({
+ body: expect.objectContaining({ display_name: 'Renamed duplicate' }),
+ }),
+ expect.anything(),
+ )
+ await waitFor(() => expect(onUrlUpdate).toHaveBeenCalled())
+ expect(onUrlUpdate.mock.lastCall?.[0].searchParams.has('rename')).toBe(false)
+ await act(async () => queryClient.invalidateQueries())
+ expect(
+ screen.queryByRole('textbox', { name: 'common.operation.rename' }),
+ ).not.toBeInTheDocument()
+ })
+
it('requires the display name before deleting a referenced skill from the sidebar', async () => {
const user = userEvent.setup()
mocks.skillDetail = createSkillDetail({ reference_count: 1 })
diff --git a/web/features/skills/__tests__/detail-page-navigation.spec.tsx b/web/features/skills/__tests__/detail-page-navigation.spec.tsx
index bc860259c5d..226b747f076 100644
--- a/web/features/skills/__tests__/detail-page-navigation.spec.tsx
+++ b/web/features/skills/__tests__/detail-page-navigation.spec.tsx
@@ -1,12 +1,15 @@
import { Dialog, DialogPopup, DialogPortal, DialogTitle } from '@langgenius/dify-ui/dialog'
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { beforeEach, describe, expect, it } from 'vite-plus/test'
import { gotoAnythingDialogHandle } from '@/app/components/goto-anything/dialog-handle'
+import { createNuqsTestWrapper } from '@/test/nuqs-testing'
import {
createFileTabSkillDetail,
createReferencePickerSkillDetail,
createSkillDetail,
+ createSkillVersion,
getFileTabButton,
getFileTreeButton,
getLiveMarkdownEditor,
@@ -78,6 +81,61 @@ describe('SkillDetailPage navigation', () => {
).toBeInTheDocument()
})
+ it('opens another skill in its editable draft without retaining the original view state', async () => {
+ const { default: SkillDetailPageRoute } = await import('../detail-page')
+ const user = userEvent.setup()
+ const version = createSkillVersion({ id: 'original-version', version_name: 'Original version' })
+ mocks.skillVersionsQueryOptions.mockImplementation((options) => ({
+ queryKey: ['skill-versions', options],
+ queryFn: async () => ({ data: [version] }),
+ }))
+ mocks.skillVersionDetailQueryOptions.mockImplementation((options) => ({
+ queryKey: ['skill-version-detail', options],
+ queryFn: async () => ({
+ ...version,
+ files: createSkillDetail().files,
+ }),
+ }))
+ const queryClient = new QueryClient({
+ defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
+ })
+ const { wrapper } = createNuqsTestWrapper()
+ const { rerender } = render(
+ <QueryClientProvider client={queryClient}>
+ <SkillDetailPageRoute />
+ </QueryClientProvider>,
+ { wrapper },
+ )
+
+ await user.click(
+ await screen.findByRole('button', { name: 'skill.skillManagement.detail.versionHistory' }),
+ )
+ await user.click(await screen.findByRole('button', { name: /Original version/ }))
+ expect(
+ screen.queryByRole('button', { name: 'common.operation.rename' }),
+ ).not.toBeInTheDocument()
+ await user.click(
+ screen.getByRole('button', { name: 'skill.skillManagement.detail.collapseSidebar' }),
+ )
+ expect(screen.queryByTestId('skill-detail-sidebar-header')).not.toBeInTheDocument()
+
+ mocks.routeSkillId = 'copied-skill'
+ mocks.skillDetail = createSkillDetail({ id: 'copied-skill', display_name: 'Copied skill' })
+ rerender(
+ <QueryClientProvider client={queryClient}>
+ <SkillDetailPageRoute />
+ </QueryClientProvider>,
+ )
+
+ expect(await screen.findByTestId('skill-detail-sidebar-header')).toBeInTheDocument()
+ expect(
+ await screen.findByRole('button', { name: 'common.operation.rename' }),
+ ).toHaveTextContent('Copied skill')
+ expect(
+ screen.queryByRole('button', { name: 'skill.skillManagement.detail.restoreVersion' }),
+ ).not.toBeInTheDocument()
+ })
+
it('shows the sidebar while the collapsed rail is hovered', async () => {
const user = userEvent.setup()
renderSkillDetailPage()
diff --git a/web/features/skills/__tests__/detail-page.fixture.tsx b/web/features/skills/__tests__/detail-page.fixture.tsx
index a845467feda..7a5532173d8 100644
--- a/web/features/skills/__tests__/detail-page.fixture.tsx
+++ b/web/features/skills/__tests__/detail-page.fixture.tsx
@@ -11,7 +11,8 @@ import { detectPlatform } from '@tanstack/react-hotkeys'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { fireEvent, render, screen, within } from '@testing-library/react'
import { StrictMode } from 'react'
-import { vi } from 'vite-plus/test'
+import { afterEach, vi } from 'vite-plus/test'
+import { createNuqsTestWrapper } from '@/test/nuqs-testing'
import { SkillDetailPage } from '../detail/page'
export const primaryModifier = detectPlatform() === 'mac' ? { metaKey: true } : { ctrlKey: true }
@@ -27,9 +28,12 @@ const mocks = vi.hoisted(() => ({
publishSkillMutationFn: vi.fn(),
publishSkillMutationOptions: vi.fn(),
routerPush: vi.fn(),
+ routeSkillId: 'skill-1',
restoreSkillMutationFn: vi.fn(),
saveDraftFileMutationFn: vi.fn(),
sendSkillAssistMessage: vi.fn(),
+ modelParameterRulesFetch: vi.fn<typeof fetch>(),
+ textGenerationModelListGet: vi.fn(),
defaultTextGenerationModel: undefined as
| { provider: { provider: string }; model: string }
| undefined,
@@ -112,6 +116,7 @@ vi.mock('@/app/components/main-nav/components/help-menu', () => ({
}))
vi.mock('@/app/components/header/account-setting/model-provider-page/hooks', () => ({
+ useLanguage: () => 'en_US',
useDefaultModel: () => ({
data: mocks.defaultTextGenerationModel,
}),
@@ -127,14 +132,6 @@ vi.mock('@/app/components/header/account-setting/model-provider-page/model-selec
SplitModelSelector: () => <button type="button">model-settings</button>,
}))
-vi.mock('@/service/use-common', async (importOriginal) => ({
- ...(await importOriginal<typeof import('@/service/use-common')>()),
- useModelParameterRules: () => ({
- data: { data: [] },
- isLoading: false,
- }),
-}))
-
vi.mock('@/app/components/workflow/nodes/_base/components/editor/code-editor', () => ({
default: ({ onChange, value }: { onChange?: (value: string) => void; value: string }) => (
<textarea
@@ -175,6 +172,7 @@ vi.mock('@/next/link', () => ({
}))
vi.mock('@/next/navigation', () => ({
+ useParams: () => ({ skillId: mocks.routeSkillId }),
useRouter: () => ({
push: mocks.routerPush,
}),
@@ -489,11 +487,15 @@ export function renderSkillDetailPage({
mutations: { retry: false },
},
}),
+ searchParams = '',
strict = false,
}: {
queryClient?: QueryClient
+ searchParams?: string
strict?: boolean
} = {}) {
+ const { wrapper, onUrlUpdate } = createNuqsTestWrapper({ searchParams })
+
return {
...render(
<QueryClientProvider client={queryClient}>
@@ -505,7 +507,9 @@ export function renderSkillDetailPage({
<SkillDetailPage skillId="skill-1" />
)}
</QueryClientProvider>,
+ { wrapper },
),
+ onUrlUpdate,
queryClient,
}
}
@@ -676,6 +680,14 @@ export function getMocks() {
export function resetDetailPageFixture() {
vi.useRealTimers()
vi.resetAllMocks()
+ mocks.modelParameterRulesFetch.mockImplementation(async (input) => {
+ const url = input instanceof Request ? input.url : String(input)
+ if (!url.includes('/models/parameter-rules'))
+ throw new Error(`Unexpected Skill detail request: ${url}`)
+ return Response.json({ data: [] })
+ })
+ vi.stubGlobal('fetch', mocks.modelParameterRulesFetch)
+ mocks.routeSkillId = 'skill-1'
mocks.defaultTextGenerationModel = {
provider: {
provider: 'langgenius/openai/openai',
@@ -694,6 +706,9 @@ export function resetDetailPageFixture() {
],
},
]
+ mocks.textGenerationModelListGet.mockImplementation(async () => ({
+ data: mocks.textGenerationModelList,
+ }))
mocks.skillDetail = createSkillDetail()
mocks.skillDetailGetFn.mockImplementation(async () => mocks.skillDetail)
mocks.skillDetailKey.mockImplementation((options) => ['skill-detail', options])
@@ -845,6 +860,10 @@ export function resetDetailPageFixture() {
})
}
+afterEach(() => {
+ vi.unstubAllGlobals()
+})
+
vi.mock('@tanstack/react-query', async (importOriginal) => {
const actual = await importOriginal<typeof import('@tanstack/react-query')>()
return {
@@ -856,7 +875,7 @@ vi.mock('@tanstack/react-query', async (importOriginal) => {
>
}) =>
options.queryKey[0].includes('modelTypes')
- ? { data: mocks.textGenerationModelList, isPending: false }
+ ? actual.useQuery({ ...options, queryFn: mocks.textGenerationModelListGet })
: actual.useQuery(options),
}
})
diff --git a/web/features/skills/__tests__/page.spec.tsx b/web/features/skills/__tests__/page.spec.tsx
index b935abe32a9..586a4da8e00 100644
--- a/web/features/skills/__tests__/page.spec.tsx
+++ b/web/features/skills/__tests__/page.spec.tsx
@@ -4,9 +4,9 @@ import type {
SkillResponse,
SkillTagResponse,
} from '@dify/contracts/api/console/workspaces/types.gen'
-import type { ReactNode } from 'react'
+import type { ComponentProps, ReactNode } from 'react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
-import { fireEvent, render, screen, waitFor, within } from '@testing-library/react'
+import { createEvent, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { beforeEach, describe, expect, it, vi } from 'vite-plus/test'
import { toast } from '@/app/notifications'
@@ -45,6 +45,27 @@ const mocks = vi.hoisted(() => ({
tagsQueryOptions: vi.fn((_options: unknown) => ({})),
}))
+vi.mock('react-i18next', async () => {
+ const actual = await vi.importActual<typeof import('react-i18next')>('react-i18next')
+ const { createInstance } = await vi.importActual<typeof import('i18next')>('i18next')
+ const { createReactI18nextMock } = await import('@/test/i18n-mock')
+ const { default: skillTranslations } = await import('@/i18n/locales/en-US/skill.json')
+ const i18n = createInstance()
+ await i18n.init({
+ lng: 'en-US',
+ fallbackLng: false,
+ keySeparator: false,
+ resources: { 'en-US': { skill: skillTranslations } },
+ })
+
+ return {
+ ...actual,
+ ...createReactI18nextMock(),
+ // Keep components embedded in translations, including the real Browse button.
+ Trans: (props: ComponentProps<typeof actual.Trans>) => <actual.Trans {...props} i18n={i18n} />,
+ }
+})
+
vi.mock('@/app/notifications', () => ({
toast: {
error: vi.fn(),
@@ -251,6 +272,14 @@ function renderSkillsPage(queryClient = createTestQueryClient()) {
)
}
+async function openImportDialog(user: ReturnType<typeof userEvent.setup>) {
+ await user.click(await screen.findByRole('button', { name: 'skill.skillManagement.import' }))
+
+ return screen.findByRole('dialog', {
+ name: 'skill.skillManagement.importDialog.title',
+ })
+}
+
describe('SkillsPage', () => {
beforeEach(() => {
vi.clearAllMocks()
@@ -769,35 +798,303 @@ describe('SkillsPage', () => {
})
})
- it('imports a package file and navigates to the imported skill', async () => {
+ it.each(['toolbar', 'empty state'])(
+ 'shows package requirements from the %s import entry',
+ async (entry) => {
+ const user = userEvent.setup()
+ if (entry === 'empty state') mocks.skillPages = [[]]
+ renderSkillsPage()
+
+ await user.click(
+ await screen.findByRole('button', {
+ name:
+ entry === 'toolbar'
+ ? 'skill.skillManagement.import'
+ : /skill\.skillManagement\.emptyAction\.importTitle/,
+ }),
+ )
+
+ const dialog = await screen.findByRole('dialog', {
+ name: 'skill.skillManagement.importDialog.title',
+ })
+ expect(dialog).toHaveAccessibleDescription('skill.skillManagement.importDialog.description')
+ expect(
+ within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }),
+ ).toBeDisabled()
+ expect(mocks.importSkillMutationFn).not.toHaveBeenCalled()
+ },
+ )
+
+ it.each(['refund.skill', 'refund.zip'])(
+ 'stages %s until confirmation, then navigates to the imported skill',
+ async (fileName) => {
+ const user = userEvent.setup()
+ const invalidateQueries = vi.spyOn(QueryClient.prototype, 'invalidateQueries')
+ renderSkillsPage()
+
+ const dialog = await openImportDialog(user)
+ const file = new File(['skill'], fileName, { type: 'application/zip' })
+
+ await user.upload(
+ within(dialog).getByLabelText('skill.skillManagement.importDialog.browse'),
+ file,
+ )
+ expect(within(dialog).getByText(fileName)).toBeInTheDocument()
+ expect(mocks.importSkillMutationFn).not.toHaveBeenCalled()
+ await user.click(within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }))
+
+ await waitFor(() => {
+ expect(mocks.importSkillMutationFn).toHaveBeenCalledWith(
+ {
+ body: {
+ file,
+ },
+ },
+ expect.anything(),
+ )
+ })
+ expect(toast.success).toHaveBeenCalledWith('skill.skillManagement.importSuccess')
+ expect(invalidateQueries).toHaveBeenCalledWith({ queryKey: ['skills', { type: 'query' }] })
+ expect(invalidateQueries).toHaveBeenCalledWith({ queryKey: ['skills', { type: 'infinite' }] })
+ expect(invalidateQueries).toHaveBeenCalledWith({
+ queryKey: ['skill-tags', { type: 'query' }],
+ })
+ expect(mocks.push).toHaveBeenCalledWith('/skills/imported-skill')
+ invalidateQueries.mockRestore()
+ },
+ )
+
+ it('opens the file picker from Browse and waits for confirmation before importing', async () => {
const user = userEvent.setup()
- const invalidateQueries = vi.spyOn(QueryClient.prototype, 'invalidateQueries')
- const { container } = renderSkillsPage()
+ renderSkillsPage()
+ const dialog = await openImportDialog(user)
+ const fileInput = within(dialog).getByLabelText('skill.skillManagement.importDialog.browse')
+ const openFilePicker = vi.spyOn(fileInput, 'click')
+
+ try {
+ await user.click(within(dialog).getByRole('button', { name: 'Browse' }))
+ expect(openFilePicker).toHaveBeenCalledOnce()
+ } finally {
+ openFilePicker.mockRestore()
+ }
+
+ const file = new File(['skill'], 'refund.zip', { type: 'application/zip' })
+ await user.upload(fileInput, file)
+ expect(within(dialog).getByText(file.name)).toBeInTheDocument()
+ expect(mocks.importSkillMutationFn).not.toHaveBeenCalled()
+
+ await user.click(within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }))
+ await waitFor(() =>
+ expect(mocks.importSkillMutationFn).toHaveBeenCalledWith(
+ { body: { file } },
+ expect.anything(),
+ ),
+ )
+ })
+
+ it('accepts a file drag after leaving and re-entering the drop zone, then waits for confirmation', async () => {
+ const user = userEvent.setup()
+ renderSkillsPage()
+ const dialog = await openImportDialog(user)
+ const dropZone = within(dialog).getByRole('group', {
+ name: 'skill.skillManagement.importDialog.title',
+ })
+ const description = within(dropZone).getByText('skill.skillManagement.importDialog.description')
+ const file = new File(['skill'], 'refund.zip', { type: 'application/zip' })
+ const dataTransfer = { files: [file], types: ['Files'] }
+
+ expect(fireEvent.dragEnter(dropZone, { dataTransfer })).toBe(false)
+ expect(fireEvent.dragEnter(description, { dataTransfer })).toBe(false)
+ fireEvent.dragLeave(description, { dataTransfer })
+ fireEvent.dragLeave(dropZone, { dataTransfer })
+ expect(within(dialog).queryByText(file.name)).not.toBeInTheDocument()
+
+ expect(fireEvent.dragEnter(dropZone, { dataTransfer })).toBe(false)
+ const dragOver = createEvent.dragOver(dropZone, { dataTransfer })
+ expect(fireEvent(dropZone, dragOver)).toBe(false)
+ expect(dragOver).toHaveProperty('dataTransfer.dropEffect', 'copy')
+ expect(fireEvent.drop(dropZone, { dataTransfer })).toBe(false)
+ expect(within(dialog).getByText(file.name)).toBeInTheDocument()
+ expect(mocks.importSkillMutationFn).not.toHaveBeenCalled()
+
+ await user.click(within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }))
+ await waitFor(() =>
+ expect(mocks.importSkillMutationFn).toHaveBeenCalledWith(
+ { body: { file } },
+ expect.anything(),
+ ),
+ )
+ })
- const fileInput = container.querySelector<HTMLInputElement>('input[type="file"]')
- expect(fileInput).not.toBeNull()
+ it.each(['text/plain', 'text/uri-list'])(
+ 'does not intercept %s drags or clear the selected package',
+ async (type) => {
+ const user = userEvent.setup()
+ renderSkillsPage()
+ const dialog = await openImportDialog(user)
+ const file = new File(['skill'], 'refund.skill', { type: 'application/zip' })
+ await user.upload(
+ within(dialog).getByLabelText('skill.skillManagement.importDialog.browse'),
+ file,
+ )
+ const dropZone = within(dialog).getByRole('group', {
+ name: 'skill.skillManagement.importDialog.title',
+ })
+ const dataTransfer = { files: [], types: [type] }
+
+ expect(fireEvent.dragEnter(dropZone, { dataTransfer })).toBe(true)
+ expect(fireEvent.dragOver(dropZone, { dataTransfer })).toBe(true)
+ fireEvent.dragLeave(dropZone, { dataTransfer })
+ expect(fireEvent.drop(dropZone, { dataTransfer })).toBe(true)
+ expect(within(dialog).queryByRole('alert')).not.toBeInTheDocument()
+ expect(within(dialog).getByText(file.name)).toBeInTheDocument()
+ expect(mocks.importSkillMutationFn).not.toHaveBeenCalled()
+
+ await user.click(within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }))
+ await waitFor(() =>
+ expect(mocks.importSkillMutationFn).toHaveBeenCalledWith(
+ { body: { file } },
+ expect.anything(),
+ ),
+ )
+ },
+ )
+
+ it.each(['common.operation.cancel', 'common.operation.close'])(
+ 'clears the staged package when dismissed with %s and reopened',
+ async (closeAction) => {
+ const user = userEvent.setup()
+ renderSkillsPage()
+ const dialog = await openImportDialog(user)
+ await user.upload(
+ within(dialog).getByLabelText('skill.skillManagement.importDialog.browse'),
+ new File(['skill'], 'refund.skill', { type: 'application/zip' }),
+ )
+
+ await user.click(within(dialog).getByRole('button', { name: closeAction }))
+ await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())
+ const reopenedDialog = await openImportDialog(user)
+
+ expect(within(reopenedDialog).queryByText('refund.skill')).not.toBeInTheDocument()
+ expect(
+ within(reopenedDialog).getByRole('button', { name: 'skill.skillManagement.import' }),
+ ).toBeDisabled()
+ expect(mocks.importSkillMutationFn).not.toHaveBeenCalled()
+ },
+ )
+
+ it('removes a staged package and allows selecting that same file again', async () => {
+ const user = userEvent.setup()
+ renderSkillsPage()
+ const dialog = await openImportDialog(user)
const file = new File(['skill'], 'refund.skill', { type: 'application/zip' })
+ const fileInput = within(dialog).getByLabelText('skill.skillManagement.importDialog.browse')
+ await user.upload(fileInput, file)
- await user.upload(fileInput!, file)
+ await user.click(within(dialog).getByRole('button', { name: 'common.operation.remove' }))
+ expect(within(dialog).queryByText('refund.skill')).not.toBeInTheDocument()
+ expect(
+ within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }),
+ ).toBeDisabled()
+ await user.upload(fileInput, file)
- await waitFor(() => {
+ expect(within(dialog).getByText('refund.skill')).toBeInTheDocument()
+ expect(
+ within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }),
+ ).toBeEnabled()
+ expect(mocks.importSkillMutationFn).not.toHaveBeenCalled()
+ })
+
+ it.each([
+ ['an unsupported extension', ['refund.txt']],
+ ['multiple packages', ['refund.skill', 'support.zip']],
+ ])('rejects dropping %s and allows correction before importing', async (_label, fileNames) => {
+ const user = userEvent.setup()
+ renderSkillsPage()
+ const dialog = await openImportDialog(user)
+ const dropZone = within(dialog).getByRole('group', {
+ name: 'skill.skillManagement.importDialog.title',
+ })
+
+ fireEvent.drop(dropZone, {
+ dataTransfer: {
+ files: fileNames.map((fileName) => new File(['skill'], fileName)),
+ types: ['Files'],
+ },
+ })
+ expect(within(dialog).getByRole('alert')).toHaveTextContent(
+ 'skill.skillManagement.importDialog.invalidFile',
+ )
+ expect(
+ within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }),
+ ).toBeDisabled()
+ expect(mocks.importSkillMutationFn).not.toHaveBeenCalled()
+
+ const file = new File(['skill'], 'refund.zip', { type: 'application/zip' })
+ fireEvent.drop(dropZone, { dataTransfer: { files: [file], types: ['Files'] } })
+ expect(within(dialog).queryByRole('alert')).not.toBeInTheDocument()
+ expect(within(dialog).getByText('refund.zip')).toBeInTheDocument()
+ expect(mocks.importSkillMutationFn).not.toHaveBeenCalled()
+ await user.click(within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }))
+
+ await waitFor(() =>
expect(mocks.importSkillMutationFn).toHaveBeenCalledWith(
- {
- body: {
- file,
- },
- },
+ { body: { file } },
expect.anything(),
- )
+ ),
+ )
+ })
+
+ it('keeps the package stable and prevents repeat submission or dismissal while importing', async () => {
+ const user = userEvent.setup()
+ let completeImport: ((skill: SkillResponse) => void) | undefined
+ mocks.importSkillMutationFn.mockImplementationOnce(
+ () =>
+ new Promise<SkillResponse>((resolve) => {
+ completeImport = resolve
+ }),
+ )
+ renderSkillsPage()
+ const dialog = await openImportDialog(user)
+ const fileInput = within(dialog).getByLabelText('skill.skillManagement.importDialog.browse')
+ const file = new File(['skill'], 'refund.skill', { type: 'application/zip' })
+ await user.upload(fileInput, file)
+ const importButton = within(dialog).getByRole('button', {
+ name: 'skill.skillManagement.import',
})
- expect(toast.success).toHaveBeenCalledWith('skill.skillManagement.importSuccess')
- expect(invalidateQueries).toHaveBeenCalledWith({ queryKey: ['skills', { type: 'query' }] })
- expect(invalidateQueries).toHaveBeenCalledWith({ queryKey: ['skills', { type: 'infinite' }] })
- expect(invalidateQueries).toHaveBeenCalledWith({
- queryKey: ['skill-tags', { type: 'query' }],
+ await user.click(importButton)
+
+ await waitFor(() => expect(importButton).toHaveAttribute('aria-disabled', 'true'))
+ expect(fileInput).toBeDisabled()
+ const cancelButton = within(dialog).getByRole('button', { name: 'common.operation.cancel' })
+ const closeButton = within(dialog).getByRole('button', { name: 'common.operation.close' })
+ expect(cancelButton).toBeDisabled()
+ expect(closeButton).toBeDisabled()
+ expect(within(dialog).getByRole('button', { name: 'common.operation.remove' })).toBeDisabled()
+ await user.click(importButton)
+ await user.click(cancelButton)
+ await user.click(closeButton)
+ await user.keyboard('{Escape}')
+ const dropZone = within(dialog).getByRole('group', {
+ name: 'skill.skillManagement.importDialog.title',
})
- expect(mocks.push).toHaveBeenCalledWith('/skills/imported-skill')
- invalidateQueries.mockRestore()
+ const dataTransfer = {
+ files: [new File(['other'], 'replacement.zip')],
+ types: ['Files'],
+ }
+ expect(fireEvent.dragEnter(dropZone, { dataTransfer })).toBe(false)
+ const dragOver = createEvent.dragOver(dropZone, { dataTransfer })
+ expect(fireEvent(dropZone, dragOver)).toBe(false)
+ expect(dragOver).toHaveProperty('dataTransfer.dropEffect', 'none')
+ fireEvent.dragLeave(dropZone, { dataTransfer })
+ fireEvent.drop(dropZone, { dataTransfer })
+
+ expect(dialog).toBeInTheDocument()
+ expect(within(dialog).getByText('refund.skill')).toBeInTheDocument()
+ expect(within(dialog).queryByText('replacement.zip')).not.toBeInTheDocument()
+ expect(mocks.importSkillMutationFn).toHaveBeenCalledTimes(1)
+ completeImport?.(createSkill({ id: 'imported-skill' }))
+ await waitFor(() => expect(mocks.push).toHaveBeenCalledWith('/skills/imported-skill'))
})
it.each([
@@ -831,35 +1128,54 @@ describe('SkillsPage', () => {
])('explains import errors for $error.code', async ({ error, message }) => {
const user = userEvent.setup()
mocks.importSkillMutationFn.mockRejectedValueOnce(error)
- const { container } = renderSkillsPage()
- const fileInput = container.querySelector<HTMLInputElement>('input[type="file"]')
+ renderSkillsPage()
+ const dialog = await openImportDialog(user)
const file = new File(['skill'], 'refund.skill', { type: 'application/zip' })
- await user.upload(fileInput!, file)
+ await user.upload(
+ within(dialog).getByLabelText('skill.skillManagement.importDialog.browse'),
+ file,
+ )
+ await user.click(within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }))
await waitFor(() => {
expect(toast.error).toHaveBeenCalledWith(message)
})
})
- it('explains an import error returned as a Response body', async () => {
+ it('keeps the package available for retry after explaining an error returned as a Response body', async () => {
const user = userEvent.setup()
mocks.importSkillMutationFn.mockRejectedValueOnce(
new Response(JSON.stringify({ message: 'Skill package must contain SKILL.md' }), {
status: 400,
}),
)
- const { container } = renderSkillsPage()
- const fileInput = container.querySelector<HTMLInputElement>('input[type="file"]')
+ renderSkillsPage()
+ const dialog = await openImportDialog(user)
+ const file = new File(['skill'], 'refund.skill', { type: 'application/zip' })
- await user.upload(fileInput!, new File(['skill'], 'refund.skill', { type: 'application/zip' }))
+ await user.upload(
+ within(dialog).getByLabelText('skill.skillManagement.importDialog.browse'),
+ file,
+ )
+ await user.click(within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }))
await waitFor(() => {
expect(toast.error).toHaveBeenCalledWith('skill.skillManagement.errors.missingSkillMd')
})
+ expect(within(dialog).getByText('refund.skill')).toBeInTheDocument()
+ expect(mocks.push).not.toHaveBeenCalled()
+ await user.click(within(dialog).getByRole('button', { name: 'skill.skillManagement.import' }))
+
+ await waitFor(() => expect(mocks.push).toHaveBeenCalledWith('/skills/imported-skill'))
+ expect(mocks.importSkillMutationFn).toHaveBeenCalledTimes(2)
+ expect(mocks.importSkillMutationFn).toHaveBeenLastCalledWith(
+ { body: { file } },
+ expect.anything(),
+ )
})
- it('duplicates a skill from the card action menu', async () => {
+ it('opens the returned duplicate for inline rename from the card action menu', async () => {
const user = userEvent.setup()
renderSkillsPage()
@@ -881,6 +1197,25 @@ describe('SkillsPage', () => {
)
})
expect(toast.success).toHaveBeenCalledWith('skill.skillManagement.duplicateSuccess')
+ expect(mocks.push).toHaveBeenCalledWith('/skills/duplicated-skill?rename=true')
+ })
+
+ it('stays on the skill list when duplication fails', async () => {
+ const user = userEvent.setup()
+ mocks.duplicateSkillMutationFn.mockRejectedValue(new Error('Duplicate failed'))
+ renderSkillsPage()
+
+ await user.click(
+ await screen.findByRole('button', {
+ name: 'skill.skillManagement.moreActions:{"name":"Refund approval"}',
+ }),
+ )
+ await user.click(await screen.findByText('common.operation.duplicate'))
+
+ await waitFor(() => {
+ expect(toast.error).toHaveBeenCalledWith('skill.skillManagement.duplicateFailed')
+ })
+ expect(mocks.push).not.toHaveBeenCalled()
})
it('exports a published skill from the card action menu', async () => {
diff --git a/web/features/skills/detail-page.tsx b/web/features/skills/detail-page.tsx
index 4b200e6dcee..33240896268 100644
--- a/web/features/skills/detail-page.tsx
+++ b/web/features/skills/detail-page.tsx
@@ -6,5 +6,5 @@ import { SkillDetailPage } from './detail/page'
export default function SkillDetailPageRoute() {
const { skillId } = useParams<{ skillId: string }>()
- return <SkillDetailPage skillId={skillId} />
+ return <SkillDetailPage key={skillId} skillId={skillId} />
}
diff --git a/web/features/skills/detail/builder-panel.tsx b/web/features/skills/detail/builder-panel.tsx
index 9e09ba3eae0..11665b76019 100644
--- a/web/features/skills/detail/builder-panel.tsx
+++ b/web/features/skills/detail/builder-panel.tsx
@@ -371,7 +371,18 @@ export function SkillBuilderPanel({
}
: undefined
const [selectedModel, setSelectedModel] = useState<SkillBuilderModel | undefined>()
- const activeSelectedModel = selectedModel ?? defaultBuilderModel ?? fallbackModel
+ const activeSelectedModel = [selectedModel, defaultBuilderModel, fallbackModel].find(
+ (candidate) =>
+ candidate &&
+ textGenerationModelList.some(
+ (provider) =>
+ provider.provider === candidate.provider &&
+ provider.status === ModelStatusEnum.active &&
+ provider.models.some(
+ (model) => model.model === candidate.model && model.status === ModelStatusEnum.active,
+ ),
+ ),
+ )
const canSendBuilderMessage = !!activeSelectedModel?.provider && !!activeSelectedModel?.model
const suggestions = [
t(($) => $['skillManagement.detail.builder.exampleIssueTriage']),
diff --git a/web/features/skills/detail/file-tree.tsx b/web/features/skills/detail/file-tree.tsx
index d7d471b6662..b226bd55f5c 100644
--- a/web/features/skills/detail/file-tree.tsx
+++ b/web/features/skills/detail/file-tree.tsx
@@ -61,6 +61,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@langgenius/dify-ui/too
import { formatForDisplay, matchesKeyboardEvent, useHotkey } from '@tanstack/react-hotkeys'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import copy from 'copy-to-clipboard'
+import { parseAsBoolean, useQueryState } from 'nuqs'
import { useCallback, useEffect, useEffectEvent, useId, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import SidebarLeftArrowIcon from '@/app/components/base/icons/src/vender/SidebarLeftArrowIcon'
@@ -189,7 +190,17 @@ export function FileTree({
const [draggingPaths, setDraggingPaths] = useState<string[]>([])
const [dropTarget, setDropTarget] = useState<SkillDropTarget>()
const [collapsedFolderPaths, setCollapsedFolderPaths] = useState<string[]>([])
- const [skillRenameEditing, setSkillRenameEditing] = useState(false)
+ const [renameRequested, setRenameRequested] = useQueryState(
+ 'rename',
+ parseAsBoolean.withDefault(false),
+ )
+ const [skillRenameEditing, setSkillRenameEditing] = useState(
+ () => canEdit && !readonly && renameRequested,
+ )
+ useEffect(() => {
+ // oxlint-disable-next-line eslint-react/set-state-in-effect -- Consume the URL navigation flag after the loaded detail initializes its local editor.
+ if (renameRequested) void setRenameRequested(null)
+ }, [renameRequested, setRenameRequested])
const [selectedPaths, setSelectedPaths] = useState<string[]>([])
const [selectionAnchorPath, setSelectionAnchorPath] = useState<string>()
const [clipboard, setClipboard] = useState<SkillFileClipboard>()
diff --git a/web/features/skills/detail/sidebar-actions.tsx b/web/features/skills/detail/sidebar-actions.tsx
index 5208818adc5..681dfeb43ea 100644
--- a/web/features/skills/detail/sidebar-actions.tsx
+++ b/web/features/skills/detail/sidebar-actions.tsx
@@ -212,6 +212,7 @@ export function SkillDetailSidebarActions({
const { t: tCommon } = useTranslation('common')
const queryClient = useQueryClient()
const [deleteOpen, setDeleteOpen] = useState(false)
+ const router = useRouter()
const duplicateMutation = useMutation(
consoleQuery.workspaces.current.skills.bySkillId.duplicate.post.mutationOptions(),
)
@@ -235,9 +236,10 @@ export function SkillDetailSidebarActions({
},
},
{
- onSuccess: () => {
+ onSuccess: (copiedSkill) => {
toast.success(t(($) => $['skillManagement.duplicateSuccess']))
invalidateSkillListQueries(queryClient)
+ router.push(`/skills/${copiedSkill.id}?rename=true`)
},
onError: () => {
toast.error(t(($) => $['skillManagement.duplicateFailed']))
diff --git a/web/features/skills/detail/skill-metadata.tsx b/web/features/skills/detail/skill-metadata.tsx
index 529605cc946..af8c077bbcd 100644
--- a/web/features/skills/detail/skill-metadata.tsx
+++ b/web/features/skills/detail/skill-metadata.tsx
@@ -32,6 +32,7 @@ import { SkillPublishShortcut } from './publish-bar'
import {
invalidateSkillDetail,
runSkillFileMutation,
+ setSkillDetailCache,
SKILL_TAG_CREATE_OPTION_PREFIX,
} from './shared'
@@ -54,9 +55,11 @@ export function SkillTagsEditor({
const [addOpen, setAddOpen] = useState(false)
const [showTagManagement, setShowTagManagement] = useState(false)
const [tagSearch, setTagSearch] = useState('')
- const [draftTags, setDraftTags] = useState<string[]>([])
+ const [draftTags, setDraftTags] = useState<string[] | null>(null)
+ const [isSavingTags, setIsSavingTags] = useState(false)
const persistedTags = useMemo(() => detail?.tags ?? [], [detail?.tags])
const tags = persistedTags
+ const visibleTags = draftTags ?? tags
const metadataMutation = useMutation(
consoleQuery.workspaces.current.skills.bySkillId.patch.mutationOptions(),
)
@@ -81,7 +84,7 @@ export function SkillTagsEditor({
for (const tag of tags) addOption(tag)
for (const tag of tagsQuery.data?.data ?? []) addOption(tag.tag)
- for (const tag of draftTags) addOption(tag)
+ for (const tag of draftTags ?? []) addOption(tag)
const hasExactMatch = options.some(
(tag) => tag.name.toLocaleLowerCase() === normalizedTagSearch.toLocaleLowerCase(),
)
@@ -106,10 +109,11 @@ export function SkillTagsEditor({
}),
[tagOptions],
)
- const draftTagIds = useMemo(() => draftTags.map(getSkillTagOptionId), [draftTags])
+ const draftTagIds = useMemo(() => visibleTags.map(getSkillTagOptionId), [visibleTags])
const saveTags = (nextTags: string[]) => {
- if (!detail || metadataMutation.isPending) return
+ if (!detail || isSavingTags) return
+ setIsSavingTags(true)
void runSkillFileMutation(fileMutationCoordinator, (expectedUpdatedAt) =>
metadataMutation.mutateAsync({
@@ -122,7 +126,8 @@ export function SkillTagsEditor({
},
}),
)
- .then(() => {
+ .then((nextDetail) => {
+ setSkillDetailCache(queryClient, skillId, nextDetail)
const addedTag = nextTags.some((tag) => !tags.includes(tag))
toast.success(
addedTag
@@ -141,9 +146,15 @@ export function SkillTagsEditor({
invalidateSkillDetail(queryClient, skillId)
toast.error(t(($) => $['skillManagement.detail.updateTagsFailed']))
})
+ .finally(() => {
+ setDraftTags(null)
+ setIsSavingTags(false)
+ })
}
const handleOpenChange = (open: boolean) => {
+ if (isSavingTags) return
+
if (open) {
setDraftTags(tags)
setTagSearch('')
@@ -153,10 +164,13 @@ export function SkillTagsEditor({
setAddOpen(false)
setTagSearch('')
+ if (!draftTags) return
+
const draftTagSet = new Set(draftTags)
const tagsChanged =
tags.length !== draftTags.length || tags.some((tag) => !draftTagSet.has(tag))
if (tagsChanged) saveTags(draftTags)
+ else setDraftTags(null)
}
const renderTagBadge = (tag: string) => (
@@ -168,6 +182,7 @@ export function SkillTagsEditor({
{!readonly && (
<button
type="button"
+ disabled={addOpen || isSavingTags}
aria-label={t(($) => $['skillManagement.detail.removeTag'], { tag })}
className="flex h-3 max-w-0 shrink-0 cursor-pointer items-center justify-center overflow-hidden text-text-quaternary opacity-0 outline-hidden transition-[max-width,margin,opacity] group-hover/tag:ml-0.5 group-hover/tag:max-w-3 group-hover/tag:opacity-100 hover:text-text-secondary focus-visible:ml-0.5 focus-visible:max-w-3 focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-state-accent-solid"
onClick={() => saveTags(tags.filter((currentTag) => currentTag !== tag))}
@@ -181,7 +196,7 @@ export function SkillTagsEditor({
return (
<>
<div className="mt-3 flex flex-wrap items-center gap-1">
- {tags.map(renderTagBadge)}
+ {visibleTags.map(renderTagBadge)}
{!readonly && (
<Combobox<string, true, TagComboboxItem>
items={tagItems}
@@ -196,7 +211,7 @@ export function SkillTagsEditor({
})
const createOption = createOptionId ? tagOptionById.get(createOptionId) : undefined
if (createOption && isCreateTagOption(createOption)) {
- setDraftTags((currentTags) => [...currentTags, createOption.name])
+ setDraftTags((currentTags) => [...(currentTags ?? tags), createOption.name])
setTagSearch('')
return
}
@@ -216,16 +231,16 @@ export function SkillTagsEditor({
>
<ComboboxTrigger
icon={false}
- disabled={!detail}
+ disabled={!detail || isSavingTags}
aria-label={t(($) => $['skillManagement.detail.addTag'])}
className={cn(
'h-4.5 w-auto min-w-4.5 rounded-[5px] border border-divider-deep bg-components-badge-bg-dimm p-0 text-text-tertiary hover:bg-state-base-hover-alt focus-visible:bg-state-base-hover-alt data-popup-open:bg-state-base-hover',
- tags.length === 0 && 'border-dashed px-1.25',
+ visibleTags.length === 0 && 'border-dashed px-1.25',
)}
>
<span className="flex items-center justify-center gap-0.5 system-2xs-medium-uppercase">
<span aria-hidden className="i-ri-add-line size-3 shrink-0" />
- {tags.length === 0 && t(($) => $['skillManagement.detail.addTag'])}
+ {visibleTags.length === 0 && t(($) => $['skillManagement.detail.addTag'])}
</span>
</ComboboxTrigger>
<ComboboxPortal>
diff --git a/web/features/skills/page.tsx b/web/features/skills/page.tsx
index 2f6816b4dd6..c3c4b728b19 100644
--- a/web/features/skills/page.tsx
+++ b/web/features/skills/page.tsx
@@ -2,7 +2,7 @@
import type { SkillResponse } from '@dify/contracts/api/console/workspaces/types.gen'
import type { QueryClient } from '@tanstack/react-query'
-import type { UIEvent } from 'react'
+import type { DragEvent, UIEvent } from 'react'
import {
AlertDialog,
AlertDialogActions,
@@ -14,6 +14,13 @@ import {
} from '@langgenius/dify-ui/alert-dialog'
import { Button } from '@langgenius/dify-ui/button'
import { cn } from '@langgenius/dify-ui/cn'
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogTitle,
+} from '@langgenius/dify-ui/dialog'
import {
DropdownMenu,
DropdownMenuContent,
@@ -48,6 +55,7 @@ import Link from '@/next/link'
import { useRouter } from '@/next/navigation'
import { consoleQuery } from '@/service/console'
import { downloadBlob } from '@/utils/download'
+import { formatFileSize } from '@/utils/format'
import { fetchSkillArchiveBlob } from './client'
import { SkillReferencesList, SkillReferencesListSkeleton } from './detail/skill-metadata'
import { getSkillErrorCode, getSkillErrorDetailString, normalizeSkillError } from './error'
@@ -413,6 +421,7 @@ function SkillCard({
const { t: tCommon } = useTranslation('common')
const { formatTimeFromNow } = useFormatTimeFromNow()
const queryClient = useQueryClient()
+ const router = useRouter()
const nameId = useId()
const descriptionId = useId()
const draftStatusId = useId()
@@ -446,9 +455,10 @@ function SkillCard({
},
},
{
- onSuccess: () => {
+ onSuccess: (copiedSkill) => {
toast.success(t(($) => $['skillManagement.duplicateSuccess']))
invalidateSkillListQueries(queryClient)
+ router.push(`/skills/${copiedSkill.id}?rename=true`)
},
onError: () => {
toast.error(t(($) => $['skillManagement.duplicateFailed']))
@@ -844,12 +854,175 @@ function SkillGrid({ state }: SkillGridProps) {
)
}
+function ImportSkillDialogForm({
+ importing,
+ onImport,
+}: {
+ importing: boolean
+ onImport: (file: File) => void
+}) {
+ const { t } = useTranslation('skill')
+ const { t: tCommon } = useTranslation('common')
+ const inputRef = useRef<HTMLInputElement>(null)
+ const dragDepthRef = useRef(0)
+ const descriptionId = useId()
+ const errorId = useId()
+ const [file, setFile] = useState<File>()
+ const [invalidFile, setInvalidFile] = useState(false)
+ const [dragging, setDragging] = useState(false)
+
+ const selectFiles = (files: File[]) => {
+ if (importing || files.length === 0) return
+ const [selectedFile] = files
+ if (files.length !== 1 || !selectedFile || !/\.(?:zip|skill)$/iu.test(selectedFile.name)) {
+ setFile(undefined)
+ setInvalidFile(true)
+ return
+ }
+ setFile(selectedFile)
+ setInvalidFile(false)
+ }
+
+ const hasFiles = (event: DragEvent<HTMLDivElement>) =>
+ Array.from(event.dataTransfer.types).includes('Files')
+
+ return (
+ <form
+ onSubmit={(event) => {
+ event.preventDefault()
+ if (file && !importing) onImport(file)
+ }}
+ >
+ <div className="flex items-center justify-between border-b border-divider-subtle px-5 py-4">
+ <DialogTitle className="title-2xl-semi-bold text-text-primary">
+ {t(($) => $['skillManagement.importDialog.title'])}
+ </DialogTitle>
+ <DialogClose
+ disabled={importing}
+ render={
+ <IconButton aria-label={tCommon(($) => $['operation.close'])}>
+ <span aria-hidden className="i-ri-close-line size-4" />
+ </IconButton>
+ }
+ />
+ </div>
+ <div className="p-5">
+ <div
+ role="group"
+ aria-label={t(($) => $['skillManagement.importDialog.title'])}
+ className={cn(
+ 'flex min-h-34 flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-components-dropzone-border-alt bg-components-dropzone-bg-alt px-5 py-4',
+ dragging && 'border-components-dropzone-border-accent bg-components-dropzone-bg-accent',
+ )}
+ onDragEnter={(event) => {
+ if (!hasFiles(event)) return
+ event.preventDefault()
+ event.stopPropagation()
+ if (importing) return
+ dragDepthRef.current += 1
+ setDragging(true)
+ }}
+ onDragOver={(event) => {
+ if (!hasFiles(event)) return
+ event.preventDefault()
+ event.stopPropagation()
+ event.dataTransfer.dropEffect = importing ? 'none' : 'copy'
+ }}
+ onDragLeave={(event) => {
+ if (!hasFiles(event)) return
+ event.preventDefault()
+ event.stopPropagation()
+ dragDepthRef.current = Math.max(0, dragDepthRef.current - 1)
+ if (dragDepthRef.current === 0) setDragging(false)
+ }}
+ onDrop={(event) => {
+ if (!hasFiles(event)) return
+ event.preventDefault()
+ event.stopPropagation()
+ dragDepthRef.current = 0
+ setDragging(false)
+ selectFiles(Array.from(event.dataTransfer.files))
+ }}
+ >
+ <input
+ ref={inputRef}
+ type="file"
+ accept=".zip,.skill,application/zip"
+ className="hidden"
+ aria-label={t(($) => $['skillManagement.importDialog.browse'])}
+ aria-describedby={invalidFile ? `${descriptionId} ${errorId}` : descriptionId}
+ aria-invalid={invalidFile}
+ disabled={importing}
+ onChange={(event) => {
+ selectFiles(Array.from(event.currentTarget.files ?? []))
+ event.currentTarget.value = ''
+ }}
+ />
+ <span aria-hidden className="i-ri-file-zip-line size-8 shrink-0 text-text-quaternary" />
+ {file ? (
+ <div className="flex w-full items-center justify-center gap-3">
+ <div className="min-w-0 text-center">
+ <p className="system-sm-medium wrap-anywhere text-text-secondary">{file.name}</p>
+ <p className="system-xs-regular text-text-tertiary">{formatFileSize(file.size)}</p>
+ </div>
+ <IconButton
+ aria-label={tCommon(($) => $['operation.remove'])}
+ disabled={importing}
+ onClick={() => setFile(undefined)}
+ >
+ <span aria-hidden className="i-ri-close-line size-4" />
+ </IconButton>
+ </div>
+ ) : (
+ <p className="text-center system-md-medium text-text-secondary">
+ <Trans
+ ns="skill"
+ i18nKey={($) => $['skillManagement.importDialog.dropzone']}
+ components={{
+ browse: (
+ <button
+ type="button"
+ disabled={importing}
+ aria-describedby={invalidFile ? `${descriptionId} ${errorId}` : descriptionId}
+ className="cursor-pointer rounded-sm text-text-accent focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden disabled:cursor-not-allowed"
+ onClick={() => inputRef.current?.click()}
+ />
+ ),
+ }}
+ />
+ </p>
+ )}
+ <DialogDescription
+ id={descriptionId}
+ className="text-center system-sm-regular text-text-tertiary"
+ >
+ {t(($) => $['skillManagement.importDialog.description'])}
+ </DialogDescription>
+ </div>
+ {invalidFile && (
+ <p id={errorId} role="alert" className="mt-2 system-xs-regular text-text-destructive">
+ {t(($) => $['skillManagement.importDialog.invalidFile'])}
+ </p>
+ )}
+ </div>
+ <div className="flex justify-end gap-2 border-t border-divider-subtle px-5 py-4">
+ <DialogClose disabled={importing} render={<Button />}>
+ {tCommon(($) => $['operation.cancel'])}
+ </DialogClose>
+ <Button type="submit" variant="primary" disabled={!file} loading={importing}>
+ {t(($) => $['skillManagement.import'])}
+ </Button>
+ </div>
+ </form>
+ )
+}
+
export default function SkillsPage() {
const { t } = useTranslation('skill')
const router = useRouter()
const queryClient = useQueryClient()
const { canDelete, canEdit } = useSkillPermissions()
- const importInputRef = useRef<HTMLInputElement>(null)
+ const [importOpen, setImportOpen] = useState(false)
const listViewportRef = useRef<HTMLDivElement>(null)
const [showTagManagementModal, setShowTagManagementModal] = useState(false)
const [keyword] = useQueryState(skillQueryParamNames.keyword, skillKeywordQueryParser)
@@ -910,8 +1083,8 @@ export default function SkillsPage() {
)
}
- const handleFileChange = (file: File | undefined) => {
- if (!file || importMutation.isPending || createMutation.isPending) return
+ const handleImport = (file: File) => {
+ if (!canEdit || importMutation.isPending || createMutation.isPending) return
importMutation.mutate(
{
@@ -921,6 +1094,7 @@ export default function SkillsPage() {
},
{
onSuccess: (skill) => {
+ setImportOpen(false)
toast.success(t(($) => $['skillManagement.importSuccess']))
invalidateSkillListQueries(queryClient)
router.push(`/skills/${skill.id}`)
@@ -946,9 +1120,6 @@ export default function SkillsPage() {
}
toast.error(t(($) => $['skillManagement.importFailed']))
},
- onSettled: () => {
- if (importInputRef.current) importInputRef.current.value = ''
- },
},
)
}
@@ -1010,7 +1181,7 @@ export default function SkillsPage() {
creating: createMutation.isPending,
importing: importMutation.isPending,
onCreate: handleCreate,
- onImport: () => importInputRef.current?.click(),
+ onImport: () => setImportOpen(true),
}
: undefined,
}
@@ -1051,19 +1222,12 @@ export default function SkillsPage() {
</h1>
</div>
<div className="mt-3.5">
- <input
- ref={importInputRef}
- type="file"
- accept=".zip,.skill,application/zip"
- className="hidden"
- onChange={(event) => handleFileChange(event.currentTarget.files?.[0])}
- />
<SkillsToolbar
canEdit={canEdit}
creating={createMutation.isPending}
importing={importMutation.isPending}
onCreate={handleCreate}
- onImport={() => importInputRef.current?.click()}
+ onImport={() => setImportOpen(true)}
onOpenTagManagement={() => setShowTagManagementModal(true)}
/>
</div>
@@ -1086,6 +1250,16 @@ export default function SkillsPage() {
</ScrollAreaScrollbar>
</ScrollArea>
</div>
+ <Dialog
+ open={importOpen}
+ onOpenChange={(open) => {
+ if (!importMutation.isPending) setImportOpen(open)
+ }}
+ >
+ <DialogContent className="p-0">
+ <ImportSkillDialogForm importing={importMutation.isPending} onImport={handleImport} />
+ </DialogContent>
+ </Dialog>
<SkillListTagManagementModal
show={showTagManagementModal}
onClose={() => setShowTagManagementModal(false)}
diff --git a/web/i18n/locales/ar-TN/skill.json b/web/i18n/locales/ar-TN/skill.json
index b4e12ee82bb..09c550c37f1 100644
--- a/web/i18n/locales/ar-TN/skill.json
+++ b/web/i18n/locales/ar-TN/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "توجد بالفعل مهارة اسمها \"{{name}}\". أعد تسميته إلى SKILL.md وقم باستيراده مرة أخرى.",
"skillManagement.errors.workspaceLimit": "وصلت مساحة العمل الخاصة بك إلى الحد الأقصى وهو 500 مهارة. احذف مهارة لإضافة مهارة جديدة.",
"skillManagement.import": "استيراد",
+ "skillManagement.importDialog.browse": "تصفّح",
+ "skillManagement.importDialog.description": "يدعم حزم .zip و.skill التي تحتوي على SKILL.md.",
+ "skillManagement.importDialog.dropzone": "اسحب ملفًا وأفلته، أو <browse>تصفّح الملفات</browse>",
+ "skillManagement.importDialog.invalidFile": "اختر حزمة واحدة بصيغة .zip أو .skill.",
+ "skillManagement.importDialog.title": "استيراد مهارة",
"skillManagement.importFailed": "فشل استيراد المهارة.",
"skillManagement.importSuccess": "Skill مستورد.",
"skillManagement.listLabel": "مهارات مساحة العمل",
diff --git a/web/i18n/locales/az-AZ/skill.json b/web/i18n/locales/az-AZ/skill.json
index 9dc09941db0..c092cc57426 100644
--- a/web/i18n/locales/az-AZ/skill.json
+++ b/web/i18n/locales/az-AZ/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "\"{{name}}\" adlı bacarıq artıq mövcuddur. SKILL.md faylında adını dəyişin və yenidən idxal edin.",
"skillManagement.errors.workspaceLimit": "İş məkanınız 500 bacarıq həddinə çatıb. Yeni bacarıq əlavə etmək üçün bir bacarığı silin.",
"skillManagement.import": "İdxal et",
+ "skillManagement.importDialog.browse": "Fayl seç",
+ "skillManagement.importDialog.description": "SKILL.md faylını ehtiva edən .zip və .skill paketləri dəstəklənir.",
+ "skillManagement.importDialog.dropzone": "Faylı sürükləyib buraxın və ya <browse>fayl seçin</browse>",
+ "skillManagement.importDialog.invalidFile": "Bir .zip və ya .skill paketi seçin.",
+ "skillManagement.importDialog.title": "Bacarıq idxal et",
"skillManagement.importFailed": "Bacarığı idxal etmək mümkün olmadı.",
"skillManagement.importSuccess": "Bacarıq idxal edildi.",
"skillManagement.listLabel": "İş məkanının bacarıqları",
diff --git a/web/i18n/locales/de-DE/skill.json b/web/i18n/locales/de-DE/skill.json
index afacee20835..ce6b6defa0a 100644
--- a/web/i18n/locales/de-DE/skill.json
+++ b/web/i18n/locales/de-DE/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Ein Skill mit dem Namen „{{name}}“ ist bereits vorhanden. Benennen Sie es in SKILL.md um und importieren Sie es erneut.",
"skillManagement.errors.workspaceLimit": "Ihr Arbeitsbereich hat die Grenze von 500 Fertigkeiten erreicht. Löschen Sie eine Fertigkeit, um eine neue hinzuzufügen.",
"skillManagement.import": "Importieren",
+ "skillManagement.importDialog.browse": "Durchsuchen",
+ "skillManagement.importDialog.description": "Unterstützt .zip- und .skill-Pakete, die SKILL.md enthalten.",
+ "skillManagement.importDialog.dropzone": "Datei hierher ziehen oder <browse>durchsuchen</browse>",
+ "skillManagement.importDialog.invalidFile": "Wählen Sie ein .zip- oder .skill-Paket aus.",
+ "skillManagement.importDialog.title": "Skill importieren",
"skillManagement.importFailed": "Der Skill konnte nicht importiert werden.",
"skillManagement.importSuccess": "Skill importiert.",
"skillManagement.listLabel": "Fähigkeiten am Arbeitsplatz",
diff --git a/web/i18n/locales/en-US/skill.json b/web/i18n/locales/en-US/skill.json
index 883139cc51f..98509cb4e71 100644
--- a/web/i18n/locales/en-US/skill.json
+++ b/web/i18n/locales/en-US/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "A skill named \"{{name}}\" already exists. Rename it in SKILL.md and import again.",
"skillManagement.errors.workspaceLimit": "Your workspace has reached the limit of 500 skills. Delete a skill to add a new one.",
"skillManagement.import": "Import",
+ "skillManagement.importDialog.browse": "Browse",
+ "skillManagement.importDialog.description": "Supports .zip and .skill packages that contain SKILL.md.",
+ "skillManagement.importDialog.dropzone": "Drag and drop file, or <browse>Browse</browse>",
+ "skillManagement.importDialog.invalidFile": "Choose one .zip or .skill package.",
+ "skillManagement.importDialog.title": "Import skill",
"skillManagement.importFailed": "Failed to import skill.",
"skillManagement.importSuccess": "Skill imported.",
"skillManagement.listLabel": "Workspace skills",
diff --git a/web/i18n/locales/es-ES/skill.json b/web/i18n/locales/es-ES/skill.json
index 11c8ffec02b..0be38e4b610 100644
--- a/web/i18n/locales/es-ES/skill.json
+++ b/web/i18n/locales/es-ES/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Ya existe una habilidad denominada \"{{name}}\". Cambie el nombre a SKILL.md e impórtelo nuevamente.",
"skillManagement.errors.workspaceLimit": "Tu espacio de trabajo ha alcanzado el límite de 500 habilidades. Elimina una habilidad para agregar una nueva.",
"skillManagement.import": "Importar",
+ "skillManagement.importDialog.browse": "Examinar",
+ "skillManagement.importDialog.description": "Se admiten paquetes .zip y .skill que contengan SKILL.md.",
+ "skillManagement.importDialog.dropzone": "Arrastra y suelta un archivo o <browse>examina los archivos</browse>",
+ "skillManagement.importDialog.invalidFile": "Selecciona un paquete .zip o .skill.",
+ "skillManagement.importDialog.title": "Importar habilidad",
"skillManagement.importFailed": "No se pudo importar la habilidad.",
"skillManagement.importSuccess": "Skill importado.",
"skillManagement.listLabel": "Habilidades en el espacio de trabajo",
diff --git a/web/i18n/locales/fa-IR/skill.json b/web/i18n/locales/fa-IR/skill.json
index 7d340c2285b..b6dc84c4b34 100644
--- a/web/i18n/locales/fa-IR/skill.json
+++ b/web/i18n/locales/fa-IR/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "مهارتی به نام \"{{name}}\" از قبل وجود دارد. نام آن را در SKILL.md تغییر دهید و دوباره وارد کنید.",
"skillManagement.errors.workspaceLimit": "فضای کاری شما به حداکثر 500 مهارت رسیده است. برای افزودن مهارت جدید، مهارت را حذف کنید.",
"skillManagement.import": "وارد کردن",
+ "skillManagement.importDialog.browse": "مرور",
+ "skillManagement.importDialog.description": "بسته‌های .zip و .skill حاوی SKILL.md پشتیبانی می‌شوند.",
+ "skillManagement.importDialog.dropzone": "فایل را بکشید و رها کنید یا <browse>مرور کنید</browse>",
+ "skillManagement.importDialog.invalidFile": "یک بستهٔ .zip یا .skill انتخاب کنید.",
+ "skillManagement.importDialog.title": "وارد کردن مهارت",
"skillManagement.importFailed": "وارد کردن مهارت انجام نشد.",
"skillManagement.importSuccess": "Skill وارد شده است.",
"skillManagement.listLabel": "مهارت های فضای کاری",
diff --git a/web/i18n/locales/fr-FR/skill.json b/web/i18n/locales/fr-FR/skill.json
index 3ecc767e05f..db58c27c594 100644
--- a/web/i18n/locales/fr-FR/skill.json
+++ b/web/i18n/locales/fr-FR/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Une compétence nommée \"{{name}}\" existe déjà. Renommez-le en SKILL.md et importez-le à nouveau.",
"skillManagement.errors.workspaceLimit": "Votre espace de travail a atteint la limite de 500 compétences. Supprimez une compétence pour en ajouter une nouvelle.",
"skillManagement.import": "Importer",
+ "skillManagement.importDialog.browse": "Parcourir",
+ "skillManagement.importDialog.description": "Les paquets .zip et .skill contenant SKILL.md sont pris en charge.",
+ "skillManagement.importDialog.dropzone": "Glissez-déposez un fichier ou <browse>parcourez les fichiers</browse>",
+ "skillManagement.importDialog.invalidFile": "Choisissez un paquet .zip ou .skill.",
+ "skillManagement.importDialog.title": "Importer une compétence",
"skillManagement.importFailed": "Échec de l'importation de la compétence.",
"skillManagement.importSuccess": "Skill importé.",
"skillManagement.listLabel": "Compétences en espace de travail",
diff --git a/web/i18n/locales/hi-IN/skill.json b/web/i18n/locales/hi-IN/skill.json
index 32696bf5ec4..82481ce545a 100644
--- a/web/i18n/locales/hi-IN/skill.json
+++ b/web/i18n/locales/hi-IN/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "\"{{name}}\" नामक कौशल पहले से मौजूद है। इसे SKILL.md में नाम बदलें और फिर से आयात करें।",
"skillManagement.errors.workspaceLimit": "आपका कार्यक्षेत्र 500 कौशल की सीमा तक पहुंच गया है। नया जोड़ने के लिए एक कौशल हटाएँ।",
"skillManagement.import": "आयात करें",
+ "skillManagement.importDialog.browse": "ब्राउज़ करें",
+ "skillManagement.importDialog.description": "SKILL.md वाली .zip और .skill पैकेज फ़ाइलें समर्थित हैं।",
+ "skillManagement.importDialog.dropzone": "फ़ाइल खींचकर छोड़ें, या <browse>ब्राउज़ करें</browse>",
+ "skillManagement.importDialog.invalidFile": "एक .zip या .skill पैकेज चुनें।",
+ "skillManagement.importDialog.title": "स्किल इम्पोर्ट करें",
"skillManagement.importFailed": "कौशल आयात करने में विफल.",
"skillManagement.importSuccess": "Skill आयातित.",
"skillManagement.listLabel": "कार्यस्थल कौशल",
diff --git a/web/i18n/locales/id-ID/skill.json b/web/i18n/locales/id-ID/skill.json
index 17b93d404ca..24f8ab9da2e 100644
--- a/web/i18n/locales/id-ID/skill.json
+++ b/web/i18n/locales/id-ID/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Skill bernama \"{{name}}\" sudah ada. Ubah namanya menjadi SKILL.md dan impor lagi.",
"skillManagement.errors.workspaceLimit": "Ruang kerja Anda telah mencapai batas 500 keterampilan. Hapus keterampilan untuk menambahkan keterampilan baru.",
"skillManagement.import": "Impor",
+ "skillManagement.importDialog.browse": "Telusuri",
+ "skillManagement.importDialog.description": "Mendukung paket .zip dan .skill yang berisi SKILL.md.",
+ "skillManagement.importDialog.dropzone": "Seret dan lepas file, atau <browse>telusuri file</browse>",
+ "skillManagement.importDialog.invalidFile": "Pilih satu paket .zip atau .skill.",
+ "skillManagement.importDialog.title": "Impor keterampilan",
"skillManagement.importFailed": "Gagal mengimpor keterampilan.",
"skillManagement.importSuccess": "Skill diimpor.",
"skillManagement.listLabel": "Keterampilan ruang kerja",
diff --git a/web/i18n/locales/it-IT/skill.json b/web/i18n/locales/it-IT/skill.json
index 19b818ec852..e71a6a63639 100644
--- a/web/i18n/locales/it-IT/skill.json
+++ b/web/i18n/locales/it-IT/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Esiste già una competenza denominata \"{{name}}\". Rinominalo in SKILL.md e importalo di nuovo.",
"skillManagement.errors.workspaceLimit": "La tua area di lavoro ha raggiunto il limite di 500 competenze. Elimina una competenza per aggiungerne una nuova.",
"skillManagement.import": "Importa",
+ "skillManagement.importDialog.browse": "Sfoglia",
+ "skillManagement.importDialog.description": "Sono supportati i pacchetti .zip e .skill che contengono SKILL.md.",
+ "skillManagement.importDialog.dropzone": "Trascina e rilascia un file oppure <browse>sfoglia</browse>",
+ "skillManagement.importDialog.invalidFile": "Scegli un pacchetto .zip o .skill.",
+ "skillManagement.importDialog.title": "Importa competenza",
"skillManagement.importFailed": "Impossibile importare la competenza.",
"skillManagement.importSuccess": "Skill importato.",
"skillManagement.listLabel": "Abilità nello spazio di lavoro",
diff --git a/web/i18n/locales/ja-JP/skill.json b/web/i18n/locales/ja-JP/skill.json
index ddd892f6696..3e2750a16b6 100644
--- a/web/i18n/locales/ja-JP/skill.json
+++ b/web/i18n/locales/ja-JP/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "「{{name}}」という名前のスキルはすでに存在します。SKILL.md で名前を変更してから、もう一度インポートしてください。",
"skillManagement.errors.workspaceLimit": "ワークスペースに追加できるスキルは 500 個までです。スキルを 1 つ削除してから、新しいスキルを追加してください。",
"skillManagement.import": "インポート",
+ "skillManagement.importDialog.browse": "参照",
+ "skillManagement.importDialog.description": "SKILL.md を含む .zip および .skill パッケージに対応しています。",
+ "skillManagement.importDialog.dropzone": "ファイルをドラッグ&ドロップするか、<browse>参照</browse>",
+ "skillManagement.importDialog.invalidFile": ".zip または .skill パッケージを1つ選択してください。",
+ "skillManagement.importDialog.title": "スキルをインポート",
"skillManagement.importFailed": "スキルのインポートに失敗しました。",
"skillManagement.importSuccess": "Skill がインポートされました。",
"skillManagement.listLabel": "ワークスペースのスキル",
diff --git a/web/i18n/locales/ko-KR/skill.json b/web/i18n/locales/ko-KR/skill.json
index 816757fd74b..f2fcf8feb13 100644
--- a/web/i18n/locales/ko-KR/skill.json
+++ b/web/i18n/locales/ko-KR/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "\"{{name}}\"라는 스킬이 이미 존재합니다. SKILL.md에서 이름을 바꾸고 다시 가져옵니다.",
"skillManagement.errors.workspaceLimit": "작업 영역이 스킬 한도인 500개에 도달했습니다. 새로운 스킬을 추가하려면 스킬을 삭제하세요.",
"skillManagement.import": "가져오기",
+ "skillManagement.importDialog.browse": "찾아보기",
+ "skillManagement.importDialog.description": "SKILL.md가 포함된 .zip 및 .skill 패키지를 지원합니다.",
+ "skillManagement.importDialog.dropzone": "파일을 끌어다 놓거나 <browse>찾아보기</browse>",
+ "skillManagement.importDialog.invalidFile": ".zip 또는 .skill 패키지 하나를 선택하세요.",
+ "skillManagement.importDialog.title": "스킬 가져오기",
"skillManagement.importFailed": "스킬을 가져오지 못했습니다.",
"skillManagement.importSuccess": "Skill 가져왔습니다.",
"skillManagement.listLabel": "작업 공간 기술",
diff --git a/web/i18n/locales/lo-LA/skill.json b/web/i18n/locales/lo-LA/skill.json
index da4e872b5a1..c9903517745 100644
--- a/web/i18n/locales/lo-LA/skill.json
+++ b/web/i18n/locales/lo-LA/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "ທັກສະທີ່ມີຊື່ວ່າ \"{{name}}\" ມີຢູ່ແລ້ວ. ປ່ຽນຊື່ມັນຢູ່ໃນ SKILL.md ແລະນໍາເຂົ້າອີກເທື່ອຫນຶ່ງ.",
"skillManagement.errors.workspaceLimit": "ພື້ນທີ່ເຮັດວຽກຂອງທ່ານຮອດຂີດຈຳກັດຂອງ 500 ທັກສະແລ້ວ. ລຶບທັກສະເພື່ອເພີ່ມອັນໃໝ່.",
"skillManagement.import": "ນຳເຂົ້າ",
+ "skillManagement.importDialog.browse": "ເລືອກໄຟລ໌",
+ "skillManagement.importDialog.description": "ຮອງຮັບແພັກເກັດ .zip ແລະ .skill ທີ່ມີ SKILL.md.",
+ "skillManagement.importDialog.dropzone": "ລາກແລະວາງໄຟລ໌ ຫຼື <browse>ເລືອກໄຟລ໌</browse>",
+ "skillManagement.importDialog.invalidFile": "ເລືອກແພັກເກັດ .zip ຫຼື .skill ໜຶ່ງໄຟລ໌.",
+ "skillManagement.importDialog.title": "ນຳເຂົ້າທັກສະ",
"skillManagement.importFailed": "ລົ້ມເຫລວໃນການນໍາເຂົ້າທັກສະ.",
"skillManagement.importSuccess": "Skill ນໍາເຂົ້າ.",
"skillManagement.listLabel": "ທັກສະພື້ນທີ່ເຮັດວຽກ",
diff --git a/web/i18n/locales/nl-NL/skill.json b/web/i18n/locales/nl-NL/skill.json
index dbf592bef27..a77c46b42e7 100644
--- a/web/i18n/locales/nl-NL/skill.json
+++ b/web/i18n/locales/nl-NL/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Er bestaat al een vaardigheid met de naam \"{{name}}\". Hernoem het in SKILL.md en importeer opnieuw.",
"skillManagement.errors.workspaceLimit": "Uw werkruimte heeft de limiet van 500 vaardigheden bereikt. Verwijder een vaardigheid om een ​​nieuwe toe te voegen.",
"skillManagement.import": "Importeren",
+ "skillManagement.importDialog.browse": "Bladeren",
+ "skillManagement.importDialog.description": "Ondersteunt .zip- en .skill-pakketten die SKILL.md bevatten.",
+ "skillManagement.importDialog.dropzone": "Sleep een bestand hierheen of <browse>blader door bestanden</browse>",
+ "skillManagement.importDialog.invalidFile": "Kies één .zip- of .skill-pakket.",
+ "skillManagement.importDialog.title": "Vaardigheid importeren",
"skillManagement.importFailed": "Kan vaardigheid niet importeren.",
"skillManagement.importSuccess": "Skill geïmporteerd.",
"skillManagement.listLabel": "Vaardigheden op het gebied van de werkruimte",
diff --git a/web/i18n/locales/pl-PL/skill.json b/web/i18n/locales/pl-PL/skill.json
index 7f8d1337292..e3952e309e8 100644
--- a/web/i18n/locales/pl-PL/skill.json
+++ b/web/i18n/locales/pl-PL/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Umiejętność o nazwie „{{name}}” już istnieje. Zmień jego nazwę na SKILL.md i zaimportuj ponownie.",
"skillManagement.errors.workspaceLimit": "Twój obszar roboczy osiągnął limit 500 umiejętności. Usuń umiejętność, aby dodać nową.",
"skillManagement.import": "Importuj",
+ "skillManagement.importDialog.browse": "Przeglądaj",
+ "skillManagement.importDialog.description": "Obsługiwane są pakiety .zip i .skill zawierające plik SKILL.md.",
+ "skillManagement.importDialog.dropzone": "Przeciągnij i upuść plik lub <browse>przeglądaj pliki</browse>",
+ "skillManagement.importDialog.invalidFile": "Wybierz jeden pakiet .zip lub .skill.",
+ "skillManagement.importDialog.title": "Importuj umiejętność",
"skillManagement.importFailed": "Nie udało się zaimportować umiejętności.",
"skillManagement.importSuccess": "Skill zaimportowano.",
"skillManagement.listLabel": "Umiejętności obszaru roboczego",
diff --git a/web/i18n/locales/pt-BR/skill.json b/web/i18n/locales/pt-BR/skill.json
index 9e8d9075739..d9730f7772b 100644
--- a/web/i18n/locales/pt-BR/skill.json
+++ b/web/i18n/locales/pt-BR/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Uma habilidade chamada \"{{name}}\" já existe. Renomeie-o para SKILL.md e importe novamente.",
"skillManagement.errors.workspaceLimit": "Seu espaço de trabalho atingiu o limite de 500 habilidades. Exclua uma habilidade para adicionar uma nova.",
"skillManagement.import": "Importar",
+ "skillManagement.importDialog.browse": "Procurar",
+ "skillManagement.importDialog.description": "Aceita pacotes .zip e .skill que contenham SKILL.md.",
+ "skillManagement.importDialog.dropzone": "Arraste e solte um arquivo ou <browse>procure nos arquivos</browse>",
+ "skillManagement.importDialog.invalidFile": "Escolha um pacote .zip ou .skill.",
+ "skillManagement.importDialog.title": "Importar habilidade",
"skillManagement.importFailed": "Falha ao importar habilidade.",
"skillManagement.importSuccess": "Skill importado.",
"skillManagement.listLabel": "Habilidades de espaço de trabalho",
diff --git a/web/i18n/locales/ro-RO/skill.json b/web/i18n/locales/ro-RO/skill.json
index 230e0dbe548..8a129e81fcc 100644
--- a/web/i18n/locales/ro-RO/skill.json
+++ b/web/i18n/locales/ro-RO/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "O abilitate numită „{{name}}” există deja. Redenumiți-l în SKILL.md și importați din nou.",
"skillManagement.errors.workspaceLimit": "Spațiul tău de lucru a atins limita de 500 de aptitudini. Ștergeți o abilitate pentru a adăuga una nouă.",
"skillManagement.import": "Importați",
+ "skillManagement.importDialog.browse": "Răsfoiește",
+ "skillManagement.importDialog.description": "Sunt acceptate pachetele .zip și .skill care conțin SKILL.md.",
+ "skillManagement.importDialog.dropzone": "Trage și plasează un fișier sau <browse>răsfoiește fișierele</browse>",
+ "skillManagement.importDialog.invalidFile": "Alege un pachet .zip sau .skill.",
+ "skillManagement.importDialog.title": "Importă abilitatea",
"skillManagement.importFailed": "Nu s-a putut importa abilitate.",
"skillManagement.importSuccess": "Skill importat.",
"skillManagement.listLabel": "Abilități de spațiu de lucru",
diff --git a/web/i18n/locales/ru-RU/skill.json b/web/i18n/locales/ru-RU/skill.json
index eb3f70eef19..5cc4e4968ae 100644
--- a/web/i18n/locales/ru-RU/skill.json
+++ b/web/i18n/locales/ru-RU/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Навык под названием «{{name}}» уже существует. Переименуйте его в SKILL.md и импортируйте снова.",
"skillManagement.errors.workspaceLimit": "Ваше рабочее пространство достигло предела в 500 навыков. Удалите навык, чтобы добавить новый.",
"skillManagement.import": "Импортировать",
+ "skillManagement.importDialog.browse": "Обзор",
+ "skillManagement.importDialog.description": "Поддерживаются пакеты .zip и .skill, содержащие SKILL.md.",
+ "skillManagement.importDialog.dropzone": "Перетащите файл или <browse>выберите его</browse>",
+ "skillManagement.importDialog.invalidFile": "Выберите один пакет .zip или .skill.",
+ "skillManagement.importDialog.title": "Импорт навыка",
"skillManagement.importFailed": "Не удалось импортировать навык.",
"skillManagement.importSuccess": "Skill импортирован.",
"skillManagement.listLabel": "Навыки рабочего пространства",
diff --git a/web/i18n/locales/sl-SI/skill.json b/web/i18n/locales/sl-SI/skill.json
index 9896fd83f8d..53093e32aba 100644
--- a/web/i18n/locales/sl-SI/skill.json
+++ b/web/i18n/locales/sl-SI/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Spretnost z imenom \"{{name}}\" že obstaja. Preimenujte ga v SKILL.md in znova uvozite.",
"skillManagement.errors.workspaceLimit": "Vaš delovni prostor je dosegel omejitev 500 veščin. Izbrišite veščino, da dodate novo.",
"skillManagement.import": "Uvozi",
+ "skillManagement.importDialog.browse": "Prebrskaj",
+ "skillManagement.importDialog.description": "Podprti so paketi .zip in .skill, ki vsebujejo SKILL.md.",
+ "skillManagement.importDialog.dropzone": "Povlecite in spustite datoteko ali <browse>prebrskajte datoteke</browse>",
+ "skillManagement.importDialog.invalidFile": "Izberite en paket .zip ali .skill.",
+ "skillManagement.importDialog.title": "Uvozi veščino",
"skillManagement.importFailed": "Spretnosti ni bilo mogoče uvoziti.",
"skillManagement.importSuccess": "Skill uvoženo.",
"skillManagement.listLabel": "Spretnosti delovnega prostora",
diff --git a/web/i18n/locales/th-TH/skill.json b/web/i18n/locales/th-TH/skill.json
index bf1c6c6d2c4..0641cc33cc5 100644
--- a/web/i18n/locales/th-TH/skill.json
+++ b/web/i18n/locales/th-TH/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "มีทักษะชื่อ \"{{name}}\" อยู่แล้ว เปลี่ยนชื่อใน SKILL.md และนำเข้าอีกครั้ง",
"skillManagement.errors.workspaceLimit": "พื้นที่ทำงานของคุณถึงขีดจำกัด 500 ทักษะแล้ว ลบทักษะเพื่อเพิ่มทักษะใหม่",
"skillManagement.import": "นำเข้า",
+ "skillManagement.importDialog.browse": "เรียกดูไฟล์",
+ "skillManagement.importDialog.description": "รองรับแพ็กเกจ .zip และ .skill ที่มี SKILL.md",
+ "skillManagement.importDialog.dropzone": "ลากและวางไฟล์ หรือ<browse>เรียกดูไฟล์</browse>",
+ "skillManagement.importDialog.invalidFile": "เลือกแพ็กเกจ .zip หรือ .skill หนึ่งไฟล์",
+ "skillManagement.importDialog.title": "นำเข้าทักษะ",
"skillManagement.importFailed": "ไม่สามารถนำเข้าทักษะได้",
"skillManagement.importSuccess": "Skill นำเข้า",
"skillManagement.listLabel": "ทักษะพื้นที่ทำงาน",
diff --git a/web/i18n/locales/tr-TR/skill.json b/web/i18n/locales/tr-TR/skill.json
index ac6af9541bd..f9fb1bf77f9 100644
--- a/web/i18n/locales/tr-TR/skill.json
+++ b/web/i18n/locales/tr-TR/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "\"{{name}}\" adlı bir beceri zaten mevcut. SKILL.md'de yeniden adlandırın ve tekrar içe aktarın.",
"skillManagement.errors.workspaceLimit": "Çalışma alanınız 500 beceri sınırına ulaştı. Yeni bir beceri eklemek için bir beceriyi silin.",
"skillManagement.import": "İçe Aktar",
+ "skillManagement.importDialog.browse": "Göz at",
+ "skillManagement.importDialog.description": "SKILL.md içeren .zip ve .skill paketleri desteklenir.",
+ "skillManagement.importDialog.dropzone": "Bir dosyayı sürükleyip bırakın veya <browse>göz atın</browse>",
+ "skillManagement.importDialog.invalidFile": "Bir .zip veya .skill paketi seçin.",
+ "skillManagement.importDialog.title": "Beceriyi içe aktar",
"skillManagement.importFailed": "Beceri içe aktarılamadı.",
"skillManagement.importSuccess": "Skill içe aktarıldı.",
"skillManagement.listLabel": "Çalışma alanı becerileri",
diff --git a/web/i18n/locales/uk-UA/skill.json b/web/i18n/locales/uk-UA/skill.json
index 26468cfe4f6..43d99938873 100644
--- a/web/i18n/locales/uk-UA/skill.json
+++ b/web/i18n/locales/uk-UA/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Уміння під назвою \"{{name}}\" уже існує. Перейменуйте його в SKILL.md і імпортуйте знову.",
"skillManagement.errors.workspaceLimit": "Ваша робоча область досягла ліміту в 500 навичок. Видаліть навик, щоб додати новий.",
"skillManagement.import": "Імпортувати",
+ "skillManagement.importDialog.browse": "Огляд",
+ "skillManagement.importDialog.description": "Підтримуються пакети .zip і .skill, що містять SKILL.md.",
+ "skillManagement.importDialog.dropzone": "Перетягніть файл або <browse>виберіть його</browse>",
+ "skillManagement.importDialog.invalidFile": "Виберіть один пакет .zip або .skill.",
+ "skillManagement.importDialog.title": "Імпорт навички",
"skillManagement.importFailed": "Не вдалося імпортувати навички.",
"skillManagement.importSuccess": "Skill імпортовано.",
"skillManagement.listLabel": "Навички роботи",
diff --git a/web/i18n/locales/vi-VN/skill.json b/web/i18n/locales/vi-VN/skill.json
index 221e406b000..1f9f4fda4ac 100644
--- a/web/i18n/locales/vi-VN/skill.json
+++ b/web/i18n/locales/vi-VN/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "Một kỹ năng có tên \"{{name}}\" đã tồn tại. Đổi tên nó thành SKILL.md và nhập lại.",
"skillManagement.errors.workspaceLimit": "Không gian làm việc của bạn đã đạt đến giới hạn 500 kỹ năng. Xóa một kỹ năng để thêm một kỹ năng mới.",
"skillManagement.import": "Nhập",
+ "skillManagement.importDialog.browse": "Duyệt tệp",
+ "skillManagement.importDialog.description": "Hỗ trợ các gói .zip và .skill có chứa SKILL.md.",
+ "skillManagement.importDialog.dropzone": "Kéo và thả tệp hoặc <browse>duyệt tệp</browse>",
+ "skillManagement.importDialog.invalidFile": "Chọn một gói .zip hoặc .skill.",
+ "skillManagement.importDialog.title": "Nhập kỹ năng",
"skillManagement.importFailed": "Không thể nhập kỹ năng.",
"skillManagement.importSuccess": "Skill đã nhập.",
"skillManagement.listLabel": "Kỹ năng không gian làm việc",
diff --git a/web/i18n/locales/zh-Hans/skill.json b/web/i18n/locales/zh-Hans/skill.json
index b238a2ff3a3..e507bef5687 100644
--- a/web/i18n/locales/zh-Hans/skill.json
+++ b/web/i18n/locales/zh-Hans/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "名为「{{name}}」的 Skill 已存在。请在 SKILL.md 中修改名称后重新导入。",
"skillManagement.errors.workspaceLimit": "工作空间最多可添加 500 个 Skill。请先删除一个 Skill,再添加新 Skill。",
"skillManagement.import": "导入",
+ "skillManagement.importDialog.browse": "浏览文件",
+ "skillManagement.importDialog.description": "支持包含 SKILL.md 的 .zip 和 .skill 压缩包。",
+ "skillManagement.importDialog.dropzone": "拖放文件,或<browse>浏览文件</browse>",
+ "skillManagement.importDialog.invalidFile": "请选择一个 .zip 或 .skill 压缩包。",
+ "skillManagement.importDialog.title": "导入 Skill",
"skillManagement.importFailed": "Skill 导入失败。",
"skillManagement.importSuccess": "Skill 已导入。",
"skillManagement.listLabel": "Workspace Skills",
diff --git a/web/i18n/locales/zh-Hant/skill.json b/web/i18n/locales/zh-Hant/skill.json
index 6680ec3e5b5..241ed834cb9 100644
--- a/web/i18n/locales/zh-Hant/skill.json
+++ b/web/i18n/locales/zh-Hant/skill.json
@@ -189,6 +189,11 @@
"skillManagement.errors.nameConflict": "名為「{{name}}」的技能已存在。將其重新命名為SKILL.md並再次匯入。",
"skillManagement.errors.workspaceLimit": "您的工作區已達到 500 項技能的限制。刪除一項技能以新增技能。",
"skillManagement.import": "匯入",
+ "skillManagement.importDialog.browse": "瀏覽檔案",
+ "skillManagement.importDialog.description": "支援包含 SKILL.md 的 .zip 和 .skill 壓縮檔。",
+ "skillManagement.importDialog.dropzone": "拖放檔案,或<browse>瀏覽檔案</browse>",
+ "skillManagement.importDialog.invalidFile": "請選擇一個 .zip 或 .skill 壓縮檔。",
+ "skillManagement.importDialog.title": "匯入 Skill",
"skillManagement.importFailed": "Skill 匯入失敗。",
"skillManagement.importSuccess": "Skill 已匯入。",
"skillManagement.listLabel": "Workspace Skills",