Skip to content

已修复:CW卡片仅在检测到时展示(commit d6a275e)。 - #16

Open
opencode-agent[bot] wants to merge 1 commit into
masterfrom
opencode/issue4-20260901124620
Open

已修复:CW卡片仅在检测到时展示(commit d6a275e)。#16
opencode-agent[bot] wants to merge 1 commit into
masterfrom
opencode/issue4-20260901124620

Conversation

@opencode-agent

@opencode-agent opencode-agent Bot commented Sep 1, 2026

Copy link
Copy Markdown

修复已完成。已提交到分支 opencode/issue4-20260901124620(commit d6a275e),push 和 PR 创建由基础设施自动处理。

问题根因

OobeWizard.tsxrecommended 列表(原第 910 行)除了 app.detected 外,还硬编码了 4 个双端联动插件的 pluginId 无条件展示:

apps.filter((app) => app.detected || app.pluginId === "classisland-connector" || ... || app.pluginId === "class-widgets")

于是即使 detectInstalledApps() 返回 detected: false(本机没装 Class Widgets),CW 卡片仍会出现在"本机已检测到"区域。后端 companion-apps.ts 的检测逻辑本身是对的,问题只在前端渲染。

改动内容

  1. 新增 src/renderer/src/companion-recommend.ts — 把过滤逻辑抽成纯函数 filterRecommendedCompanionApps,卡片仅在满足任一条件时展示:

    • 应用被自动检测到(app.detected);或
    • SecAgent 端联动插件已安装(plugins.some(...));或
    • 已找到/手动添加了安装目标(classIslandTargets.length > 0 等)。
  2. OobeWizard.tsx

    • recommended 改用上述纯函数(第 916-919 行)。
    • "一键安装所有"按钮在 recommended.length === 0 时禁用,避免无目标时点击报错。
    • 空状态改为在无任何卡片时展示:提示文案 + 4 个"选择可执行文件"兜底按钮(保留非标准目录安装的手动入口——这是之前分析中标注的设计取舍点)。
  3. styles.css — 为空状态新增 .oobe-plugin-empty / .oobe-plugin-manual-picks 最小样式。

  4. 新增 src/renderer/src/companion-recommend.test.ts — 6 个单测覆盖:全新机器不出卡片、检测到/已装连接器/已手动选目标时保留卡片、各联动插件各自的目标列表门控、单端插件不被强制列出。

验证结果

  • tsc -p tsconfig.json:0 错误
  • electron-vite build:成功
  • npm test:135 项测试全部通过(含新增 6 项),0 失败

行为变化

场景 修复前 修复后
全新机器(没装任何课堂软件) 4 个双端卡片全部出现 无卡片,仅提示 + 手动选择入口
CW 已安装(标准/非标目录) CW 卡片(含"未自动找到"状态) CW 卡片正常展示(检测到或目标存在)
已装过 SecAgent 端联动插件 卡片出现 卡片保留(可继续配置另一端)

Closes #4

New%20session%20-%202026-09-01T12%3A46%3A19.711Z
opencode session  |  github run

…present

Previously the four dual-end linkage apps (ClassIsland / Class Widgets /
SecRandom / ICC-CE) were force-listed on the OOBE plugins page regardless
of detection, so e.g. Class Widgets appeared as "detected" on machines
that never had it installed.

A card now appears only when there is real evidence for it:
- the app was auto-detected, or
- its SecAgent-side connector is already installed, or
- an installation target was found or manually picked.

The empty state keeps a manual "choose executable" entry point so
non-standard installs remain configurable, and the install-all button is
disabled when nothing qualifies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug:即使没有安装Class Widgets,OOBE 检测联动插件也会有CW

0 participants