Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
贴着窗口左上角的页签组为红绿灯与 ChromeActions 让位
Dash1df47eceeda9
diff --git a/apps/desktop/src/renderer/components/layout/MainLayout.tsx b/apps/desktop/src/renderer/components/layout/MainLayout.tsxindex 60ce344aa0..8c583cd83d 100644--- a/apps/desktop/src/renderer/components/layout/MainLayout.tsx+++ b/apps/desktop/src/renderer/components/layout/MainLayout.tsx@@ -1153,8 +1153,9 @@ export function MainLayout() {subagentsAvailable: rightSidebarSubagentsAvailable,isMac,onDetachTab: isSecondaryWindow() ? undefined : handleDetachRightSidebarTab,- // 左栏完全收起或 rail 态时,窗口左上的红绿灯 / ChromeActions 会压到最左面板顶栏。- reserveLeftChromeActions: isSidebarCollapsed || hasRailChromeActions,+ // 左栏完全收起 / rail 态时,窗口左上的红绿灯 / ChromeActions 会压到最左面板顶栏。+ sidebarCollapsed: isSidebarCollapsed,+ hasRailChromeActions,}),[handleDetachRightSidebarTab,diff --git a/apps/desktop/src/renderer/features/right-sidebar/TabGroupPanel.tsx b/apps/desktop/src/renderer/features/right-sidebar/TabGroupPanel.tsxindex af9f6125ba..a61f8c992e 100644--- a/apps/desktop/src/renderer/features/right-sidebar/TabGroupPanel.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/TabGroupPanel.tsx@@ -15,7 +15,7 @@ import { useTranslation } from 'react-i18next';import { tabGroupPanelKind, type TabGroupId } from '../../../shared/layoutTree';import { usePanelMaximize } from '@/layout/panelMaximize';-import { usePaneAtWindowTop, usePaneFill } from '@/layout/panePlacement';+import { usePaneAtWindowLeft, usePaneAtWindowTop, usePaneFill } from '@/layout/panePlacement';import { usePanelWidth } from '@/layout/paneWidths';import type { PanelComponentProps } from '@/panels/registry';import { RightSidebarShell } from './RightSidebarShell';@@ -27,6 +27,7 @@ function TabGroupPanelBody({ groupId }: { groupId: TabGroupId }): ReactNode {const host = useTabGroupHost();const fill = usePaneFill();const atWindowTop = usePaneAtWindowTop();+ const atWindowLeft = usePaneAtWindowLeft();const maximize = usePanelMaximize();const kind = tabGroupPanelKind(groupId);const engineWidth = usePanelWidth(kind);@@ -55,8 +56,13 @@ function TabGroupPanelBody({ groupId }: { groupId: TabGroupId }): ReactNode {subagentsAvailable={host.subagentsAvailable}isMac={host.isMac}unifiedTopbar={host.isMac && atWindowTop}+ // 贴着窗口左上角(左栏收起后左侧组 / 聊天列里的上方组都可能):给红绿灯与+ // ChromeActions 让位,否则页签与关闭按钮压在它们下面。reserveLeftChromeActions={- host.isMac && atWindowTop && groupId === 'left' && host.reserveLeftChromeActions+ host.isMac && atWindowTop && atWindowLeft && host.sidebarCollapsed+ }+ railChromeActionsHitHole={+ host.isMac && atWindowTop && atWindowLeft && host.hasRailChromeActions}onMaximize={maximize ? () => maximize.toggle(kind) : undefined}isMaximized={isMaximized}diff --git a/apps/desktop/src/renderer/features/right-sidebar/tabGroupHost.tsx b/apps/desktop/src/renderer/features/right-sidebar/tabGroupHost.tsxindex 5b46044b00..4c67be1010 100644--- a/apps/desktop/src/renderer/features/right-sidebar/tabGroupHost.tsx+++ b/apps/desktop/src/renderer/features/right-sidebar/tabGroupHost.tsx@@ -15,10 +15,12 @@ export interface TabGroupHostValue {/** 「在独立窗口中打开」某个页签(带 windowId = 搬进已有窗口);副窗口不提供。 */onDetachTab?: (tabId: string, targetWindowId?: string) => void;/**- * mac 下窗口左上的红绿灯 / ChromeActions 会盖住最左面板的顶栏:左侧组贴着窗口- * 顶边且左栏收起 / rail 时,为它们预留 no-drag 空位。+ * 左栏完全收起:mac 下窗口左上的红绿灯 / ChromeActions 浮在内容区最左面板的顶栏上,+ * 贴着窗口左上角的组要为它们预留 no-drag 空位。*/- reserveLeftChromeActions: boolean;+ sidebarCollapsed: boolean;+ /** 左栏为 rail:ChromeActions 跨到内容区,贴着窗口左上角的组顶栏要挖 no-drag 命中洞。 */+ hasRailChromeActions: boolean;}const TabGroupHostContext = createContext<TabGroupHostValue | null>(null);diff --git a/apps/desktop/src/renderer/layout/LayoutRoot.tsx b/apps/desktop/src/renderer/layout/LayoutRoot.tsxindex 97a48e93e6..c6f5921b7f 100644--- a/apps/desktop/src/renderer/layout/LayoutRoot.tsx+++ b/apps/desktop/src/renderer/layout/LayoutRoot.tsx@@ -29,7 +29,11 @@ import {} from '../panels/registry';import { installLayoutDevTools } from './layoutDevTools';import { PanelMaximizeContext, type PanelMaximizeState } from './panelMaximize';-import { PaneAtWindowTopProvider, PaneFillProvider } from './panePlacement';+import {+ PaneAtWindowLeftProvider,+ PaneAtWindowTopProvider,+ PaneFillProvider,+} from './panePlacement';import { PaneWidthProvider, useContentAvailableWidth } from './paneWidths';/**@@ -102,20 +106,24 @@ const PanelHost = memo(function PanelHost({visible,fill = false,atWindowTop = true,+ atWindowLeft = true,}: {node: PaneNode;definition: PanelDefinition | null;visible: boolean;fill?: boolean;atWindowTop?: boolean;+ atWindowLeft?: boolean;}): ReactNode {if (!definition || !visible) return null;const Component = definition.Component;return (<PaneAtWindowTopProvider value={atWindowTop}>- <PaneFillProvider value={fill}>- <Component paneId={node.id} />- </PaneFillProvider>+ <PaneAtWindowLeftProvider value={atWindowLeft}>+ <PaneFillProvider value={fill}>+ <Component paneId={node.id} />+ </PaneFillProvider>+ </PaneAtWindowLeftProvider></PaneAtWindowTopProvider>);});@@ -302,6 +310,8 @@ interface NodeViewProps {node: LayoutNode;fillPane?: boolean;atWindowTop?: boolean;+ /** 本节点是否贴着内容区左边(根横排里的第一块,及它的聊天列里的全部格)。 */+ atWindowLeft?: boolean;liveFractions: Record<string, number> | null;maximizedKind: string | null;/** 接管态(设置页):聊天列里只渲染聊天区,上下页签组连同横缝一起不画。 */@@ -315,6 +325,7 @@ function NodeView({node,fillPane = false,atWindowTop = true,+ atWindowLeft = true,liveFractions,maximizedKind,chatOnly = false,@@ -330,6 +341,7 @@ function NodeView({visible={isPanelKindVisible(node.panelKind)}fill={fillPane}atWindowTop={atWindowTop}+ atWindowLeft={atWindowLeft}/>);}@@ -369,6 +381,9 @@ function NodeView({const childAtWindowTop =atWindowTop &&(node.direction === 'row' || (maximizedKind !== null ? entryHasMaximized : i === 0));+ const childAtWindowLeft =+ atWindowLeft &&+ (node.direction === 'column' || (maximizedKind !== null ? entryHasMaximized : i === 0));// 接管态下列里只剩聊天区一格:撑满整列,不按旧份额留空。const fillsColumn = entryHasMaximized || (chatOnly && visible.length === 1);items.push(@@ -392,6 +407,7 @@ function NodeView({node={entry.node}fillPaneatWindowTop={childAtWindowTop}+ atWindowLeft={childAtWindowLeft}liveFractions={liveFractions}maximizedKind={maximizedKind}chatOnly={chatOnly}@@ -958,6 +974,7 @@ export function LayoutRoot({ suppressNonChatPanels = false }: LayoutRootProps =<div key={entry.node.id} aria-hidden className="flex w-0 flex-none overflow-hidden"><NodeViewnode={entry.node}+ atWindowLeft={false}liveFractions={liveFractions}maximizedKind={maximizedKind}onLive={setLiveFractions}@@ -1031,6 +1048,7 @@ export function LayoutRoot({ suppressNonChatPanels = false }: LayoutRootProps =<NodeViewnode={entry.node}fillPane+ atWindowLeft={i === 0}liveFractions={liveFractions}maximizedKind={null}chatOnly={suppressNonChatPanels}@@ -1044,6 +1062,7 @@ export function LayoutRoot({ suppressNonChatPanels = false }: LayoutRootProps =<NodeViewkey={entry.node.id}node={entry.node}+ atWindowLeft={i === 0}liveFractions={liveFractions}maximizedKind={null}onLive={setLiveFractions}diff --git a/apps/desktop/src/renderer/layout/__tests__/LayoutRoot.test.tsx b/apps/desktop/src/renderer/layout/__tests__/LayoutRoot.test.tsxindex 2ad4785f65..1f8b208d9f 100644--- a/apps/desktop/src/renderer/layout/__tests__/LayoutRoot.test.tsx+++ b/apps/desktop/src/renderer/layout/__tests__/LayoutRoot.test.tsx@@ -11,7 +11,7 @@ import {import { __resetBuiltinPanelsForTest } from '../../panels/builtinPanels';import { __resetPanelRegistryForTest, registerPanelKind } from '../../panels/registry';import { LayoutRoot, normalizeSubMinFractions } from '../LayoutRoot';-import { usePaneAtWindowTop, usePaneFill } from '../panePlacement';+import { usePaneAtWindowTop, usePaneFill, usePaneAtWindowLeft } from '../panePlacement';const ghostPanelSyncMock = vi.hoisted(() => ({ version: 0 }));@@ -319,7 +319,18 @@ describe('LayoutRoot · 树驱动的顺序与在场', () => {it('聊天列:chat-main 与下方页签组同列,列是根级弹性区域;接管态只剩聊天区', () => {registerPanelKind({kind: 'tab-group:bottom',- Component: () => <div data-testid="p-bottom" data-fill={String(usePaneFill())} />,+ Component: () => (+ <div+ data-testid="p-bottom"+ data-fill={String(usePaneFill())}+ data-window-left={String(usePaneAtWindowLeft())}+ />+ ),+ collapseMemory: 'none',+ });+ registerPanelKind({+ kind: 'tab-group:probe-right',+ Component: () => <div data-testid="p-probe" data-window-left={String(usePaneAtWindowLeft())} />,collapseMemory: 'none',});currentLayout = {@@ -341,11 +352,16 @@ describe('LayoutRoot · 树驱动的顺序与在场', () => {],},},- { fraction: 0.3, node: { type: 'pane', id: 'right', panelKind: 'right-tabs' } },+ { fraction: 0.2, node: { type: 'pane', id: 'right', panelKind: 'right-tabs' } },+ { fraction: 0.1, node: { type: 'pane', id: 'probe', panelKind: 'tab-group:probe-right' } },],},};const rendered = renderLayoutRoot();+ // 聊天列是最左的根级区域:列里的下方组贴着内容区左边(左栏收起时就是窗口左上角,+ // 顶栏要给红绿灯让位);右边的面板不贴。+ expect(screen.getByTestId('p-bottom').getAttribute('data-window-left')).toBe('true');+ expect(screen.getByTestId('p-probe').getAttribute('data-window-left')).toBe('false');const column = document.querySelector<HTMLElement>('[data-layout-root-child-id="chat-column"]');expect(column).not.toBeNull();expect(column!.className).toContain('flex-1');@@ -353,7 +369,7 @@ describe('LayoutRoot · 树驱动的顺序与在场', () => {expect(screen.getByTestId('p-chat')).toBeTruthy();expect(screen.getByTestId('p-bottom').getAttribute('data-fill')).toBe('true');// 列内一条横缝 + 根级一条竖缝。- expect(screen.getAllByTestId('layout-divider')).toHaveLength(2);+ expect(screen.getAllByTestId('layout-divider')).toHaveLength(3);rendered.rerender(<BuiltinPanelBridgeProvider value={bridge}>diff --git a/apps/desktop/src/renderer/layout/panePlacement.tsx b/apps/desktop/src/renderer/layout/panePlacement.tsxindex e8de18db36..99cac497eb 100644--- a/apps/desktop/src/renderer/layout/panePlacement.tsx+++ b/apps/desktop/src/renderer/layout/panePlacement.tsx@@ -8,9 +8,11 @@ import { createContext, useContext } from 'react';*/const PaneFillContext = createContext(false);const PaneAtWindowTopContext = createContext(true);+const PaneAtWindowLeftContext = createContext(true);export const PaneFillProvider = PaneFillContext.Provider;export const PaneAtWindowTopProvider = PaneAtWindowTopContext.Provider;+export const PaneAtWindowLeftProvider = PaneAtWindowLeftContext.Provider;export function usePaneFill(): boolean {return useContext(PaneFillContext);@@ -20,3 +22,11 @@ export function usePaneFill(): boolean {export function usePaneAtWindowTop(): boolean {return useContext(PaneAtWindowTopContext);}++/**+ * 当前 pane 是否贴着内容区左边(左栏收起 / rail 时即窗口左上角):mac 的红绿灯与+ * ChromeActions 浮在那里,贴着的面板顶栏要给它们让位。+ */+export function usePaneAtWindowLeft(): boolean {+ return useContext(PaneAtWindowLeftContext);+}