Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🧭 refactor: Give the Desktop Icon Rail Nav Hover and Selected States (#16937)
Marco Berettad4b220d610ee
diff --git a/client/src/components/UnifiedSidebar/ExpandedPanel.tsx b/client/src/components/UnifiedSidebar/ExpandedPanel.tsxindex 0d006512d9..462ee4163b 100644--- a/client/src/components/UnifiedSidebar/ExpandedPanel.tsx+++ b/client/src/components/UnifiedSidebar/ExpandedPanel.tsx@@ -10,7 +10,6 @@ import { CLOSE_SIDEBAR_ID } from '~/components/Chat/Menus/OpenSidebar';import { lazyWithRecovery } from '~/lib/assets/lazy';import useNewChat from '~/hooks/Chat/useNewChat';import { useLocalize } from '~/hooks';-import { cn } from '~/utils';const AccountSettings = lazyWithRecovery(() => import('~/components/Nav/AccountSettings'));@@ -104,15 +103,12 @@ const NavIconButton = memo(function NavIconButton({render={<Buttonsize="icon"- variant="ghost"+ variant="nav"aria-label={localize(link.title)}aria-pressed={isActive}disabled={link.disabled}data-testid={`nav-panel-${link.id}`}- className={cn(- 'h-9 w-9 rounded-lg',- isActive ? 'bg-surface-active-alt text-text-primary' : 'text-text-secondary',- )}+ className="h-9 w-9 rounded-lg"onClick={handleClick}><link.icon className="h-5 w-5" aria-hidden="true" />diff --git a/client/src/components/UnifiedSidebar/__tests__/ExpandedPanel.spec.tsx b/client/src/components/UnifiedSidebar/__tests__/ExpandedPanel.spec.tsxindex 668cb688b3..7fdb63c889 100644--- a/client/src/components/UnifiedSidebar/__tests__/ExpandedPanel.spec.tsx+++ b/client/src/components/UnifiedSidebar/__tests__/ExpandedPanel.spec.tsx@@ -196,6 +196,26 @@ describe('ExpandedPanel', () => {expect(onClick).toHaveBeenCalledTimes(1);expect(onNavigate).toHaveBeenCalledTimes(1);});++ it('marks only the current panel pressed and paints it with the navigation roles', () => {+ renderPanel({ expanded: true });+ const active = screen.getByRole('button', { name: 'com_ui_chat_history' });+ const idle = screen.getByRole('button', { name: 'com_ui_prompts' });++ expect(active).toHaveAttribute('aria-pressed', 'true');+ expect(idle).toHaveAttribute('aria-pressed', 'false');+ for (const button of [active, idle]) {+ expect(button).toHaveClass(+ 'hover:bg-surface-nav-hover',+ 'aria-pressed:bg-surface-nav-selected',+ );+ expect(button).not.toHaveClass('bg-surface-active-alt');+ }++ fireEvent.click(idle);+ expect(idle).toHaveAttribute('aria-pressed', 'true');+ expect(active).toHaveAttribute('aria-pressed', 'false');+ });});describe('NewChatButton panel switch', () => {diff --git a/e2e/specs/mock/scenarios/rail-nav-states.spec.ts b/e2e/specs/mock/scenarios/rail-nav-states.spec.tsnew file mode 100644index 0000000000..6fde58b594--- /dev/null+++ b/e2e/specs/mock/scenarios/rail-nav-states.spec.ts@@ -0,0 +1,107 @@+import { expect, test } from '@playwright/test';+import type { Locator, Page } from '@playwright/test';+import { clickHouseTheme } from '../../../../packages/client/src/theme/themes/clickhouse';+import { NEW_CHAT_PATH } from '../helpers';++/**+ * The desktop icon rail marks its current panel and the one under the pointer with the theme's+ * navigation roles, the same layers the sidebar rows use, so a theme that sets them apart from+ * the generic hover and active fills paints the rail with them too.+ */+test.describe.configure({ timeout: 120_000 });+test.use({ viewport: { width: 1280, height: 800 }, isMobile: false, hasTouch: false });++type Mode = 'light' | 'dark';++type ThemeChoice = 'clickhouse' | 'default';++async function installThemeBridge(page: Page) {+ await page.addInitScript((definition) => {+ const params = new URL(location.href).searchParams;+ const theme = params.get('e2eTheme');+ const mode = params.get('e2eThemeMode');+ if (theme === null || mode === null) {+ return;+ }+ localStorage.setItem('color-theme', mode);+ localStorage.removeItem('theme-colors');+ localStorage.removeItem('theme-name');+ if (theme === 'clickhouse') {+ localStorage.setItem('theme-definition', JSON.stringify(definition));+ localStorage.setItem('theme-source', 'definition');+ } else {+ localStorage.removeItem('theme-definition');+ localStorage.removeItem('theme-source');+ }+ }, clickHouseTheme);+}++const rgb = (triplet: string | undefined) => `rgb(${(triplet ?? '').split(' ').join(', ')})`;++const fill = (locator: Locator) =>+ locator.evaluate((node) => getComputedStyle(node).backgroundColor);++async function openRail(page: Page, theme: ThemeChoice, mode: Mode) {+ await page.goto(`${NEW_CHAT_PATH}?e2eTheme=${theme}&e2eThemeMode=${mode}`, { timeout: 15000 });+ const selected = page.locator('[data-testid^="nav-panel-"][aria-pressed="true"]');+ await expect(selected).toHaveCount(1);+ await expect(selected).toBeVisible();+ const idleId = await page+ .locator('[data-testid^="nav-panel-"][aria-pressed="false"]')+ .first()+ .getAttribute('data-testid');+ const idle = page.getByTestId(idleId ?? '');+ await expect(idle).toBeVisible();+ return { selected, idle };+}++test.describe('desktop icon rail', () => {+ test('the rail paints its selected and hovered destinations with the navigation roles under the ClickHouse theme @scenario:rail-nav-roles-clickhouse', async ({+ page,+ }) => {+ await installThemeBridge(page);+ for (const mode of ['light', 'dark'] as Mode[]) {+ const { selected, idle } = await openRail(page, 'clickhouse', mode);+ await expect(page.locator('html')).toHaveAttribute('data-theme', 'clickhouse');+ const colors = clickHouseTheme.modes[mode]?.colors ?? {};++ await expect(selected).toHaveAttribute('data-testid', 'nav-panel-conversations');+ await expect.poll(() => fill(selected)).toBe(rgb(colors['rgb-surface-nav-selected']));+ expect(rgb(colors['rgb-surface-nav-selected'])).not.toBe(+ rgb(colors['rgb-surface-active-alt']),+ );++ await idle.focus();+ expect(await idle.evaluate((node) => node.matches(':focus-visible'))).toBe(true);+ await expect+ .poll(() => idle.evaluate((node) => getComputedStyle(node).boxShadow))+ .not.toBe('none');++ await idle.hover();+ await expect.poll(() => fill(idle)).toBe(rgb(colors['rgb-surface-nav-hover']));++ await page.mouse.move(640, 400);+ await expect.poll(() => fill(idle)).toBe('rgba(0, 0, 0, 0)');+ }+ });++ test('the default theme keeps the rail selected and hovered fills @scenario:rail-nav-default-unchanged', async ({+ page,+ }) => {+ await installThemeBridge(page);+ for (const [mode, active] of [+ ['light', 'rgb(227, 227, 227)'],+ ['dark', 'rgb(47, 47, 47)'],+ ] as Array<[Mode, string]>) {+ const { selected, idle } = await openRail(page, 'default', mode);++ await expect.poll(() => fill(selected)).toBe(active);+ await idle.hover();+ await expect.poll(() => fill(idle)).toBe(active);++ await idle.click();+ await expect(idle).toHaveAttribute('aria-pressed', 'true');+ await expect(selected).toHaveCount(1);+ }+ });+});diff --git a/eslint-suppressions.json b/eslint-suppressions.jsonindex 1ae7489cf1..a3da23d731 100644--- a/eslint-suppressions.json+++ b/eslint-suppressions.json@@ -1268,7 +1268,7 @@},"client/src/components/UnifiedSidebar/ExpandedPanel.tsx": {"shadcn/no-restyle": {- "count": 5+ "count": 2}},"client/src/components/UnifiedSidebar/Sidebar.tsx": {