Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): suppress shared task sidebar context menus
DavidShend6365fd02795
diff --git a/apps/desktop/src/renderer/features/device-link/SharedTasksSection.tsx b/apps/desktop/src/renderer/features/device-link/SharedTasksSection.tsxindex 40859b1b84..1e1a5cb442 100644--- a/apps/desktop/src/renderer/features/device-link/SharedTasksSection.tsx+++ b/apps/desktop/src/renderer/features/device-link/SharedTasksSection.tsx@@ -79,7 +79,12 @@ export function SharedTasksSection({ activeSessionId, localSessions = [], onSelefinally { if (current()) { pending.current = false; setOpening(null); } }};if (!isAuthenticated) return null;- return <>{(owned.length > 0 || joined.length > 0) && <section className="mx-3 mb-2 border-b border-[var(--border-default)] pb-3" aria-label={t('sharedTask.title')}>+ return <>{(owned.length > 0 || joined.length > 0) && <section className="mx-3 mb-2 border-b border-[var(--border-default)] pb-3" aria-label={t('sharedTask.title')}+ onContextMenu={event => {+ // Shared entries have no context menu; do not open the sidebar's blank-space menu.+ event.preventDefault();+ event.stopPropagation();+ }}><div className="flex min-h-8 items-center justify-between gap-2">{both ? <SegmentedControl role="tablist" fullWidth className="min-w-0 flex-1"aria-label={t('sharedTask.title')} value={visibleTab} onValueChange={value => { setTab(value); setCollapsed(false); }}diff --git a/apps/desktop/src/renderer/features/device-link/__tests__/SharedTasksSection.test.tsx b/apps/desktop/src/renderer/features/device-link/__tests__/SharedTasksSection.test.tsxindex 4da103cc85..5fdda04635 100644--- a/apps/desktop/src/renderer/features/device-link/__tests__/SharedTasksSection.test.tsx+++ b/apps/desktop/src/renderer/features/device-link/__tests__/SharedTasksSection.test.tsx@@ -1,6 +1,6 @@import { sharedTaskHostPeer } from '@cindy/device-link';// @vitest-environment jsdom-import { render, screen, fireEvent, cleanup, waitFor, act } from '@testing-library/react';+import { render, screen, fireEvent, createEvent, cleanup, waitFor, act } from '@testing-library/react';import { afterEach, beforeEach, expect, it, vi } from 'vitest';import { SharedTasksSection } from '../SharedTasksSection';import { setDataOwnerGeneration } from '@/contexts/dataOwnerGeneration';@@ -22,6 +22,59 @@ beforeEach(() => {Object.assign(window, { electronAPI: { sharedTask: { account: state.account }, deviceLink: { openLink: state.openLink } } });});afterEach(cleanup);+it.each(['owned', 'joined'] as const)('suppresses context menus within the %s group without changing left-click actions or sidebar blank space', async (role) => {+ if (role === 'owned') {+ state.sessions = [];+ state.account.mockResolvedValue([{ sharedTaskId: 'owned-1', sessionId: 'host-task', local: true, title: 'Hosted task' }]);+ }+ const organize = vi.fn();+ const select = vi.fn();+ render(<div onContextMenu={organize}>+ <SharedTasksSection onSelect={select} />+ <div data-testid="sidebar-blank" />+ </div>);+ const heading = await screen.findByRole('button', { name: `sharedTask.${role}Section` });+ const title = role === 'owned' ? 'Hosted task' : 'Joined task';+ for (const target of [heading, screen.getByText(title), screen.getByRole('region')]) {+ const event = createEvent.contextMenu(target);+ fireEvent(target, event);+ expect(event.defaultPrevented).toBe(true);+ }+ expect(organize).not.toHaveBeenCalled();+ expect(select).not.toHaveBeenCalled();+ expect(state.openLink).not.toHaveBeenCalled();+ expect(heading.getAttribute('aria-expanded')).toBe('true');+ fireEvent.click(heading);+ expect(screen.queryByText(title)).toBeNull();+ fireEvent.click(heading);+ fireEvent.click(screen.getByText(title));+ expect(select).toHaveBeenCalledWith(role === 'owned' ? 'host-task' : 'joined-1');+ fireEvent.contextMenu(screen.getByTestId('sidebar-blank'));+ expect(organize).toHaveBeenCalledTimes(1);+});+it('suppresses context menus on role tabs and both task lists without switching or opening tasks', async () => {+ state.account.mockResolvedValue([{ sharedTaskId: 'owned-1', sessionId: 'host-task', local: true, title: 'Hosted task' }]);+ const organize = vi.fn();+ const select = vi.fn();+ render(<div onContextMenu={organize}><SharedTasksSection onSelect={select} /></div>);+ await screen.findByRole('tablist');+ for (const role of ['owned', 'joined']) {+ const tab = screen.getByRole('tab', { name: `sharedTask.${role}Tab` });+ const selected = tab.getAttribute('aria-selected');+ const event = createEvent.contextMenu(tab);+ fireEvent(tab, event);+ expect(event.defaultPrevented).toBe(true);+ expect(tab.getAttribute('aria-selected')).toBe(selected);+ fireEvent.click(tab);+ const row = screen.getByText(role === 'owned' ? 'Hosted task' : 'Joined task');+ const rowEvent = createEvent.contextMenu(row);+ fireEvent(row, rowEvent);+ expect(rowEvent.defaultPrevented).toBe(true);+ }+ expect(organize).not.toHaveBeenCalled();+ expect(select).not.toHaveBeenCalled();+ expect(state.openLink).not.toHaveBeenCalled();+});it('shows only joined tasks independently of the machine filter and does not reopen the active task', async () => {const select = vi.fn();render(<SharedTasksSection activeSessionId="joined-1" onSelect={select} />);diff --git a/docs/product-rules/shared-task-mode.md b/docs/product-rules/shared-task-mode.mdindex 69f7bba49b..09dc946621 100644--- a/docs/product-rules/shared-task-mode.md+++ b/docs/product-rules/shared-task-mode.md@@ -91,6 +91,7 @@- 设备菜单仅保留真实设备,不显示共享任务或内部 peer 标识。访客任务不再重复混入下方普通项目/任务列表。房主任务仍保留原项目归属,共享分组作为快捷入口。- 共享任务行沿用普通任务的 Agent 身份图标,按任务的 Agent 类型显示;不得因共享状态替换为人群图标。- 已加入任务直接打开既有任务页面,重复点击当前任务不重新连接、不清空页面。访客撤权继续使用现有结束提示与清理路径,不缓存已失效的可访问内容。+- 共享分组标题、角色切换条和任务行不提供右键菜单,也不触发侧栏空白处的整理菜单;左键折叠/展开、切换角色与进入任务保持不变,共享管理仍使用任务内已有入口(2026-09-21,用户确认)。侧栏其他区域的右键行为不变。- 加入弹窗采用 C 方案:标题说明下显示「我发起的共享 / N 个进行中」,右侧灰阶「关闭全部共享」,与底部加入按钮分离。无共享时禁用,获取失败可重试,不把未知状态当成零个。- 关闭确认在同一个窗口内替换表单内容,不叠加第二个弹窗;列出确认时的任务及所在电脑类别,默认聚焦取消。取消保留邀请与昵称。只关闭确认清单中的我发起的共享,失败保留未关闭项重试;不退出我加入的任务、不停止 Agent、不删除记录。账号变化或窗口退出后,旧请求不得继续操作下一项。- 本轮设计稿面向 Desktop;Mobile 仍遵循上文全屏主页面和平台确认控件规则。