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
refactor(web): refine detail sidebar states and preview (#42938)
yyhf4602cc1fe84
diff --git a/web/app/components/app-sidebar/app-detail-section.tsx b/web/app/components/app-sidebar/app-detail-section.tsxindex b0f2a2245f5..88e2ce0641c 100644--- a/web/app/components/app-sidebar/app-detail-section.tsx+++ b/web/app/components/app-sidebar/app-detail-section.tsx@@ -162,7 +162,10 @@ const AppDetailSection = ({ expand = true }: AppDetailSectionProps) => {<div className={cn('px-1 py-2', expand && '-mx-2')}><AppInfoView key={appDetail.id} expand={expand} /></div>- <nav className={cn('flex flex-col gap-y-0.5 py-1', expand ? 'px-1' : 'px-3')}>+ <nav+ aria-label={appDetail.name}+ className={cn('flex flex-col gap-y-0.5 py-1', expand ? 'px-1' : 'px-3')}+ >{navigation.map((item) => {const shouldRenderDividerBefore =isLogsNavItem(item) || (!hasLogsNavigation && isAnnotationsNavItem(item))diff --git a/web/app/components/app-sidebar/dataset-detail-section.tsx b/web/app/components/app-sidebar/dataset-detail-section.tsxindex 4052d764207..fe3dbcb670e 100644--- a/web/app/components/app-sidebar/dataset-detail-section.tsx+++ b/web/app/components/app-sidebar/dataset-detail-section.tsx@@ -146,7 +146,10 @@ const DatasetDetailSection = ({ expand = true }: DatasetDetailSectionProps) => {<div className="py-2"><DatasetInfo expand={expand} /></div>- <nav className={cn('mt-3 flex flex-col gap-y-0.5 pb-2', expand ? 'px-1' : 'px-3')}>+ <nav+ aria-label={datasetRes.name}+ className={cn('mt-3 flex flex-col gap-y-0.5 pb-2', expand ? 'px-1' : 'px-3')}+ >{navigation.map((item) => (<NavLinkkey={item.href}diff --git a/web/app/components/app-sidebar/nav-link/index.tsx b/web/app/components/app-sidebar/nav-link/index.tsxindex c7779020344..6d17d98a6d7 100644--- a/web/app/components/app-sidebar/nav-link/index.tsx+++ b/web/app/components/app-sidebar/nav-link/index.tsx@@ -52,6 +52,7 @@ const NavLink = ({? 'flex size-8 items-center justify-center p-1.5': 'flex h-8 items-center rounded-lg pr-1 pl-3','rounded-lg',+ 'focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden',)const renderIcon = () => (diff --git a/web/app/components/detail-sidebar/__tests__/index.spec.tsx b/web/app/components/detail-sidebar/__tests__/index.spec.tsxindex 9a30571c36d..81e6fea7d15 100644--- a/web/app/components/detail-sidebar/__tests__/index.spec.tsx+++ b/web/app/components/detail-sidebar/__tests__/index.spec.tsx@@ -6,6 +6,7 @@ import userEvent from '@testing-library/user-event'import { Provider } from 'jotai'import { useHydrateAtoms } from 'jotai/utils'import Cookies from 'js-cookie'+import { useState } from 'react'import { renderWithConsoleQuery } from '@/test/console/query-data'import { DetailSidebarFrame } from '..'import { DETAIL_SIDEBAR_COOKIE_NAME } from '../cookie'@@ -182,6 +183,41 @@ describe('DetailSidebarFrame', () => {expect(Cookies.get(DETAIL_SIDEBAR_COOKIE_NAME)).toBe('collapse')})+ it('does not restore a stale hover preview after leaving compact layout', async () => {+ const user = userEvent.setup()++ function ResponsiveDetailSidebar() {+ const [compact, setCompact] = useState(false)+ return (+ <Provider>+ <InitialDetailSidebarMode mode="collapse">+ <HotkeysProvider>+ <button type="button" onClick={() => setCompact((value) => !value)}>+ Switch layout+ </button>+ <DetailSidebarFrame+ compact={compact}+ renderTop={({ expand }) => <div data-testid="detail-top" data-expand={expand} />}+ renderSection={() => <div>Section</div>}+ />+ </HotkeysProvider>+ </InitialDetailSidebarMode>+ </Provider>+ )+ }++ renderWithConsoleQuery(<ResponsiveDetailSidebar />, {+ accountProfileMeta: { currentEnv: null },+ })+ fireEvent.mouseEnter(screen.getByTestId('detail-top').parentElement!)+ expect(screen.getByRole('button', { name: 'account' })).toHaveTextContent('Expanded account')++ await user.click(screen.getByRole('button', { name: 'Switch layout' }))+ await user.click(screen.getByRole('button', { name: 'Switch layout' }))++ expect(screen.getByRole('button', { name: 'account' })).toHaveTextContent('Compact account')+ })+it('persists expansion when the hovered preview toggle is clicked', () => {renderDetailSidebarFrame()fireEvent.click(screen.getByTestId('detail-toggle'))diff --git a/web/app/components/detail-sidebar/index.tsx b/web/app/components/detail-sidebar/index.tsxindex 0aaa8a67d43..78a7b02b833 100644--- a/web/app/components/detail-sidebar/index.tsx+++ b/web/app/components/detail-sidebar/index.tsx@@ -25,6 +25,8 @@ type DetailSidebarFrameProps = {renderSection: (props: Pick<DetailSidebarRenderProps, 'expand'>) => ReactNode}+type SidebarView = 'collapsed' | 'preview' | 'expanded'+const secondarySidebarHelpTriggerIcon = (<span aria-hidden className="i-ri-question-line size-4 shrink-0" />)@@ -49,23 +51,19 @@ export function DetailSidebarFrame({...userProfileQueryOptions(),select: (data) => data.meta.currentEnv,})- const storedDetailSidebarExpand = useAtomValue(detailSidebarModeAtom)- const setStoredDetailSidebarExpand = useSetAtom(setDetailSidebarModeAtom)+ const storedMode = useAtomValue(detailSidebarModeAtom)+ const setStoredMode = useSetAtom(setDetailSidebarModeAtom)const [compactExpanded, setCompactExpanded] = useState(false)- const detailNavigationMode = storedDetailSidebarExpand === 'collapse' ? 'collapse' : 'expand'- const detailNavigationExpanded = compact ? compactExpanded : detailNavigationMode === 'expand'- const [detailNavigationHoverPreviewOpen, setDetailNavigationHoverPreviewOpen] = useState(false)- const [detailNavigationTransitionDisabled, setDetailNavigationTransitionDisabled] =- useState(false)- const closeDetailNavigationHoverPreviewTimerRef = useRef<ReturnType<typeof setTimeout> | null>(- null,- )- const detailNavigationTransitionTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)- const isDetailNavigationHoverPreviewOpen =- !compact && !detailNavigationExpanded && detailNavigationHoverPreviewOpen- const detailNavigationVisibleExpanded =- detailNavigationExpanded || isDetailNavigationHoverPreviewOpen- const bottomNavigationExpanded = detailNavigationVisibleExpanded+ const [hoverPreviewOpen, setHoverPreviewOpen] = useState(false)+ const closePreviewTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)+ if (compact && hoverPreviewOpen) setHoverPreviewOpen(false)+ const expanded = compact ? compactExpanded : storedMode === 'expand'+ const sidebarView: SidebarView = expanded+ ? 'expanded'+ : !compact && hoverPreviewOpen+ ? 'preview'+ : 'collapsed'+ const visibleExpanded = sidebarView !== 'collapsed'const showEnvTag = currentEnv === 'TESTING' || currentEnv === 'DEVELOPMENT'function handleToggleDetailNavigation() {@@ -74,48 +72,41 @@ export function DetailSidebarFrame({return}- if (isDetailNavigationHoverPreviewOpen) {- if (detailNavigationTransitionTimerRef.current)- clearTimeout(detailNavigationTransitionTimerRef.current)-- setDetailNavigationTransitionDisabled(true)- setDetailNavigationHoverPreviewOpen(false)- setStoredDetailSidebarExpand('expand')- detailNavigationTransitionTimerRef.current = setTimeout(() => {- setDetailNavigationTransitionDisabled(false)- }, 200)+ if (sidebarView === 'preview') {+ setHoverPreviewOpen(false)+ setStoredMode('expand')return}- const nextMode = detailNavigationExpanded ? 'collapse' : 'expand'- setDetailNavigationHoverPreviewOpen(false)- setStoredDetailSidebarExpand(nextMode)+ setHoverPreviewOpen(false)+ setStoredMode(expanded ? 'collapse' : 'expand')}- function openDetailNavigationHoverPreview() {- if (compact || detailNavigationExpanded) return+ function cancelClosePreview() {+ if (closePreviewTimerRef.current) {+ clearTimeout(closePreviewTimerRef.current)+ closePreviewTimerRef.current = null+ }+ }- if (closeDetailNavigationHoverPreviewTimerRef.current)- clearTimeout(closeDetailNavigationHoverPreviewTimerRef.current)+ function openHoverPreview() {+ if (compact || expanded) return- setDetailNavigationHoverPreviewOpen(true)+ cancelClosePreview()+ setHoverPreviewOpen(true)}- function closeDetailNavigationHoverPreview() {- if (closeDetailNavigationHoverPreviewTimerRef.current)- clearTimeout(closeDetailNavigationHoverPreviewTimerRef.current)+ function closeHoverPreview() {+ cancelClosePreview()- closeDetailNavigationHoverPreviewTimerRef.current = setTimeout(() => {- setDetailNavigationHoverPreviewOpen(false)+ closePreviewTimerRef.current = setTimeout(() => {+ setHoverPreviewOpen(false)}, 120)}useEffect(() => {return () => {- if (closeDetailNavigationHoverPreviewTimerRef.current)- clearTimeout(closeDetailNavigationHoverPreviewTimerRef.current)- if (detailNavigationTransitionTimerRef.current)- clearTimeout(detailNavigationTransitionTimerRef.current)+ if (closePreviewTimerRef.current) clearTimeout(closePreviewTimerRef.current)}}, [])@@ -125,53 +116,48 @@ export function DetailSidebarFrame({})return (- <aside+ <divclassName={cn(- 'relative flex h-full shrink-0 bg-background-body p-1',- detailNavigationTransitionDisabled ? 'transition-none' : 'transition-all',- isDetailNavigationHoverPreviewOpen- ? 'w-16 overflow-visible'- : detailNavigationExpanded- ? 'w-62 overflow-hidden'- : 'w-16 overflow-hidden',+ 'relative flex h-full w-16 min-w-0 shrink-0 bg-background-body p-1 transition-[width] motion-reduce:transition-none',+ 'data-[sidebar-view=expanded]:w-62',className,)}+ data-sidebar-view={sidebarView}+ onMouseEnter={cancelClosePreview}+ onMouseLeave={sidebarView === 'preview' ? closeHoverPreview : undefined}><divclassName={cn(- 'flex min-h-0 flex-1 flex-col',- isDetailNavigationHoverPreviewOpen- ? 'absolute top-1 bottom-1 left-1 z-40 w-60 overflow-hidden rounded-lg border border-divider-subtle bg-components-panel-bg shadow-lg'- : 'overflow-hidden rounded-lg bg-components-panel-bg',- detailNavigationVisibleExpanded ? 'w-60' : 'w-14',+ 'flex min-h-0 w-14 shrink-0 flex-col overflow-hidden rounded-lg bg-components-panel-bg',+ 'data-visible-expanded:z-40 data-visible-expanded:w-60',+ 'data-preview:absolute data-preview:inset-y-1 data-preview:left-1',+ 'data-preview:bg-components-panel-bg-blur data-preview:shadow-[0px_12px_16px_0px_var(--color-shadow-shadow-5),0px_4px_6px_0px_var(--color-shadow-shadow-1)] data-preview:backdrop-blur-[5px]',)}- onMouseLeave={!detailNavigationExpanded ? closeDetailNavigationHoverPreview : undefined}+ data-visible-expanded={visibleExpanded || undefined}+ data-preview={sidebarView === 'preview' || undefined}>- <div- className="flex min-h-0 flex-1 flex-col"- onMouseEnter={!detailNavigationExpanded ? openDetailNavigationHoverPreview : undefined}- >+ <div className="flex min-h-0 flex-1 flex-col" onMouseEnter={openHoverPreview}>{renderTop({- expand: detailNavigationVisibleExpanded,+ expand: visibleExpanded,onToggle: handleToggleDetailNavigation,})}{renderSection({- expand: detailNavigationVisibleExpanded,+ expand: visibleExpanded,})}- {showEnvTag && detailNavigationVisibleExpanded && (- <div className="relative z-30 mt-auto shrink-0 px-3 pb-2">+ {showEnvTag && visibleExpanded && (+ <div className="mt-auto shrink-0 px-3 pb-2"><EnvNav /></div>)}</div><divclassName={cn(- !bottomNavigationExpanded- ? 'flex w-full shrink-0 flex-col items-center gap-0.5 rounded-lg px-2 pt-1 pb-3'- : 'flex w-60 items-center justify-between bg-components-panel-bg p-3',+ 'flex w-full shrink-0 flex-col items-center gap-0.5 rounded-lg px-2 pt-1 pb-3',+ 'data-visible-expanded:flex-row data-visible-expanded:justify-between data-visible-expanded:gap-0 data-visible-expanded:p-3',)}+ data-visible-expanded={visibleExpanded || undefined}>- {!bottomNavigationExpanded ? (+ {!visibleExpanded ? (<><SecondarySidebarHelpMenu triggerClassName="mb-2" /><AccountSection compact />@@ -186,6 +172,6 @@ export function DetailSidebarFrame({)}</div></div>- </aside>+ </div>)}diff --git a/web/features/agent-v2/agent-detail/navigation.tsx b/web/features/agent-v2/agent-detail/navigation.tsxindex 07e4523c181..1ba403c15b7 100644--- a/web/features/agent-v2/agent-detail/navigation.tsx+++ b/web/features/agent-v2/agent-detail/navigation.tsx@@ -219,7 +219,10 @@ export function AgentDetailSection({ expand = true }: AgentDetailSectionProps) {!expand && 'hidden',)}>- <div className="truncate system-md-semibold text-text-secondary">+ <div+ className="truncate system-md-semibold text-text-secondary"+ title={agent?.name ?? t(($) => $['agentDetail.title'])}+ >{agent?.name ?? t(($) => $['agentDetail.title'])}</div>{agent?.role?.trim() && (