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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: improve snippets list accessibility (#41579)
Joelc25b439d8b68
diff --git a/web/app/components/snippet-list/__tests__/index.spec.tsx b/web/app/components/snippet-list/__tests__/index.spec.tsxindex e63bb7cb42b..758ecbcc5c5 100644--- a/web/app/components/snippet-list/__tests__/index.spec.tsx+++ b/web/app/components/snippet-list/__tests__/index.spec.tsx@@ -1,4 +1,4 @@-import { fireEvent, screen } from '@testing-library/react'+import { fireEvent, screen, within } from '@testing-library/react'import userEvent from '@testing-library/user-event'import * as React from 'react'import { createConsoleQueryWrapper } from '@/test/console/query-data'@@ -244,12 +244,17 @@ const renderList = ({accountProfile: { id: 'creator-1' },systemFeatures: { branding: { enabled: brandingEnabled } },})-- return renderWithNuqs(+ const createList = () => (<ConsoleQueryWrapper><SnippetList />- </ConsoleQueryWrapper>,+ </ConsoleQueryWrapper>)+ const rendered = renderWithNuqs(createList())++ return {+ ...rendered,+ rerenderList: () => rendered.rerender(createList()),+ }}describe('SnippetList', () => {@@ -288,15 +293,6 @@ describe('SnippetList', () => {expect(screen.getByTestId('tag-management-modal')).toBeInTheDocument()})- it('lays out snippet cards with auto-fill grid columns', () => {- renderList()-- const card = screen.getByRole('link', { name: /Sales Snippet/ }).closest('article')- const grid = card?.parentElement-- expect(grid).toHaveClass('grid', 'grid-cols-[repeat(auto-fill,minmax(296px,1fr))]')- })-it('passes creator, tag, and search filters to the snippets list query', () => {mockQueryState.tagIDs = ['tag-1', 'tag-2']mockQueryState.keywords = 'sales'@@ -421,13 +417,15 @@ describe('SnippetList', () => {it('does not fetch or render snippets without snippet list permissions', () => {mockWorkspacePermissionKeys.mockReturnValue([])- renderList()+ const { container } = renderList()+ const list = container.querySelector<HTMLElement>('[aria-busy]')+ if (!list) throw new Error('Snippet list did not render its result owner')expect(mockUseInfiniteSnippetList).toHaveBeenCalledWith(expect.any(Object), {enabled: false,})expect(screen.queryByRole('link', { name: /Sales Snippet/ })).not.toBeInTheDocument()- expect(screen.getByText('workflow.tabs.noSnippetsFound')).toBeInTheDocument()+ expect(within(list).getByText('workflow.tabs.noSnippetsFound')).toBeInTheDocument()})it('shows the create button for users with snippet create permission even when they are not workspace editors', () => {@@ -457,24 +455,194 @@ describe('SnippetList', () => {fetchNextPage: mockFetchNextPage,})+ const { container } = renderList()+ const list = container.querySelector<HTMLElement>('[aria-busy]')+ if (!list) throw new Error('Snippet list did not render its result owner')++ expect(within(list).getByText('workflow.tabs.noSnippetsFound')).toBeInTheDocument()+ expect(screen.getByRole('status')).toHaveTextContent('workflow.tabs.noSnippetsFound')+ })++ it('announces request failures and preserves retry focus while refetching', async () => {+ const user = userEvent.setup()+ const requestError = new Error('Request failed')+ mockUseInfiniteSnippetList.mockReturnValue({+ ...mockSnippetListState,+ data: { pages: [] },+ error: requestError,+ refetch: mockRefetch,+ fetchNextPage: mockFetchNextPage,+ })++ const { rerenderList } = renderList()+ const status = screen.getByRole('status')+ const retryButton = screen.getByRole('button', { name: 'common.operation.retry' })++ expect(screen.queryByRole('alert')).not.toBeInTheDocument()+ expect(status).toHaveTextContent('common.errorBoundary.title')+ expect(status).not.toHaveTextContent('workflow.tabs.noSnippetsFound')++ await user.click(retryButton)++ expect(mockRefetch).toHaveBeenCalledTimes(1)+ expect(retryButton).toHaveFocus()++ mockUseInfiniteSnippetList.mockReturnValue({+ ...mockSnippetListState,+ data: { pages: [] },+ error: requestError,+ isFetching: true,+ refetch: mockRefetch,+ fetchNextPage: mockFetchNextPage,+ })+ rerenderList()++ expect(screen.getByRole('button', { name: 'common.operation.retry' })).toBe(retryButton)+ expect(retryButton).toHaveFocus()+ expect(status).toHaveTextContent('common.loading')++ mockUseInfiniteSnippetList.mockReturnValue({+ ...mockSnippetListState,+ data: { pages: [] },+ error: requestError,+ refetch: mockRefetch,+ fetchNextPage: mockFetchNextPage,+ })+ rerenderList()++ expect(screen.getByRole('button', { name: 'common.operation.retry' })).toBe(retryButton)+ expect(retryButton).toHaveFocus()+ expect(status).toHaveTextContent('common.errorBoundary.title')+ })++ it('announces the current result count', () => {renderList()- expect(screen.getByText('workflow.tabs.noSnippetsFound')).toBeInTheDocument()+ expect(screen.getByRole('status')).toHaveTextContent(+ 'common.operation.searchCount:{"count":1,"content":"workflow.tabs.snippets"}',+ )})- it('renders loading and next-page skeleton cards', () => {+ it('announces the total result count when only the first page is loaded', () => {+ mockUseInfiniteSnippetList.mockReturnValue({+ ...mockSnippetListState,+ data: {+ pages: [+ {+ ...mockSnippetListState.data.pages[0]!,+ total: 80,+ has_more: true,+ },+ ],+ },+ hasNextPage: true,+ refetch: mockRefetch,+ fetchNextPage: mockFetchNextPage,+ })++ renderList()++ expect(screen.getByRole('status')).toHaveTextContent(+ 'common.operation.searchCount:{"count":80,"content":"workflow.tabs.snippets"}',+ )+ })++ it('announces kept-data refreshes when the result count stays the same', () => {+ const { rerenderList } = renderList()+ const status = screen.getByRole('status')+ const grid = screen.getByRole('link', { name: /Sales Snippet/ }).closest('[aria-busy]')++ expect(status.closest('[aria-busy]')).toBeNull()+ expect(status).toHaveTextContent(+ 'common.operation.searchCount:{"count":1,"content":"workflow.tabs.snippets"}',+ )++ mockUseInfiniteSnippetList.mockReturnValue({+ ...mockSnippetListState,+ isFetching: true,+ refetch: mockRefetch,+ fetchNextPage: mockFetchNextPage,+ })+ rerenderList()++ expect(screen.getByRole('status')).toBe(status)+ expect(status).toHaveTextContent('common.loading')+ expect(grid).toHaveAttribute('aria-busy', 'true')++ mockUseInfiniteSnippetList.mockReturnValue({+ ...mockSnippetListState,+ data: {+ pages: [+ {+ ...mockSnippetListState.data.pages[0]!,+ data: [+ {+ ...mockSnippetListState.data.pages[0]!.data[0]!,+ id: 'snippet-2',+ name: 'Support Snippet',+ },+ ],+ },+ ],+ },+ refetch: mockRefetch,+ fetchNextPage: mockFetchNextPage,+ })+ rerenderList()++ expect(screen.getByRole('status')).toBe(status)+ expect(status).toHaveTextContent(+ 'common.operation.searchCount:{"count":1,"content":"workflow.tabs.snippets"}',+ )+ expect(screen.getByRole('link', { name: /Support Snippet/ })).toBeInTheDocument()+ expect(grid).toHaveAttribute('aria-busy', 'false')+ })++ it('mounts an empty live region before announcing initial results', () => {mockUseInfiniteSnippetList.mockReturnValue({...mockSnippetListState,data: { pages: [] },+ isFetching: true,isLoading: true,+ refetch: mockRefetch,+ fetchNextPage: mockFetchNextPage,+ })++ const { container, rerenderList } = renderList()+ const status = screen.getByRole('status')++ expect(status).toBeEmptyDOMElement()+ expect(status.closest('[aria-busy]')).toBeNull()+ expect(container.querySelector('[aria-busy="true"]')).toBeInTheDocument()++ mockUseInfiniteSnippetList.mockReturnValue({+ ...mockSnippetListState,+ refetch: mockRefetch,+ fetchNextPage: mockFetchNextPage,+ })+ rerenderList()++ expect(screen.getByRole('status')).toBe(status)+ expect(status).toHaveTextContent(+ 'common.operation.searchCount:{"count":1,"content":"workflow.tabs.snippets"}',+ )+ })++ it('keeps current results available while the next page is loading', () => {+ mockUseInfiniteSnippetList.mockReturnValue({+ ...mockSnippetListState,isFetchingNextPage: true,refetch: mockRefetch,fetchNextPage: mockFetchNextPage,})- const { container } = renderList()+ renderList()+ const card = screen.getByRole('link', { name: /Sales Snippet/ })+ const list = card.closest('[aria-busy]')- expect(container.querySelectorAll('.animate-pulse')).toHaveLength(9)+ expect(card).toBeInTheDocument()+ expect(list).toHaveAttribute('aria-busy', 'true')+ expect(screen.getByRole('status')).toHaveTextContent('common.loading')})it('fetches the next page when the scroll anchor intersects', () => {diff --git a/web/app/components/snippet-list/__tests__/reflow.browser.spec.tsx b/web/app/components/snippet-list/__tests__/reflow.browser.spec.tsxnew file mode 100644index 00000000000..629c80c43ae--- /dev/null+++ b/web/app/components/snippet-list/__tests__/reflow.browser.spec.tsx@@ -0,0 +1,230 @@+import type { SnippetListItem } from '@/types/snippet'+import { QueryClient, QueryClientProvider } from '@tanstack/react-query'+import { createStore, Provider } from 'jotai'+import { page } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import { seedRegisteredConsoleStateFixture } from '@/test/console/state-fixture'+import SnippetList from '..'++const mockUseInfiniteSnippetList = vi.hoisted(() => vi.fn())+const mockQueryState = vi.hoisted(() => ({+ creatorIDs: [] as string[],+ keywords: '',+ tagIDs: [] as string[],+}))++vi.mock('@/service/use-snippets', () => ({+ useConfirmSnippetImportMutation: () => ({ isPending: false, mutateAsync: vi.fn() }),+ useCreateSnippetMutation: () => ({ isPending: false, mutateAsync: vi.fn() }),+ useDeleteSnippetMutation: () => ({ isPending: false, mutate: vi.fn() }),+ useExportSnippetMutation: () => ({ mutateAsync: vi.fn() }),+ useImportSnippetDSLMutation: () => ({ isPending: false, mutateAsync: vi.fn() }),+ useInfiniteSnippetList: (params: unknown, options: unknown) =>+ mockUseInfiniteSnippetList(params, options),+ useUpdateSnippetMutation: () => ({ isPending: false, mutate: vi.fn() }),+}))++vi.mock('../hooks/use-snippets-query-state', () => ({+ useSnippetsQueryState: () => ({+ query: mockQueryState,+ setCreatorIDs: vi.fn(),+ setKeywords: vi.fn(),+ setTagIDs: vi.fn(),+ }),+}))++vi.mock('@/context/workspace-state', async () => {+ const { createWorkspaceStateModuleMock } = await import('@/test/console/state-fixture')+ return createWorkspaceStateModuleMock(() => ({+ currentWorkspace: { id: 'workspace-1' },+ isLoadingCurrentWorkspace: false,+ }))+})++vi.mock('@/context/permission-state', async () => {+ const { createPermissionStateModuleMock } = await import('@/test/console/state-fixture')+ return createPermissionStateModuleMock(() => ({+ workspacePermissionKeys: ['snippets.create_and_modify'],+ }))+})++vi.mock('@/service/use-common', () => ({+ useMembers: () => ({+ data: {+ accounts: [+ {+ avatar_url: null,+ id: 'creator-1',+ name: 'Alice',+ status: 'active',+ },+ ],+ },+ }),+}))++vi.mock('@/features/account-profile/client', () => ({+ userProfileQueryOptions: () => ({+ queryFn: async () => ({ profile: { id: 'creator-1' } }),+ queryKey: ['account-profile'],+ }),+}))++vi.mock('@/service/client', () => ({+ consoleClient: {+ snippets: {+ bySnippetId: {+ workflows: {+ draft: {+ post: vi.fn(),+ },+ },+ },+ },+ },+ consoleQuery: {+ tags: {+ get: {+ key: () => ['tags'],+ queryOptions: ({ input }: { input: { query: { type: string } } }) => ({+ queryFn: async () => [],+ queryKey: ['tags', input.query.type],+ }),+ },+ post: {+ mutationOptions: () => ({ mutationFn: vi.fn() }),+ },+ },+ },+}))++vi.mock('@/next/navigation', () => ({+ useRouter: () => ({ push: vi.fn() }),+ useSearchParams: () => new URLSearchParams(),+}))++vi.mock('@/next/dynamic', () => ({+ default: () => () => null,+}))++vi.mock('@/hooks/use-document-title', () => ({+ default: vi.fn(),+}))++const snippet: SnippetListItem = {+ created_at: 1704067200,+ created_by: 'creator-1',+ description: 'Builds a sales follow-up.',+ id: 'snippet-1',+ is_published: true,+ name: 'Sales Snippet',+ tags: [],+ type: 'node',+ updated_at: 1704153600,+ updated_by: 'creator-1',+ use_count: 12,+ version: 1,+}++const expectWithinHorizontalBounds = (element: Element, container: Element) => {+ const elementRect = element.getBoundingClientRect()+ const containerRect = container.getBoundingClientRect()++ expect(elementRect.left).toBeGreaterThanOrEqual(containerRect.left - 0.5)+ expect(elementRect.right).toBeLessThanOrEqual(containerRect.right + 0.5)+}++const renderSnippetList = async () => {+ const queryClient = new QueryClient({+ defaultOptions: {+ queries: { retry: false },+ },+ })+ queryClient.setQueryData(['account-profile'], { profile: { id: 'creator-1' } })+ queryClient.setQueryData(['tags', 'snippet'], [])++ const store = createStore()+ seedRegisteredConsoleStateFixture(store)++ return render(+ <QueryClientProvider client={queryClient}>+ <Provider store={store}>+ <main+ aria-label="Snippet list page"+ className="flex h-dvh w-full min-w-0 flex-col overflow-hidden"+ style={{ width: 320 }}+ >+ <SnippetList />+ </main>+ </Provider>+ </QueryClientProvider>,+ )+}++describe('Snippet list reflow', () => {+ beforeEach(() => {+ vi.clearAllMocks()+ mockUseInfiniteSnippetList.mockReturnValue({+ data: {+ pages: [+ {+ data: [snippet],+ has_more: false,+ limit: 30,+ page: 1,+ total: 1,+ },+ ],+ },+ error: null,+ fetchNextPage: vi.fn(),+ hasNextPage: false,+ isFetching: false,+ isFetchingNextPage: false,+ isLoading: false,+ refetch: vi.fn(),+ })+ })++ afterEach(async () => {+ await page.viewport(1280, 720)+ })++ it('keeps the real filters, search, create action, and card overflow-free with 320 CSS pixels available', async () => {+ // This isolates SnippetList's 320px component contract; the route shell owns page-level width.+ await page.viewport(400, 800)+ const screen = await renderSnippetList()+ const main = screen.getByRole('main', { name: 'Snippet list page' })+ const creatorFilter = screen.getByRole('combobox', {+ name: 'app.studio.filters.creators',+ })+ const statusFilter = screen.getByRole('button', {+ name: /workflow\.common\.published \/ snippet\.draft/i,+ })+ const tagFilter = screen.getByRole('combobox', { name: 'common.tag.placeholder' })+ const search = screen.getByRole('searchbox', { name: 'workflow.tabs.searchSnippets' })+ const createAction = screen.getByRole('button', { name: 'snippet.create' })+ const card = screen.getByRole('article')++ await expect+ .element(screen.getByRole('heading', { name: 'workflow.tabs.snippets' }))+ .toBeVisible()+ await expect.element(creatorFilter).toBeVisible()+ await expect.element(statusFilter).toBeVisible()+ await expect.element(tagFilter).toBeVisible()+ await expect.element(search).toBeVisible()+ await expect.element(createAction).toBeVisible()+ await expect.element(card).toBeVisible()++ const mainElement = main.element()+ const gridElement = card.element().closest('[aria-busy]')+ if (!gridElement) throw new Error('Snippet card did not render inside the list grid')++ expect(mainElement.clientWidth).toBe(320)+ expect(mainElement.scrollWidth).toBe(mainElement.clientWidth)+ expect(gridElement.scrollWidth).toBe(gridElement.clientWidth)+ ;[creatorFilter, statusFilter, tagFilter, search, createAction, card].forEach((locator) => {+ expectWithinHorizontalBounds(locator.element(), mainElement)+ })+ })+})diff --git a/web/app/components/snippet-list/components/__tests__/snippet-card.spec.tsx b/web/app/components/snippet-list/components/__tests__/snippet-card.spec.tsxindex 13383d3c5d3..d4d824a6c9d 100644--- a/web/app/components/snippet-list/components/__tests__/snippet-card.spec.tsx+++ b/web/app/components/snippet-list/components/__tests__/snippet-card.spec.tsx@@ -108,6 +108,7 @@ vi.mock('@/features/tag-management/components/tag-selector', () => ({onTagsChange: () => voidvalue: Array<{ name: string }>canBindOrUnbindTags?: boolean+ contextLabel?: string}) => {mockRenderTagSelector(props)const { onOpenTagManagement, onTagsChange, value } = props@@ -190,7 +191,11 @@ describe('SnippetCard', () => {it('should render supported operations only', async () => {render(<SnippetCard snippet={createSnippet()} />)- fireEvent.click(screen.getByRole('button', { name: 'common.operation.more' }))+ fireEvent.click(+ screen.getByRole('button', {+ name: 'common.operation.moreActionsFor:{"name":"Tone Rewriter"}',+ }),+ )expect(await screen.findByRole('menuitem', { name: 'snippet.menu.editInfo' }),@@ -210,7 +215,9 @@ describe('SnippetCard', () => {render(<SnippetCard snippet={createSnippet()} />)expect(- screen.queryByRole('button', { name: 'common.operation.more' }),+ screen.queryByRole('button', {+ name: 'common.operation.moreActionsFor:{"name":"Tone Rewriter"}',+ }),).not.toBeInTheDocument()})@@ -220,7 +227,11 @@ describe('SnippetCard', () => {render(<SnippetCard snippet={createSnippet()} />)- fireEvent.click(screen.getByRole('button', { name: 'common.operation.more' }))+ fireEvent.click(+ screen.getByRole('button', {+ name: 'common.operation.moreActionsFor:{"name":"Tone Rewriter"}',+ }),+ )expect(await screen.findByRole('menuitem', { name: 'snippet.menu.editInfo' }),@@ -239,7 +250,11 @@ describe('SnippetCard', () => {render(<SnippetCard snippet={createSnippet()} />)- fireEvent.click(screen.getByRole('button', { name: 'common.operation.more' }))+ fireEvent.click(+ screen.getByRole('button', {+ name: 'common.operation.moreActionsFor:{"name":"Tone Rewriter"}',+ }),+ )expect(screen.queryByRole('menuitem', { name: 'snippet.menu.editInfo' }),@@ -261,6 +276,7 @@ describe('SnippetCard', () => {expect.objectContaining({type: 'snippet',targetId: 'snippet-1',+ contextLabel: 'Tone Rewriter',canBindOrUnbindTags: true,}),)@@ -308,7 +324,11 @@ describe('SnippetCard', () => {render(<SnippetCard snippet={createSnippet()} />)- fireEvent.click(screen.getByRole('button', { name: 'common.operation.more' }))+ fireEvent.click(+ screen.getByRole('button', {+ name: 'common.operation.moreActionsFor:{"name":"Tone Rewriter"}',+ }),+ )fireEvent.click(await screen.findByRole('menuitem', { name: 'snippet.menu.exportSnippet' }))await waitFor(() => {@@ -327,7 +347,11 @@ describe('SnippetCard', () => {render(<SnippetCard snippet={createSnippet()} />)- fireEvent.click(screen.getByRole('button', { name: 'common.operation.more' }))+ fireEvent.click(+ screen.getByRole('button', {+ name: 'common.operation.moreActionsFor:{"name":"Tone Rewriter"}',+ }),+ )fireEvent.click(await screen.findByRole('menuitem', { name: 'snippet.menu.exportSnippet' }))await waitFor(() => {@@ -343,7 +367,11 @@ describe('SnippetCard', () => {render(<SnippetCard snippet={createSnippet()} onRefresh={mockOnRefresh} />)- fireEvent.click(screen.getByRole('button', { name: 'common.operation.more' }))+ fireEvent.click(+ screen.getByRole('button', {+ name: 'common.operation.moreActionsFor:{"name":"Tone Rewriter"}',+ }),+ )fireEvent.click(await screen.findByRole('menuitem', { name: 'snippet.menu.editInfo' }))fireEvent.change(screen.getByPlaceholderText('workflow.snippet.namePlaceholder'), {target: { value: 'Updated Snippet' },@@ -377,7 +405,11 @@ describe('SnippetCard', () => {render(<SnippetCard snippet={createSnippet({ description: '' })} onRefresh={mockOnRefresh} />)- fireEvent.click(screen.getByRole('button', { name: 'common.operation.more' }))+ fireEvent.click(+ screen.getByRole('button', {+ name: 'common.operation.moreActionsFor:{"name":"Tone Rewriter"}',+ }),+ )fireEvent.click(await screen.findByRole('menuitem', { name: 'snippet.menu.editInfo' }))fireEvent.change(screen.getByPlaceholderText('workflow.snippet.namePlaceholder'), {target: { value: 'Updated Snippet' },@@ -406,7 +438,11 @@ describe('SnippetCard', () => {render(<SnippetCard snippet={createSnippet()} onRefresh={mockOnRefresh} />)- fireEvent.click(screen.getByRole('button', { name: 'common.operation.more' }))+ fireEvent.click(+ screen.getByRole('button', {+ name: 'common.operation.moreActionsFor:{"name":"Tone Rewriter"}',+ }),+ )fireEvent.click(await screen.findByRole('menuitem', { name: 'snippet.menu.deleteSnippet' }))fireEvent.click(screen.getByRole('button', { name: 'snippet.menu.deleteSnippet' }))@@ -433,7 +469,11 @@ describe('SnippetCard', () => {render(<SnippetCard snippet={createSnippet()} onRefresh={mockOnRefresh} />)- fireEvent.click(screen.getByRole('button', { name: 'common.operation.more' }))+ fireEvent.click(+ screen.getByRole('button', {+ name: 'common.operation.moreActionsFor:{"name":"Tone Rewriter"}',+ }),+ )fireEvent.click(await screen.findByRole('menuitem', { name: 'snippet.menu.deleteSnippet' }))fireEvent.click(screen.getByRole('button', { name: 'snippet.menu.deleteSnippet' }))diff --git a/web/app/components/snippet-list/components/__tests__/snippet-create-button.spec.tsx b/web/app/components/snippet-list/components/__tests__/snippet-create-button.spec.tsxindex b7f8eb5f2a9..f61422e78a0 100644--- a/web/app/components/snippet-list/components/__tests__/snippet-create-button.spec.tsx+++ b/web/app/components/snippet-list/components/__tests__/snippet-create-button.spec.tsx@@ -96,6 +96,7 @@ describe('SnippetCreateButton', () => {render(<SnippetCreateButton />)fireEvent.click(screen.getByRole('button', { name: 'snippet.create' }))+ expect(screen.getByRole('dialog', { name: 'snippet.createFrom' })).toBeInTheDocument()fireEvent.click(screen.getByRole('button', { name: 'snippet.createFromBlank' }))expect(screen.getByText('workflow.snippet.createDialogTitle')).toBeInTheDocument()@@ -152,9 +153,9 @@ describe('SnippetCreateButton', () => {fireEvent.click(screen.getByRole('button', { name: 'snippet.create' }))fireEvent.click(screen.getByRole('button', { name: 'snippet.importDSLFile' }))- expect(screen.getByText('snippet.importDialogTitle')).toBeInTheDocument()+ expect(screen.getByRole('dialog', { name: 'snippet.importDialogTitle' })).toBeInTheDocument()- fireEvent.click(screen.getByRole('button', { name: 'snippet.importFromDSLUrl' }))+ fireEvent.click(screen.getByRole('tab', { name: 'snippet.importFromDSLUrl' }))fireEvent.change(screen.getByPlaceholderText('snippet.importFromDSLUrlPlaceholder'), {target: { value: 'https://example.com/snippet.yml' },})diff --git a/web/app/components/snippet-list/components/snippet-card.tsx b/web/app/components/snippet-list/components/snippet-card.tsxindex 21ff28e4021..4330ffb746b 100644--- a/web/app/components/snippet-list/components/snippet-card.tsx+++ b/web/app/components/snippet-list/components/snippet-card.tsx@@ -180,6 +180,7 @@ const SnippetCard = ({type="snippet"targetId={snippet.id}value={snippet.tags}+ contextLabel={snippet.name}onOpenTagManagement={onOpenTagManagement}onTagsChange={onTagsChange}canBindOrUnbindTags={canManageSnippet}@@ -202,7 +203,10 @@ const SnippetCard = ({onOpenChange={setIsOperationsMenuOpen}><DropdownMenuTrigger- aria-label={tCommon(($) => $['operation.more'], { ns: 'common' })}+ aria-label={tCommon(($) => $['operation.moreActionsFor'], {+ ns: 'common',+ name: snippet.name,+ })}className="flex size-8 items-center justify-center rounded-md border-none bg-transparent p-2 hover:bg-state-base-hover focus-visible:bg-state-base-hover focus-visible:inset-ring-1 focus-visible:inset-ring-components-input-border-active data-popup-open:bg-state-base-hover data-popup-open:shadow-none"onClick={(e) => {e.stopPropagation()@@ -210,9 +214,6 @@ const SnippetCard = ({}}><div className="flex size-8 cursor-pointer items-center justify-center rounded-md">- <span className="sr-only">- {tCommon(($) => $['operation.more'], { ns: 'common' })}- </span><span aria-hidden className="i-ri-more-fill size-4 text-text-tertiary" /></div></DropdownMenuTrigger>diff --git a/web/app/components/snippet-list/components/snippet-create-button.tsx b/web/app/components/snippet-list/components/snippet-create-button.tsxindex b174b4b1b0c..ef00e2c395d 100644--- a/web/app/components/snippet-list/components/snippet-create-button.tsx+++ b/web/app/components/snippet-list/components/snippet-create-button.tsx@@ -1,7 +1,7 @@'use client'import { Button } from '@langgenius/dify-ui/button'-import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'+import { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '@langgenius/dify-ui/popover'import { useState } from 'react'import { useTranslation } from 'react-i18next'import { CreateSnippetDialog } from '@/app/components/snippets/create-snippet-dialog'@@ -40,9 +40,9 @@ const SnippetCreateButton = () => {sideOffset={6}className="w-[228px] rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-1 shadow-lg backdrop-blur-xs">- <div className="px-2 pt-2 pb-1 text-xs leading-4.5 font-medium text-text-tertiary">+ <PopoverTitle className="px-2 pt-2 pb-1 text-xs leading-4.5 font-medium text-text-tertiary">{t(($) => $.createFrom)}- </div>+ </PopoverTitle><buttontype="button"className="mb-1 flex w-full cursor-pointer items-center rounded-lg px-2 py-1.75 text-[13px] leading-4.5 font-medium text-text-tertiary hover:bg-state-base-hover hover:text-text-secondary"diff --git a/web/app/components/snippet-list/index.tsx b/web/app/components/snippet-list/index.tsxindex b51c432df39..b5b0a4ddc85 100644--- a/web/app/components/snippet-list/index.tsx+++ b/web/app/components/snippet-list/index.tsx@@ -2,6 +2,7 @@import type { SnippetPublishStatus } from './components/snippet-publish-status-filter'import type { SnippetListItem } from '@/types/snippet'+import { Button } from '@langgenius/dify-ui/button'import { cn } from '@langgenius/dify-ui/cn'import { useDebounce } from 'ahooks'import { useAtomValue } from 'jotai'@@ -146,10 +147,31 @@ const SnippetList = () => {() => pages.flatMap(({ data: pageSnippets }) => pageSnippets),[pages],)- const hasAnySnippet = (pages[0]?.total ?? 0) > 0+ const totalSnippetCount = pages[0]?.total ?? 0+ const hasAnySnippet = totalSnippetCount > 0+ const hasInitialQueryError = canQuerySnippetList && Boolean(error) && pages.length === 0const showSkeleton =- isLoadingCurrentWorkspace ||- (canQuerySnippetList && (isLoading || (isFetching && pages.length === 0)))+ !hasInitialQueryError &&+ (isLoadingCurrentWorkspace ||+ (canQuerySnippetList && (isLoading || (isFetching && pages.length === 0))))+ const isListBusy =+ isLoadingCurrentWorkspace || (canQuerySnippetList && (isFetching || isFetchingNextPage))+ const initialQueryErrorMessage = hasInitialQueryError+ ? t(($) => $['errorBoundary.title'], { ns: 'common' })+ : ''+ const listStatus = showSkeleton+ ? ''+ : isListBusy+ ? t(($) => $.loading, { ns: 'common' })+ : hasInitialQueryError+ ? initialQueryErrorMessage+ : hasAnySnippet+ ? t(($) => $['operation.searchCount'], {+ ns: 'common',+ count: totalSnippetCount,+ content: t(($) => $['tabs.snippets'], { ns: 'workflow' }),+ })+ : t(($) => $['tabs.noSnippetsFound'], { ns: 'workflow' })return (<div@@ -173,7 +195,7 @@ const SnippetList = () => {}><div className="flex flex-wrap items-center justify-between gap-2">- <div className="flex flex-wrap items-center gap-2">+ <div className="flex min-w-0 flex-1 flex-wrap items-center gap-2"><CreatorsFilter value={creatorIDs} onChange={setCreatorIDs} /><SnippetPublishStatusFilter value={publishStatus} onChange={setPublishStatus} /><TagFilter@@ -184,7 +206,7 @@ const SnippetList = () => {/><SearchInputname="snippet-query"- className="w-50"+ className="w-full sm:w-50"value={keywords}onValueChange={setKeywords}placeholder={t(($) => $['tabs.searchSnippets'], { ns: 'workflow' })}@@ -194,14 +216,25 @@ const SnippetList = () => {<SnippetCreateButton /></div></StudioListHeader>+ <div className="sr-only" role="status" aria-live="polite" aria-atomic="true">+ {listStatus}+ </div><div+ aria-busy={isListBusy}className={cn(- 'relative grid grow grid-cols-[repeat(auto-fill,minmax(296px,1fr))] content-start gap-4 px-8 pt-2',+ 'relative grid grow grid-cols-1 content-start gap-4 px-4 pt-2 sm:grid-cols-[repeat(auto-fill,minmax(296px,1fr))] sm:px-8',!hasAnySnippet && 'overflow-hidden',)}>{showSkeleton ? (<SnippetCardSkeleton count={6} />+ ) : hasInitialQueryError ? (+ <div className="col-span-full flex min-h-55 flex-col items-center justify-center gap-3 text-center">+ <p className="system-md-medium text-text-secondary">{initialQueryErrorMessage}</p>+ <Button variant="secondary" loading={isFetching} onClick={() => refetch()}>+ {t(($) => $['operation.retry'], { ns: 'common' })}+ </Button>+ </div>) : hasAnySnippet ? (snippets.map((snippet) => (<SnippetCarddiff --git a/web/app/components/snippets/__tests__/import-snippet-dsl-dialog.spec.tsx b/web/app/components/snippets/__tests__/import-snippet-dsl-dialog.spec.tsxindex 94184e1fdb1..966f0a47b28 100644--- a/web/app/components/snippets/__tests__/import-snippet-dsl-dialog.spec.tsx+++ b/web/app/components/snippets/__tests__/import-snippet-dsl-dialog.spec.tsx@@ -73,7 +73,18 @@ describe('ImportSnippetDSLDialog', () => {render(<ImportSnippetDSLDialog isOpen onClose={onClose} />)- await user.click(screen.getByRole('button', { name: 'snippet.importFromDSLUrl' }))+ expect(screen.getByRole('dialog', { name: 'snippet.importDialogTitle' })).toBeInTheDocument()+ expect(screen.getByRole('tablist', { name: 'snippet.importDialogTitle' })).toBeInTheDocument()+ expect(screen.getByRole('tab', { name: 'snippet.importFromDSLFile' })).toHaveAttribute(+ 'aria-selected',+ 'true',+ )++ await user.click(screen.getByRole('tab', { name: 'snippet.importFromDSLUrl' }))+ expect(screen.getByRole('tab', { name: 'snippet.importFromDSLUrl' })).toHaveAttribute(+ 'aria-selected',+ 'true',+ )await user.type(screen.getByPlaceholderText('snippet.importFromDSLUrlPlaceholder'),'https://example.com/snippet.yml',@@ -147,7 +158,7 @@ describe('ImportSnippetDSLDialog', () => {render(<ImportSnippetDSLDialog isOpen onClose={vi.fn()} />)- await user.click(screen.getByRole('button', { name: 'snippet.importFromDSLUrl' }))+ await user.click(screen.getByRole('tab', { name: 'snippet.importFromDSLUrl' }))await user.type(screen.getByPlaceholderText('snippet.importFromDSLUrlPlaceholder'),'https://example.com/snippet.yml',diff --git a/web/app/components/snippets/import-snippet-dsl-dialog.tsx b/web/app/components/snippets/import-snippet-dsl-dialog.tsxindex 693a8720683..1e1834a91e0 100644--- a/web/app/components/snippets/import-snippet-dsl-dialog.tsx+++ b/web/app/components/snippets/import-snippet-dsl-dialog.tsx@@ -12,12 +12,12 @@ import {AlertDialogTitle,} from '@langgenius/dify-ui/alert-dialog'import { Button } from '@langgenius/dify-ui/button'-import { cn } from '@langgenius/dify-ui/cn'-import { Dialog, DialogContent } from '@langgenius/dify-ui/dialog'+import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'import { Input } from '@langgenius/dify-ui/input'+import { Tabs, TabsList, TabsPanel, TabsTab } from '@langgenius/dify-ui/tabs'import { toast } from '@langgenius/dify-ui/toast'import { useAtomValue } from 'jotai'-import { useCallback, useId, useMemo, useState } from 'react'+import { useCallback, useId, useState } from 'react'import { useTranslation } from 'react-i18next'import { Uploader } from '@/app/components/app/create-from-dsl-modal/uploader'import { workspacePermissionKeysAtom } from '@/context/permission-state'@@ -211,19 +211,12 @@ function ImportSnippetDSLDialog({ isOpen, onClose }: ImportSnippetDSLDialogProps}}, [canCreateAndModifySnippet, confirmSnippetImportMutation, handleImportResponse, importId])- const tabs = useMemo(- () => [- {- key: ImportSnippetDSLDialogTab.FromFile,- label: t(($) => $.importFromDSLFile, { ns: 'snippet' }),- },- {- key: ImportSnippetDSLDialogTab.FromUrl,- label: t(($) => $.importFromDSLUrl, { ns: 'snippet' }),- },- ],- [t],- )+ const handleTabChange = (value: string | number) => {+ if (value === ImportSnippetDSLDialogTab.FromFile)+ setCurrentTab(ImportSnippetDSLDialogTab.FromFile)+ if (value === ImportSnippetDSLDialogTab.FromUrl)+ setCurrentTab(ImportSnippetDSLDialogTab.FromUrl)+ }const isSubmitting = importSnippetMutation.isPending || confirmSnippetImportMutation.isPendingconst importDisabled =@@ -236,8 +229,10 @@ function ImportSnippetDSLDialog({ isOpen, onClose }: ImportSnippetDSLDialogProps<><Dialog open={isOpen} onOpenChange={(open) => !open && !showConfirmModal && onClose()}><DialogContent className="w-full max-w-120! overflow-hidden! rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg p-0! text-left align-middle shadow-xl">- <div className="flex items-center justify-between pt-6 pr-5 pb-3 pl-6 title-2xl-semi-bold text-text-primary">- {t(($) => $.importDialogTitle, { ns: 'snippet' })}+ <div className="flex items-center justify-between pt-6 pr-5 pb-3 pl-6">+ <DialogTitle className="title-2xl-semi-bold text-text-primary">+ {t(($) => $.importDialogTitle, { ns: 'snippet' })}+ </DialogTitle><buttontype="button"aria-label={t(($) => $['operation.close'], { ns: 'common' })}@@ -247,29 +242,38 @@ function ImportSnippetDSLDialog({ isOpen, onClose }: ImportSnippetDSLDialogProps<span className="i-ri-close-line size-5" /></button></div>- <div className="flex h-9 items-center space-x-6 border-b border-divider-subtle px-6 system-md-semibold text-text-tertiary">- {tabs.map((tab) => (- <button- key={tab.key}- type="button"- className={cn(- 'relative flex h-full cursor-pointer items-center',- currentTab === tab.key && 'text-text-primary',- )}- onClick={() => setCurrentTab(tab.key)}+ <Tabs value={currentTab} onValueChange={handleTabChange}>+ <TabsList+ aria-label={t(($) => $.importDialogTitle, { ns: 'snippet' })}+ className="h-9 gap-6 border-b border-divider-subtle px-6"+ >+ <TabsTab+ value={ImportSnippetDSLDialogTab.FromFile}+ className="h-full pt-0 pb-0 data-active:border-util-colors-blue-brand-blue-brand-600!"+ disabled={isSubmitting}>- {tab.label}- {currentTab === tab.key && (- <span className="absolute bottom-0 h-0.5 w-full bg-util-colors-blue-brand-blue-brand-600" />- )}- </button>- ))}- </div>- <div className="px-6 py-4">- {currentTab === ImportSnippetDSLDialogTab.FromFile && (+ {t(($) => $.importFromDSLFile, { ns: 'snippet' })}+ </TabsTab>+ <TabsTab+ value={ImportSnippetDSLDialogTab.FromUrl}+ className="h-full pt-0 pb-0 data-active:border-util-colors-blue-brand-blue-brand-600!"+ disabled={isSubmitting}+ >+ {t(($) => $.importFromDSLUrl, { ns: 'snippet' })}+ </TabsTab>+ </TabsList>+ <TabsPanel+ value={ImportSnippetDSLDialogTab.FromFile}+ tabIndex={-1}+ className="px-6 py-4"+ ><Uploader className="mt-0" file={currentFile} updateFile={handleFileChange} />- )}- {currentTab === ImportSnippetDSLDialogTab.FromUrl && (+ </TabsPanel>+ <TabsPanel+ value={ImportSnippetDSLDialogTab.FromUrl}+ tabIndex={-1}+ className="px-6 py-4"+ ><div><labelhtmlFor={dslUrlInputId}@@ -284,8 +288,8 @@ function ImportSnippetDSLDialog({ isOpen, onClose }: ImportSnippetDSLDialogPropsonChange={(event) => setDslUrl(event.target.value)}/></div>- )}- </div>+ </TabsPanel>+ </Tabs><div className="flex justify-end px-6 py-5"><Button className="mr-2" disabled={isSubmitting} onClick={onClose}>{t(($) => $['operation.cancel'], { ns: 'common' })}