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): preserve primary navigation across console routes (#44633)
yyh44564a1dec7d
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.jsonindex 690f89c8ad9..59f4529560f 100644--- a/oxlint-suppressions.json+++ b/oxlint-suppressions.json@@ -3643,11 +3643,6 @@"count": 1}},- "web/app/components/main-nav/__tests__/responsive-main-nav.spec.tsx": {- "typescript/no-deprecated": {- "count": 2- }- },"web/app/components/main-nav/components/workspace-switcher.tsx": {"jsx-a11y/no-autofocus": {"count": 1diff --git a/web/app/(commonLayout)/integrations/[[...slug]]/not-found.tsx b/web/app/(commonLayout)/not-found.tsxsimilarity index 100%rename from web/app/(commonLayout)/integrations/[[...slug]]/not-found.tsxrename to web/app/(commonLayout)/not-found.tsxdiff --git a/web/app/components/main-nav/__tests__/layout.spec.tsx b/web/app/components/main-nav/__tests__/layout.spec.tsxindex 55fbd44acea..e4347d67e22 100644--- a/web/app/components/main-nav/__tests__/layout.spec.tsx+++ b/web/app/components/main-nav/__tests__/layout.spec.tsx@@ -53,6 +53,9 @@ vi.mock('../index', () => ({MainNav: ({ className }: { className?: string }) => (<aside className={className} data-testid="main-nav">MainNav+ <a href="/apps">Apps</a>+ <a href="/agents">Agents</a>+ <a href="/integrations/model-provider">Integrations</a></aside>),}))@@ -72,6 +75,29 @@ describe('MainNavLayout', () => {;(isAgentV2Enabled as Mock).mockReturnValue(true)})+ it.each([+ { from: '/apps', to: '/agents', name: 'Agents' },+ { from: '/agents', to: '/apps', name: 'Apps' },+ { from: '/apps', to: '/integrations/model-provider', name: 'Integrations' },+ { from: '/integrations/model-provider', to: '/apps', name: 'Apps' },+ { from: '/datasets/create', to: '/apps', name: 'Apps' },+ ])('preserves navigation focus from $from to $to', async ({ from, to, name }) => {+ const user = userEvent.setup()+ vi.mocked(usePathname).mockReturnValue(from)+ const renderLayout = () => (+ <MainNavLayout initialDetailSidebarMode="expand">+ <div>content</div>+ </MainNavLayout>+ )+ const { rerender } = render(renderLayout())++ await user.click(screen.getByRole('link', { name }))+ vi.mocked(usePathname).mockReturnValue(to)+ rerender(renderLayout())++ expect(screen.getByRole('link', { name })).toHaveFocus()+ })+it('uses the request preference in server-rendered sidebar markup', () => {;(usePathname as Mock).mockReturnValue('/datasets/dataset-1/documents')diff --git a/web/app/components/main-nav/__tests__/nav-link.spec.tsx b/web/app/components/main-nav/__tests__/nav-link.spec.tsxnew file mode 100644index 00000000000..e65999ed5f2--- /dev/null+++ b/web/app/components/main-nav/__tests__/nav-link.spec.tsx@@ -0,0 +1,57 @@+import type { ContextType } from 'react'+import { render, screen } from '@testing-library/react'+import userEvent from '@testing-library/user-event'+import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime'+import MainNavLink from '../components/nav-link'++vi.mock('@/features/studio-list-navigation', () => ({+ useStudioListHref: () => '/apps',+}))++it('navigates from the primary sidebar without requesting route scroll and focus handling', async () => {+ const user = userEvent.setup()+ const router: NonNullable<ContextType<typeof RouterContext>> = {+ basePath: '',+ pathname: '/apps',+ route: '/apps',+ query: {},+ asPath: '/apps',+ push: vi.fn().mockResolvedValue(true),+ replace: vi.fn().mockResolvedValue(true),+ reload: vi.fn(),+ back: vi.fn(),+ forward: vi.fn(),+ prefetch: vi.fn().mockResolvedValue(undefined),+ beforePopState: vi.fn(),+ events: { on: vi.fn(), off: vi.fn(), emit: vi.fn() },+ isFallback: false,+ isLocaleDomain: false,+ isReady: true,+ isPreview: false,+ }++ render(+ <RouterContext value={router}>+ <MainNavLink+ pathname="/apps"+ item={{+ href: '/marketplace',+ label: 'Marketplace',+ icon: 'i-ri-store-2-line',+ activeIcon: 'i-ri-store-2-fill',+ active: (pathname) => pathname === '/marketplace',+ }}+ />+ </RouterContext>,+ )++ await user.tab()+ await user.keyboard('{Enter}')++ expect(router.push).toHaveBeenCalledWith(+ '/marketplace',+ '/marketplace',+ expect.objectContaining({ scroll: false }),+ )+ expect(screen.getByRole('link', { name: 'Marketplace' })).toHaveFocus()+})diff --git a/web/app/components/main-nav/__tests__/responsive-main-nav.spec.tsx b/web/app/components/main-nav/__tests__/responsive-main-nav.spec.tsxdeleted file mode 100644index 937229b180c..00000000000--- a/web/app/components/main-nav/__tests__/responsive-main-nav.spec.tsx+++ /dev/null@@ -1,51 +0,0 @@-import { screen, waitFor, within } from '@testing-library/react'-import userEvent from '@testing-library/user-event'-import { render } from '@/test/console/render'-import { ResponsiveMainNav } from '../responsive-main-nav'--vi.mock('../index', () => ({- MainNav: () => <div data-testid="main-nav-content">Navigation content</div>,-}))--describe('ResponsiveMainNav', () => {- afterEach(() => {- vi.restoreAllMocks()- })-- const setCompactViewport = (matches: boolean) => {- vi.spyOn(window, 'matchMedia').mockImplementation((media) => ({- matches,- media,- onchange: null,- addListener: vi.fn(),- removeListener: vi.fn(),- addEventListener: vi.fn(),- removeEventListener: vi.fn(),- dispatchEvent: vi.fn(),- }))- }-- it('keeps navigation inline on wide screens', () => {- setCompactViewport(false)- render(<ResponsiveMainNav />)-- expect(screen.getByTestId('main-nav-content')).toBeInTheDocument()- expect(screen.queryByRole('button')).not.toBeInTheDocument()- })-- it('makes navigation available in a dismissible drawer on narrow screens', async () => {- setCompactViewport(true)- const user = userEvent.setup()- render(<ResponsiveMainNav />)-- expect(screen.queryByTestId('main-nav-content')).not.toBeInTheDocument()- await user.click(screen.getByRole('button', { name: /navigation\.primary/ }))-- const drawer = await screen.findByRole('dialog', { name: /navigation\.primary/ })- expect(within(drawer).getByTestId('main-nav-content')).toBeInTheDocument()- await user.click(within(drawer).getByRole('button', { name: /operation\.close/ }))-- await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument())- expect(screen.getByRole('button', { name: /navigation\.primary/ })).toBeInTheDocument()- })-})diff --git a/web/app/components/main-nav/components/nav-link.tsx b/web/app/components/main-nav/components/nav-link.tsxindex f6f1d29831d..f8abfcdc39d 100644--- a/web/app/components/main-nav/components/nav-link.tsx+++ b/web/app/components/main-nav/components/nav-link.tsx@@ -23,6 +23,7 @@ const MainNavLink = ({ item, pathname, children }: MainNavLinkProps) => {return (<Linkhref={item.href === '/apps' ? appsHref : item.href}+ scroll={false}aria-current={activated ? 'page' : undefined}title={item.label}className={cn(diff --git a/web/app/components/main-nav/layout.tsx b/web/app/components/main-nav/layout.tsxindex 5705fdb0d77..8c0b824f2a1 100644--- a/web/app/components/main-nav/layout.tsx+++ b/web/app/components/main-nav/layout.tsx@@ -14,7 +14,6 @@ import { isCurrentWorkspaceDatasetOperatorAtom } from '@/context/workspace-stateimport { isAgentV2Enabled } from '@/features/agent-v2/feature-flag'import { usePathname } from '@/next/navigation'import { MainNav } from '.'-import { ResponsiveMainNav } from './responsive-main-nav'import { shouldHideMainNavigation, shouldUseDetailSidebar } from './routes'import { MAIN_CONTENT_ID, SkipLink } from './skip-link'@@ -36,10 +35,6 @@ const MainNavLayout = ({const pathname = usePathname()const isCurrentWorkspaceDatasetOperator = useAtomValue(isCurrentWorkspaceDatasetOperatorAtom)const appId = getAppIdFromPathname(pathname)- const useResponsiveNavigation =- pathname === '/agents' ||- pathname === '/datasets/create' ||- pathname.startsWith('/integrations/')const hideMainNavigation = shouldHideMainNavigation(pathname)const useDetailSidebar = shouldUseDetailSidebar(pathname, {agentV2Enabled: isAgentV2Enabled(),@@ -47,18 +42,11 @@ const MainNavLayout = ({})return (- <div- className={cn(- 'flex h-0 min-h-0 min-w-0 grow overflow-hidden bg-background-body',- useResponsiveNavigation && 'flex-col md:flex-row',- )}- >+ <div className="flex h-0 min-h-0 min-w-0 grow overflow-hidden bg-background-body"><SkipLink>{t(($) => $['navigation.skipToMain'])}</SkipLink>{appId && <AppDetailPrefetch appId={appId} />}{hideMainNavigation ? null : useDetailSidebar ? (detailSidebar- ) : useResponsiveNavigation ? (- <ResponsiveMainNav initialPlatform={initialPlatform} />) : (<MainNav initialPlatform={initialPlatform} />)}diff --git a/web/app/components/main-nav/responsive-main-nav.tsx b/web/app/components/main-nav/responsive-main-nav.tsxdeleted file mode 100644index 473483f5ded..00000000000--- a/web/app/components/main-nav/responsive-main-nav.tsx+++ /dev/null@@ -1,71 +0,0 @@-'use client'--import type { MainNavProps } from './types'-import { Button } from '@langgenius/dify-ui/button'-import {- Drawer,- DrawerBackdrop,- DrawerClose,- DrawerContent,- DrawerPopup,- DrawerPortal,- DrawerTitle,- DrawerTrigger,- DrawerViewport,-} from '@langgenius/dify-ui/drawer'-import { IconButton } from '@langgenius/dify-ui/icon-button'-import { useSyncExternalStore } from 'react'-import { useTranslation } from 'react-i18next'-import { MainNav } from '.'--const compactNavigationQuery = '(width < 48rem)'-const subscribe = (onChange: () => void) => {- const mediaQuery = window.matchMedia(compactNavigationQuery)- mediaQuery.addEventListener('change', onChange)- return () => mediaQuery.removeEventListener('change', onChange)-}-const getSnapshot = () => window.matchMedia(compactNavigationQuery).matches-const getServerSnapshot = () => false--export function ResponsiveMainNav({ initialPlatform }: Pick<MainNavProps, 'initialPlatform'>) {- const { t } = useTranslation(['common'])- const isCompact = useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)-- if (!isCompact) return <MainNav initialPlatform={initialPlatform} />-- return (- <div className="shrink-0 p-2">- <Drawer swipeDirection="left">- <DrawerTrigger render={<Button variant="secondary" />}>- <span aria-hidden="true" className="i-ri-menu-line size-4" />- {t(($) => $['navigation.primary'])}- </DrawerTrigger>- <DrawerPortal>- <DrawerBackdrop className="fixed" />- <DrawerViewport>- <DrawerPopup>- <div className="flex shrink-0 items-center justify-between gap-2 p-3">- <DrawerTitle className="system-md-semibold">- {t(($) => $['navigation.primary'])}- </DrawerTitle>- <DrawerClose- render={- <IconButton aria-label={t(($) => $['operation.close'])} size="lg">- <span aria-hidden="true" className="i-ri-close-line size-4" />- </IconButton>- }- />- </div>- <DrawerContent className="touch-auto p-0 pb-0">- <MainNav- initialPlatform={initialPlatform}- className="h-auto min-h-full w-full overflow-visible [&>div]:shrink-0 [&>div]:overflow-visible"- />- </DrawerContent>- </DrawerPopup>- </DrawerViewport>- </DrawerPortal>- </Drawer>- </div>- )-}