Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): reserve macOS chrome space for left panels (#1924)

许君山 Junshan1d01b1338263
diff --git a/apps/desktop/src/renderer/components/layout/MainLayout.tsx b/apps/desktop/src/renderer/components/layout/MainLayout.tsx
index 8292e64ff0..afad6e05e6 100644
--- a/apps/desktop/src/renderer/components/layout/MainLayout.tsx
+++ b/apps/desktop/src/renderer/components/layout/MainLayout.tsx
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { BrowserWebviewPool } from '@/components/layout/BrowserWebviewPool';
import { ChromeActions } from '@/components/layout/ChromeActions';
+import { shouldReserveLeftChromeActions } from '@/components/layout/chromeActionsLayout';
import { ContentHeaderSlot } from '@/components/layout/ContentHeader';
import { rightSidebarOwnsRailChromeActions as resolveRightSidebarRailChromeActionsOwner } from '@/components/layout/railChromeActions';
import { FadeSwitcher } from '@/components/layout/FadeSwitcher';
@@ -1328,7 +1329,11 @@ export function MainLayout() {
onCloseSidebar={isMac ? undefined : handleToggleRightSidebar}
onMaximize={handleMaximizeRightSidebar}
isMaximized={isRightSidebarMaximized}
- reserveLeftChromeActions={isRightSidebarMaximized && isSidebarCollapsed}
+ reserveLeftChromeActions={shouldReserveLeftChromeActions({
+ isSidebarCollapsed,
+ rightSidebarSide,
+ isRightSidebarMaximized,
+ })}
railChromeActionsHitHole={rightSidebarOwnsRailChromeActions}
sessionId={rightSidebarSessionId}
workdir={rightSidebarWorkdirInfo.workdir}
diff --git a/apps/desktop/src/renderer/components/layout/__tests__/chromeActionsLayout.test.ts b/apps/desktop/src/renderer/components/layout/__tests__/chromeActionsLayout.test.ts
new file mode 100644
index 0000000000..4cacd3ed52
--- /dev/null
+++ b/apps/desktop/src/renderer/components/layout/__tests__/chromeActionsLayout.test.ts
@@ -0,0 +1,55 @@
+import { describe, expect, it } from 'vitest';
+
+import { shouldReserveLeftChromeActions } from '../chromeActionsLayout';
+
+describe('shouldReserveLeftChromeActions', () => {
+ it.each([
+ [
+ 'collapsed left-docked panel',
+ {
+ isSidebarCollapsed: true,
+ rightSidebarSide: 'left' as const,
+ isRightSidebarMaximized: false,
+ },
+ ],
+ [
+ 'collapsed maximized panel',
+ {
+ isSidebarCollapsed: true,
+ rightSidebarSide: 'right' as const,
+ isRightSidebarMaximized: true,
+ },
+ ],
+ ])('reserves the topbar chrome area for %s', (_name, input) => {
+ expect(shouldReserveLeftChromeActions(input)).toBe(true);
+ });
+
+ it.each([
+ [
+ 'expanded left-docked panel',
+ {
+ isSidebarCollapsed: false,
+ rightSidebarSide: 'left' as const,
+ isRightSidebarMaximized: false,
+ },
+ ],
+ [
+ 'expanded maximized panel',
+ {
+ isSidebarCollapsed: false,
+ rightSidebarSide: 'right' as const,
+ isRightSidebarMaximized: true,
+ },
+ ],
+ [
+ 'collapsed right-docked panel',
+ {
+ isSidebarCollapsed: true,
+ rightSidebarSide: 'right' as const,
+ isRightSidebarMaximized: false,
+ },
+ ],
+ ])('does not reserve the area for %s', (_name, input) => {
+ expect(shouldReserveLeftChromeActions(input)).toBe(false);
+ });
+});
diff --git a/apps/desktop/src/renderer/components/layout/chromeActionsLayout.ts b/apps/desktop/src/renderer/components/layout/chromeActionsLayout.ts
new file mode 100644
index 0000000000..8bc76a9e35
--- /dev/null
+++ b/apps/desktop/src/renderer/components/layout/chromeActionsLayout.ts
@@ -0,0 +1,11 @@
+export function shouldReserveLeftChromeActions({
+ isSidebarCollapsed,
+ rightSidebarSide,
+ isRightSidebarMaximized,
+}: {
+ isSidebarCollapsed: boolean;
+ rightSidebarSide: 'left' | 'right';
+ isRightSidebarMaximized: boolean;
+}): boolean {
+ return isSidebarCollapsed && (rightSidebarSide === 'left' || isRightSidebarMaximized);
+}