Skip to content

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

Open

Description

@PANDAJSR

Activity

  1. deleted a comment from github-actions on Aug 31, 2026
  2. deleted a comment from github-actions on Aug 31, 2026
  3. PANDAJSR commented on Aug 31, 2026

    @PANDAJSR
    CollaboratorAuthor

    /oc 分析

  4. github-actions commented on Aug 31, 2026

    @github-actions
    Contributor

    分析完成。以下是该 Bug 的完整分析。

    结论

    这是前端 OOBE 卡片渲染逻辑的问题,不是后端检测逻辑的问题。OobeWizard.tsx 中 recommended 列表把 4 个"双端联动"插件(ClassIsland / Class Widgets / SecRandom / ICC-CE)的卡片无条件强制展示,即使本机根本没有安装这些软件。

    根因

    src/renderer/src/components/OobeWizard.tsx:910

    const recommended = useMemo(() => apps.filter((app) =>
      app.detected ||
      app.pluginId === "classisland-connector" ||
      app.pluginId === "secrandom" ||
      app.pluginId === "iccce-connector" ||
      app.pluginId === "class-widgets"
    ), [apps]);

    复现链路:

    1. bridge.detectInstalledApps()(OobeWizard.tsx:161)→ IPC apps:detect(electron/main.ts:1142)→ detectCompanionApps()(companion-apps.ts:19)返回目录中全部 5 个应用,每个都带 detected: boolean。
    2. recommended 的过滤条件除了 app.detected,还硬编码了 4 个 pluginId。于是即使 detected === false(CW 未安装),class-widgets 卡片也会被保留。
    3. 卡片渲染在 OobeWizard.tsx:1030 {recommended.map(...)} 之下,标题是"本机已检测到"(:1028)。

    用户看到的结果就是:没装 Class Widgets,但 CW 卡片(含"安装 SecAgent 端插件""选择 Class Widgets 可执行文件"按钮)出现在"本机已检测到"区域,误导用户以为被检测到/已安装。

    佐证:检测本身是对的

    • companion-apps.ts:19-33 的 detectCompanionApps 只在找到候选路径时置 detected: true。
    • companion-apps.test.ts 也验证了"没装就不 detected"的语义。
    • "一键安装所有"(installAllPlugins,:783-784)对未检测到且未手动选目标的 app 会 return 跳过——说明后端/批量安装逻辑尊重检测结果,只有渲染列表强制展示,两者不一致。

    影响范围

    文件 行 影响
    src/renderer/src/components/OobeWizard.tsx 910 根因:4 个双端卡片无条件渲染
    src/renderer/src/components/OobeWizard.tsx 1028-1030 "本机已检测到"标题 + 空状态提示与卡片矛盾
    无 — 该过滤逻辑目前没有任何单测覆盖(只有 companion-apps.test.ts 测检测层)

    建议修复方案

    把"强制展示"改为"有条件展示":卡片仅在满足任一条件时出现——

    1. 应用已被检测到(app.detected);或
    2. SecAgent 端联动插件已安装(plugins.some(...),用户可能已配置过该联动);或
    3. 用户已手动添加过该应用的安装目标(如通过"选择可执行文件")。
    const recommended = useMemo(() => apps.filter((app) => {
      if (app.detected) return true;
      if (plugins.some((plugin) => plugin.id === app.pluginId)) return true;
      switch (app.pluginId) {
        case "classisland-connector": return classIslandTargets.length > 0;
        case "secrandom": return secRandomTargets.length > 0;
        case "iccce-connector": return iccceTargets.length > 0;
        case "class-widgets": return cwTargets.length > 0;
        default: return false;
      }
    }), [apps, plugins, classIslandTargets, secRandomTargets, iccceTargets, cwTargets]);

    这样一台全新、未装 CW 的机器上 OOBE 不会出现 CW 卡片;而装了 CW(即使路径非标准、通过手动选择加入)或已装过 SecAgent 端联动插件的机器,卡片仍然保留。

    需要注意的设计取舍:当前"无条件展示"可能是刻意设计——为了让安装在非标准目录、自动检测不到的双端应用仍能在 OOBE 里通过"选择可执行文件"完成手动配置。如果直接按上面的方案收紧,这些用户会失去入口。因此实现前需要确认产品意图:

    • 若确认"应只展示已安装/已有依据的应用"→ 采用上面的条件过滤;
    • 若想保留手动入口 → 可以在空状态提示(:1029)里放一个通用的"选择可执行文件"按钮作为兜底,同时让卡片只在检测到时展示。

    验证建议

    • 单测:在 src/companion-apps.test.ts 基础上补一个"未安装 Class Widgets 时 detectCompanionApps 返回 detected: false"的用例(已有类似语义);若将过滤逻辑抽成纯函数,可单独测卡片可见性。
    • 手动:在未安装 Class Widgets / SecRandom 的机器上跑 OOBE 到"安装课堂联动插件"页,确认只有已检测到或已装过插件的卡片出现。

    由于你发出的是 /oc 分析,我按"只分析、不改代码"处理,未做任何修改。如需我按上面的方案直接实现并跑测试、提交 PR,告诉我即可。

    New%20session%20-%202026-08-31T10%3A18%3A56.061Z
    opencode session  |  github run

  5. PANDAJSR commented on Aug 31, 2026

    @PANDAJSR
    CollaboratorAuthor

    /oc 修复

  6. github-actions commented on Aug 31, 2026

    @github-actions
    Contributor

    Author identity unknown

    *** Please tell me who you are.

    Run

    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"

    to set your account's default identity.
    Omit --global to set the identity only in this repository.

    fatal: empty ident name (for runner@runnervmgx7h7.1rxsas4jmcgutcxaxjgeesxcfa.gx.internal.cloudapp.net) not allowed

    opencode session  |  github run

  7. PANDAJSR commented on Aug 31, 2026

    @PANDAJSR
    CollaboratorAuthor

    /oc 请继续完成这个修复,提交代码并创建 PR

  8. github-actions commented on Aug 31, 2026

    @github-actions
    Contributor

    GitHub Actions is not permitted to create or approve pull requests. - https://docs.github.com/rest/pulls/pulls#create-a-pull-request

    opencode session  |  github run

  9. PANDAJSR commented on Sep 1, 2026

    @PANDAJSR
    CollaboratorAuthor

    /oc 重试

  10. PANDAJSR commented on Sep 1, 2026

    @PANDAJSR
    CollaboratorAuthor

    /oc 重试

  11. opencode-agent commented on Sep 1, 2026

    @opencode-agent

    Created PR #16

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

  12. opencode-agent commented on Sep 1, 2026

    @opencode-agent

    User opencode-agent[bot] does not have write permissions

    github run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions