Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): worker 菜单布局切换项小窗口下不被裁掉
Shinkua8ea952ef71b
diff --git a/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsx b/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsxindex 4e14e9d5a4..aa6cd2e605 100644--- a/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/RolePillDropdown.tsx@@ -318,9 +318,12 @@ export interface WorkerListToolbarProps extends RolePillDropdownProps {// 菜单经 top-full + mt-1 从锚点下方定位。按锚点实际 viewport 位置计算下方可用高度,// 避免 Worker 工具栏不在视口顶部时,菜单底部的 Worker 行 / 布局切换项越过视口而不可达。// 当锚点下方空间不足(低于上方空间)时改为向上展开,保证任意窗口高度下菜单都不越出视口。+// minContentHeight:菜单内不可收缩(shrink-0)内容(header + 布局切换项)所需的最小高度,+// 作为 maxHeight 的保底——否则小窗口下可用高度低于该值时,外层 overflow-hidden 会裁掉底部布局切换项。function useAnchorMenuMaxHeight(anchorRef: { current: HTMLElement | null },open: boolean,+ minContentHeight = 0,): { maxHeight: number; placeAbove: boolean } | undefined {const [placement, setPlacement] = useState<{ maxHeight: number; placeAbove: boolean } | undefined>(undefined,@@ -337,12 +340,15 @@ function useAnchorMenuMaxHeight(const belowSpace = window.innerHeight - rect.bottom - gap - pad;const aboveSpace = rect.top - gap - pad;const placeAbove = aboveSpace > belowSpace;- setPlacement({ maxHeight: Math.max(0, placeAbove ? aboveSpace : belowSpace), placeAbove });+ setPlacement({+ maxHeight: Math.max(minContentHeight, placeAbove ? aboveSpace : belowSpace),+ placeAbove,+ });};update();window.addEventListener('resize', update);return () => window.removeEventListener('resize', update);- }, [anchorRef, open]);+ }, [anchorRef, open, minContentHeight]);return placement;}@@ -407,6 +413,9 @@ function WorkerLayoutMenu({// 点击固定 (pinned)、移出后延迟关闭 —— 两种布局下 ⋮ 的操作体感一致。const [openMode, setOpenMode] = useState<DropdownOpenMode>(null);const wrapperRef = useRef<HTMLDivElement | null>(null);+ // 菜单内不可收缩内容(header + 布局切换项)的测量 ref,用于 maxHeight 保底。+ const headerRef = useRef<HTMLDivElement | null>(null);+ const footerRef = useRef<HTMLDivElement | null>(null);const hoverOpenTimerRef = useRef<number | null>(null);const hoverCloseTimerRef = useRef<number | null>(null);const attention = useWorkerAttentionSnapshot();@@ -414,7 +423,17 @@ function WorkerLayoutMenu({const totalWorkerCount = workers.length;const activeCount = activeWorkerCount;const open = openMode !== null;- const menuPlacement = useAnchorMenuMaxHeight(wrapperRef, open);+ const [fixedContentHeight, setFixedContentHeight] = useState(0);+ // 打开后测量 header + 布局切换项的高度,作为 maxHeight 保底:小窗口下可用高度再小+ // 也不能低于它,否则外层 overflow-hidden 会裁掉底部布局切换项。header/footer 文案+ // 固定(无换行),高度恒定,一次测量即可。+ useLayoutEffect(() => {+ if (!open) return;+ setFixedContentHeight(+ (headerRef.current?.offsetHeight ?? 0) + (footerRef.current?.offsetHeight ?? 0),+ );+ }, [open]);+ const menuPlacement = useAnchorMenuMaxHeight(wrapperRef, open, fixedContentHeight);const menuMaxWidth = useAnchorMenuMaxWidth(wrapperRef, open, 'right');const clearHoverTimers = useCallback(() => {@@ -528,7 +547,7 @@ function WorkerLayoutMenu({{/* Header: WORKERS + count */}{layout === 'tabs' && (<>- <div className="flex shrink-0 select-none items-center justify-between px-4 pt-3 pb-2">+ <div ref={headerRef} className="flex shrink-0 select-none items-center justify-between px-4 pt-3 pb-2"><span className="text-10 font-medium uppercase tracking-[0.5px] text-[var(--text-tertiary)]">{t('orca.rolePill.workersHeader')}</span>@@ -611,7 +630,7 @@ function WorkerLayoutMenu({)}{/* Layout options */}- <div className="shrink-0 p-1">+ <div ref={footerRef} className="shrink-0 p-1"><div className="select-none px-2.5 py-1.5 text-10 font-medium leading-snug text-[var(--text-tertiary)]">{t('orca.rolePill.layoutMenuLabel')}</div>