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): 重命名输入框上右键不再叠弹整理菜单

Dash98f3160275c4
diff --git a/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts b/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts
index 784a1d2614..d7d94f3169 100644
--- a/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts
+++ b/apps/desktop/src/renderer/__tests__/machineSwitcherMenu.test.ts
@@ -181,6 +181,25 @@ describe('远程机器切换入口并入 SidebarTopNav(置顶段上方,固定不
expect(sidebarUpperSource).toContain('contextMenuPos={organizeMenuPos}');
});
+ // 2026-08-13 实机回归:重命名输入框上右键,行级 handler 裸 return 让事件冒泡到
+ // 滚动容器,整理菜单和系统的剪切/粘贴菜单叠着弹。编辑态必须 stopPropagation
+ // (但不 preventDefault——系统可编辑菜单要照常出)。
+ it('行级右键在编辑态阻止冒泡,不触发空白处整理菜单', () => {
+ const files = [
+ ['features', 'cc-agent', 'sidebar', 'SessionItem.tsx'],
+ ['features', 'cc-agent', 'sidebar', 'SessionCard.tsx'],
+ ['features', 'cc-agent', 'sidebar', 'sections', 'ProjectNode.tsx'],
+ ] as const;
+ for (const parts of files) {
+ const source = read(...parts);
+ // 编辑态分支必须 stopPropagation 后再 return;裸 `if (isEditing) return` 即回归。
+ expect(source).toMatch(
+ /if \(isEditing(?:Name)?\) \{\s*\n(?:\s*\/\/[^\n]*\n)*\s*e\.stopPropagation\(\);\s*\n\s*return;/,
+ );
+ expect(source).not.toMatch(/onContextMenu=\{\(e\) => \{\s*\n\s*if \(isEditing(?:Name)?\) return;/);
+ }
+ });
+
// 2026-08-12 用户裁决:筛选各维度选中后菜单不关闭(常要连调几项);排序与显示
// 模式仍选完即关(一次一个决定)。
it('筛选维度选中后保持菜单打开,排序 / 显示模式仍选完即关', () => {
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx
index e96bebfc64..f98f33ce1a 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionCard.tsx
@@ -642,7 +642,12 @@ export function SessionCard({
}
}}
onContextMenu={(e) => {
- if (isEditing) return;
+ if (isEditing) {
+ // 同 SessionItem:编辑态放行系统可编辑菜单,但拦下冒泡,避免与滚动
+ // 容器的空白处整理菜单叠弹(2026-08-13 实机回归)。
+ e.stopPropagation();
+ return;
+ }
e.preventDefault();
e.stopPropagation();
prefetchRemovalPreflight();
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx
index 83d31f57fa..b592c5b365 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx
@@ -840,7 +840,13 @@ export const SessionItem = memo(function SessionItem({
}
}}
onContextMenu={(e) => {
- if (isEditing) return;
+ if (isEditing) {
+ // 重命名输入框上的右键交给系统的可编辑菜单(剪切/复制/粘贴,main 侧
+ // selection-context-menu),但必须拦下冒泡——否则会穿透到滚动容器的
+ // 空白处右键 handler,整理菜单和原生菜单叠着弹(2026-08-13 实机回归)。
+ e.stopPropagation();
+ return;
+ }
e.preventDefault();
e.stopPropagation();
prefetchRemovalPreflight();
diff --git a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsx b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsx
index 2db8f90075..63e4a48efb 100644
--- a/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/sidebar/sections/ProjectNode.tsx
@@ -274,7 +274,12 @@ export function ProjectNode({
}
}}
onContextMenu={(e) => {
- if (isEditingName) return;
+ if (isEditingName) {
+ // 同 SessionItem:编辑态放行系统可编辑菜单,但拦下冒泡,避免与滚动
+ // 容器的空白处整理菜单叠弹(2026-08-13 实机回归)。
+ e.stopPropagation();
+ return;
+ }
e.preventDefault();
e.stopPropagation();
setMenuPos({ x: e.clientX, y: e.clientY });