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(web): synchronize locale direction and support RTL primary pages (#44621)
yyh53c998abd7b0
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.jsonindex e5040e24e21..d18c09edb9b 100644--- a/oxlint-suppressions.json+++ b/oxlint-suppressions.json@@ -955,11 +955,6 @@"count": 8}},- "web/app/components/apps/app-card/interactions.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 1- }- },"web/app/components/apps/app-list-header.tsx": {"better-tailwindcss/enforce-logical-properties": {"count": 1@@ -3082,11 +3077,6 @@}},"web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 3- }- },- "web/app/components/datasets/list/dataset-card/components/operations-dropdown.tsx": {"better-tailwindcss/enforce-logical-properties": {"count": 1}@@ -3200,11 +3190,6 @@"count": 1}},- "web/app/components/explore/installed-app-navigation/app-nav-item.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 3- }- },"web/app/components/explore/installed-app/index.tsx": {"better-tailwindcss/enforce-logical-properties": {"count": 1@@ -3260,11 +3245,6 @@"count": 3}},- "web/app/components/header/account-dropdown/index.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 1- }- },"web/app/components/header/account-dropdown/workplace-selector/index.tsx": {"better-tailwindcss/enforce-logical-properties": {"count": 2@@ -3328,11 +3308,6 @@"count": 1}},- "web/app/components/header/account-setting/index.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 6- }- },"web/app/components/header/account-setting/ip-policies-page/policy-item.tsx": {"better-tailwindcss/enforce-logical-properties": {"count": 1@@ -3363,11 +3338,6 @@"count": 2}},- "web/app/components/header/account-setting/menu-dialog.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 1- }- },"web/app/components/header/account-setting/model-provider-page/__tests__/hooks.spec.ts": {"typescript/no-deprecated": {"count": 1@@ -3388,11 +3358,6 @@"count": 2}},- "web/app/components/header/account-setting/model-provider-page/install-from-marketplace.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 1- }- },"web/app/components/header/account-setting/model-provider-page/model-auth/add-credential-in-load-balancing.tsx": {"better-tailwindcss/enforce-logical-properties": {"count": 1@@ -3513,7 +3478,7 @@},"web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx": {"better-tailwindcss/enforce-logical-properties": {- "count": 16+ "count": 2}},"web/app/components/header/account-setting/model-provider-page/provider-added-card/lazy-custom-model-actions.tsx": {@@ -3683,49 +3648,11 @@"count": 2}},- "web/app/components/main-nav/components/account-section.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 3- }- },- "web/app/components/main-nav/components/help-menu.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 4- }- },- "web/app/components/main-nav/components/web-apps-section.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 4- }- },- "web/app/components/main-nav/components/workspace-card.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 14- }- },- "web/app/components/main-nav/components/workspace-menu-content.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 1- }- },"web/app/components/main-nav/components/workspace-switcher.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 4- },"jsx-a11y/no-autofocus": {"count": 1}},- "web/app/components/main-nav/index.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 6- }- },- "web/app/components/main-nav/skip-nav.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 1- }- },"web/app/components/plugins/base/deprecation-notice.tsx": {"better-tailwindcss/enforce-logical-properties": {"count": 1@@ -3829,11 +3756,6 @@"count": 3}},- "web/app/components/plugins/marketplace/home/home-trending-navigation.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 3- }- },"web/app/components/plugins/marketplace/home/home-trending-slides.tsx": {"better-tailwindcss/enforce-logical-properties": {"count": 3@@ -3871,9 +3793,6 @@}},"web/app/components/plugins/marketplace/list/carousel.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 1- },"eslint-react/set-state-in-effect": {"count": 4}@@ -7385,7 +7304,7 @@},"web/features/agent-v2/roster/components/agent-roster-list.tsx": {"better-tailwindcss/enforce-logical-properties": {- "count": 14+ "count": 5}},"web/features/agent-v2/roster/components/agent-workflow-references-dropdown.tsx": {@@ -7393,11 +7312,6 @@"count": 3}},- "web/features/agent-v2/roster/components/roster-toolbar.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 1- }- },"web/features/agent-v2/template-preview/grid-background.tsx": {"better-tailwindcss/enforce-logical-properties": {"count": 1@@ -7423,31 +7337,6 @@"count": 1}},- "web/features/home/banner/banner-item.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 3- }- },- "web/features/home/banner/banner.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 5- }- },- "web/features/home/continue-work/continue-work.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 2- }- },- "web/features/home/continue-work/item.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 1- }- },- "web/features/home/template-card.tsx": {- "better-tailwindcss/enforce-logical-properties": {- "count": 1- }- },"web/features/network-access/app-binding/chip-affix.tsx": {"better-tailwindcss/enforce-logical-properties": {"count": 1@@ -7823,7 +7712,7 @@},"web/features/skills/page.tsx": {"better-tailwindcss/enforce-logical-properties": {- "count": 11+ "count": 4}},"web/features/tag-management/components/tag-filter.tsx": {diff --git a/web/app/__tests__/home-banner.browser.spec.tsx b/web/app/__tests__/home-banner.browser.spec.tsxindex 8bb42cb7801..986bd0f6be9 100644--- a/web/app/__tests__/home-banner.browser.spec.tsx+++ b/web/app/__tests__/home-banner.browser.spec.tsx@@ -1,4 +1,5 @@import type { BannerResponse } from '@dify/contracts/api/console/explore/types.gen'+import { DirectionProvider } from '@langgenius/dify-ui/direction-provider'import { userEvent } from 'vite-plus/test/browser'import { render } from 'vitest-browser-react'import { Banner } from '@/features/home/banner/banner'@@ -39,14 +40,16 @@ const banners: BannerResponse[] = [},]-async function renderBanner() {+async function renderBanner(direction: 'ltr' | 'rtl' = 'ltr') {const { wrapper: Wrapper } = createConsoleQueryWrapper({ accountProfile: { id: 'account-123' } })return render(<Wrapper><button type="button">Before carousel</button>- <div style={{ width: 300 }}>- <Banner banners={banners} />- </div>+ <DirectionProvider direction={direction}>+ <div dir={direction} style={{ width: 300 }}>+ <Banner banners={banners} />+ </div>+ </DirectionProvider><button type="button">After carousel</button></Wrapper>,)@@ -63,6 +66,27 @@ describe('Home banner browser interactions', () => {vi.restoreAllMocks()})+ it.each(['ltr', 'rtl'] as const)(+ 'keeps the selected banner inside the viewport in %s',+ async (direction) => {+ // Embla's real transforms must agree with CSS direction; ARIA visibility alone misses offscreen slides.+ const screen = await renderBanner(direction)+ const carousel = screen.getByRole('region', { name: 'explore.banner.carouselLabel' })+ const secondPicker = screen.getByRole('button', { name: '02 Second banner' })+ await secondPicker.click()+ await expect.element(secondPicker).toHaveAttribute('aria-current', 'true')+ const slide = screen.getByRole('group', { name: 'Second banner' })+ await expect.element(slide).toBeVisible()+ await expect+ .poll(() => {+ const viewport = carousel.element().getBoundingClientRect()+ const selected = slide.element().getBoundingClientRect()+ return selected.left >= viewport.left - 1 && selected.right <= viewport.right + 1+ })+ .toBe(true)+ },+ )+it('puts the rotation control first in the native tab order and keeps focus-triggered pauses', async () => {// Chromium owns native tab order, layout geometry, and focus transitions; happy-dom cannot prove these contracts.const screen = await renderBanner()diff --git a/web/app/__tests__/layout.spec.tsx b/web/app/__tests__/layout.spec.tsxindex 8ed5b4258a8..c15db9a20b6 100644--- a/web/app/__tests__/layout.spec.tsx+++ b/web/app/__tests__/layout.spec.tsx@@ -36,25 +36,35 @@ describe('Root layout System Features bootstrap', () => {mocks.headers.mockResolvedValue(new Headers())})- it('renders the terminal error document without requesting console bootstrap', async () => {- mocks.headers.mockResolvedValue(- new Headers({- 'x-dify-pathname': '/webapp-unavailable',- 'accept-language': 'zh-CN,zh;q=0.9',- }),- )- const { default: RootLayout, generateMetadata } = await import('../layout')-- const html = renderToStaticMarkup(await RootLayout({ children: <main>App unavailable</main> }))- const document = new DOMParser().parseFromString(html, 'text/html')-- expect(document.documentElement.lang).toBe('zh-Hans')- expect(document.body.querySelector('main')).toHaveTextContent('App unavailable')- await expect(generateMetadata()).resolves.toEqual({ icons: { icon: '/favicon.ico' } })-- expect(mocks.getOptionalSystemFeatures).not.toHaveBeenCalled()- expect(mocks.dehydrateSystemFeatures).not.toHaveBeenCalled()- })+ it.each([+ ['zh-CN,zh;q=0.9', 'zh-Hans', 'ltr'],+ ['ar-TN,ar;q=0.9', 'ar-TN', 'rtl'],+ ['fa-IR,fa;q=0.9', 'fa-IR', 'rtl'],+ ])(+ 'renders the terminal error document in %s without console bootstrap',+ async (language, locale, direction) => {+ mocks.headers.mockResolvedValue(+ new Headers({+ 'x-dify-pathname': '/webapp-unavailable',+ 'accept-language': language,+ }),+ )+ const { default: RootLayout, generateMetadata } = await import('../layout')++ const html = renderToStaticMarkup(+ await RootLayout({ children: <main>App unavailable</main> }),+ )+ const document = new DOMParser().parseFromString(html, 'text/html')++ expect(document.documentElement.lang).toBe(locale)+ expect(document.documentElement.dir).toBe(direction)+ expect(document.body.querySelector('main')).toHaveTextContent('App unavailable')+ await expect(generateMetadata()).resolves.toEqual({ icons: { icon: '/favicon.ico' } })++ expect(mocks.getOptionalSystemFeatures).not.toHaveBeenCalled()+ expect(mocks.dehydrateSystemFeatures).not.toHaveBeenCalled()+ },+ )it('uses optional System Features for branded metadata', async () => {mocks.getOptionalSystemFeatures.mockResolvedValue({diff --git a/web/app/components/apps/app-card/interactions.tsx b/web/app/components/apps/app-card/interactions.tsxindex 5c841c08777..0380819ea20 100644--- a/web/app/components/apps/app-card/interactions.tsx+++ b/web/app/components/apps/app-card/interactions.tsx@@ -482,7 +482,7 @@ export function AppCardInteractions({)}<divclassName={cn(- 'pointer-events-none absolute top-[-0.5px] right-[-0.5px] flex h-16 w-30 items-start justify-end bg-[linear-gradient(67deg,var(--color-components-card-bg-alt-transparent)_0%,var(--color-components-card-bg-alt)_75%)] p-2 opacity-0',+ 'pointer-events-none absolute inset-e-[-0.5px] top-[-0.5px] flex h-16 w-30 items-start justify-end bg-[linear-gradient(67deg,var(--color-components-card-bg-alt-transparent)_0%,var(--color-components-card-bg-alt)_75%)] p-2 opacity-0 rtl:bg-[linear-gradient(293deg,var(--color-components-card-bg-alt-transparent)_0%,var(--color-components-card-bg-alt)_75%)]',isOperationsMenuOpen || isExporting? 'opacity-100': 'group-focus-within:opacity-100 group-hover:opacity-100 has-data-popup-open:opacity-100 [@media(hover:none)]:opacity-100',diff --git a/web/app/components/base/carousel/__tests__/index.spec.tsx b/web/app/components/base/carousel/__tests__/index.spec.tsxindex 689b62976a9..7cd2978985b 100644--- a/web/app/components/base/carousel/__tests__/index.spec.tsx+++ b/web/app/components/base/carousel/__tests__/index.spec.tsx@@ -107,13 +107,19 @@ describe('Carousel', () => {</Carousel>,)- expect(mockedUseEmblaCarousel).toHaveBeenCalledWith({ loop: true, axis: 'x' }, [plugin])+ expect(mockedUseEmblaCarousel).toHaveBeenCalledWith(+ { loop: true, axis: 'x', direction: 'ltr' },+ [plugin],+ )})it('configures the vertical Embla axis', () => {renderCarouselWithControls('vertical')- expect(mockedUseEmblaCarousel).toHaveBeenCalledWith({ axis: 'y' }, undefined)+ expect(mockedUseEmblaCarousel).toHaveBeenCalledWith(+ { axis: 'y', direction: 'ltr' },+ undefined,+ )})})diff --git a/web/app/components/base/carousel/index.tsx b/web/app/components/base/carousel/index.tsxindex 14816e135c0..137eb3c6c06 100644--- a/web/app/components/base/carousel/index.tsx+++ b/web/app/components/base/carousel/index.tsx@@ -1,5 +1,6 @@import type { UseEmblaCarouselType } from 'embla-carousel-react'import { cn } from '@langgenius/dify-ui/cn'+import { useDirection } from '@langgenius/dify-ui/direction-provider'import Autoplay from 'embla-carousel-autoplay'import Fade from 'embla-carousel-fade'import useEmblaCarousel from 'embla-carousel-react'@@ -46,8 +47,9 @@ function Carousel({...props}: React.HTMLAttributes<HTMLDivElement> &CarouselProps & { ref?: React.Ref<CarouselContextValue> }) {+ const direction = useDirection()const [carouselRef, api] = useEmblaCarousel(- { ...opts, axis: orientation === 'horizontal' ? 'x' : 'y' },+ { direction, ...opts, axis: orientation === 'horizontal' ? 'x' : 'y' },plugins,)const [canScrollPrev, setCanScrollPrev] = React.useState(false)diff --git a/web/app/components/base/date-time-picker/__tests__/localization.spec.tsx b/web/app/components/base/date-time-picker/__tests__/localization.spec.tsxindex 48ad0df2116..f1026b3a862 100644--- a/web/app/components/base/date-time-picker/__tests__/localization.spec.tsx+++ b/web/app/components/base/date-time-picker/__tests__/localization.spec.tsx@@ -1,3 +1,4 @@+import { DirectionProvider } from '@langgenius/dify-ui/direction-provider'import { act, render, screen } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { createInstance } from 'i18next'@@ -19,6 +20,7 @@ import {TimePickerLabel,TimePickerTrigger,} from '@/app/components/base/date-time-picker/time-picker'+import { I18nDirectionProvider } from '@/app/components/provider/i18n-direction'import en from '@/i18n/locales/en-US/time.json'import fa from '@/i18n/locales/fa-IR/time.json'import lo from '@/i18n/locales/lo-LA/time.json'@@ -80,11 +82,13 @@ it('updates time formatting and popup labels from the application language withoconst i18n = await createI18n()render(<I18nextProvider i18n={i18n}>- <TimePicker defaultValue="13:30">- <TimePickerLabel className="sr-only">Time</TimePickerLabel>- <TimePickerTrigger />- <TimePickerContent />- </TimePicker>+ <I18nDirectionProvider syncDocument>+ <TimePicker defaultValue="13:30">+ <TimePickerLabel className="sr-only">Time</TimePickerLabel>+ <TimePickerTrigger />+ <TimePickerContent />+ </TimePicker>+ </I18nDirectionProvider></I18nextProvider>,)expect(screen.getByRole('button', { name: 'Time 1:30 PM' })).toBeInTheDocument()@@ -103,16 +107,18 @@ it('updates time formatting and popup labels from the application language withoexpect(screen.getByRole('dialog')).toHaveAttribute('dir', 'rtl')})-it('owns the application calendar locale and RTL while preserving caller label overrides', async () => {+it('inherits application direction and localizes the calendar while preserving label overrides', async () => {const user = userEvent.setup()const i18n = await createI18n('fa-IR')render(<I18nextProvider i18n={i18n}>- <DatePicker defaultValue="2025-01-15" labels={{ nextMonth: 'Next billing month' }}>- <DatePickerLabel className="sr-only">Date</DatePickerLabel>- <DatePickerTrigger />- <DatePickerContent />- </DatePicker>+ <I18nDirectionProvider syncDocument>+ <DatePicker defaultValue="2025-01-15" labels={{ nextMonth: 'Next billing month' }}>+ <DatePickerLabel className="sr-only">Date</DatePickerLabel>+ <DatePickerTrigger />+ <DatePickerContent />+ </DatePicker>+ </I18nDirectionProvider></I18nextProvider>,)const trigger = screen.getByRole('button', { name: /^Date / })@@ -126,6 +132,43 @@ it('owns the application calendar locale and RTL while preserving caller label oexpect(screen.getByRole('option', { name: 'ژانویه' })).toHaveAttribute('aria-selected', 'true')})+it('inherits a local direction override independently of the application language', async () => {+ const user = userEvent.setup()+ const i18n = await createI18n('fa-IR')+ render(+ <I18nextProvider i18n={i18n}>+ <I18nDirectionProvider syncDocument>+ <DirectionProvider direction="ltr">+ <DatePicker>+ <DatePickerLabel>Date</DatePickerLabel>+ <DatePickerTrigger />+ <DatePickerContent />+ </DatePicker>+ <TimePicker>+ <TimePickerLabel>Time</TimePickerLabel>+ <TimePickerTrigger />+ </TimePicker>+ <DateTimePicker timeZone="UTC">+ <DateTimePickerLabel>Meeting</DateTimePickerLabel>+ <DateTimePickerTrigger />+ </DateTimePicker>+ <DatePicker direction="rtl">+ <DatePickerLabel>Explicit RTL</DatePickerLabel>+ <DatePickerTrigger />+ </DatePicker>+ </DirectionProvider>+ </I18nDirectionProvider>+ </I18nextProvider>,+ )++ for (const name of ['Date', 'Time', 'Meeting'])+ expect(screen.getByRole('button', { name })).toHaveAttribute('dir', 'ltr')+ expect(screen.getByRole('button', { name: 'Explicit RTL' })).toHaveAttribute('dir', 'rtl')+ await user.click(screen.getByRole('button', { name: 'Date' }))+ expect(screen.getByRole('dialog', { name: 'Date' })).toHaveAttribute('dir', 'ltr')+ expect(document.documentElement.dir).toBe('rtl')+})+it.each([['zh-Hans', '今天,2026年9月28日 星期一,已选择'],[diff --git a/web/app/components/base/date-time-picker/use-picker-labels.ts b/web/app/components/base/date-time-picker/use-picker-labels.tsindex f891e96b1f1..fe4cfd33b62 100644--- a/web/app/components/base/date-time-picker/use-picker-labels.ts+++ b/web/app/components/base/date-time-picker/use-picker-labels.ts@@ -1,6 +1,5 @@'use client'-import type { TextDirection } from '@langgenius/dify-ui/direction-provider'import { useTranslation } from 'react-i18next'import { useLocale } from '#i18n'@@ -11,9 +10,7 @@ export function usePickerLabels() {new Intl.DateTimeFormat(locale, { hour: 'numeric', hour12: true, timeZone: 'UTC' }).formatToParts(new Date(Date.UTC(2025, 0, 1, hour))).find((part) => part.type === 'dayPeriod')?.value ?? (hour < 12 ? 'AM' : 'PM')- const direction: TextDirection = locale === 'ar-TN' || locale === 'fa-IR' ? 'rtl' : 'ltr'return {- direction,locale,requiredLabel: t(($) => $['picker.requiredLabel']),validationMessage: t(($) => $['picker.required']),diff --git a/web/app/components/base/theme-selector.tsx b/web/app/components/base/theme-selector.tsxindex 913bf1c47d5..b024361d97d 100644--- a/web/app/components/base/theme-selector.tsx+++ b/web/app/components/base/theme-selector.tsx@@ -1,5 +1,6 @@'use client'+import { useDirection } from '@langgenius/dify-ui/direction-provider'import {DropdownMenu,DropdownMenuContent,@@ -20,6 +21,7 @@ const isTheme = (value: string): value is Theme => {}export default function ThemeSelector() {+ const direction = useDirection()const { t } = useTranslation(['common'])const { theme, setTheme } = useTheme()const currentTheme: Theme = theme && isTheme(theme) ? theme : 'system'@@ -48,7 +50,7 @@ export default function ThemeSelector() {</IconButton>}/>- <DropdownMenuContent sideOffset={6} className="w-36">+ <DropdownMenuContent dir={direction} sideOffset={6} className="w-36"><DropdownMenuRadioGroup<Theme>value={currentTheme}onValueChange={(nextTheme) => setTheme(nextTheme)}diff --git a/web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsx b/web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsxindex 055daa118d3..2a51aafe9a9 100644--- a/web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsx+++ b/web/app/components/datasets/list/dataset-card/components/dataset-card-header.tsx@@ -122,7 +122,7 @@ const DatasetCardHeader = ({ dataset, nameId }: DatasetCardHeaderProps) => {return (<divclassName={cn(- 'flex items-center gap-x-3 pt-4 pr-14 pb-2 pl-4',+ 'flex items-center gap-x-3 ps-4 pe-14 pt-4 pb-2',!dataset.embedding_available && 'opacity-30',)}>diff --git a/web/app/components/datasets/list/dataset-card/components/operations-dropdown.tsx b/web/app/components/datasets/list/dataset-card/components/operations-dropdown.tsxindex 70b35d7d4fc..7fd63dc1a4a 100644--- a/web/app/components/datasets/list/dataset-card/components/operations-dropdown.tsx+++ b/web/app/components/datasets/list/dataset-card/components/operations-dropdown.tsx@@ -89,7 +89,7 @@ const OperationsDropdown = ({return (<divclassName={cn(- 'absolute right-2 z-5',+ 'absolute inset-e-2 z-5',dataset.embedding_available ? 'top-2' : 'top-6',open? 'pointer-events-auto opacity-100'diff --git a/web/app/components/datasets/list/dataset-card/index.tsx b/web/app/components/datasets/list/dataset-card/index.tsxindex 885e6cad2ff..1e9ac8dd075 100644--- a/web/app/components/datasets/list/dataset-card/index.tsx+++ b/web/app/components/datasets/list/dataset-card/index.tsx@@ -102,7 +102,7 @@ const DatasetCard = ({// The entry's hit area stretches over the card. Tags, footer details, and operations are// positioned later in the card, so they stay independent controls above that area.const entryClassName =- "block rounded-t-xl text-left outline-hidden before:absolute before:inset-0 before:rounded-xl before:content-['']"+ "block rounded-t-xl text-start outline-hidden before:absolute before:inset-0 before:rounded-xl before:content-['']"return (<lidiff --git a/web/app/components/explore/installed-app-navigation/app-nav-item.tsx b/web/app/components/explore/installed-app-navigation/app-nav-item.tsxindex 5c404242f81..43945dde66f 100644--- a/web/app/components/explore/installed-app-navigation/app-nav-item.tsx+++ b/web/app/components/explore/installed-app-navigation/app-nav-item.tsx@@ -28,7 +28,7 @@ export default function AppNavItem({return (<divkey={id}- className="group flex h-7 items-center justify-between gap-2 rounded-lg py-0.5 pr-0.5 pl-2 transition-colors not-has-[>a[aria-current=page]]:hover:bg-state-base-hover has-[>a:focus-visible]:inset-ring-2 has-[>a:focus-visible]:inset-ring-state-accent-solid has-[>a[aria-current=page]]:bg-state-base-active"+ className="group flex h-7 items-center justify-between gap-2 rounded-lg py-0.5 ps-2 pe-0.5 transition-colors not-has-[>a[aria-current=page]]:hover:bg-state-base-hover has-[>a:focus-visible]:inset-ring-2 has-[>a:focus-visible]:inset-ring-state-accent-solid has-[>a[aria-current=page]]:bg-state-base-active"><Linkhref={url}@@ -39,7 +39,7 @@ export default function AppNavItem({className="flex min-w-0 flex-1 items-center gap-2 outline-hidden"><AppIcon size="tiny" className="size-5 rounded-md text-sm" icon={installedApp.app} />- <div className="min-w-0 flex-1 truncate py-1 pr-1 system-sm-regular" title={name}>+ <div className="min-w-0 flex-1 truncate py-1 pe-1 system-sm-regular" title={name}>{name}</div></Link>diff --git a/web/app/components/goto-anything/__tests__/index.spec.tsx b/web/app/components/goto-anything/__tests__/index.spec.tsxindex e18e89af16b..74589388795 100644--- a/web/app/components/goto-anything/__tests__/index.spec.tsx+++ b/web/app/components/goto-anything/__tests__/index.spec.tsx@@ -32,15 +32,18 @@ const api = vi.hoisted(() => ({marketplace: vi.fn<typeof marketplaceClient.searchAdvanced>(),install: vi.fn<typeof consoleClient.workspaces.current.plugin.install.marketplace.post>(),push: vi.fn(),+ refresh: vi.fn(),+ setLocale: vi.fn<(locale: string) => Promise<void>>(),agentEnabled: true,pathname: '/',}))vi.mock('@/next/navigation', async (importOriginal) => ({...(await importOriginal<typeof import('@/next/navigation')>()),- useRouter: () => ({ push: api.push }),+ useRouter: () => ({ push: api.push, refresh: api.refresh }),usePathname: () => api.pathname,useParams: () => ({}),}))+vi.mock('@/i18n/client', () => ({ setLocaleOnClient: api.setLocale }))vi.mock('@/features/agent-v2/feature-flag', () => ({isAgentV2Enabled: () => api.agentEnabled,}))@@ -169,6 +172,8 @@ beforeEach(() => {api.marketplace.mockReset().mockResolvedValue({ data: { plugins: [], total: 0 } })api.install.mockReset().mockResolvedValue({ all_installed: true, task_id: '' })api.push.mockReset()+ api.refresh.mockReset()+ api.setLocale.mockReset().mockResolvedValue(undefined)api.agentEnabled = trueapi.pathname = '/'})@@ -177,6 +182,30 @@ afterEach(() => {act(() => toast.dismiss())})+it('switches language through the command palette before refreshing the current route', async () => {+ const languageChange = createDeferred()+ api.setLocale.mockReturnValueOnce(languageChange.promise)+ const { user } = setup()+ await user.type(await openSearch(), '/language fa-IR')+ await user.click(await screen.findByRole('option', { name: /Farsi \(Iran\)/ }))+ expect(api.setLocale).toHaveBeenCalledExactlyOnceWith('fa-IR')+ expect(api.refresh).not.toHaveBeenCalled()+ await act(async () => languageChange.resolve())+ await waitFor(() => expect(api.refresh).toHaveBeenCalledOnce())+ expect(api.push).not.toHaveBeenCalled()+})++it('does not refresh when a language command fails', async () => {+ api.setLocale.mockRejectedValueOnce(new Error('Language resources unavailable'))+ vi.spyOn(console, 'error').mockImplementation(() => {})+ const { user } = setup()+ await user.type(await openSearch(), '/language fa-IR')+ await user.click(await screen.findByRole('option', { name: /Farsi \(Iran\)/ }))+ await screen.findByText('common.api.actionFailed')+ expect(api.refresh).not.toHaveBeenCalled()+ expect(api.push).not.toHaveBeenCalled()+})+describe('search shortcut ownership', () => {it('suspends background commands while search is open and restores them after closing', async () => {const save = vi.fn()diff --git a/web/app/components/goto-anything/actions/commands/use-command-context.ts b/web/app/components/goto-anything/actions/commands/use-command-context.tsindex d31a584a5b0..9cb32f3803d 100644--- a/web/app/components/goto-anything/actions/commands/use-command-context.ts+++ b/web/app/components/goto-anything/actions/commands/use-command-context.ts@@ -23,7 +23,7 @@ export function useCommandContext(): CommandContext {const { t, i18n } = useTranslation(['app', 'common', 'modelProvider', 'accountSettings'])const { setTheme } = useTheme()- const { push } = useRouter()+ const { push, refresh } = useRouter()const getDocsHomeUrl = useDocLink()const { appId: routeAppId } = useParams<{ appId?: string }>()// Only the app workflow page has an app id param that names an app; other routes reuse the@@ -48,7 +48,10 @@ export function useCommandContext(? { id: appId, mode: appMode }: null,setTheme,- setLocale: setLocaleOnClient,+ setLocale: async (locale) => {+ await setLocaleOnClient(locale)+ refresh()+ },getDocsHomeUrl,navigate: push,onError: (error) => {@@ -69,6 +72,7 @@ export function useCommandContext(setTheme,getDocsHomeUrl,push,+ refresh,],)}diff --git a/web/app/components/header/account-dropdown/__tests__/focus.browser.spec.tsx b/web/app/components/header/account-dropdown/__tests__/focus.browser.spec.tsxindex 6948fae18cb..380cff69742 100644--- a/web/app/components/header/account-dropdown/__tests__/focus.browser.spec.tsx+++ b/web/app/components/header/account-dropdown/__tests__/focus.browser.spec.tsx@@ -1,6 +1,7 @@import { Dialog, DialogContent, DialogTitle } from '@langgenius/dify-ui/dialog'+import { DirectionProvider } from '@langgenius/dify-ui/direction-provider'import { useQueryState } from 'nuqs'-import { userEvent } from 'vite-plus/test/browser'+import { page, userEvent } from 'vite-plus/test/browser'import { render } from 'vitest-browser-react'import {settingsQueryParamName,@@ -9,6 +10,7 @@ import {import AccountSection from '@/app/components/main-nav/components/account-section'import { createConsoleQueryWrapper } from '@/test/console/query-data'import { createNuqsTestWrapper } from '@/test/nuqs-testing'+import AccountDropdown from '../index'vi.mock('@/service/use-common', () => ({ useLogout: () => ({ mutate: vi.fn() }) }))vi.mock('next-themes', () => ({@@ -50,6 +52,54 @@ async function renderAccount() {)}+it.each(['ltr', 'rtl'] as const)(+ 'opens the appearance submenu toward the reading direction in %s',+ async (direction) => {+ await page.viewport(1280, 800)+ const { wrapper: ConsoleProvider } = createConsoleQueryWrapper({+ accountProfile: { name: 'Current User', email: '[email protected]' },+ features: { education: { enabled: false } },+ })+ const { wrapper: NuqsProvider } = createNuqsTestWrapper()+ const previousDirection = document.documentElement.dir+ document.documentElement.dir = direction+ try {+ const screen = await render(+ <DirectionProvider direction={direction}>+ <ConsoleProvider>+ <NuqsProvider>+ <div style={{ marginInline: 'auto', paddingTop: 300, width: 240 }}>+ <AccountDropdown+ trigger={({ ariaLabel }) => <button aria-label={ariaLabel}>Account</button>}+ />+ </div>+ </NuqsProvider>+ </ConsoleProvider>+ </DirectionProvider>,+ )+ await screen.getByRole('button', { name: 'accountSettings.account.account' }).click()+ const appearance = screen.getByRole('menuitem', {+ name: 'accountSettings.account.appearanceLabel',+ })+ await appearance.click()+ const submenu = screen.getByRole('menu', { name: 'accountSettings.account.appearanceLabel' })+ await expect.element(submenu).toBeVisible()+ // Leave room on both sides so collision fallback cannot hide a fixed-side override.+ await expect+ .poll(() => {+ const triggerBounds = appearance.element().getBoundingClientRect()+ const submenuBounds = submenu.element().getBoundingClientRect()+ return direction === 'rtl'+ ? submenuBounds.right <= triggerBounds.left+ : submenuBounds.left >= triggerBounds.right+ })+ .toBe(true)+ } finally {+ document.documentElement.dir = previousDirection+ }+ },+)+// Chromium supplies the native focus-visible heuristic after menu focus restoration.it.each(['outside', 'Escape'])('does not highlight a pointer-opened account trigger after %s dismissal',diff --git a/web/app/components/header/account-dropdown/index.tsx b/web/app/components/header/account-dropdown/index.tsxindex bf3b34b336d..315ed62282d 100644--- a/web/app/components/header/account-dropdown/index.tsx+++ b/web/app/components/header/account-dropdown/index.tsx@@ -84,7 +84,7 @@ function AppearanceSubmenu() {label={t(($) => $['account.appearanceLabel'], { ns: 'accountSettings' })}/></DropdownMenuSubTrigger>- <DropdownMenuSubContent side="right" sideOffset={6} className="max-h-90 w-34.75 px-1">+ <DropdownMenuSubContent sideOffset={6} className="max-h-90 w-34.75 px-1"><DropdownMenuRadioGroup<Theme>value={currentTheme}onValueChange={(nextTheme) => setTheme(nextTheme)}@@ -150,7 +150,7 @@ function MainNavMenuContent({ onLogout }: MainNavMenuContentProps) {</div>{isEducationAccount && (<PremiumBadge size="s" color="blue" className="shrink-0 px-2!">- <span aria-hidden className="mr-1 i-ri-graduation-cap-fill h-3 w-3" />+ <span aria-hidden className="me-1 i-ri-graduation-cap-fill size-3" /><span className="system-2xs-medium">EDU</span></PremiumBadge>)}diff --git a/web/app/components/header/account-dropdown/menu-item-content.tsx b/web/app/components/header/account-dropdown/menu-item-content.tsxindex 23ea5b63e58..fa4d5a94b94 100644--- a/web/app/components/header/account-dropdown/menu-item-content.tsx+++ b/web/app/components/header/account-dropdown/menu-item-content.tsx@@ -1,11 +1,6 @@import type { ReactNode } from 'react'import { cn } from '@langgenius/dify-ui/cn'-const menuLabelClassName = 'min-w-0 grow truncate px-1 text-text-secondary system-md-regular'-const menuLeadingIconClassName = 'size-4 shrink-0 text-text-tertiary'--const menuTrailingIconClassName = 'size-[14px] shrink-0 text-text-tertiary'-type MenuItemContentProps = {iconClassName: stringlabel: ReactNode@@ -17,8 +12,11 @@ export function MenuItemContent({ iconClassName, label, trailing }: MenuItemContreturn (<>- <span aria-hidden className={cn(menuLeadingIconClassName, iconClassName)} />- <div className={menuLabelClassName} title={labelTitle}>+ <span aria-hidden className={cn('size-4 shrink-0 text-text-tertiary', iconClassName)} />+ <div+ className="min-w-0 grow truncate px-1 system-md-regular text-text-secondary"+ title={labelTitle}+ >{label}</div>{trailing}@@ -27,5 +25,10 @@ export function MenuItemContent({ iconClassName, label, trailing }: MenuItemCont}export function ExternalLinkIndicator() {- return <span aria-hidden className={cn('i-ri-arrow-right-up-line', menuTrailingIconClassName)} />+ return (+ <span+ aria-hidden+ className="i-ri-arrow-right-up-line size-3.5 shrink-0 text-text-tertiary [&:dir(rtl)]:-scale-x-100"+ />+ )}diff --git a/web/app/components/header/account-setting/index.tsx b/web/app/components/header/account-setting/index.tsxindex db8c25616e1..fdb27a97466 100644--- a/web/app/components/header/account-setting/index.tsx+++ b/web/app/components/header/account-setting/index.tsx@@ -38,7 +38,7 @@ import ResourceAccessTokenPage from './resource-access-token-page'import WorkflowLogArchivesPage from './workflow-log-archives-page'const iconClassName = `- size-4 shrink-0 sm:mr-2+ size-4 shrink-0 sm:me-2`type IAccountSettingProps = {@@ -215,7 +215,7 @@ export default function AccountSetting({onClose={onCancelAction}><div className="mx-auto flex h-screen w-full max-w-270 px-4">- <div className="flex w-11 shrink-0 flex-col pr-2 sm:w-56 sm:pr-6 sm:pl-4">+ <div className="flex w-11 shrink-0 flex-col pe-2 sm:w-56 sm:ps-4 sm:pe-6"><div className="invisible mt-6 mb-8 flex h-9.5 items-center px-3 title-2xl-semi-bold whitespace-nowrap text-text-primary sm:visible">{t(($) => $['settings.settings'], { ns: 'navigation' })}</div>@@ -240,7 +240,7 @@ export default function AccountSetting({type="button"key={item.key}className={cn(- 'mb-0.5 flex h-8 w-full items-center justify-center rounded-lg px-2 text-left text-sm focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden sm:justify-start sm:px-3',+ 'mb-0.5 flex h-8 w-full items-center justify-center rounded-lg px-2 text-start text-sm focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden sm:justify-start sm:px-3',activeMenu === item.key? 'bg-state-base-active system-sm-semibold text-components-menu-item-text-active': 'system-sm-medium text-components-menu-item-text',@@ -264,11 +264,11 @@ export default function AccountSetting({<div className="relative flex min-h-0 min-w-0 flex-1"><divaria-hidden- className="pointer-events-none absolute inset-y-0 left-full w-screen bg-components-panel-bg"+ className="pointer-events-none absolute inset-y-0 inset-s-full w-screen bg-components-panel-bg"/><ScrollArea className="flex h-full min-h-0 min-w-0 flex-1 flex-col bg-components-panel-bg">{activeMenu !== ACCOUNT_SETTING_TAB.IP_POLICIES && (- <div className="mx-4 flex min-h-15 shrink-0 items-end bg-components-panel-bg pt-8 pr-12 pb-2 sm:mx-8">+ <div className="mx-4 flex min-h-15 shrink-0 items-end bg-components-panel-bg pe-12 pt-8 pb-2 sm:mx-8"><div className="min-w-0 flex-1"><h3 className="title-2xl-semi-bold text-text-primary">{activeItem?.title ?? activeItem?.name}diff --git a/web/app/components/header/account-setting/menu-dialog.tsx b/web/app/components/header/account-setting/menu-dialog.tsxindex 372ee73b315..6635d7d27e5 100644--- a/web/app/components/header/account-setting/menu-dialog.tsx+++ b/web/app/components/header/account-setting/menu-dialog.tsx@@ -32,7 +32,7 @@ const MenuDialog = ({ children, title, onClose }: MenuDialogProps) => {<DialogViewport><DialogPopup className="pointer-events-none isolate h-full w-full scale-100 transition-opacity data-ending-style:scale-100 data-starting-style:scale-100"><DialogTitle className="sr-only">{title}</DialogTitle>- <div className="pointer-events-auto absolute top-6 right-6 z-10 flex shrink-0 flex-col items-center">+ <div className="pointer-events-auto absolute inset-e-6 top-6 z-10 flex shrink-0 flex-col items-center"><DialogCloserender={<IconButtondiff --git a/web/app/components/header/account-setting/model-provider-page/install-from-marketplace.tsx b/web/app/components/header/account-setting/model-provider-page/install-from-marketplace.tsxindex ebe0155aca2..dc427a3389a 100644--- a/web/app/components/header/account-setting/model-provider-page/install-from-marketplace.tsx+++ b/web/app/components/header/account-setting/model-provider-page/install-from-marketplace.tsx@@ -90,11 +90,16 @@ const InstallFromMarketplace = ({<div className="flex h-5 items-center justify-between"><buttontype="button"- className="flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0 text-left system-md-semibold text-text-primary"+ className="flex cursor-pointer items-center gap-1 border-0 bg-transparent p-0 text-start system-md-semibold text-text-primary"onClick={handleToggle}aria-expanded={!collapse}>- <span className={cn('i-ri-arrow-down-s-line size-4', collapse && '-rotate-90')} />+ <span+ className={cn(+ 'i-ri-arrow-down-s-line size-4',+ collapse && '-rotate-90 rtl:rotate-90',+ )}+ />{t(($) => $['modelProvider.installProvider'], { ns: 'modelProvider' })}</button><div className="flex items-center gap-1">@@ -108,7 +113,10 @@ const InstallFromMarketplace = ({onClick={onOpenMarketplace}>{t(($) => $['marketplace.difyMarketplace'], { ns: 'plugin' })}- <span className="i-ri-arrow-right-up-line size-4" aria-hidden="true" />+ <span+ className="i-ri-arrow-right-up-line size-4 [&:dir(rtl)]:-scale-x-100"+ aria-hidden="true"+ /></button>) : (<Link@@ -118,7 +126,10 @@ const InstallFromMarketplace = ({className="inline-flex items-center system-sm-medium text-text-accent">{t(($) => $['marketplace.difyMarketplace'], { ns: 'plugin' })}- <span className="i-ri-arrow-right-up-line size-4" aria-hidden="true" />+ <span+ className="i-ri-arrow-right-up-line size-4 [&:dir(rtl)]:-scale-x-100"+ aria-hidden="true"+ /></Link>)}</div>diff --git a/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx b/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsxindex 083e059a5ce..85fb5b5a2e9 100644--- a/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx+++ b/web/app/components/header/account-setting/model-provider-page/provider-added-card/index.tsx@@ -226,10 +226,13 @@ const ProviderAddedCard: FC<ProviderAddedCardProps> = ({: t(($) => $['modelProvider.showModels'], { ns: 'modelProvider' })}</span>{!loading && (- <span aria-hidden className="ml-1 i-ri-arrow-right-s-line size-4 shrink-0" />+ <span+ aria-hidden+ className="ms-1 i-ri-arrow-right-s-line size-4 shrink-0 rtl:rotate-180"+ />)}{loading && (- <span aria-hidden className="ml-1 i-ri-loader-2-line size-3 animate-spin" />+ <span aria-hidden className="ms-1 i-ri-loader-2-line size-3 animate-spin" />)}</button>)}@@ -237,7 +240,7 @@ const ProviderAddedCard: FC<ProviderAddedCardProps> = ({<div className="flex h-8 min-w-0 flex-1 items-center justify-center rounded-lg bg-background-default-subtle px-2"><spanaria-hidden- className="mr-1 i-ri-information-2-fill size-4 shrink-0 text-text-accent"+ className="me-1 i-ri-information-2-fill size-4 shrink-0 text-text-accent"/><span className="truncate system-xs-medium text-text-secondary">{t(($) => $['modelProvider.configureTip'], { ns: 'modelProvider' })}@@ -275,7 +278,7 @@ const ProviderAddedCard: FC<ProviderAddedCardProps> = ({'bg-third-party-model-bg-anthropic',)}>- <div className="flex rounded-t-xl py-2 pr-2 pl-3">+ <div className="flex rounded-t-xl py-2 ps-3 pe-2"><div className="grow px-1 pt-1 pb-0.5"><div className="mb-2 flex items-center gap-1"><ProviderIcon provider={provider} />@@ -296,12 +299,12 @@ const ProviderAddedCard: FC<ProviderAddedCardProps> = ({{showCredential && <CredentialPanel provider={provider} />}</div>{showCollapsedSection && (- <div className="group flex items-center justify-between border-t border-t-divider-subtle py-1.5 pr-2.75 pl-2 system-xs-medium text-text-tertiary">+ <div className="group flex items-center justify-between border-t border-t-divider-subtle py-1.5 ps-2 pe-2.75 system-xs-medium text-text-tertiary">{canSetPluginPreferences && (showModelProvider || !notConfigured) && (<buttonref={collapsedButtonRef}type="button"- className="flex h-6 items-center rounded-lg border-none bg-transparent pr-1.5 pl-1 text-left outline-hidden hover:bg-components-button-ghost-bg-hover focus-visible:ring-2 focus-visible:ring-state-accent-solid"+ className="flex h-6 items-center rounded-lg border-none bg-transparent ps-1 pe-1.5 text-start outline-hidden hover:bg-components-button-ghost-bg-hover focus-visible:ring-2 focus-visible:ring-state-accent-solid"onClick={handleOpenModelList}>{hasModelList@@ -310,13 +313,15 @@ const ProviderAddedCard: FC<ProviderAddedCardProps> = ({num: modelList.length,}): t(($) => $['modelProvider.showModels'], { ns: 'modelProvider' })}- {!loading && <div className="i-ri-arrow-right-s-line size-4" aria-hidden="true" />}- {loading && <div className="ml-0.5 i-ri-loader-2-line size-3 animate-spin" />}+ {!loading && (+ <div className="i-ri-arrow-right-s-line size-4 rtl:rotate-180" aria-hidden="true" />+ )}+ {loading && <div className="ms-0.5 i-ri-loader-2-line size-3 animate-spin" />}</button>)}{!showModelProvider && notConfigured && (- <div className="flex h-6 items-center pr-1.5 pl-1">- <div className="mr-1 i-ri-information-2-fill size-4 text-text-accent" />+ <div className="flex h-6 items-center ps-1 pe-1.5">+ <div className="me-1 i-ri-information-2-fill size-4 text-text-accent" /><span className="system-xs-medium text-text-secondary">{t(($) => $['modelProvider.configureTip'], { ns: 'modelProvider' })}</span>diff --git a/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsx b/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsxindex ad35f245a58..4c97f6c4a36 100644--- a/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsx+++ b/web/app/components/header/account-setting/preference-page/__tests__/index.spec.tsx@@ -245,7 +245,7 @@ describe('PreferencePage - Interactions', () => {})await act(async () => save.resolve(response()))await waitFor(() => expect(mockGet).toHaveBeenCalled())- await waitFor(() => expect(setLocaleOnClient).toHaveBeenCalledWith(chinese.value, false))+ await waitFor(() => expect(setLocaleOnClient).toHaveBeenCalledWith(chinese.value))expect(language).toHaveAttribute('aria-readonly', 'true')expect(timezone).toHaveAttribute('aria-readonly', 'true')expect(mockRefresh).not.toHaveBeenCalled()diff --git a/web/app/components/header/account-setting/preference-page/index.tsx b/web/app/components/header/account-setting/preference-page/index.tsxindex 741c7b859dc..784e4b10f3e 100644--- a/web/app/components/header/account-setting/preference-page/index.tsx+++ b/web/app/components/header/account-setting/preference-page/index.tsx@@ -75,7 +75,7 @@ export default function PreferencePage() {await Promise.all([profileMutationOptions.onSuccess?.(data, variables, onMutateResult, context),language- ? setLocaleOnClient(language, false).then(+ ? setLocaleOnClient(language).then(() => router.refresh(),(error: unknown) => {toast.error(diff --git a/web/app/components/integrations/index.tsx b/web/app/components/integrations/index.tsxindex 84d9db49383..9493cc46c64 100644--- a/web/app/components/integrations/index.tsx+++ b/web/app/components/integrations/index.tsx@@ -108,7 +108,7 @@ const DescriptionWithLearnMore = ({ children, href, label }: DescriptionWithLearrel="noopener noreferrer">{label}- <span aria-hidden className="i-ri-external-link-line size-3" />+ <span aria-hidden className="i-ri-external-link-line size-3 [&:dir(rtl)]:-scale-x-100" /></Link></span>)diff --git a/web/app/components/main-nav/components/account-section.tsx b/web/app/components/main-nav/components/account-section.tsxindex a2e346ae4b7..56698b7a7f2 100644--- a/web/app/components/main-nav/components/account-section.tsx+++ b/web/app/components/main-nav/components/account-section.tsx@@ -24,8 +24,8 @@ const AccountSection = ({ compact = false }: AccountSectionProps) => {type="button"title={userProfile.name}className={cn(- 'flex min-w-0 shrink items-center rounded-full text-left text-components-main-nav-text transition-colors hover:bg-state-base-hover focus-visible:ring-inset disabled:cursor-default disabled:hover:bg-transparent',- compact ? 'justify-center p-1' : 'max-w-45 gap-3 py-1 pr-4 pl-1',+ 'flex min-w-0 shrink items-center rounded-full text-start text-components-main-nav-text transition-colors hover:bg-state-base-hover focus-visible:ring-inset disabled:cursor-default disabled:hover:bg-transparent',+ compact ? 'justify-center p-1' : 'max-w-45 gap-3 py-1 ps-1 pe-4','data-popup-open:bg-state-base-hover',)}>diff --git a/web/app/components/main-nav/components/help-menu.tsx b/web/app/components/main-nav/components/help-menu.tsxindex fbd6b3e4e57..bfeaaf862d5 100644--- a/web/app/components/main-nav/components/help-menu.tsx+++ b/web/app/components/main-nav/components/help-menu.tsx@@ -215,7 +215,7 @@ const HelpMenu = ({ triggerIcon, triggerClassName, triggerRef, triggerSize }: He<DropdownMenuCheckboxItemchecked={!learnDifyHidden}closeOnClick={false}- className="mx-0 h-8 gap-1 px-0 py-1 pr-2 pl-3"+ className="mx-0 h-8 gap-1 py-1 ps-3 pe-2"onCheckedChange={(checked) => setLearnDifyHidden(!checked)}><span@@ -232,7 +232,7 @@ const HelpMenu = ({ triggerIcon, triggerClassName, triggerRef, triggerSize }: He<DropdownMenuCheckboxItemchecked={stepByStepTourEnabled}closeOnClick={!stepByStepTourEnabled}- className="mx-0 h-8 gap-1 px-0 py-1 pr-2 pl-3"+ className="mx-0 h-8 gap-1 py-1 ps-3 pe-2"disabled={!canToggleStepByStepTour}onCheckedChange={handleStepByStepTourCheckedChange}>diff --git a/web/app/components/main-nav/components/web-apps-section.tsx b/web/app/components/main-nav/components/web-apps-section.tsxindex 47c486dd58f..54ccaa8eff2 100644--- a/web/app/components/main-nav/components/web-apps-section.tsx+++ b/web/app/components/main-nav/components/web-apps-section.tsx@@ -191,13 +191,13 @@ const WebAppsSectionContent = () => {onOpenChange={setAppsExpanded}className="grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)_auto] grid-rows-[auto_auto_minmax(0,1fr)]">- <CollapsibleTrigger className="group/collapsible col-start-1 row-start-1 my-1 ml-2 flex min-h-6 w-fit min-w-0 touch-manipulation items-center justify-start gap-0 rounded-md px-2 py-1 text-left system-sm-medium text-text-tertiary select-none hover:text-text-secondary">+ <CollapsibleTrigger className="group/collapsible col-start-1 row-start-1 my-1 ms-2 flex min-h-6 w-fit min-w-0 touch-manipulation items-center justify-start gap-0 rounded-md px-2 py-1 text-start system-sm-medium text-text-tertiary select-none hover:text-text-secondary"><span id={sectionLabelId} className="system-xs-medium-uppercase">{t(($) => $['sidebar.webApps'], { ns: 'explore' })}</span><spanaria-hidden- className="i-ri-arrow-down-s-fill h-4 w-4 shrink-0 -rotate-90 transition-transform group-data-panel-open/collapsible:rotate-0 motion-reduce:transition-none"+ className="i-ri-arrow-down-s-fill size-4 shrink-0 -rotate-90 transition-transform group-data-panel-open/collapsible:rotate-0 motion-reduce:transition-none rtl:rotate-90 rtl:group-data-panel-open/collapsible:rotate-0"/></CollapsibleTrigger><Collapsible@@ -206,7 +206,7 @@ const WebAppsSectionContent = () => {className="contents"><CollapsibleTrigger- className="col-start-2 row-start-1 my-1 mr-2 self-center text-text-secondary data-panel-open:bg-state-base-hover"+ className="col-start-2 row-start-1 my-1 me-2 self-center text-text-secondary data-panel-open:bg-state-base-hover"render={<IconButton aria-label={t(($) => $['operation.search'], { ns: 'common' })}><span aria-hidden className="i-ri-search-line size-3.5" />@@ -282,7 +282,7 @@ const WebAppsSectionContent = () => {onFocusCapture={row.kind === 'app' ? () => setLastFocusedAppId(row.app.id) : undefined}- className="absolute top-0 left-0 w-full"+ className="absolute inset-s-0 top-0 w-full"style={{height: `${virtualRow.size}px`,transform: `translateY(${virtualRow.start}px)`,diff --git a/web/app/components/main-nav/components/workspace-card.tsx b/web/app/components/main-nav/components/workspace-card.tsxindex 006b062711f..2d6a7f21b86 100644--- a/web/app/components/main-nav/components/workspace-card.tsx+++ b/web/app/components/main-nav/components/workspace-card.tsx@@ -54,15 +54,15 @@ function WorkspaceCardSkeleton({aria-hidden="true"className="overflow-hidden rounded-xl border border-components-card-border bg-components-card-bg shadow-xs">- <div className="flex w-full items-center gap-1.5 py-1.5 pr-3 pl-1.5">- <div className={cn(workspaceCardSkeletonClassName, 'h-6 w-6 shrink-0 rounded-lg')} />+ <div className="flex w-full items-center gap-1.5 py-1.5 ps-1.5 pe-3">+ <div className={cn(workspaceCardSkeletonClassName, 'size-6 shrink-0 rounded-lg')} /><div className="flex min-w-0 grow items-center"><div className={cn(workspaceCardSkeletonClassName, 'h-4 w-32 max-w-full')} /></div>- <div className={cn(workspaceCardSkeletonClassName, 'h-4 w-4 shrink-0')} />+ <div className={cn(workspaceCardSkeletonClassName, 'size-4 shrink-0')} /></div>{showCloudBilling && (- <div className="flex items-center justify-center gap-1.5 border-t border-divider-subtle py-2 pr-2.5 pl-2">+ <div className="flex items-center justify-center gap-1.5 border-t border-divider-subtle py-2 ps-2 pe-2.5"><div className="flex min-w-0 flex-1 items-center px-1"><div className={cn(workspaceCardSkeletonClassName, 'h-4 w-24 max-w-full')} /></div>@@ -119,13 +119,13 @@ function WorkspaceCardTrigger({const showStatus = status !== undefined && status !== nullreturn (- <div className="overflow-hidden rounded-xl border border-components-card-border bg-components-card-bg text-left shadow-xs">+ <div className="overflow-hidden rounded-xl border border-components-card-border bg-components-card-bg text-start shadow-xs"><PopoverTriggertitle={name}onMouseEnter={onPrefetchWorkspaces}onFocus={onPrefetchWorkspaces}className={cn(- 'flex w-full items-center gap-1.5 py-1.5 pr-3 pl-1.5 text-left transition-colors hover:bg-state-base-hover focus-visible:ring-inset',+ 'flex w-full items-center gap-1.5 py-1.5 ps-1.5 pe-3 text-start transition-colors hover:bg-state-base-hover focus-visible:ring-inset',showCloudBilling ? 'rounded-t-xl' : 'rounded-xl','data-popup-open:bg-linear-to-b data-popup-open:from-background-section-burn data-popup-open:to-background-section',)}@@ -134,27 +134,24 @@ function WorkspaceCardTrigger({<WorkspaceAvatar name={name} size="sm" /></span><div className="min-w-0 grow">- <div className="flex min-w-0 items-center gap-1 pr-0.5">+ <div className="flex min-w-0 items-center gap-1 pe-0.5"><span className="max-w-30 min-w-0 shrink truncate system-sm-medium text-text-primary">{name}</span>{showStatus && <span className="flex shrink-0 items-center">{status}</span>}</div></div>- <span- aria-hidden- className="i-ri-expand-up-down-line h-4 w-4 shrink-0 text-text-tertiary"- />+ <span aria-hidden className="i-ri-expand-up-down-line size-4 shrink-0 text-text-tertiary" /><span className="sr-only">{openMenuLabel}</span></PopoverTrigger>{showCloudBilling && (- <div className="flex items-center justify-center gap-1.5 border-t border-divider-subtle py-2 pr-2.5 pl-2">+ <div className="flex items-center justify-center gap-1.5 border-t border-divider-subtle py-2 ps-2 pe-2.5">{credits !== null && (<Linkhref={creditsHref}- className="flex min-w-0 flex-1 items-center gap-0.5 px-1 text-left text-text-tertiary transition-colors hover:text-text-secondary focus-visible:inset-ring-2 focus-visible:inset-ring-state-accent-solid focus-visible:outline-hidden"+ className="flex min-w-0 flex-1 items-center gap-0.5 px-1 text-start text-text-tertiary transition-colors hover:text-text-secondary focus-visible:inset-ring-2 focus-visible:inset-ring-state-accent-solid focus-visible:outline-hidden">- <span className="i-custom-vender-main-nav-credits h-3 w-3 shrink-0" aria-hidden />+ <span className="i-custom-vender-main-nav-credits size-3 shrink-0" aria-hidden /><WorkspaceCreditsLabelcredits={formattedCredits}unit={isUnlimited ? undefined : creditsUnit}@@ -212,12 +209,12 @@ function WorkspaceMenuHeader({<buttontype="button"title={settingsLabel}- className="flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-1 text-left outline-hidden hover:bg-state-base-hover focus-visible:inset-ring-2 focus-visible:inset-ring-state-accent-solid"+ className="flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-1 text-start outline-hidden hover:bg-state-base-hover focus-visible:inset-ring-2 focus-visible:inset-ring-state-accent-solid"onClick={onOpenSettings}><WorkspaceMenuItemContenticon={- <span aria-hidden className="i-custom-vender-main-nav-workspace-settings h-4 w-4" />+ <span aria-hidden className="i-custom-vender-main-nav-workspace-settings size-4" />}label={settingsLabel}/>@@ -226,11 +223,11 @@ function WorkspaceMenuHeader({<buttontype="button"title={inviteMembersLabel}- className="flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-1 text-left outline-hidden hover:bg-state-base-hover focus-visible:inset-ring-2 focus-visible:inset-ring-state-accent-solid"+ className="flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-1 text-start outline-hidden hover:bg-state-base-hover focus-visible:inset-ring-2 focus-visible:inset-ring-state-accent-solid"onClick={onInviteMembers}><WorkspaceMenuItemContent- icon={<span aria-hidden className="i-ri-user-add-line h-4 w-4" />}+ icon={<span aria-hidden className="i-ri-user-add-line size-4" />}label={inviteMembersLabel}/></button>diff --git a/web/app/components/main-nav/components/workspace-menu-content.tsx b/web/app/components/main-nav/components/workspace-menu-content.tsxindex b3d110fbc91..7c8d9711de4 100644--- a/web/app/components/main-nav/components/workspace-menu-content.tsx+++ b/web/app/components/main-nav/components/workspace-menu-content.tsx@@ -18,17 +18,15 @@ export function WorkspaceMenuItemContent({<><spanaria-hidden- className="flex h-4 w-4 shrink-0 items-center justify-center text-text-tertiary"+ className="flex size-4 shrink-0 items-center justify-center text-text-tertiary">{icon}</span>- <span className="min-w-0 flex-1 truncate text-left system-md-regular text-text-secondary">+ <span className="min-w-0 flex-1 truncate text-start system-md-regular text-text-secondary">{label}</span>{showTrailing && (- <span- className={cn('flex h-4 w-4 shrink-0 items-center justify-center', trailingClassName)}- >+ <span className={cn('flex size-4 shrink-0 items-center justify-center', trailingClassName)}>{trailing}</span>)}diff --git a/web/app/components/main-nav/components/workspace-switcher.tsx b/web/app/components/main-nav/components/workspace-switcher.tsxindex d3269c62598..f1cc0ba3a01 100644--- a/web/app/components/main-nav/components/workspace-switcher.tsx+++ b/web/app/components/main-nav/components/workspace-switcher.tsx@@ -64,7 +64,7 @@ function WorkspaceSwitchControls({return (<Collapsible>- <div className="flex items-start gap-0.5 py-1 pr-2 pl-3">+ <div className="flex items-start gap-0.5 py-1 ps-3 pe-2"><div className="flex min-w-0 flex-1 items-center justify-center py-1"><spanid={labelId}@@ -94,7 +94,7 @@ function WorkspaceSwitchControls({className="mx-0 h-8 gap-1 px-2 py-1"><span className="flex size-4 shrink-0 items-center justify-center">- <DropdownMenuRadioItemIndicator className="ml-0" />+ <DropdownMenuRadioItemIndicator className="ms-0" /></span><span className="min-w-0 flex-1 truncate px-1 system-md-regular text-text-secondary">{option.label}@@ -208,7 +208,7 @@ export function WorkspaceSwitcher({type="button"aria-current={workspace.current ? 'true' : undefined}title={workspaceName}- className="group flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-1 text-left outline-hidden hover:bg-state-base-hover focus-visible:inset-ring-2 focus-visible:inset-ring-state-accent-solid"+ className="group flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-3 py-1 text-start outline-hidden hover:bg-state-base-hover focus-visible:inset-ring-2 focus-visible:inset-ring-state-accent-solid"onClick={() => {onSwitchWorkspace(workspace.id)}}@@ -218,7 +218,7 @@ export function WorkspaceSwitcher({label={workspaceName}trailingClassName="hidden group-aria-current:flex"trailing={- <span aria-hidden className="i-ri-check-line h-4 w-4 text-text-accent" />+ <span aria-hidden className="i-ri-check-line size-4 text-text-accent" />}/></button>diff --git a/web/app/components/main-nav/index.tsx b/web/app/components/main-nav/index.tsxindex 0ac0fd9e4d6..860bb54ae7f 100644--- a/web/app/components/main-nav/index.tsx+++ b/web/app/components/main-nav/index.tsx@@ -106,7 +106,7 @@ export function MainNav({ className, initialPlatform }: MainNavProps) {)}><div className="flex min-h-0 w-60 flex-1 flex-col overflow-hidden">- <div className="flex items-center justify-between pt-3 pr-2 pb-2 pl-4">+ <div className="flex items-center justify-between ps-4 pe-2 pt-3 pb-2">{renderLogo()}<MainNavSearchButton initialPlatform={initialPlatform} /></div>@@ -124,7 +124,7 @@ export function MainNav({ className, initialPlatform }: MainNavProps) {size="xs"variant="dimm"text={t(($) => $['menus.status'], { ns: 'navigation' })}- className="ml-auto shrink-0"+ className="ms-auto shrink-0"/>)}</MainNavLink>@@ -144,9 +144,9 @@ export function MainNav({ className, initialPlatform }: MainNavProps) {<div className="isolate w-60 shrink-0"><StepByStepTourMountrecoveryAnchorRef={systemFeatures.branding.enabled ? undefined : helpMenuTriggerRef}- className="relative z-1 -mb-1 ml-2.5 h-8 w-45.75 overflow-visible"+ className="relative z-1 ms-2.5 -mb-1 h-8 w-45.75 overflow-visible"/>- <div className="flex w-60 items-center justify-between bg-linear-to-b from-background-body-transparent to-background-body to-50% py-3 pr-1 pl-3 backdrop-blur-[2px]">+ <div className="flex w-60 items-center justify-between bg-linear-to-b from-background-body-transparent to-background-body to-50% py-3 ps-3 pe-1 backdrop-blur-[2px]"><div className="flex min-w-0 items-center gap-1 overflow-hidden"><AccountSection /></div>diff --git a/web/app/components/main-nav/layout.tsx b/web/app/components/main-nav/layout.tsxindex 7b6635b404e..5705fdb0d77 100644--- a/web/app/components/main-nav/layout.tsx+++ b/web/app/components/main-nav/layout.tsx@@ -16,7 +16,7 @@ import { usePathname } from '@/next/navigation'import { MainNav } from '.'import { ResponsiveMainNav } from './responsive-main-nav'import { shouldHideMainNavigation, shouldUseDetailSidebar } from './routes'-import { MAIN_CONTENT_ID, SkipNav } from './skip-nav'+import { MAIN_CONTENT_ID, SkipLink } from './skip-link'type MainNavLayoutProps = {children: ReactNode@@ -53,7 +53,7 @@ const MainNavLayout = ({useResponsiveNavigation && 'flex-col md:flex-row',)}>- <SkipNav>{t(($) => $['navigation.skipToMain'])}</SkipNav>+ <SkipLink>{t(($) => $['navigation.skipToMain'])}</SkipLink>{appId && <AppDetailPrefetch appId={appId} />}{hideMainNavigation ? null : useDetailSidebar ? (detailSidebardiff --git a/web/app/components/main-nav/skip-link.tsx b/web/app/components/main-nav/skip-link.tsxnew file mode 100644index 00000000000..9f491c8f36d--- /dev/null+++ b/web/app/components/main-nav/skip-link.tsx@@ -0,0 +1,31 @@+'use client'++import type { ComponentProps, MouseEventHandler } from 'react'+import { cn } from '@langgenius/dify-ui/cn'++export const MAIN_CONTENT_ID = 'main-content'+const MAIN_CONTENT_HREF = `#${MAIN_CONTENT_ID}`++export function SkipLink({ className, children, onClick, ...props }: ComponentProps<'a'>) {+ const handleClick: MouseEventHandler<HTMLAnchorElement> = (event) => {+ onClick?.(event)++ if (event.defaultPrevented) return++ document.getElementById(MAIN_CONTENT_ID)?.focus()+ }++ return (+ <a+ href={MAIN_CONTENT_HREF}+ onClick={handleClick}+ className={cn(+ 'fixed inset-s-2 top-2 z-60 inline-flex h-9 -translate-y-[calc(100%+0.75rem)] items-center justify-center rounded-lg border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg px-3 system-sm-medium text-components-button-secondary-text outline-hidden backdrop-blur-[5px] transition-transform duration-150 focus-visible:translate-y-0 focus-visible:shadow-lg focus-visible:ring-2 focus-visible:shadow-shadow-shadow-5 focus-visible:ring-state-accent-solid motion-reduce:transition-none',+ className,+ )}+ {...props}+ >+ {children}+ </a>+ )+}diff --git a/web/app/components/main-nav/skip-nav.tsx b/web/app/components/main-nav/skip-nav.tsxdeleted file mode 100644index 9d63984b9ca..00000000000--- a/web/app/components/main-nav/skip-nav.tsx+++ /dev/null@@ -1,31 +0,0 @@-'use client'--import type { ComponentProps, MouseEventHandler } from 'react'-import { cn } from '@langgenius/dify-ui/cn'--export const MAIN_CONTENT_ID = 'main-content'-const MAIN_CONTENT_HREF = `#${MAIN_CONTENT_ID}`--export function SkipNav({ className, children, onClick, ...props }: ComponentProps<'a'>) {- const handleClick: MouseEventHandler<HTMLAnchorElement> = (event) => {- onClick?.(event)-- if (event.defaultPrevented) return-- document.getElementById(MAIN_CONTENT_ID)?.focus()- }-- return (- <a- href={MAIN_CONTENT_HREF}- onClick={handleClick}- className={cn(- 'fixed top-2 left-2 z-60 inline-flex h-9 -translate-y-[calc(100%+0.75rem)] items-center justify-center rounded-lg border-[0.5px] border-components-button-secondary-border bg-components-button-secondary-bg px-3 system-sm-medium text-components-button-secondary-text outline-hidden backdrop-blur-[5px] transition-transform duration-150 focus-visible:translate-y-0 focus-visible:shadow-lg focus-visible:ring-2 focus-visible:shadow-shadow-shadow-5 focus-visible:ring-state-accent-solid motion-reduce:transition-none',- className,- )}- {...props}- >- {children}- </a>- )-}diff --git a/web/app/components/plugins/marketplace/home/__tests__/home-trending-loop.browser.spec.tsx b/web/app/components/plugins/marketplace/home/__tests__/home-trending-loop.browser.spec.tsxindex 0e046391a1f..7ed91b506c1 100644--- a/web/app/components/plugins/marketplace/home/__tests__/home-trending-loop.browser.spec.tsx+++ b/web/app/components/plugins/marketplace/home/__tests__/home-trending-loop.browser.spec.tsx@@ -1,4 +1,5 @@import type { PluginBanner } from '@dify/contracts/marketplace'+import { DirectionProvider } from '@langgenius/dify-ui/direction-provider'import { render } from 'vitest-browser-react'import HomeTrending from '../home-trending'@@ -28,30 +29,51 @@ describe('Marketplace home trending loop', () => {// The unit spec stubs the autoplay animation and fires a synthetic// transitionend; only real rendering proves the track transition completes// and returns the carousel from the loop clone to the first slide.- it('wraps from the last banner back to the first visible slide', async () => {- const screen = await render(- <HomeTrending banners={carouselBanners} isMarketplacePlatform page="plugins" />,- )-- await screen.getByRole('button', { name: 'Third banner' }).click()- expect(screen.getByRole('button', { name: 'Third banner' }).element()).toHaveAttribute(- 'aria-current',- 'true',- )+ it.each(['ltr', 'rtl'] as const)(+ 'wraps from the last banner back to the first visible slide in %s',+ async (direction) => {+ const screen = await render(+ <DirectionProvider direction={direction}>+ <div dir={direction}>+ <HomeTrending banners={carouselBanners} isMarketplacePlatform page="plugins" />+ </div>+ </DirectionProvider>,+ )- await expect- .poll(- () =>- screen- .getByRole('button', { name: 'First banner' })- .element()- .getAttribute('aria-current'),- { timeout: 8000 },+ await screen.getByRole('button', { name: 'Third banner' }).click()+ expect(screen.getByRole('button', { name: 'Third banner' }).element()).toHaveAttribute(+ 'aria-current',+ 'true',)- .toBe('true')- expect(screen.getByRole('group', { name: 'First banner' }).element()).not.toHaveAttribute(- 'inert',- )- })+ const expectSlideInViewport = async (name: string) => {+ await expect+ .poll(() => {+ const viewport = document+ .querySelector('[data-home-trending-carousel-root]')!+ .getBoundingClientRect()+ const slide = screen.getByRole('group', { name }).element().getBoundingClientRect()+ return slide.left >= viewport.left - 1 && slide.right <= viewport.right + 1+ })+ .toBe(true)+ }+ await expectSlideInViewport('Third banner')++ await expect+ .poll(+ () =>+ screen+ .getByRole('button', { name: 'First banner' })+ .element()+ .getAttribute('aria-current'),+ { timeout: 8000 },+ )+ .toBe('true')++ await expectSlideInViewport('First banner')+ expect(screen.getByRole('group', { name: 'First banner' }).element()).not.toHaveAttribute(+ 'inert',+ )+ },+ )})diff --git a/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsx b/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsxindex d74fc0ec704..c3e2a64743c 100644--- a/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsx+++ b/web/app/components/plugins/marketplace/home/__tests__/home-trending.spec.tsx@@ -1,6 +1,7 @@import type { PluginBanner } from '@dify/contracts/marketplace'import type { Window } from 'happy-dom'import type { ReactElement } from 'react'+import { DirectionProvider } from '@langgenius/dify-ui/direction-provider'import { act, fireEvent, screen, waitFor, within } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'@@ -815,47 +816,56 @@ describe('HomeTrending', () => {fireEvent.pointerUp(slide, { ...touch, clientX, clientY })}- const renderCarousel = () =>- render(<HomeTrending banners={banners} isMarketplacePlatform page="plugins" />)+ const renderCarousel = (direction: 'ltr' | 'rtl' = 'ltr') =>+ render(+ <DirectionProvider direction={direction}>+ <div dir={direction}>+ <HomeTrending banners={banners} isMarketplacePlatform page="plugins" />+ </div>+ </DirectionProvider>,+ )afterEach(() => {vi.restoreAllMocks()})- it('switches in both directions without activating a dragged link or clearing Pause', async () => {- const user = userEvent.setup()- stubViewport(true)- renderCarousel()-- swipe(screen.getByRole('group', { name: 'Trending' }), [- [480, 160],- [300, 166],- ])+ it.each(['ltr', 'rtl'] as const)(+ 'swipes forward and back without activating a link or clearing Pause in %s',+ async (direction) => {+ const user = userEvent.setup()+ stubViewport(true)+ renderCarousel(direction)- expect(fireEvent.click(screen.getByRole('link', { name: 'Dropbox', hidden: true }))).toBe(- false,- )- expect(screen.getByRole('button', { name: 'Dify Updates' })).toHaveAttribute(- 'aria-current',- 'true',- )+ swipe(screen.getByRole('group', { name: 'Trending' }), [+ [direction === 'ltr' ? 480 : 300, 160],+ [direction === 'ltr' ? 300 : 480, 166],+ ])- await user.click(- screen.getByRole('button', { name: 'plugin.marketplace.home.trendingPause' }),- )- swipe(screen.getByRole('group', { name: 'Dify Updates' }), [- [260, 160],- [440, 166],- ])+ expect(fireEvent.click(screen.getByRole('link', { name: 'Dropbox', hidden: true }))).toBe(+ false,+ )+ expect(screen.getByRole('button', { name: 'Dify Updates' })).toHaveAttribute(+ 'aria-current',+ 'true',+ )- expect(screen.getByRole('button', { name: 'Trending' })).toHaveAttribute(- 'aria-current',- 'true',- )- expect(- screen.getByRole('button', { name: 'plugin.marketplace.home.trendingPlay' }),- ).toBeInTheDocument()- })+ await user.click(+ screen.getByRole('button', { name: 'plugin.marketplace.home.trendingPause' }),+ )+ swipe(screen.getByRole('group', { name: 'Dify Updates' }), [+ [direction === 'ltr' ? 260 : 440, 160],+ [direction === 'ltr' ? 440 : 260, 166],+ ])++ expect(screen.getByRole('button', { name: 'Trending' })).toHaveAttribute(+ 'aria-current',+ 'true',+ )+ expect(+ screen.getByRole('button', { name: 'plugin.marketplace.home.trendingPlay' }),+ ).toBeInTheDocument()+ },+ )it('suppresses the trailing click when a horizontal drag is pulled back before release', () => {stubViewport(true)diff --git a/web/app/components/plugins/marketplace/home/home-trending-navigation.tsx b/web/app/components/plugins/marketplace/home/home-trending-navigation.tsxindex 7a86be5d3f1..53547ea3b79 100644--- a/web/app/components/plugins/marketplace/home/home-trending-navigation.tsx+++ b/web/app/components/plugins/marketplace/home/home-trending-navigation.tsx@@ -209,23 +209,23 @@ function TrendingNavigation({aria-label={t(($) => $['marketplace.home.trendingPaginationLabel'])}className={cn(styles.navigation,- 'absolute right-0 z-10 flex h-[22px] items-center gap-2 px-5 py-2',+ 'absolute inset-e-0 z-10 flex h-[22px] items-center gap-2 px-5 py-2',)}><div className="relative h-1.5 shrink-0" style={{ width: paginationWidth }}><spanaria-hidden- className="pointer-events-none absolute top-0 left-0 z-1 flex h-1.5 w-10 items-center overflow-hidden rounded-full bg-state-base-handle transition-transform duration-500 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform motion-reduce:transition-none"+ className="pointer-events-none absolute inset-s-0 top-0 z-1 flex h-1.5 w-10 items-center overflow-hidden rounded-full bg-state-base-handle transition-transform duration-500 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform motion-reduce:transition-none"style={{- transform: `translate3d(${selectedIndex * PAGINATION_STEP}px, 0, 0)`,+ transform: `translate3d(calc(var(--pagination-direction) * ${selectedIndex * PAGINATION_STEP}px), 0, 0)`,}}><spankey={selectedIndex}ref={progressRef}data-carousel-progress- className="h-full w-full rounded-full bg-text-accent"- style={{ transform: 'scaleX(0)', transformOrigin: 'left center' }}+ className="h-full w-full origin-left rounded-full bg-text-accent rtl:origin-right"+ style={{ transform: 'scaleX(0)' }}/></span>{banners.map((banner, index) => {@@ -246,12 +246,12 @@ function TrendingNavigation({clearImplicitPauseReasons()}}className={cn(- 'absolute top-0 left-0 z-2 h-1.5 overflow-hidden rounded-full outline-hidden transition-[transform,width,background-color] duration-500 ease-[cubic-bezier(0.22,1,0.36,1)] after:absolute after:-inset-2 hover:bg-state-base-handle-hover focus-visible:ring-2 focus-visible:ring-state-accent-solid motion-reduce:transition-none',+ 'absolute inset-s-0 top-0 z-2 h-1.5 overflow-hidden rounded-full outline-hidden transition-[transform,width,background-color] duration-500 ease-[cubic-bezier(0.22,1,0.36,1)] after:absolute after:-inset-2 hover:bg-state-base-handle-hover focus-visible:ring-2 focus-visible:ring-state-accent-solid motion-reduce:transition-none',isCurrent ? 'bg-transparent' : 'bg-state-base-handle',)}style={{width: isCurrent ? PAGINATION_ACTIVE_WIDTH : PAGINATION_DOT_SIZE,- transform: `translate3d(${getPaginationItemOffset(index, selectedIndex)}px, 0, 0)`,+ transform: `translate3d(calc(var(--pagination-direction) * ${getPaginationItemOffset(index, selectedIndex)}px), 0, 0)`,}}/>)diff --git a/web/app/components/plugins/marketplace/home/home-trending.module.css b/web/app/components/plugins/marketplace/home/home-trending.module.cssindex 34272cf272b..ee01a2b5373 100644--- a/web/app/components/plugins/marketplace/home/home-trending.module.css+++ b/web/app/components/plugins/marketplace/home/home-trending.module.css@@ -23,10 +23,15 @@}.navigation {+ --pagination-direction: 1;top: 208px;width: 100%;}+.navigation:dir(rtl) {+ --pagination-direction: -1;+}+.contentTrack {transition: transform 400ms ease-out;}diff --git a/web/app/components/plugins/marketplace/home/home-trending.tsx b/web/app/components/plugins/marketplace/home/home-trending.tsxindex 68a03da4b7f..824d537d260 100644--- a/web/app/components/plugins/marketplace/home/home-trending.tsx+++ b/web/app/components/plugins/marketplace/home/home-trending.tsx@@ -8,6 +8,7 @@ import type {} from 'react'import type { MarketplaceBannerPage } from './banners'import { cn } from '@langgenius/dify-ui/cn'+import { useDirection } from '@langgenius/dify-ui/direction-provider'import { useCallback, useEffect, useRef, useState } from 'react'import { useTranslation } from '#i18n'import { trackEvent } from '@/app/components/base/amplitude'@@ -93,6 +94,8 @@ function HomeTrending({page: MarketplaceBannerPage}) {const { t } = useTranslation(['plugin'])+ const direction = useDirection()+ const directionMultiplier = direction === 'rtl' ? -1 : 1const carouselRootRef = useRef<HTMLDivElement>(null)const swipeGestureRef = useRef<SwipeGesture | null>(null)const suppressClickRef = useRef(false)@@ -234,11 +237,12 @@ function HomeTrending({const viewportWidth = event.currentTarget.getBoundingClientRect().widthconst boundedOffset = Math.max(-viewportWidth, Math.min(viewportWidth, deltaX))- const isPastStart = gesture.selectedIndex === 0 && boundedOffset > 0- const isPastEnd = gesture.selectedIndex === banners.length - 1 && boundedOffset < 0+ const isPastStart = gesture.selectedIndex === 0 && boundedOffset * directionMultiplier > 0+ const isPastEnd =+ gesture.selectedIndex === banners.length - 1 && boundedOffset * directionMultiplier < 0setDragOffset(isPastStart || isPastEnd ? boundedOffset * 0.35 : boundedOffset)},- [banners.length],+ [banners.length, directionMultiplier],)const finishSwipe = useCallback(@@ -274,11 +278,12 @@ function HomeTrending({)if (Math.abs(deltaX) < swipeThreshold) return- if (deltaX < 0 && gesture.selectedIndex < banners.length - 1)+ if (deltaX * directionMultiplier < 0 && gesture.selectedIndex < banners.length - 1)selectSlide(gesture.selectedIndex + 1)- else if (deltaX > 0 && gesture.selectedIndex > 0) selectSlide(gesture.selectedIndex - 1)+ else if (deltaX * directionMultiplier > 0 && gesture.selectedIndex > 0)+ selectSlide(gesture.selectedIndex - 1)},- [banners.length, selectSlide],+ [banners.length, directionMultiplier, selectSlide],)const handleClickCapture = useCallback((event: ReactMouseEvent<HTMLDivElement>) => {@@ -346,8 +351,8 @@ function HomeTrending({style={{transform:dragOffset === 0- ? `translate3d(-${trackIndex * 100}%, 0, 0)`- : `translate3d(calc(-${trackIndex * 100}% + ${dragOffset}px), 0, 0)`,+ ? `translate3d(${-trackIndex * 100 * directionMultiplier}%, 0, 0)`+ : `translate3d(calc(${-trackIndex * 100 * directionMultiplier}% + ${dragOffset}px), 0, 0)`,transition: loopPhase === 'resetting' || isDragging ? 'none' : undefined,}}>diff --git a/web/app/components/plugins/marketplace/list/__tests__/list-with-collection-layout.browser.spec.tsx b/web/app/components/plugins/marketplace/list/__tests__/list-with-collection-layout.browser.spec.tsxindex 4c696640363..c35e4c07708 100644--- a/web/app/components/plugins/marketplace/list/__tests__/list-with-collection-layout.browser.spec.tsx+++ b/web/app/components/plugins/marketplace/list/__tests__/list-with-collection-layout.browser.spec.tsx@@ -1,7 +1,9 @@import type { MarketplaceCollection } from '@dify/contracts/marketplace'import type { Plugin } from '@/app/components/plugins/types'+import { DirectionProvider } from '@langgenius/dify-ui/direction-provider'import { page } from 'vite-plus/test/browser'import { render } from 'vitest-browser-react'+import Carousel from '../carousel'import ListWithCollection from '../list-with-collection'vi.mock('#i18n', async () => {@@ -9,6 +11,7 @@ vi.mock('#i18n', async () => {const translations: Record<string, string> = {'marketplace.becomePartner': 'Torne-se um parceiro','marketplace.carousel.scrollPrevious': 'Previous',+ 'marketplace.carousel.scrollNext': 'Next',}return {@@ -53,39 +56,86 @@ const partnerPlugins = Array.from({ length: 9 }, (_, index) => ({})) as Plugin[]describe('Partner collection header layout', () => {- it('keeps a long mobile call to action clear of carousel controls at a 320px viewport', async () => {- await page.viewport(320, 844)- const screen = await render(- <div data-marketplace-standalone style={{ width: 280 }}>- <ListWithCollection- marketplaceCollections={[partnerCollection]}- marketplaceCollectionPluginsMap={{ partners: partnerPlugins }}- />- </div>,- )+ it.each(['ltr', 'rtl'] as const)(+ 'keeps the mobile call to action clear of carousel controls in %s',+ async (direction) => {+ await page.viewport(320, 844)+ const screen = await render(+ <DirectionProvider direction={direction}>+ <div dir={direction} data-marketplace-standalone style={{ width: 280 }}>+ <ListWithCollection+ marketplaceCollections={[partnerCollection]}+ marketplaceCollectionPluginsMap={{ partners: partnerPlugins }}+ />+ </div>+ </DirectionProvider>,+ )- await expect.element(screen.getByRole('button', { name: 'Previous' })).toBeVisible()- await expect.element(screen.getByRole('link', { name: 'Torne-se um parceiro' })).toBeVisible()- const titleRect = screen- .getByText('Partners', { exact: true })- .element()- .getBoundingClientRect()- const descriptionRect = screen- .getByText('Plugins verified by Dify partners.')- .element()- .getBoundingClientRect()- const partnerLinkRect = screen- .getByRole('link', { name: 'Torne-se um parceiro' })- .element()- .getBoundingClientRect()- const previousButtonRect = screen- .getByRole('button', { name: 'Previous' })- .element()- .getBoundingClientRect()+ await expect.element(screen.getByRole('button', { name: 'Previous' })).toBeVisible()+ await expect.element(screen.getByRole('link', { name: 'Torne-se um parceiro' })).toBeVisible()+ const titleRect = screen+ .getByText('Partners', { exact: true })+ .element()+ .getBoundingClientRect()+ const descriptionRect = screen+ .getByText('Plugins verified by Dify partners.')+ .element()+ .getBoundingClientRect()+ const partnerLinkRect = screen+ .getByRole('link', { name: 'Torne-se um parceiro' })+ .element()+ .getBoundingClientRect()+ const previousButtonRect = screen+ .getByRole('button', { name: 'Previous' })+ .element()+ .getBoundingClientRect()- expect(previousButtonRect.left - partnerLinkRect.right).toBeGreaterThanOrEqual(8)- expect(descriptionRect.top).toBeGreaterThanOrEqual(- Math.max(titleRect.bottom, partnerLinkRect.bottom),- )- })+ const gap =+ direction === 'ltr'+ ? previousButtonRect.left - partnerLinkRect.right+ : partnerLinkRect.left - previousButtonRect.right+ expect(gap).toBeGreaterThanOrEqual(8)+ expect(descriptionRect.top).toBeGreaterThanOrEqual(+ Math.max(titleRect.bottom, partnerLinkRect.bottom),+ )+ },+ )+})++describe('Marketplace carousel direction', () => {+ it.each(['ltr', 'rtl'] as const)(+ 'keeps the next and previous pages inside the viewport in %s',+ async (direction) => {+ // Real Embla transforms can place an ARIA-visible slide outside the viewport.+ const screen = await render(+ <DirectionProvider direction={direction}>+ <div dir={direction} style={{ width: 280, paddingTop: 48 }}>+ <Carousel+ ariaLabel="Featured plugins"+ pages={Array.from({ length: 3 }, (_, index) => ({+ id: `page-${index}`,+ content: <button type="button">Plugin {index + 1}</button>,+ }))}+ />+ </div>+ </DirectionProvider>,+ )+ const carousel = screen.getByRole('region', { name: 'Featured plugins' })+ for (const [action, pageNumber] of [+ ['Next', 2],+ ['Previous', 1],+ ] as const) {+ await screen.getByRole('button', { name: action, exact: true }).click()+ const slide = screen.getByRole('group', { name: `${pageNumber} / 3` })+ await expect.element(slide).toBeVisible()+ await expect+ .poll(() => {+ const viewport = carousel.element().getBoundingClientRect()+ const selected = slide.element().getBoundingClientRect()+ return selected.left >= viewport.left - 1 && selected.right <= viewport.right + 1+ })+ .toBe(true)+ }+ },+ )})diff --git a/web/app/components/plugins/marketplace/list/carousel.tsx b/web/app/components/plugins/marketplace/list/carousel.tsxindex 3c9380bc53e..323f5a34728 100644--- a/web/app/components/plugins/marketplace/list/carousel.tsx+++ b/web/app/components/plugins/marketplace/list/carousel.tsx@@ -2,6 +2,7 @@import type { ReactNode } from 'react'import { cn } from '@langgenius/dify-ui/cn'+import { useDirection } from '@langgenius/dify-ui/direction-provider'import Autoplay from 'embla-carousel-autoplay'import useEmblaCarousel from 'embla-carousel-react'import { useCallback, useEffect, useMemo, useRef, useState } from 'react'@@ -46,7 +47,7 @@ const NavButton = ({ disabled, label, onClick, iconClassName }: NavButtonProps)><spanaria-hidden- className={cn('size-4 text-components-button-secondary-text', iconClassName)}+ className={cn('size-4 text-components-button-secondary-text rtl:rotate-180', iconClassName)}/></button>)@@ -80,7 +81,7 @@ const CarouselControls = ({if (totalPages === 0 || (totalPages === 1 && !showSinglePageNavigation)) return nullreturn (- <div className="absolute -top-10 right-0 flex items-center gap-3">+ <div className="absolute inset-e-0 -top-10 flex items-center gap-3">{showPagination && (<div className={cn(styles.pagination, 'flex items-center gap-1')}>{paginationItems.map((item, index) => (@@ -89,7 +90,7 @@ const CarouselControls = ({type="button"aria-current={selectedIndex === index ? 'page' : undefined}className={cn(- 'h-1.25 w-1.25 rounded-full transition-all',+ 'size-1.25 rounded-full transition-all',selectedIndex === index? 'w-4 bg-components-button-primary-bg': 'bg-components-button-secondary-border hover:bg-components-button-secondary-border-hover',@@ -145,6 +146,7 @@ const Carousel = ({deferMountPages = false,pauseWhenOffscreen = false,}: CarouselProps) => {+ const direction = useDirection()const carouselRootRef = useRef<HTMLDivElement>(null)const [isFocusPaused, setIsFocusPaused] = useState(false)// Tracked independently of pauseWhenOffscreen so every autoplay path honors@@ -166,7 +168,7 @@ const Carousel = ({}, [autoPlay, autoPlayInterval, pauseWhenOffscreen])const plugins = useMemo(() => (autoplay ? [autoplay] : []), [autoplay])const [carouselRef, api] = useEmblaCarousel(- { align: 'start', containScroll: 'trimSnaps', loop: true },+ { align: 'start', containScroll: 'trimSnaps', loop: true, direction },plugins,)const [selectedIndex, setSelectedIndex] = useState(0)diff --git a/web/app/components/plugins/marketplace/list/list-with-collection.tsx b/web/app/components/plugins/marketplace/list/list-with-collection.tsxindex d799c88876a..90ff9547048 100644--- a/web/app/components/plugins/marketplace/list/list-with-collection.tsx+++ b/web/app/components/plugins/marketplace/list/list-with-collection.tsx@@ -233,7 +233,10 @@ const CollectionSection = ({</span><spanaria-hidden- className={cn(styles.partnerActionIcon, 'i-ri-external-link-line size-3')}+ className={cn(+ styles.partnerActionIcon,+ 'i-ri-external-link-line size-3 [&:dir(rtl)]:-scale-x-100',+ )}/></a></>diff --git a/web/app/components/plugins/marketplace/list/partner-header.module.css b/web/app/components/plugins/marketplace/list/partner-header.module.cssindex 3124c729091..fbe4412a829 100644--- a/web/app/components/plugins/marketplace/list/partner-header.module.css+++ b/web/app/components/plugins/marketplace/list/partner-header.module.css@@ -12,7 +12,7 @@}:global([data-marketplace-standalone]) .partnerHeaderWithNavigation {- padding-right: 80px;+ padding-inline-end: 80px;}:global([data-marketplace-standalone]) .partnerTitle {diff --git a/web/app/components/plugins/marketplace/plugin-type-switch.tsx b/web/app/components/plugins/marketplace/plugin-type-switch.tsxindex e611b096a7f..8dad5ad7bfd 100644--- a/web/app/components/plugins/marketplace/plugin-type-switch.tsx+++ b/web/app/components/plugins/marketplace/plugin-type-switch.tsx@@ -19,7 +19,6 @@ const PluginTypeSwitch = ({ className, variant = 'default' }: PluginTypeSwitchPrconst setSearchMode = useSetAtom(searchModeAtom)const isHero = variant === 'hero'const isHome = variant === 'home'- const iconClassName = 'mr-1.5 size-4'const options: Array<{value: ActivePluginType@@ -33,50 +32,40 @@ const PluginTypeSwitch = ({ className, variant = 'default' }: PluginTypeSwitchPr: t(($) => $['category.all'], { ns: 'plugin' }),icon:isHero || isHome ? (- <span- aria-hidden- className={cn('i-custom-vender-plugin-plugin h-4 w-4', iconClassName)}- />+ <span aria-hidden className="i-custom-vender-plugin-plugin size-4" />) : null,},{value: PLUGIN_TYPE_SEARCH_MAP.model,text: t(($) => $['category.models'], { ns: 'plugin' }),- icon: <span aria-hidden className={cn('i-ri-brain-2-line', iconClassName)} />,+ icon: <span aria-hidden className="i-ri-brain-2-line size-4" />,},{value: PLUGIN_TYPE_SEARCH_MAP.tool,text: t(($) => $['category.tools'], { ns: 'plugin' }),- icon: <span aria-hidden className={cn('i-ri-hammer-line', iconClassName)} />,+ icon: <span aria-hidden className="i-ri-hammer-line size-4" />,},{value: PLUGIN_TYPE_SEARCH_MAP.datasource,text: t(($) => $[isHome ? 'categorySingle.datasource' : 'category.datasources'], {ns: 'plugin',}),- icon: <span aria-hidden className={cn('i-ri-database-2-line', iconClassName)} />,+ icon: <span aria-hidden className="i-ri-database-2-line size-4" />,},{value: PLUGIN_TYPE_SEARCH_MAP.agent,text: t(($) => $[isHome ? 'categorySingle.agent' : 'category.agents'], { ns: 'plugin' }),- icon: (- <span- aria-hidden- className={cn('i-custom-vender-integrations-agent-strategy', iconClassName)}- />- ),+ icon: <span aria-hidden className="i-custom-vender-integrations-agent-strategy size-4" />,},{value: PLUGIN_TYPE_SEARCH_MAP.trigger,text: t(($) => $['category.triggers'], { ns: 'plugin' }),- icon: (- <span aria-hidden className={cn('i-custom-vender-integrations-trigger', iconClassName)} />- ),+ icon: <span aria-hidden className="i-custom-vender-integrations-trigger size-4" />,},{value: PLUGIN_TYPE_SEARCH_MAP.extension,text: t(($) => $['category.extensions'], { ns: 'plugin' }),- icon: <span aria-hidden className={cn('i-ri-puzzle-2-line', iconClassName)} />,+ icon: <span aria-hidden className="i-ri-puzzle-2-line size-4" />,},]@@ -104,7 +93,7 @@ const PluginTypeSwitch = ({ className, variant = 'default' }: PluginTypeSwitchPrtype="button"aria-pressed={isActive}className={cn(- 'flex h-8 cursor-pointer appearance-none items-center rounded-lg border border-transparent px-2.5 system-md-medium whitespace-nowrap outline-hidden focus-visible:ring-2 focus-visible:ring-state-accent-solid',+ 'flex h-8 cursor-pointer appearance-none items-center gap-1.5 rounded-lg border border-transparent px-2.5 system-md-medium whitespace-nowrap outline-hidden focus-visible:ring-2 focus-visible:ring-state-accent-solid',isHero? 'text-text-primary-on-surface': isHomediff --git a/web/app/components/plugins/marketplace/templates/template-collection-list.tsx b/web/app/components/plugins/marketplace/templates/template-collection-list.tsxindex ae3259f2bff..790bce28577 100644--- a/web/app/components/plugins/marketplace/templates/template-collection-list.tsx+++ b/web/app/components/plugins/marketplace/templates/template-collection-list.tsx@@ -115,7 +115,10 @@ export default function TemplateCollectionList({<span className={styles.partnerActionLabel}>{becomePartnerText}</span><spanaria-hidden- className={cn(styles.partnerActionIcon, 'i-ri-external-link-line size-3')}+ className={cn(+ styles.partnerActionIcon,+ 'i-ri-external-link-line size-3 [&:dir(rtl)]:-scale-x-100',+ )}/></a></>diff --git a/web/app/components/plugins/plugin-page/category-marketplace-panel.tsx b/web/app/components/plugins/plugin-page/category-marketplace-panel.tsxindex 3af8cc48a97..fc1396c7d04 100644--- a/web/app/components/plugins/plugin-page/category-marketplace-panel.tsx+++ b/web/app/components/plugins/plugin-page/category-marketplace-panel.tsx@@ -96,7 +96,7 @@ const CategoryMarketplacePanel = ({><spanaria-hidden- className={cn('i-ri-arrow-down-s-line size-4', collapsed && '-rotate-90')}+ className={cn('i-ri-arrow-down-s-line size-4', collapsed && '-rotate-90 rtl:rotate-90')}/>{t(($) => $['list.source.marketplace'], { ns: 'plugin' })}</button>@@ -111,7 +111,10 @@ const CategoryMarketplacePanel = ({target="_blank">{t(($) => $['marketplace.difyMarketplace'], { ns: 'plugin' })}- <span aria-hidden className="i-ri-arrow-right-up-line size-4" />+ <span+ aria-hidden+ className="i-ri-arrow-right-up-line size-4 [&:dir(rtl)]:-scale-x-100"+ /></Link></div></div>diff --git a/web/app/components/provider/__tests__/i18n-direction.browser.spec.tsx b/web/app/components/provider/__tests__/i18n-direction.browser.spec.tsxnew file mode 100644index 00000000000..5f91389c3bb--- /dev/null+++ b/web/app/components/provider/__tests__/i18n-direction.browser.spec.tsx@@ -0,0 +1,88 @@+import { Tabs, TabsList, TabsTab } from '@langgenius/dify-ui/tabs'+import Cookies from 'js-cookie'+import { page, userEvent } from 'vite-plus/test/browser'+import { render } from 'vitest-browser-react'+import {+ DatePicker,+ DatePickerContent,+ DatePickerLabel,+ DatePickerTrigger,+} from '@/app/components/base/date-time-picker/date-picker'+import { I18nClientProvider } from '@/app/components/provider/i18n'+import { LOCALE_COOKIE_NAME } from '@/config'+import { setLocaleOnClient } from '@/i18n/client'+import arTime from '@/i18n/locales/ar-TN/time.json'+import enTime from '@/i18n/locales/en-US/time.json'++vi.mock('react-i18next', async (importOriginal) => await importOriginal())+vi.mock('@/next/navigation', () => ({ useServerInsertedHTML: () => {} }))++function LanguageControls() {+ return (+ <>+ <button onClick={() => void setLocaleOnClient('ar-TN')}>Arabic</button>+ <button onClick={() => void setLocaleOnClient('en-US')}>English</button>+ </>+ )+}++it('keeps document layout, keyboard navigation and portaled pickers aligned when language changes', async () => {+ const { lang, dir } = document.documentElement+ const savedLocale = Cookies.get(LOCALE_COOKIE_NAME)+ const screen = await render(+ <I18nClientProvider+ locale="en-US"+ resource={{ 'en-US': { time: enTime }, 'ar-TN': { time: arTime } }}+ >+ <LanguageControls />+ <Tabs defaultValue="first">+ <TabsList aria-label="Sections">+ <TabsTab value="first">First</TabsTab>+ <TabsTab value="second">Second</TabsTab>+ <TabsTab value="third">Third</TabsTab>+ </TabsList>+ </Tabs>+ <DatePicker defaultValue="2025-01-15">+ <DatePickerLabel>Date</DatePickerLabel>+ <DatePickerTrigger />+ <DatePickerContent />+ </DatePicker>+ </I18nClientProvider>,+ )+ try {+ const first = screen.getByRole('tab', { name: 'First' })+ const second = screen.getByRole('tab', { name: 'Second' })+ await second.click()+ await screen.getByRole('button', { name: 'Arabic' }).click()+ await expect.poll(() => document.documentElement.lang).toBe('ar-TN')+ expect(document.documentElement.dir).toBe('rtl')+ expect(Cookies.get(LOCALE_COOKIE_NAME)).toBe('ar-TN')+ await expect.element(second).toHaveAttribute('aria-selected', 'true')+ expect(second.element().getBoundingClientRect().left).toBeLessThan(+ first.element().getBoundingClientRect().left,+ )+ await first.click()+ await userEvent.keyboard('{ArrowLeft}')+ await expect.element(second).toHaveFocus()+ await screen.getByRole('button', { name: /^Date / }).click()+ await expect.element(page.getByRole('dialog')).toHaveAttribute('dir', 'rtl')+ await userEvent.keyboard('{Escape}')+ await second.click()+ await screen.getByRole('button', { name: 'English' }).click()+ await expect.poll(() => document.documentElement.lang).toBe('en-US')+ expect(document.documentElement.dir).toBe('ltr')+ expect(Cookies.get(LOCALE_COOKIE_NAME)).toBe('en-US')+ await expect.element(second).toHaveAttribute('aria-selected', 'true')+ expect(second.element().getBoundingClientRect().left).toBeGreaterThan(+ first.element().getBoundingClientRect().left,+ )+ await first.click()+ await userEvent.keyboard('{ArrowRight}')+ await expect.element(second).toHaveFocus()+ } finally {+ document.documentElement.lang = lang+ document.documentElement.dir = dir+ if (savedLocale === undefined) Cookies.remove(LOCALE_COOKIE_NAME)+ else Cookies.set(LOCALE_COOKIE_NAME, savedLocale)+ }+})diff --git a/web/app/components/provider/i18n-direction.tsx b/web/app/components/provider/i18n-direction.tsxnew file mode 100644index 00000000000..9cefedbb9f7--- /dev/null+++ b/web/app/components/provider/i18n-direction.tsx@@ -0,0 +1,26 @@+'use client'++import type { ReactNode } from 'react'+import { DirectionProvider } from '@langgenius/dify-ui/direction-provider'+import { dir } from 'i18next'+import { useLayoutEffect } from 'react'+import { useLocale } from '@/i18n/lib.client'++export function I18nDirectionProvider({+ children,+ syncDocument,+}: {+ children: ReactNode+ syncDocument: boolean+}) {+ const locale = useLocale()+ const direction = dir(locale)++ useLayoutEffect(() => {+ if (!syncDocument) return+ document.documentElement.lang = locale+ document.documentElement.dir = direction+ }, [direction, locale, syncDocument])++ return <DirectionProvider direction={direction}>{children}</DirectionProvider>+}diff --git a/web/app/components/provider/i18n.tsx b/web/app/components/provider/i18n.tsxindex 9289fc089f8..b50329df231 100644--- a/web/app/components/provider/i18n.tsx+++ b/web/app/components/provider/i18n.tsx@@ -10,6 +10,7 @@ import { loadI18nResource } from '@/i18n/load-resource'import { supportedLocales } from '@/i18n/locale'import { getInitOptions } from '@/i18n/settings'import { getStreamedResources, mergeResources } from '@/i18n/streamed-resources'+import { I18nDirectionProvider } from './i18n-direction'import { I18nResourceStream } from './i18n-stream'export function I18nClientProvider({@@ -47,7 +48,7 @@ export function I18nClientProvider({return (<I18nextProvider i18n={initial.i18n}><I18nResourceStream id={streamId} initial={initial.resources} nonce={nonce} />- {children}+ <I18nDirectionProvider syncDocument>{children}</I18nDirectionProvider></I18nextProvider>)}diff --git a/web/app/device/_header.tsx b/web/app/device/_header.tsxindex e3525bce408..41ffa75158e 100644--- a/web/app/device/_header.tsx+++ b/web/app/device/_header.tsx@@ -34,7 +34,7 @@ const Header = () => {value={locale}items={languages.filter((item) => item.supported)}onChange={(value) => {- setLocaleOnClient(value, false)+ setLocaleOnClient(value)}}/><Separator decorative orientation="vertical" className="mx-0 ml-2 h-4" />diff --git a/web/app/layout.tsx b/web/app/layout.tsxindex 120d35e9bce..5078248b712 100644--- a/web/app/layout.tsx+++ b/web/app/layout.tsx@@ -2,6 +2,7 @@ import type { ThemeProviderProps } from 'next-themes'import type { Metadata, Viewport } from '@/next'import { TooltipProvider } from '@langgenius/dify-ui/tooltip'import { HydrationBoundary } from '@tanstack/react-query'+import { dir } from 'i18next'import { Provider as JotaiProvider } from 'jotai/react'import { ThemeProvider } from 'next-themes'import { NuqsAdapter } from 'nuqs/adapters/next/app'@@ -73,7 +74,7 @@ export default async function RootLayout({ children }: { children: React.ReactNoconst dehydratedState = errorDocument ? undefined : dehydrateSystemFeatures()return (- <html lang={locale} suppressHydrationWarning>+ <html lang={locale} dir={dir(locale)} suppressHydrationWarning><head>{!errorDocument && <ReactScanLoader />}</head><body className="bg-background-body" {...datasetMap}>{!errorDocument && <CloudAnalytics />}diff --git a/web/app/signin/__tests__/_header.spec.tsx b/web/app/signin/__tests__/_header.spec.tsxindex 001c83d3a09..737daaac6c6 100644--- a/web/app/signin/__tests__/_header.spec.tsx+++ b/web/app/signin/__tests__/_header.spec.tsx@@ -1,7 +1,8 @@-import { screen } from '@testing-library/react'+import { act, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { setLocaleOnClient } from '@/i18n/client'import { renderWithConsoleQuery as render } from '@/test/console/query-data'+import { createDeferred } from '@/test/deferred'import Header from '../_header'vi.mock('@/i18n/client', () => ({@@ -13,6 +14,8 @@ vi.mock('next/dynamic', () => ({}))const mockSetLocaleOnClient = vi.mocked(setLocaleOnClient)+const navigation = vi.hoisted(() => ({ refresh: vi.fn() }))+vi.mock('@/next/navigation', () => ({ useRouter: () => navigation }))describe('Signin Header', () => {it('uses the application title as the custom logo accessible name', () => {@@ -53,13 +56,18 @@ describe('Signin Header', () => {expect(screen.getByRole('img', { name: 'Dify' })).toBeInTheDocument()})- it('switches locale through the language menu without forcing a full page reload', async () => {+ it('refreshes server content only after the selected language is ready', async () => {const user = userEvent.setup()+ const languageChange = createDeferred()+ mockSetLocaleOnClient.mockReturnValueOnce(languageChange.promise)render(<Header />)await user.click(screen.getByRole('button', { name: /English/i }))await user.click(screen.getByRole('menuitemradio', { name: '日本語 (日本)' }))- expect(mockSetLocaleOnClient).toHaveBeenCalledWith('ja-JP', false)+ expect(mockSetLocaleOnClient).toHaveBeenCalledWith('ja-JP')+ expect(navigation.refresh).not.toHaveBeenCalled()+ await act(async () => languageChange.resolve())+ await waitFor(() => expect(navigation.refresh).toHaveBeenCalledOnce())})})diff --git a/web/app/signin/__tests__/layout.spec.tsx b/web/app/signin/__tests__/layout.spec.tsxindex 43b748d468b..653233dea47 100644--- a/web/app/signin/__tests__/layout.spec.tsx+++ b/web/app/signin/__tests__/layout.spec.tsx@@ -2,6 +2,10 @@ import { screen, within } from '@testing-library/react'import { renderWithConsoleQuery as render } from '@/test/console/query-data'import SignInLayout from '../layout'+vi.mock('@/next/navigation', () => ({+ useRouter: () => ({ refresh: vi.fn() }),+}))+describe('SignInLayout landmarks', () => {it('separates the site header, sign-in content, and copyright', () => {render(diff --git a/web/app/signin/_header.tsx b/web/app/signin/_header.tsxindex 3e75d0596b4..94660760d90 100644--- a/web/app/signin/_header.tsx+++ b/web/app/signin/_header.tsx@@ -7,6 +7,7 @@ import { DifyLogo } from '@/app/components/base/logo/dify-logo'import { systemFeaturesQueryOptions } from '@/features/system-features/client'import { setLocaleOnClient } from '@/i18n/client'import { languages } from '@/i18n/language'+import { useRouter } from '@/next/navigation'import LocaleMenu from './_locale-menu'const ThemeSelector = dynamic(() => import('@/app/components/base/theme-selector'), {@@ -16,6 +17,7 @@ const ThemeSelector = dynamic(() => import('@/app/components/base/theme-selectorconst Header = () => {const locale = useLocale()+ const router = useRouter()const { data: systemFeatures } = useSuspenseQuery(systemFeaturesQueryOptions())return (@@ -33,8 +35,9 @@ const Header = () => {<LocaleMenuvalue={locale}items={languages.filter((item) => item.supported)}- onChange={(value) => {- setLocaleOnClient(value, false)+ onChange={async (value) => {+ await setLocaleOnClient(value)+ router.refresh()}}/><Separator decorative orientation="vertical" className="mx-0 ml-2 h-4" />diff --git a/web/app/signin/invite-settings/__tests__/page.spec.tsx b/web/app/signin/invite-settings/__tests__/page.spec.tsxindex 2de70651a98..3a0de8ba45b 100644--- a/web/app/signin/invite-settings/__tests__/page.spec.tsx+++ b/web/app/signin/invite-settings/__tests__/page.spec.tsx@@ -1,6 +1,7 @@import { screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { useLocale } from '#i18n'+import { setLocaleOnClient } from '@/i18n/client'import { consoleQuery } from '@/service/console'import { createConsoleQueryClient, renderWithConsoleQuery } from '@/test/console/query-data'import { createDeferred } from '@/test/deferred'@@ -130,6 +131,7 @@ describe('Invitation activation', () => {},})expect(mocks.profile).toHaveBeenCalled()+ expect(setLocaleOnClient).toHaveBeenCalledExactlyOnceWith(expected)},)@@ -143,6 +145,7 @@ describe('Invitation activation', () => {await user.click(screen.getByRole('button', { name: 'Rejoindre Acme' }))await waitFor(() => expect(mocks.replace).toHaveBeenCalledWith('/'))expect(mocks.activate).toHaveBeenCalledExactlyOnceWith({ body: { token: 'invite-token' } })+ expect(setLocaleOnClient).not.toHaveBeenCalled()},)diff --git a/web/app/signin/invite-settings/page.tsx b/web/app/signin/invite-settings/page.tsxindex 9fb51820342..faa58316540 100644--- a/web/app/signin/invite-settings/page.tsx+++ b/web/app/signin/invite-settings/page.tsx@@ -163,7 +163,7 @@ export default function InviteSettingsPage() {const res = await consoleClient.activate.post({ body })if (res.result === 'success') {// Tokens are now stored in cookies by the backend- if (requiresAccountSetup) await setLocaleOnClient(language!, false)+ if (requiresAccountSetup) await setLocaleOnClient(language!)await queryClient.resetQueries({ queryKey: consoleQuery.account.profile.get.key() })replaceLoginRedirect(resolvePostLoginRedirect(searchParams), router.replace, basePath)}diff --git a/web/app/webapp-unavailable/page.tsx b/web/app/webapp-unavailable/page.tsxindex b4c50c0cb7d..ac7a5406d6a 100644--- a/web/app/webapp-unavailable/page.tsx+++ b/web/app/webapp-unavailable/page.tsx@@ -50,6 +50,7 @@ export default async function UnavailableWebAppDocument() {])return (<AppNotAccessible+ syncDocumentclientIp={requestHeaders.get(APP_UNAVAILABLE_IP_HEADER) ?? undefined}initialLocale={locale}initialResources={{diff --git a/web/features/agent-v2/roster/components/agent-roster-list.tsx b/web/features/agent-v2/roster/components/agent-roster-list.tsxindex 3a42deefe13..6ca0bbd6455 100644--- a/web/features/agent-v2/roster/components/agent-roster-list.tsx+++ b/web/features/agent-v2/roster/components/agent-roster-list.tsx@@ -85,7 +85,7 @@ function AgentRosterSkeleton() {key={id}className="relative h-36.5 rounded-xl border-[0.5px] border-components-card-border bg-components-card-bg shadow-xs shadow-shadow-shadow-3">- <div className="flex items-center gap-3 pt-3.5 pr-4 pb-2 pl-3.5">+ <div className="flex items-center gap-3 ps-3.5 pe-4 pt-3.5 pb-2"><SkeletonRectangle className="my-0 size-12 shrink-0 rounded-full opacity-20" /><div className="flex min-w-0 flex-1 flex-col gap-1.5 py-1"><SkeletonRectangle className="my-0 h-3 w-36 max-w-full rounded-md opacity-20" />@@ -288,7 +288,7 @@ function AgentRosterItem({const cardContent = (<>- <div className="flex items-center gap-3 pt-3.5 pr-4 pb-2 pl-3.5">+ <div className="flex items-center gap-3 ps-3.5 pe-4 pt-3.5 pb-2"><span aria-hidden className="shrink-0"><AppIcon size="xl" shape="circle" icon={agent} /></span>@@ -305,11 +305,11 @@ function AgentRosterItem({</div></div>{isDraft && (- <div className="pointer-events-none absolute top-[-0.5px] right-0 flex h-5 items-start overflow-hidden">- <div className="h-5 w-3 bg-background-section-burn [clip-path:polygon(0_0,100%_0,100%_100%)]" />+ <div className="pointer-events-none absolute inset-e-0 top-[-0.5px] flex h-5 items-start overflow-hidden">+ <div className="h-5 w-3 bg-background-section-burn [clip-path:polygon(0_0,100%_0,100%_100%)] rtl:-scale-x-100" /><divid={draftStatusId}- className="flex h-5 items-center bg-background-section-burn pr-2 pl-0.5 system-2xs-medium-uppercase text-text-tertiary"+ className="flex h-5 items-center bg-background-section-burn ps-0.5 pe-2 system-2xs-medium-uppercase text-text-tertiary">{t(($) => $['roster.usageStatus.draft'], { ns: 'agentRoster' })}</div>@@ -347,7 +347,7 @@ function AgentRosterItem({type="button"aria-labelledby={nameId}aria-describedby={accessibleDescriptionIds || undefined}- className={cn(cardClassName, 'w-full cursor-not-allowed text-left')}+ className={cn(cardClassName, 'w-full cursor-not-allowed text-start')}onClick={showPreviewOnlyAccessWarning}>{cardContent}@@ -371,7 +371,7 @@ function AgentRosterItem({)}</ContextMenu>{hasActions && (- <div className="pointer-events-none absolute top-[-0.5px] right-[-0.5px] flex h-16 w-30 items-start justify-end bg-[linear-gradient(67deg,var(--color-components-card-bg-alt-transparent)_0%,var(--color-components-card-bg-alt)_75%)] p-2 opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 has-data-popup-open:opacity-100 [@media(hover:none)]:opacity-100">+ <div className="pointer-events-none absolute inset-e-[-0.5px] top-[-0.5px] flex h-16 w-30 items-start justify-end bg-[linear-gradient(67deg,var(--color-components-card-bg-alt-transparent)_0%,var(--color-components-card-bg-alt)_75%)] p-2 opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 has-data-popup-open:opacity-100 rtl:bg-[linear-gradient(293deg,var(--color-components-card-bg-alt-transparent)_0%,var(--color-components-card-bg-alt)_75%)] [@media(hover:none)]:opacity-100"><div className="pointer-events-none flex items-center overflow-hidden rounded-[10px] border-[0.5px] border-components-actionbar-border bg-components-actionbar-bg p-0.5 shadow-lg backdrop-blur-xs group-focus-within:pointer-events-auto group-hover:pointer-events-auto has-data-popup-open:pointer-events-auto [@media(hover:none)]:pointer-events-auto"><DropdownMenu modal={false}><DropdownMenuTriggerdiff --git a/web/features/agent-v2/roster/components/agent-workflow-references-dropdown.tsx b/web/features/agent-v2/roster/components/agent-workflow-references-dropdown.tsxindex ddbd192c05e..b41c04aea4b 100644--- a/web/features/agent-v2/roster/components/agent-workflow-references-dropdown.tsx+++ b/web/features/agent-v2/roster/components/agent-workflow-references-dropdown.tsx@@ -71,7 +71,7 @@ export function AgentWorkflowReferencesDropdown({<span className="min-w-0 flex-1 truncate">{reference.app_name}</span><spanaria-hidden- className="i-ri-external-link-line size-3 shrink-0 text-text-quaternary group-data-highlighted:text-text-secondary"+ className="i-ri-external-link-line size-3 shrink-0 text-text-quaternary group-data-highlighted:text-text-secondary [&:dir(rtl)]:-scale-x-100"/></DropdownMenuLinkItem>)diff --git a/web/features/agent-v2/roster/components/roster-toolbar.tsx b/web/features/agent-v2/roster/components/roster-toolbar.tsxindex 24f6a0ca8c9..10ba45950ae 100644--- a/web/features/agent-v2/roster/components/roster-toolbar.tsx+++ b/web/features/agent-v2/roster/components/roster-toolbar.tsx@@ -119,7 +119,7 @@ export function RosterToolbar({ publicationCounts }: RosterToolbarProps) {<div className="h-full w-px bg-divider-regular" /></div><RosterCreatedByMeFilter />- <div className="ml-auto flex flex-wrap items-center justify-end gap-2">+ <div className="ms-auto flex flex-wrap items-center justify-end gap-2"><RosterSortSelect /><RosterCreateMenu /></div>diff --git a/web/features/agent-v2/roster/page.tsx b/web/features/agent-v2/roster/page.tsxindex 733d6573bb0..1f446c55700 100644--- a/web/features/agent-v2/roster/page.tsx+++ b/web/features/agent-v2/roster/page.tsx@@ -126,7 +126,10 @@ export default function RosterPage() {{t(($) => $['roster.learnMore'], { ns: 'agentRoster' })}</span><span aria-hidden className="i-ri-book-open-line size-4 sm:hidden" />- <span aria-hidden className="i-ri-external-link-line hidden size-3 sm:inline-block" />+ <span+ aria-hidden+ className="i-ri-external-link-line hidden size-3 sm:inline-block [&:dir(rtl)]:-scale-x-100"+ /></a></div><div className="mt-3.5">diff --git a/web/features/app-access-error/__tests__/boundary.spec.tsx b/web/features/app-access-error/__tests__/boundary.spec.tsxindex 70ab9230ac1..5dcfb26dda1 100644--- a/web/features/app-access-error/__tests__/boundary.spec.tsx+++ b/web/features/app-access-error/__tests__/boundary.spec.tsx@@ -3,6 +3,7 @@ import { act, render, screen } from '@testing-library/react'import { createInstance } from 'i18next'import { StrictMode } from 'react'import { I18nextProvider, initReactI18next } from 'react-i18next'+import { I18nClientProvider } from '@/app/components/provider/i18n'import enCommon from '@/i18n/locales/en-US/common.json'import enShare from '@/i18n/locales/en-US/share.json'import AppAccessBoundary from '../boundary'@@ -15,6 +16,7 @@ vi.mock('@/i18n/load-resource', () => ({}),}))vi.mock('@/next/navigation', () => ({+ useServerInsertedHTML: () => {},usePathname: () => window.location.pathname,useSearchParams: () => new URLSearchParams(window.location.search),}))@@ -42,6 +44,7 @@ describe('IP denial page boundary', () => {afterEach(() => {vi.useRealTimers()+ vi.restoreAllMocks()})it.each([@@ -128,14 +131,18 @@ describe('IP denial page boundary', () => {})it('starts a new visit after leaving for a console page with no public requests', async () => {+ vi.spyOn(navigator, 'languages', 'get').mockReturnValue(['ar-TN'])window.history.replaceState({}, '', '/chat/app')const previousScope = captureAppAccessScope()const application = (- <I18nextProvider i18n={i18n}>+ <I18nClientProvider+ locale="en-US"+ resource={{ 'en-US': { share: enShare, common: enCommon } }}+ ><AppAccessBoundary><p>Current application</p></AppAccessBoundary>- </I18nextProvider>+ </I18nClientProvider>)const { rerender } = render(application)act(() => {@@ -144,16 +151,26 @@ describe('IP denial page boundary', () => {expect(await screen.findByRole('heading', { name: enShare['appNotAccessible.title'] }),).toBeInTheDocument()+ expect(+ screen.getByRole('heading', { name: enShare['appNotAccessible.title'] }).closest('[dir]'),+ ).toHaveAttribute('dir', 'rtl')+ expect(document.documentElement.lang).toBe('en-US')+ expect(document.documentElement.dir).toBe('ltr')window.history.replaceState({}, '', '/apps')rerender(- <I18nextProvider i18n={i18n}>+ <I18nClientProvider+ locale="en-US"+ resource={{ 'en-US': { share: enShare, common: enCommon } }}+ ><AppAccessBoundary><p>Console</p></AppAccessBoundary>- </I18nextProvider>,+ </I18nClientProvider>,)expect(screen.getByText('Console')).toBeInTheDocument()+ expect(document.documentElement.lang).toBe('en-US')+ expect(document.documentElement.dir).toBe('ltr')window.history.replaceState({}, '', '/chat/app')rerender(application)diff --git a/web/features/app-access-error/__tests__/page.spec.tsx b/web/features/app-access-error/__tests__/page.spec.tsxindex 5d187348b17..e9b3e40ff0d 100644--- a/web/features/app-access-error/__tests__/page.spec.tsx+++ b/web/features/app-access-error/__tests__/page.spec.tsx@@ -3,6 +3,9 @@ import userEvent from '@testing-library/user-event'import { createInstance } from 'i18next'import { renderToString } from 'react-dom/server'import { I18nextProvider } from 'react-i18next'+import arCommon from '@/i18n/locales/ar-TN/common.json'+import arLogin from '@/i18n/locales/ar-TN/login.json'+import arShare from '@/i18n/locales/ar-TN/share.json'import enCommon from '@/i18n/locales/en-US/common.json'import enLogin from '@/i18n/locales/en-US/login.json'import enShare from '@/i18n/locales/en-US/share.json'@@ -21,6 +24,8 @@ vi.mock('@/next/navigation', () => ({}))beforeEach(() => {+ document.documentElement.lang = 'zh-Hans'+ document.documentElement.dir = 'ltr'window.history.replaceState({}, '', '/chat/app')vi.spyOn(navigator, 'languages', 'get').mockReturnValue(['en-US'])document.title = 'Previous title'@@ -82,23 +87,56 @@ it.each([undefined, '', 'unknown', '203.0.113.1, 192.0.2.1', '999.1.1.1'])(},)-it('changes only the error-page language, retaining the IP and restoring the title on exit', async () => {+it.each([+ { syncDocument: false, expectedDocumentLocale: 'zh-Hans', expectedDirection: 'ltr' },+ { syncDocument: true, expectedDocumentLocale: 'ar-TN', expectedDirection: 'rtl' },+])(+ 'changes error-page language without persisting console preferences (document owner: $syncDocument)',+ async ({ syncDocument, expectedDocumentLocale, expectedDirection }) => {+ const user = userEvent.setup()+ const { unmount } = render(+ <AppNotAccessible syncDocument={syncDocument} clientIp="203.0.113.8" />,+ )+ await user.click(await screen.findByRole('button', { name: 'English' }))+ await user.click(screen.getByRole('menuitemradio', { name: 'العربية (تونس)' }))+ expect(+ await screen.findByRole('heading', { name: arShare['appNotAccessible.title'] }),+ ).toBeInTheDocument()+ await waitFor(() => expect(document.title).toBe(arShare['appNotAccessible.documentTitle']))+ expect(screen.getByText('203.0.113.8', { selector: 'code' })).toBeInTheDocument()+ expect(screen.getByRole('link', { name: arLogin.signBtn })).toHaveAttribute(+ 'href',+ '/signin?redirect_url=%2Fchat%2Fapp',+ )+ expect(document.cookie).toContain('locale=zh-Hans')+ expect(document.documentElement.lang).toBe(expectedDocumentLocale)+ expect(document.documentElement.dir).toBe(expectedDirection)+ unmount()+ expect(document.title).toBe('Previous title')+ },+)++it('keeps an embedded error language and its portaled menus local to the dialog', async () => {const user = userEvent.setup()- const { unmount } = render(<AppNotAccessible clientIp="203.0.113.8" />)- await user.click(await screen.findByRole('button', { name: 'English' }))- await user.click(screen.getByRole('menuitemradio', { name: '日本語 (日本)' }))- expect(- await screen.findByRole('heading', { name: jaShare['appNotAccessible.title'] }),- ).toBeInTheDocument()- await waitFor(() => expect(document.title).toBe(jaShare['appNotAccessible.documentTitle']))- expect(screen.getByText('203.0.113.8', { selector: 'code' })).toBeInTheDocument()- expect(screen.getByRole('link', { name: jaLogin.signBtn })).toHaveAttribute(- 'href',- '/signin?redirect_url=%2Fchat%2Fapp',+ render(+ <AppNotAccessible+ embedded+ initialLocale="ar-TN"+ initialResources={{+ 'en-US': { share: enShare, common: enCommon, login: enLogin },+ 'ar-TN': { share: arShare, common: arCommon, login: arLogin },+ }}+ />,)- expect(document.cookie).toContain('locale=zh-Hans')- unmount()- expect(document.title).toBe('Previous title')+ const heading = await screen.findByRole('heading', { name: arShare['appNotAccessible.title'] })+ expect(heading.closest('[dir]')).toHaveAttribute('dir', 'rtl')+ await user.click(screen.getByRole('button', { name: 'العربية (تونس)' }))+ expect(screen.getByRole('menu')).toHaveAttribute('dir', 'rtl')+ await user.keyboard('{Escape}')+ await user.click(screen.getByRole('button', { name: arCommon['theme.theme'] }))+ expect(screen.getByRole('menu')).toHaveAttribute('dir', 'rtl')+ expect(document.documentElement.lang).toBe('zh-Hans')+ expect(document.documentElement.dir).toBe('ltr')})it.each([diff --git a/web/features/app-access-error/locale-menu.tsx b/web/features/app-access-error/locale-menu.tsxindex 7572fff1e6f..e4595577e90 100644--- a/web/features/app-access-error/locale-menu.tsx+++ b/web/features/app-access-error/locale-menu.tsx@@ -1,4 +1,5 @@import type { Locale } from '@/i18n'+import { useDirection } from '@langgenius/dify-ui/direction-provider'import {DropdownMenu,DropdownMenuContent,@@ -18,6 +19,7 @@ export default function LocaleMenu({locale: LocaleonChange: (locale: Locale) => void}) {+ const direction = useDirection()const selectedLanguage = supportedLanguages.find((language) => language.value === locale)const selectedLanguageName =selectedLanguage?.value === 'en-US' ? selectedLanguage.prompt_name : selectedLanguage?.name@@ -37,7 +39,7 @@ export default function LocaleMenu({<span className="truncate">{selectedLanguageName}</span><span aria-hidden className="i-ri-arrow-down-s-line size-4 shrink-0" /></DropdownMenuTrigger>- <DropdownMenuContent className="max-h-80 w-60 overflow-y-auto">+ <DropdownMenuContent dir={direction} className="max-h-80 w-60 overflow-y-auto"><DropdownMenuRadioGroup<Locale>value={locale}onValueChange={(value) => {diff --git a/web/features/app-access-error/page.tsx b/web/features/app-access-error/page.tsxindex f98d77521fc..adaa5db1e1f 100644--- a/web/features/app-access-error/page.tsx+++ b/web/features/app-access-error/page.tsx@@ -10,6 +10,7 @@ import { I18nextProvider, Trans, useTranslation } from 'react-i18next'import { LoadingPlaceholder } from '@/app/components/base/loading-placeholder'import { DifyLogo } from '@/app/components/base/logo/dify-logo'import ThemeSelector from '@/app/components/base/theme-selector'+import { I18nDirectionProvider } from '@/app/components/provider/i18n-direction'import { loadI18nResource } from '@/i18n/load-resource'import { getInitOptions } from '@/i18n/settings'import { usePathname, useSearchParams } from '@/next/navigation'@@ -22,6 +23,8 @@ type AppNotAccessibleProps = {clientIp?: string/** A dialog supplies its own landmarks and close control. */embedded?: boolean+ /** Only the standalone error document owns the document language. */+ syncDocument?: boolean/** The document gate supplies browser-language resources before streaming. */initialLocale?: LocaleinitialResources?: Resource@@ -50,7 +53,7 @@ function PageContent({ clientIp, embedded }: AppNotAccessibleProps) {return (<divlang={i18n.language}- dir={i18n.dir()}+ dir={i18n.dir(i18n.language)}className={cn('w-full overflow-y-auto bg-background-default-burn p-1',embedded ? 'min-h-full' : 'h-dvh',@@ -151,7 +154,9 @@ export default function AppNotAccessible(props: AppNotAccessibleProps) {return (<Suspense fallback={<LoadingPlaceholder className="min-h-dvh" />}><I18nextProvider i18n={i18n}>- <PageContent {...props} />+ <I18nDirectionProvider syncDocument={props.syncDocument ?? false}>+ <PageContent {...props} />+ </I18nDirectionProvider></I18nextProvider></Suspense>)diff --git a/web/features/home/banner/banner-item.tsx b/web/features/home/banner/banner-item.tsxindex c4553c4e0c7..2d2f93795b0 100644--- a/web/features/home/banner/banner-item.tsx+++ b/web/features/home/banner/banner-item.tsx@@ -27,9 +27,9 @@ export function BannerItem({ banner, sort, language, accountId, titleId }: Bannereturn (<article className="relative flex h-56 w-full items-start overflow-hidden rounded-2xl bg-components-panel-on-panel-item-bg shadow-xs after:pointer-events-none after:absolute after:inset-0 after:z-30 after:rounded-2xl after:content-[''] has-[>a:focus-visible]:after:inset-ring-2 has-[>a:focus-visible]:after:inset-ring-state-accent-solid @min-[996px]/banner:h-46">- <div className="pointer-events-none relative z-20 min-w-px flex-1 self-stretch rounded-2xl py-6 pl-8">+ <div className="pointer-events-none relative z-20 min-w-px flex-1 self-stretch rounded-2xl py-6 ps-8"><div className="flex min-h-24 w-full flex-col gap-1 py-1 @min-[996px]/banner:flex-row @min-[996px]/banner:flex-wrap @min-[996px]/banner:items-end">- <div className="flex min-w-0 flex-col pr-4 @min-[996px]/banner:max-w-170 @min-[996px]/banner:min-w-120 @min-[996px]/banner:flex-[1_0_0]">+ <div className="flex min-w-0 flex-col pe-4 @min-[996px]/banner:max-w-170 @min-[996px]/banner:min-w-120 @min-[996px]/banner:flex-[1_0_0]"><p className="line-clamp-1 h-[1.8rem] w-full title-4xl-semi-bold wrap-break-word text-dify-logo-blue">{category}</p>@@ -41,7 +41,7 @@ export function BannerItem({ banner, sort, language, accountId, titleId }: Banne</p></div>- <div className="flex min-w-0 items-end pr-4 @min-[996px]/banner:max-w-150 @min-[996px]/banner:min-w-60 @min-[996px]/banner:flex-[1_0_0] @min-[996px]/banner:py-1">+ <div className="flex min-w-0 items-end pe-4 @min-[996px]/banner:max-w-150 @min-[996px]/banner:min-w-60 @min-[996px]/banner:flex-[1_0_0] @min-[996px]/banner:py-1"><p className="line-clamp-3 min-w-0 flex-1 overflow-hidden body-sm-regular text-text-tertiary">{description}</p>diff --git a/web/features/home/banner/banner.tsx b/web/features/home/banner/banner.tsxindex aa2fc28873b..a8a2f0a6ef5 100644--- a/web/features/home/banner/banner.tsx+++ b/web/features/home/banner/banner.tsx@@ -114,7 +114,7 @@ function BannerCarouselContent({banners.length > 1 ? (<divdata-carousel-control- className="pointer-events-auto flex h-7 min-w-0 shrink-0 items-center gap-2 @min-[996px]/banner:max-w-150 @min-[996px]/banner:min-w-60 @min-[996px]/banner:flex-[1_0_0] @min-[996px]/banner:pr-10"+ className="pointer-events-auto flex h-7 min-w-0 shrink-0 items-center gap-2 @min-[996px]/banner:max-w-150 @min-[996px]/banner:min-w-60 @min-[996px]/banner:flex-[1_0_0] @min-[996px]/banner:pe-10"><IconButtonsize="md"@@ -159,12 +159,12 @@ function BannerCarouselContent({return (<>{hasFooter ? (- <div className="pointer-events-none absolute right-4 bottom-6 left-8 z-40 flex min-w-0 items-center justify-between gap-4 @min-[720px]/banner:right-64 @min-[996px]/banner:right-60 @min-[996px]/banner:flex-wrap @min-[996px]/banner:justify-start @min-[996px]/banner:gap-1">+ <div className="pointer-events-none absolute inset-s-8 inset-e-4 bottom-6 z-40 flex min-w-0 items-center justify-between gap-4 @min-[720px]/banner:inset-e-64 @min-[996px]/banner:inset-e-60 @min-[996px]/banner:flex-wrap @min-[996px]/banner:justify-start @min-[996px]/banner:gap-1">{activeBanner?.link ? (<div className="flex min-w-0 items-center gap-1.5 py-1 @min-[996px]/banner:max-w-170 @min-[996px]/banner:min-w-120 @min-[996px]/banner:flex-[1_0_0]"><span className="flex size-4 items-center justify-center rounded-full bg-text-accent p-0.5"><span- className="i-ri-arrow-right-line size-3 text-text-primary-on-surface"+ className="i-ri-arrow-right-line size-3 text-text-primary-on-surface rtl:rotate-180"aria-hidden="true"/></span>diff --git a/web/features/home/continue-work/continue-work.tsx b/web/features/home/continue-work/continue-work.tsxindex 94565ff3286..1fd5e0ba415 100644--- a/web/features/home/continue-work/continue-work.tsx+++ b/web/features/home/continue-work/continue-work.tsx@@ -19,19 +19,22 @@ export function ContinueWork({ apps, className }: ContinueWorkProps) {return (<section className={cn('px-8 pb-5', className)} aria-labelledby="continue-work-title">- <div className="flex items-center justify-between pt-2">+ <div className="flex items-center gap-3 pt-2"><h2id="continue-work-title"- className="min-w-0 truncate system-xl-medium text-text-primary"+ className="min-w-0 flex-1 truncate system-xl-medium text-text-primary">{t(($) => $['continueWork.title'], { ns: 'explore' })}</h2><Linkhref="/apps"- className="-my-1 -mr-1 ml-3 flex min-h-6 shrink-0 touch-manipulation items-center gap-1 rounded-md p-1 system-xs-medium text-text-tertiary outline-hidden transition-colors hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid motion-reduce:transition-none"+ className="-my-1 -me-1 flex min-h-6 shrink-0 touch-manipulation items-center gap-1 rounded-md p-1 system-xs-medium text-text-tertiary outline-hidden transition-colors hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid motion-reduce:transition-none">{t(($) => $['continueWork.exploreStudio'], { ns: 'explore' })}- <span className="i-ri-arrow-right-line size-3 shrink-0" aria-hidden="true" />+ <span+ className="i-ri-arrow-right-line size-3 shrink-0 rtl:rotate-180"+ aria-hidden="true"+ /></Link></div><div className={cn('gap-2.5 pt-2', MAIN_NAV_APP_CARD_GRID_CLASS_NAME)}>diff --git a/web/features/home/continue-work/item.tsx b/web/features/home/continue-work/item.tsxindex ef844be8cc8..4e3199e17b2 100644--- a/web/features/home/continue-work/item.tsx+++ b/web/features/home/continue-work/item.tsx@@ -53,7 +53,7 @@ export function ContinueWorkItem({ app }: ContinueWorkItemProps) {isRbacEnabled,})const cardClassName = cn(- 'relative flex min-w-0 items-center gap-3 overflow-hidden rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg px-4 pt-4 pb-4 text-left shadow-xs shadow-shadow-shadow-3',+ 'relative flex min-w-0 items-center gap-3 overflow-hidden rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg px-4 pt-4 pb-4 text-start shadow-xs shadow-shadow-shadow-3',isPreviewOnly && 'cursor-not-allowed opacity-60',)diff --git a/web/features/home/home-content/templates-header.tsx b/web/features/home/home-content/templates-header.tsxindex 0100e5096a8..566755283bc 100644--- a/web/features/home/home-content/templates-header.tsx+++ b/web/features/home/home-content/templates-header.tsx@@ -34,10 +34,13 @@ export function HomeTemplatesHeader({href="https://marketplace.dify.ai/templates"target="_blank"rel="noopener noreferrer"- className="-m-1 flex min-h-6 shrink-0 touch-manipulation items-center gap-1 rounded-md p-1 system-xs-medium text-text-tertiary outline-hidden transition-colors hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid motion-reduce:transition-none"+ className="-my-1 -me-1 flex min-h-6 shrink-0 touch-manipulation items-center gap-1 rounded-md p-1 system-xs-medium text-text-tertiary outline-hidden transition-colors hover:text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid motion-reduce:transition-none">{t(($) => $['apps.viewMore'], { ns: 'explore' })}- <span className="i-ri-arrow-right-line size-3 shrink-0" aria-hidden="true" />+ <span+ className="i-ri-arrow-right-line size-3 shrink-0 rtl:rotate-180"+ aria-hidden="true"+ /></a></div>@@ -49,14 +52,12 @@ export function HomeTemplatesHeader({onChange={onCategoryChange}allCategoriesEn={allCategoriesEn}/>- <div className="flex shrink-0 items-center gap-3">- <SearchInput- className="w-40 shrink-0"- aria-label={t(($) => $['newAppFromTemplate.searchAllTemplate'], { ns: 'app' })}- value={keywords}- onValueChange={onKeywordsChange}- />- </div>+ <SearchInput+ className="w-40 shrink-0"+ aria-label={t(($) => $['newAppFromTemplate.searchAllTemplate'], { ns: 'app' })}+ value={keywords}+ onValueChange={onKeywordsChange}+ /></div></div>)diff --git a/web/features/home/template-card.tsx b/web/features/home/template-card.tsxindex 089b5c0c046..8815ea9f6c6 100644--- a/web/features/home/template-card.tsx+++ b/web/features/home/template-card.tsx@@ -54,7 +54,7 @@ export function TemplateCard({ app, canCreate, onCreate, onTry }: TemplateCardPrreturn (<liclassName={cn(- 'group relative isolate col-span-1 flex h-35.5 flex-col overflow-hidden rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-on-panel-item-bg pb-3 text-left shadow-xs shadow-shadow-shadow-3',+ 'group relative isolate col-span-1 flex h-35.5 flex-col overflow-hidden rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-on-panel-item-bg pb-3 text-start shadow-xs shadow-shadow-shadow-3',isClickable && 'cursor-pointer',)}>diff --git a/web/features/skills/page.tsx b/web/features/skills/page.tsxindex 78726ea638d..b712182b054 100644--- a/web/features/skills/page.tsx+++ b/web/features/skills/page.tsx@@ -506,7 +506,7 @@ function SkillCard({</div></div><div className="h-6.5 shrink-0" />- <div className="flex min-w-0 shrink-0 items-center pt-2 pr-3 pb-3 pl-4 system-xs-regular text-text-tertiary">+ <div className="flex min-w-0 shrink-0 items-center ps-4 pe-3 pt-2 pb-3 system-xs-regular text-text-tertiary"><div className="flex min-w-0 flex-1 items-center gap-1"><span className="shrink-0">{t(($) => $['skillManagement.referenceCount'], { count: skill.reference_count ?? 0 })}@@ -525,15 +525,15 @@ function SkillCard({{isDraft && (<divid={draftStatusId}- className="pointer-events-none absolute top-[-0.5px] right-0 flex h-5 items-start overflow-hidden"+ className="pointer-events-none absolute inset-e-0 top-[-0.5px] flex h-5 items-start overflow-hidden">- <div className="h-5 w-3 bg-background-section-burn [clip-path:polygon(0_0,100%_0,100%_100%)]" />- <div className="flex h-5 items-center bg-background-section-burn pr-2 pl-0.5 system-2xs-medium-uppercase text-text-tertiary">+ <div className="h-5 w-3 bg-background-section-burn [clip-path:polygon(0_0,100%_0,100%_100%)] rtl:-scale-x-100" />+ <div className="flex h-5 items-center bg-background-section-burn ps-0.5 pe-2 system-2xs-medium-uppercase text-text-tertiary">{t(($) => $['skillManagement.draft'])}</div></div>)}- <div className="pointer-events-none absolute top-[-0.5px] right-[-0.5px] flex h-16 w-30 items-start justify-end bg-[linear-gradient(67deg,var(--color-components-card-bg-alt-transparent)_0%,var(--color-components-card-bg-alt)_75%)] p-2 opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 has-data-popup-open:opacity-100 [@media(hover:none)]:opacity-100">+ <div className="pointer-events-none absolute inset-e-[-0.5px] top-[-0.5px] flex h-16 w-30 items-start justify-end bg-[linear-gradient(67deg,var(--color-components-card-bg-alt-transparent)_0%,var(--color-components-card-bg-alt)_75%)] p-2 opacity-0 group-focus-within:opacity-100 group-hover:opacity-100 has-data-popup-open:opacity-100 rtl:bg-[linear-gradient(293deg,var(--color-components-card-bg-alt-transparent)_0%,var(--color-components-card-bg-alt)_75%)] [@media(hover:none)]:opacity-100"><div className="pointer-events-none flex items-center overflow-hidden rounded-[10px] border-[0.5px] border-components-actionbar-border bg-components-actionbar-bg p-0.5 shadow-lg backdrop-blur-xs group-focus-within:pointer-events-auto group-hover:pointer-events-auto has-data-popup-open:pointer-events-auto [@media(hover:none)]:pointer-events-auto"><DropdownMenu modal={false}><DropdownMenuTrigger@@ -692,7 +692,7 @@ function SkillsToolbar({void setKeyword(value)}}/>- <div className="ml-auto flex shrink-0 items-center gap-2">+ <div className="ms-auto flex shrink-0 items-center gap-2">{canEdit && (<ButtonclassName="h-8 gap-1 px-3"diff --git a/web/i18n/__tests__/client-locale.spec.ts b/web/i18n/__tests__/client-locale.spec.tsindex bd380f6332a..64de4d670c0 100644--- a/web/i18n/__tests__/client-locale.spec.ts+++ b/web/i18n/__tests__/client-locale.spec.ts@@ -9,7 +9,9 @@ vi.mock('react-i18next', () => ({ getI18n: () => ({ changeLanguage: mocks.changedescribe('client locale inputs', () => {beforeEach(() => {mocks.changeLanguage.mockResolvedValue(undefined)+ vi.spyOn(window.location, 'reload').mockImplementation(() => {})})+ afterEach(() => vi.restoreAllMocks())it.each([['zh_Hans', 'zh-Hans'],@@ -20,10 +22,11 @@ describe('client locale inputs', () => {['en--US', 'en-US'],['unsupported', 'en-US'],])('changes and persists %s as %s', async (input, expected) => {- await setLocaleOnClient(input, false)+ await setLocaleOnClient(input)expect(Cookies.set).toHaveBeenCalledWith('locale', expected, { expires: 365 })expect(mocks.changeLanguage).toHaveBeenCalledWith(expected)+ expect(window.location.reload).not.toHaveBeenCalled()})it('normalizes a share-app override without persisting console preferences', async () => {diff --git a/web/i18n/__tests__/route-loading.spec.tsx b/web/i18n/__tests__/route-loading.spec.tsxindex 26295d4c01f..3eadfce6d8f 100644--- a/web/i18n/__tests__/route-loading.spec.tsx+++ b/web/i18n/__tests__/route-loading.spec.tsx@@ -1,4 +1,5 @@import type { ReactNode } from 'react'+import { useDirection } from '@langgenius/dify-ui/direction-provider'import { createToast, createToastManager } from '@langgenius/dify-ui/toast'import { act, render, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'@@ -55,7 +56,7 @@ describe('on-demand translation loading', () => {it('reads and updates the locale without loading any translation namespace', async () => {function LocaleLabel() {- return <span>{useLocale()}</span>+ return <span dir={useDirection()}>{useLocale()}</span>}render(<I18nClientProvider locale="en-US" resource={{}}>@@ -63,8 +64,16 @@ describe('on-demand translation loading', () => {</I18nClientProvider>,)expect(await screen.findByText('en-US')).toBeVisible()+ expect(document.documentElement.lang).toBe('en-US')+ expect(document.documentElement.dir).toBe('ltr')+ await act(() => changeLanguage('ar-TN'))+ expect(await screen.findByText('ar-TN')).toHaveAttribute('dir', 'rtl')+ expect(document.documentElement.lang).toBe('ar-TN')+ expect(document.documentElement.dir).toBe('rtl')await act(() => changeLanguage('zh-Hans'))- expect(await screen.findByText('zh-Hans')).toBeVisible()+ expect(await screen.findByText('zh-Hans')).toHaveAttribute('dir', 'ltr')+ expect(document.documentElement.lang).toBe('zh-Hans')+ expect(document.documentElement.dir).toBe('ltr')expect(mocks.loadResource).not.toHaveBeenCalled()})diff --git a/web/i18n/client.ts b/web/i18n/client.tsindex a1d69f1472c..5574285722c 100644--- a/web/i18n/client.ts+++ b/web/i18n/client.ts@@ -10,9 +10,8 @@ export const changeLanguage = async (lng?: string) => {await i18n.changeLanguage(normalizeLocale(lng))}-export const setLocaleOnClient = async (locale: string, reloadPage = true) => {+export const setLocaleOnClient = async (locale: string) => {const normalized = normalizeLocale(locale)Cookies.set(LOCALE_COOKIE_NAME, normalized, { expires: 365 })await changeLanguage(normalized)- if (reloadPage) location.reload()}