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。

feat(desktop): 侧栏空白处右键开整理菜单;菜单补图标、任务信息摘要改图标串

Dash3d5f2b24cb49
diff --git a/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts b/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts
index 889972d637..d99940e951 100644
--- a/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts
+++ b/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts
@@ -164,6 +164,41 @@ describe('远程机器切换入口并入 SidebarTopNav(置顶段上方,固定不
expect(pinnedSectionSource).not.toContain('<LayoutGrid size={13} strokeWidth={2} />');
});
+ // 2026-08-12 用户裁决:侧栏空白处右键也能开整理菜单。
+ it('侧栏空白处右键打开整理菜单(行级右键仍归各自的菜单)', () => {
+ const filterSource = read('features', 'cc-agent', 'sidebar', 'SidebarFilterPopover.tsx');
+ // 同一组件两种形态:段头按钮 / 受控光标定位(隐形 fixed trigger,同 ProjectNode 做法)。
+ expect(filterSource).toContain('const isContextMode = contextMenuPos !== undefined');
+ expect(filterSource).toContain("position: 'fixed'");
+ expect(filterSource).toContain('left: contextMenuPos?.x ?? 0');
+ expect(filterSource).toContain('top: contextMenuPos?.y ?? 0');
+
+ // 滚动容器接右键;行级菜单靠自身 stopPropagation 抢先处理,这里只兜空白区。
+ expect(sidebarUpperSource).toContain('onContextMenu={handleSidebarBlankContextMenu}');
+ expect(sidebarUpperSource).toContain(
+ 'setOrganizeMenuPos({ x: event.clientX, y: event.clientY })',
+ );
+ expect(sidebarUpperSource).toContain('contextMenuPos={organizeMenuPos}');
+ });
+
+ // 2026-08-12 用户裁决:任务信息行的当前选中项用图标表示,不再罗列短词。
+ it('任务信息摘要用图标串,筛选各维度行也有图标', () => {
+ const filterSource = read('features', 'cc-agent', 'sidebar', 'SidebarFilterPopover.tsx');
+ // 摘要节点按 TASK_INFO_OPTIONS 顺序过滤已选项渲染图标;文字版留给 aria-label。
+ expect(filterSource).toContain('valueNode={');
+ expect(filterSource).toContain(
+ 'TASK_INFO_OPTIONS.filter((option) => taskInfoFields.includes(option.value))',
+ );
+ expect(filterSource).toContain('aria-label={valueNode ? value : undefined}');
+ // 具体维度行配图标(状态 / 项目 / Agent / 最近活跃 / 筛选 / 任务信息)。
+ expect(filterSource).toContain('Icon={Filter}');
+ expect(filterSource).toContain('Icon={CircleDot}');
+ expect(filterSource).toContain('Icon={Folder}');
+ expect(filterSource).toContain('Icon={Bot}');
+ expect(filterSource).toContain('Icon={CalendarClock}');
+ expect(filterSource).toContain('Icon={Info}');
+ });
+
it('连接中占位页不再自带 MachineSwitcherMenu(固定行已常驻,不会被困住)', () => {
const idx = sidebarUpperSource.indexOf('selectedMachineConnecting ?');
expect(idx).toBeGreaterThanOrEqual(0);
@@ -360,7 +395,9 @@ describe('远程机器切换入口并入 SidebarTopNav(置顶段上方,固定不
expect(filterSource).not.toContain('HoverMenuAreaContext.Provider');
expect(filterSource).not.toContain('{...triggerProps}');
expect(filterSource).not.toContain('{...contentProps}');
- expect(filterSource).toContain('<DropdownMenu modal={false}>');
+ // 非模态保留(侧栏常驻,不锁滚动);2026-08-12 起同一组件还支持受控光标模式
+ // (空白处右键),故 modal 与 open 分行书写,断言收窄到 modal 本身。
+ expect(filterSource).toMatch(/<DropdownMenu\s+modal=\{false\}/);
// 触发按钮配色与段头其余按钮统一到侧栏 token 对(此前用通用 text-tertiary,hover 不齐)。
expect(filterSource).toContain("'text-[var(--sidebar-list-muted)]'");
expect(filterSource).toContain("'transition-colors hover:text-[var(--sidebar-nav-text)]'");
diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
index f8c4e420c2..e786e30953 100644
--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSidebarUpper.tsx
@@ -63,6 +63,7 @@ import {
import { setSessionOrdinalBadges } from './sidebar/sessionOrdinalBadges';
import { useOwnTopNavScrollableRows, useSidebarCollapsedState } from '../feature-context';
import { SidebarTopNav } from '@/components/sidebar/SidebarTopNav';
+import { SidebarFilterPopover } from './sidebar/SidebarFilterPopover';
import { stripTrailingPathSeparators } from '../../../shared/pathText';
import { useRefreshWorktrees } from '@/contexts/WorktreeContext';
import {
@@ -1679,6 +1680,15 @@ function ExpandedView({
* 用 mask-image(基于 alpha)而非叠色块:透出的是侧栏自身背景,light / dark /
* 任意扩展主题天然正确,不需要按主题取色。
*/
+ /**
+ * 空白处右键打开的整理菜单(2026-08-12 用户裁决)。会话行 / 项目行 / 对话组头
+ * 都在自己的 onContextMenu 里 stopPropagation,冒泡到滚动容器的必然是空白区域。
+ */
+ const [organizeMenuPos, setOrganizeMenuPos] = useState<{ x: number; y: number } | null>(null);
+ const handleSidebarBlankContextMenu = useCallback((event: React.MouseEvent) => {
+ event.preventDefault();
+ setOrganizeMenuPos({ x: event.clientX, y: event.clientY });
+ }, []);
const [topFade, setTopFade] = useState(false);
useEffect(() => {
const el = sidebarScrollRef.current;
@@ -3055,6 +3065,10 @@ function ExpandedView({
<div
ref={sidebarScrollRef}
className="flex flex-col gap-2 pt-0 pb-4 overflow-y-auto flex-1"
+ // 空白处右键 = 打开整理菜单(2026-08-12 用户裁决)。命中会话行 / 项目行 /
+ // 对话组头时不接管——那些行有各自的右键菜单,由它们 stopPropagation 后
+ // 自行处理;这里只兜「没有任何行响应」的空白区域。
+ onContextMenu={handleSidebarBlankContextMenu}
style={
{
scrollbarGutter: 'stable',
@@ -3247,6 +3261,18 @@ function ExpandedView({
)}
</div>
+ {/* 空白处右键的整理菜单:与段头 sliders 按钮同一个组件、同一份内容,
+ 只是改用隐形定位 trigger 开在光标处(2026-08-12 用户裁决)。 */}
+ <SidebarFilterPopover
+ filter={filter}
+ allKnownProjects={visibleProjectUniverse}
+ hasRemoteDevices={(remoteDeviceIndex?.size ?? 0) > 0}
+ contextMenuPos={organizeMenuPos}
+ onContextMenuOpenChange={(open) => {
+ if (!open) setOrganizeMenuPos(null);
+ }}
+ />
+
{/* Delete / Archive confirm dialog */}
<ConfirmDialog
open={confirm.open}
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SidebarFilterPopover.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SidebarFilterPopover.tsx
index f01e12f408..fe68f10796 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SidebarFilterPopover.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SidebarFilterPopover.tsx
@@ -23,12 +23,18 @@
import type { ReactNode } from 'react';
import {
AlignJustify,
+ Bot,
+ CalendarClock,
Check,
ChevronRight,
+ CircleDot,
Clock,
Coins,
+ Filter,
+ Folder,
GitPullRequest,
Globe,
+ Info,
LayoutList,
SlidersHorizontal,
Wallet,
@@ -141,6 +147,14 @@ export interface SidebarFilterPopoverProps {
* 仅远程连接时显示;仅本机时该选项整行隐藏。
*/
hasRemoteDevices?: boolean;
+ /**
+ * 受控光标定位模式(2026-08-12 用户裁决:侧栏空白处右键也能开这个菜单)。
+ * 传入时不渲染段头那个 sliders 按钮,改用「隐形定位 trigger」把菜单开在光标处
+ * (与 ProjectNode / ChatImageView 的右键菜单同款做法)。null = 关闭。
+ */
+ contextMenuPos?: { x: number; y: number } | null;
+ /** 受控模式下的关闭回调(点外部 / Esc / 选中项)。 */
+ onContextMenuOpenChange?: (open: boolean) => void;
}
function optionLabel<T extends string>(
@@ -154,11 +168,21 @@ function optionLabel<T extends string>(
function MenuSubRow({
label,
value,
+ valueNode,
valueEmphasized = false,
+ Icon,
children,
}: {
label: string;
+ /** 文字摘要;给了 valueNode 时忽略(仍需传,用于 aria-label 之类的可读兜底)。 */
value: string;
+ /** 行首图标,与 MenuItemIcon 同规格。 */
+ Icon?: LucideIcon;
+ /**
+ * 自定义摘要节点。任务信息行用它渲染「已选项的图标串」——图标比逗号分隔的
+ * 短词更快扫读,且不会在 4 项全选时把行挤爆(2026-08-12 用户裁决)。
+ */
+ valueNode?: ReactNode;
/** 偏离默认值时右侧摘要转正文色,提示筛选生效。 */
valueEmphasized?: boolean;
children: ReactNode;
@@ -166,14 +190,17 @@ function MenuSubRow({
return (
<DropdownMenuSub>
<DropdownMenuSubTrigger className={MENU_ROW_CLASS}>
+ <MenuItemIcon Icon={Icon} />
<span className="truncate">{label}</span>
<span
className={cn(
'ml-auto max-w-[96px] truncate text-right',
valueEmphasized ? 'text-foreground' : 'text-[var(--cmd-palette-item-meta)]',
)}
+ // 图标摘要下把文字版留给读屏(图标本身 aria-hidden)。
+ aria-label={valueNode ? value : undefined}
>
- {value}
+ {valueNode ?? value}
</span>
<ChevronRight size={14} className="shrink-0 text-[var(--cmd-palette-item-meta)]" />
</DropdownMenuSubTrigger>
@@ -248,8 +275,13 @@ export function SidebarFilterPopover({
filter,
allKnownProjects,
hasRemoteDevices = false,
+ contextMenuPos,
+ onContextMenuOpenChange,
}: SidebarFilterPopoverProps) {
const { t } = useTranslation();
+ // 受控光标模式 = 调用方传了 contextMenuPos 这个 prop(值为 null 表示"当前关闭",
+ // 仍算受控);段头按钮模式则完全不传。用 !== undefined 而非真值判断。
+ const isContextMode = contextMenuPos !== undefined;
const {
status,
projects,
@@ -332,30 +364,53 @@ export function SidebarFilterPopover({
return (
// modal={false}:侧栏是常驻面板,整理菜单不该锁住列表滚动、也不该给 body
// 加 pointer-events:none 屏蔽其余界面(点外部 / Esc 仍正常关闭)。
- <DropdownMenu modal={false}>
+ <DropdownMenu
+ modal={false}
+ {...(isContextMode
+ ? {
+ open: contextMenuPos !== null,
+ onOpenChange: (open: boolean) => onContextMenuOpenChange?.(open),
+ }
+ : null)}
+ >
<DropdownMenuTrigger asChild>
- {/* hover 不再展开菜单,补一个与邻居同规的 tooltip(复用菜单标题文案,
- 与「对话」段头同款按钮一致);aria-label 仍带完整设置摘要。 */}
- <Tip text={t('ccAgent.sidebar.organizeSidebar')} side="bottom">
- <button
- type="button"
- aria-label={ariaLabel}
- aria-pressed={isFilterActive}
- className={cn(
- // 配色与段头其余按钮统一(侧栏 token 对),不用通用 text-tertiary。
- 'flex h-7 w-7 items-center justify-center rounded-md',
- 'text-[var(--sidebar-list-muted)]',
- 'transition-colors hover:text-[var(--sidebar-nav-text)]',
- )}
- >
- <SlidersHorizontal size={14} strokeWidth={2} />
- </button>
- </Tip>
+ {isContextMode ? (
+ // 隐形定位 trigger:菜单开在光标处(与 ProjectNode / ChatImageView 右键菜单同款)。
+ <span
+ aria-hidden
+ style={{
+ position: 'fixed',
+ left: contextMenuPos?.x ?? 0,
+ top: contextMenuPos?.y ?? 0,
+ width: 0,
+ height: 0,
+ pointerEvents: 'none',
+ }}
+ />
+ ) : (
+ /* hover 不再展开菜单,补一个与邻居同规的 tooltip(复用菜单标题文案,
+ 与「对话」段头同款按钮一致);aria-label 仍带完整设置摘要。 */
+ <Tip text={t('ccAgent.sidebar.organizeSidebar')} side="bottom">
+ <button
+ type="button"
+ aria-label={ariaLabel}
+ aria-pressed={isFilterActive}
+ className={cn(
+ // 配色与段头其余按钮统一(侧栏 token 对),不用通用 text-tertiary。
+ 'flex h-7 w-7 items-center justify-center rounded-md',
+ 'text-[var(--sidebar-list-muted)]',
+ 'transition-colors hover:text-[var(--sidebar-nav-text)]',
+ )}
+ >
+ <SlidersHorizontal size={14} strokeWidth={2} />
+ </button>
+ </Tip>
+ )}
</DropdownMenuTrigger>
<DropdownMenuContent
side="bottom"
align="start"
- sideOffset={8}
+ sideOffset={isContextMode ? 2 : 8}
// 与窗口边缘留白:菜单向上翻转时不顶死在标题栏上(仓库既有 8~16 的先例)。
collisionPadding={8}
className={cn(MENU_CONTENT_CLASS, 'w-[248px]')}
@@ -416,8 +471,13 @@ export function SidebarFilterPopover({
label={t('ccAgent.sidebar.filterHeading')}
value={filterSummary}
valueEmphasized={activeFilterCount > 0}
+ Icon={Filter}
>
- <MenuSubRow label={t('ccAgent.sidebar.filterStatusHeading')} value={statusValue}>
+ <MenuSubRow
+ label={t('ccAgent.sidebar.filterStatusHeading')}
+ value={statusValue}
+ Icon={CircleDot}
+ >
{STATUS_OPTIONS.map((option) => (
<SelectMenuItem
key={option.value}
@@ -428,7 +488,11 @@ export function SidebarFilterPopover({
))}
</MenuSubRow>
- <MenuSubRow label={t('ccAgent.sidebar.filterProjectsHeading')} value={projectValue}>
+ <MenuSubRow
+ label={t('ccAgent.sidebar.filterProjectsHeading')}
+ value={projectValue}
+ Icon={Folder}
+ >
<DropdownMenuItem
onSelect={(event) => {
event.preventDefault();
@@ -487,7 +551,11 @@ export function SidebarFilterPopover({
</div>
</MenuSubRow>
- <MenuSubRow label={t('ccAgent.sidebar.filterAgentHeading')} value={vendorValue}>
+ <MenuSubRow
+ label={t('ccAgent.sidebar.filterAgentHeading')}
+ value={vendorValue}
+ Icon={Bot}
+ >
{VENDOR_OPTIONS.map((option) => (
<SelectMenuItem
key={option.value}
@@ -501,6 +569,7 @@ export function SidebarFilterPopover({
<MenuSubRow
label={t('ccAgent.sidebar.filterLastActivityHeading')}
value={lastActivityValue}
+ Icon={CalendarClock}
>
{LAST_ACTIVITY_OPTIONS.map((option) => (
<SelectMenuItem
@@ -545,6 +614,27 @@ export function SidebarFilterPopover({
<MenuSubRow
label={t('ccAgent.sidebar.taskInfoHeading')}
value={taskInfoSummary}
+ Icon={Info}
+ valueNode={
+ taskInfoFields.length > 0 ? (
+ // 已选项用图标串表示(顺序固定为 TASK_INFO_OPTIONS 的展示顺序,
+ // 与列表行的渲染顺序一致),不再罗列短词。
+ <span className="flex items-center justify-end gap-1">
+ {TASK_INFO_OPTIONS.filter((option) => taskInfoFields.includes(option.value)).map(
+ (option) =>
+ option.Icon ? (
+ <option.Icon
+ key={option.value}
+ size={13}
+ strokeWidth={1.8}
+ className="shrink-0"
+ aria-hidden
+ />
+ ) : null,
+ )}
+ </span>
+ ) : undefined
+ }
valueEmphasized={!taskInfoIsDefault}
>
{TASK_INFO_OPTIONS.map((option) => (