Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(desktop): keep collapsed titlebar nav clear of macOS traffic lights (#20397)

Innei026e7afc519e
diff --git a/src/features/Electron/titlebar/NavigationBar.test.tsx b/src/features/Electron/titlebar/NavigationBar.test.tsx
index 495857a1947..f1f0115c6a2 100644
--- a/src/features/Electron/titlebar/NavigationBar.test.tsx
+++ b/src/features/Electron/titlebar/NavigationBar.test.tsx
@@ -4,6 +4,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
import NavigationBar from './NavigationBar';
const mocks = vi.hoisted(() => ({
+ isMac: false,
handlers: new Map<string, () => void>(),
leftPanelVisible: false,
leftPanelWidth: 0,
@@ -42,7 +43,7 @@ vi.mock('@/store/electron', () => ({
selector({ activeRecentScope: { slug: 'acme', type: 'workspace' } }),
}));
vi.mock('@/styles/electron', () => ({ electronStylish: { nodrag: 'nodrag' } }));
-vi.mock('@/utils/platform', () => ({ isMacOS: () => false }));
+vi.mock('@/utils/platform', () => ({ isMacOS: () => mocks.isMac }));
vi.mock('../navigation/useNavigationHistory', () => ({
useNavigationHistory: () => ({
canGoBack: false,
@@ -57,6 +58,7 @@ vi.mock('./TrayMenu/useTrayMenuSync', () => ({ useTrayMenuSync: vi.fn() }));
describe('NavigationBar tray broadcasts', () => {
beforeEach(() => {
mocks.handlers.clear();
+ mocks.isMac = false;
mocks.leftPanelVisible = false;
mocks.leftPanelWidth = 0;
vi.clearAllMocks();
@@ -92,4 +94,14 @@ describe('NavigationBar tray broadcasts', () => {
expect(expanded.container.querySelector('.root')).toHaveStyle({ width: '268px' });
});
+
+ it('reserves the traffic light inset on macOS when the sidebar is collapsed', async () => {
+ mocks.isMac = true;
+ vi.resetModules();
+ const { default: MacNavigationBar } = await import('./NavigationBar');
+
+ const { container } = render(<MacNavigationBar />);
+
+ expect(container.querySelector('.root')).toHaveStyle({ width: '184px' });
+ });
});
diff --git a/src/features/Electron/titlebar/NavigationBar.tsx b/src/features/Electron/titlebar/NavigationBar.tsx
index aa9cce26042..413aa82e5b0 100644
--- a/src/features/Electron/titlebar/NavigationBar.tsx
+++ b/src/features/Electron/titlebar/NavigationBar.tsx
@@ -128,9 +128,9 @@ const NavigationBar = memo(() => {
const isLeftPanelVisible = leftPanelWidth > 0;
const macTrafficLightPadding = getMacTrafficLightPadding(isMac, isWindowFullScreen);
- const collapsedWidth = isMac
- ? MAC_COLLAPSED_NAVIGATION_BAR_WIDTH
- : COLLAPSED_NAVIGATION_BAR_WIDTH;
+ const collapsedWidth =
+ (isMac ? MAC_COLLAPSED_NAVIGATION_BAR_WIDTH : COLLAPSED_NAVIGATION_BAR_WIDTH) +
+ macTrafficLightPadding;
const navigationWidth = isLeftPanelVisible
? Math.max(leftPanelWidth - 12, collapsedWidth)
: collapsedWidth;