For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: 让 Windows 桌面设置页显示「电脑控制」分区,并只提供与 macOS 共用的官方 zcode-cua 插件总开关。
Architecture: 设置页配置改为按明确的 isMacDesktop / isWindowsDesktop props 生成,避免 Web 端依赖 user agent 误露出桌面能力。ComputerUseSection 保留共享插件开关流程,同时把本地 Windows 的“开关能力”与仅限 macOS 的权限、Helper 和附加设置能力分开。
Tech Stack: React 19、TypeScript、Zustand、Vitest、Testing Library、Tailwind CSS
ZCODE_CUA_OFFICIAL_PLUGIN_ID、插件 store 和 setEnabled 流程。SettingsGroupCard、SettingsRow、Switch 和既有国际化文案。pnpm typecheck 与 pnpm lint。packages/ui/src/settings/settingsPageConfig.ts — 按桌面平台生成可见分区,并解析平台可见的导航落点。packages/ui/src/settingsPageHelpers.tsx — 向设置页重导出平台配置函数。packages/ui/src/SettingsPage.tsx — 使用平台配置、保护初始落点和导航意图,并把 Windows 标记传给电脑控制分区。packages/ui/test/settingsPageConfig.test.ts — 覆盖 macOS、Windows、非桌面端的分区和不可见落点回退。packages/ui/test/settingsPageIntegratedTerminalShell.test.ts — 让既有 SettingsPage 测试 mock 提供新的配置函数接口。packages/ui/src/settings/ComputerUseSection.tsx — Windows 复用总开关,macOS 独占附加设置与权限副作用。packages/ui/test/computerUseWindowsSettings.test.ts — 渲染级验证 Windows 只有总开关且调用共享插件启停流程。Files:
packages/ui/test/settingsPageConfig.test.tspackages/ui/src/settings/settingsPageConfig.tsInterfaces:
createSettingsPageConfig(options: { isMacDesktop?: boolean; isWindowsDesktop?: boolean })resolveSettingsSectionForPlatform(section, visibleSections, fallbackSection?)Returns: { settingsSections, settingsSectionGroups }
[ ] Step 1: 写平台配置和落点回退的失败测试
在 packages/ui/test/settingsPageConfig.test.ts 中改为通过工厂读取配置,并加入以下断言:
it.each([
["macOS", { isMacDesktop: true }, true],
["Windows", { isWindowsDesktop: true }, true],
["Web/Linux", {}, false],
] as const)("%s 的电脑控制入口符合桌面平台边界", async (_name, options, expected) => {
const { createSettingsPageConfig } = await loadSettingsPageConfig("test");
const { settingsSections } = createSettingsPageConfig(options);
expect(settingsSections.some((section) => section.id === "computerUse")).toBe(expected);
});
it("不可见的电脑控制落点回退到 general", async () => {
const { createSettingsPageConfig, resolveSettingsSectionForPlatform } =
await loadSettingsPageConfig("test");
const { settingsSections } = createSettingsPageConfig({});
expect(resolveSettingsSectionForPlatform("computerUse", settingsSections, "general")).toBe(
"general",
);
});
同步把既有顺序测试改为调用 createSettingsPageConfig({}),其非桌面端预期顺序保持不含
computerUse。
Run:
pnpm exec vitest run packages/ui/test/settingsPageConfig.test.ts
Expected: FAIL,提示 createSettingsPageConfig 或 resolveSettingsSectionForPlatform 尚未导出。
在 packages/ui/src/settings/settingsPageConfig.ts 中删除 IS_MACOS_DESKTOP 依赖,并实现:
export interface SettingsPageConfigOptions {
isMacDesktop?: boolean;
isWindowsDesktop?: boolean;
}
export function createSettingsPageConfig({
isMacDesktop = false,
isWindowsDesktop = false,
}: SettingsPageConfigOptions = {}) {
const showComputerUse = isMacDesktop || isWindowsDesktop;
const settingsSections = BASE_SETTINGS_SECTIONS.filter((section) => {
if (section.id === "computerUse" && !showComputerUse) return false;
return isSettingsSectionEnabled(section.id);
});
const settingsSectionGroups = BASE_SETTINGS_SECTION_GROUPS.map((group) => ({
...group,
sections: settingsSections.filter((section) => section.groupId === group.id),
})).filter((group) => group.sections.length > 0);
return { settingsSectionGroups, settingsSections };
}
export function resolveSettingsSectionForPlatform(
section: SettingsSectionId,
visibleSections: ReadonlyArray<Pick<SettingsSectionDefinition, "id">>,
fallbackSection: SettingsSectionId = "general",
): SettingsSectionId {
if (visibleSections.some((candidate) => candidate.id === section)) return section;
if (visibleSections.some((candidate) => candidate.id === fallbackSection)) {
return fallbackSection;
}
return visibleSections[0]?.id ?? "general";
}
Run:
pnpm exec vitest run packages/ui/test/settingsPageConfig.test.ts
Expected: PASS,所有设置顺序、平台入口和落点回退断言通过。
Files:
packages/ui/src/settingsPageHelpers.tsxpackages/ui/src/SettingsPage.tsxpackages/ui/test/settingsPageIntegratedTerminalShell.test.tspackages/ui/test/settingsPageConfig.test.tsInterfaces:
createSettingsPageConfig 和 resolveSettingsSectionForPlatformsettingsSections / settingsSectionGroupsProduces: ComputerUseSection.isWindowsDesktop
[ ] Step 1: 扩展既有 SettingsPage 测试 mock,先暴露新接口缺口
把 packages/ui/test/settingsPageIntegratedTerminalShell.test.ts 的
settingsPageHelpers.js mock 改为返回固定配置的工厂:
const settingsSections = [
{
id: "general",
titleId: "settings.general",
navLabelId: "settings.general",
icon: () => null,
},
];
const settingsSectionGroups = [
{
id: "basics",
titleId: "settings.general",
sections: settingsSections,
},
];
vi.mock("../src/settingsPageHelpers.js", () => ({
createSettingsPageConfig: () => ({ settingsSectionGroups, settingsSections }),
resolveSettingsSectionForPlatform: (section: string) => section,
GeneralSectionContent: (props: Record<string, unknown>) => {
generalSectionCapture.props = props;
return createElement("div", null, "general");
},
GeneralSectionHeader: () => null,
}));
在真实 settingsPageHelpers.tsx 尚未重导出新接口时运行测试,确认 SettingsPage 切换接口前测试
环境仍能明确暴露导出不匹配。
在 packages/ui/src/settingsPageHelpers.tsx 中改为:
import {
createSettingsPageConfig,
resolveSettingsSectionForPlatform,
type SettingsSectionId,
} from "@/settings/settingsPageConfig.js";
export type { SettingsSectionId };
export { createSettingsPageConfig, resolveSettingsSectionForPlatform };
在 packages/ui/src/SettingsPage.tsx 的组件开头生成配置:
const { settingsSectionGroups, settingsSections } = useMemo(
() =>
createSettingsPageConfig({
isMacDesktop: Boolean(isMacDesktop),
isWindowsDesktop: Boolean(isWindowsDesktop),
}),
[isMacDesktop, isWindowsDesktop],
);
初始化 activeSection 时通过平台可见性解析:
const [activeSection, setActiveSection] = useState<SettingsSectionId>(() => {
const initialSection = resolveSettingsSectionForPlatform(
consumeInitialSettingsSection("general"),
settingsSections,
"general",
);
writeLastSettingsSectionPreference(initialSection);
return initialSection;
});
更新导航回调,确保运行时 intent 也不能跳到不可见页面:
const setActiveSettingsSection = useCallback(
(section: SettingsSectionId, fallbackSection: SettingsSectionId = activeSection) => {
const globallyResolved = resolveSettingsSection(section, fallbackSection);
const resolvedSection = resolveSettingsSectionForPlatform(
globallyResolved,
settingsSections,
fallbackSection,
);
setActiveSection(resolvedSection);
writeLastSettingsSectionPreference(resolvedSection);
},
[activeSection, settingsSections],
);
把侧栏和 active meta 分别改为使用 settingsSectionGroups、settingsSections,并向组件传递:
<ComputerUseSection
isWindowsDesktop={Boolean(isWindowsDesktop)}
workspacePath={activeWorkspacePath}
workspaceIdentity={activeWorkspaceIdentity}
remoteSessionId={activeWorkspaceTab?.remoteSessionId}
remoteTarget={activeWorkspaceTab?.remoteTarget}
localWorkspacePath={activeWorkspaceTab?.localWorkspacePath}
/>
Run:
pnpm exec vitest run packages/ui/test/settingsPageConfig.test.ts packages/ui/test/settingsPageIntegratedTerminalShell.test.ts
Expected: PASS;平台配置顺序、不可见落点回退和既有 Windows 终端设置测试均通过。
Files:
packages/ui/test/computerUseWindowsSettings.test.tspackages/ui/src/settings/ComputerUseSection.tsxInterfaces:
ComputerUseSectionProps.isWindowsDesktop?: booleanZCODE_CUA_OFFICIAL_PLUGIN_IDPreserves: usePluginManagementStore.setEnabled(pluginId, next, pluginManagementService)
[ ] Step 1: 写 Windows 渲染和开关行为的失败测试
新建 packages/ui/test/computerUseWindowsSettings.test.ts,mock 平台、服务、权限 hook、设置
hook、国际化和插件 store。核心用例为:
it("Windows 只展示共享总开关", () => {
render(
<ComputerUseSection
isWindowsDesktop
workspacePath="C:\\workspace"
workspaceIdentity="local-workspace"
/>,
);
expect(screen.getByText("settings.computerUse.toggleLabel")).toBeTruthy();
expect(screen.queryByText("settings.computerUse.pipModeLabel")).toBeNull();
expect(screen.queryByText("settings.computerUse.backgroundModeLabel")).toBeNull();
expect(screen.queryByText("settings.computerUse.helperLabel")).toBeNull();
expect(screen.queryByText("cuaPermission.perm.accessibility")).toBeNull();
expect(screen.queryByText("cuaPermission.perm.screenRecording")).toBeNull();
});
it("Windows 总开关复用官方 zcode-cua 启停流程", async () => {
render(
<ComputerUseSection
isWindowsDesktop
workspacePath="C:\\workspace"
workspaceIdentity="local-workspace"
/>,
);
fireEvent.click(screen.getByRole("switch", { name: "settings.computerUse.toggleLabel" }));
await waitFor(() => {
expect(setEnabled).toHaveBeenCalledWith(
ZCODE_CUA_OFFICIAL_PLUGIN_ID,
false,
pluginManagementService,
);
});
});
另加 macOS 回归用例,确认插件已启用时仍渲染 PiP、后台模式和两项权限行。
Run:
pnpm exec vitest run packages/ui/test/computerUseWindowsSettings.test.ts
Expected: FAIL;当前组件没有 isWindowsDesktop 能力并会被 macOS-only 门禁整体隐藏。
在 ComputerUseSectionProps 增加:
isWindowsDesktop?: boolean;
在组件中拆分平台边界:
const isLocalWorkspace =
!remoteSessionId &&
!remoteTarget &&
!(workspaceIdentity?.trim() && isRemoteWorkspaceIdentity(workspaceIdentity.trim()));
const supportsLocalMacWorkspace =
!isWindowsDesktop && supportsLocalMacCuaPermissionOnboarding(platform) && isLocalWorkspace;
const supportsLocalWindowsWorkspace = Boolean(isWindowsDesktop) && isLocalWorkspace;
const supportsComputerUseSettings = supportsLocalMacWorkspace || supportsLocalWindowsWorkspace;
const path = supportsLocalMacWorkspace ? (localWorkspacePath ?? workspacePath) : null;
插件初始化 effect 改用 supportsComputerUseSettings,组件返回门禁也使用同一变量。给总开关增加
已有文案作为可访问名称:
<Switch
aria-label={intl.formatMessage({ id: "settings.computerUse.toggleLabel" })}
checked={cuaEnabled}
disabled={cuaToggling || !workspacePath}
onCheckedChange={(checked) => void onTogglePlugin(checked)}
/>
macOS 附加内容只在以下条件渲染:
{
cuaEnabled && supportsLocalMacWorkspace ? (
<>{/* 保留现有 PiP、后台模式、Helper 和权限内容 */}</>
) : null;
}
插件切换成功后只在 supportsLocalMacWorkspace 时刷新权限与 Helper 展示状态;Windows 仅依赖
共享插件 store 确认新状态。
Run:
pnpm exec vitest run packages/ui/test/computerUseWindowsSettings.test.ts
Expected: PASS;Windows 仅有总开关、共享启停调用正确、macOS 附加设置仍存在。
Files:
docs/superpowers/specs/2026-08-06-windows-computer-use-settings-design.mdInterfaces:
Produces: 一个通过仓库门禁的 Conventional Commit
[ ] Step 1: 运行聚焦回归测试
Run:
pnpm exec vitest run packages/ui/test/settingsPageConfig.test.ts packages/ui/test/settingsPageIntegratedTerminalShell.test.ts packages/ui/test/computerUseWindowsSettings.test.ts packages/ui/test/computerUseNoAutoPermissionModal.test.ts
Expected: PASS,四个测试文件零失败。
Run:
pnpm test:unit:affected
Expected: PASS;如果发现与本改动无关的分支既有失败,记录测试名和证据,不得忽略本改动相关失败。
Run:
pnpm typecheck
pnpm lint
Expected: 两个命令都以 exit code 0 完成。
Run:
git diff --check
git diff --stat
git status --short
逐项确认:Windows 只有共享总开关;macOS 附加设置保留;非桌面端不显示入口;远程 workspace 仍被拒绝;没有修改协议、runtime 或远控状态。
审查范围从设计 spec 提交后的基线到当前工作树,重点检查平台配置是否会让 Web 端误露出入口、 Windows 是否触发 macOS 权限副作用,以及插件启停是否仍使用官方 plugin id。
[ ] Step 6: 提交实现
git add -- packages/ui/src/settings/settingsPageConfig.ts packages/ui/src/settingsPageHelpers.tsx packages/ui/src/SettingsPage.tsx packages/ui/src/settings/ComputerUseSection.tsx packages/ui/test/settingsPageConfig.test.ts packages/ui/test/settingsPageIntegratedTerminalShell.test.ts packages/ui/test/computerUseWindowsSettings.test.ts docs/superpowers/plans/2026-08-06-windows-computer-use-settings.md
git commit -m "feat(cua): add Windows computer control setting"
Expected: Conventional Commit 创建成功,且不包含 .pnpm-store/、.tmp/ 或其他无关文件。