Skip to content

fix(webui): 按实例服务器刷新活动候选与旧选择 - #1309

Merged
Beatrice-betty merged 1 commit into
wess09:devfrom
Beatrice-betty:codex/fix-event-options-by-server
Oct 22, 2026
Merged

Beatrice-betty merged 1 commit into
wess09:devfrom
Beatrice-betty:codex/fix-event-options-by-server

Conversation

@Beatrice-betty

@Beatrice-betty Beatrice-betty commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

复用运行器的活动迁移规则,为配置 API 返回实例级候选,并以同批最终包名校验保存。同步前端、内存模拟服务、四服回归用例及模块文档。

📋 许可确认

  • 我已仔细阅读并同意 GPL-3.0 开源协议 中的所有条款,并理解我的贡献将受到该协议的约束
  • 我确认我提交的代码不会侵犯任何第三方的知识产权

💯 代码质量确认

  • 我已执行静态类型检查,确保代码不含基本类型错误:
    • 后端:uv run ruff check . --select E9,F63,F7,F82 --ignore F821,F722
    • 前端:npm run typecheck --prefix frontend
  • 对于难以解决的必要类型忽略标记,我已添加注释说明原因
  • 涉及游戏交互的代码遵循状态循环模式(截图-检查循环),未使用"点击-等待-休眠"模式
  • 新增/修改的 UI 模板图像基于固定的 1280×720 分辨率截图
  • 若修改了 module/config/argument/ 下的 YAML 源文件,已运行 uv run -m module.config.config_updater 并提交生成产物
  • 若修改了游戏逻辑,已在真实模拟器实例上运行验证(游戏逻辑无自动化测试)

🔍 变更类型 (勾选所有适用项)

  • 🐛 Bug 修复 (修复一个问题)
  • ✨ 新功能 (添加新功能)
  • 🔄 重构 (不改变功能的代码调整)
  • 📝 文档更新
  • 🔧 配置变更
  • 🎨 代码风格优化
  • 💅 样式调整 (UI/UX 外观变化)
  • 🚀 性能提升
  • ✅ 测试相关
  • 🌐 国际化/本地化
  • 🔗 依赖更新
  • 🗺️ 活动/地图数据 (campaign/)
  • 🖼️ 资源图像 (assets/)
  • 🔌 MCP 工具相关 (mcp_server_sse.py)
  • 🔄 其他...

📄 PR 描述

🔗 相关 Issue

📸 修改效果截图

🛠️ 实现复杂度

  • 简单 (小改动,影响有限)
  • 中等 (需要一些技术考量)
  • 复杂 (涉及多个组件或系统)

📋 实现细节 (可选)

🧪 测试步骤 (可选)

Sourcery 摘要

根据各实例的软件包区域,统一运行时、配置 API、模拟服务和任务 UI 中的活动候选项选择逻辑。

新功能:

  • 配置 API 返回特定实例的活动事件候选项,并在任务配置 UI 中使用这些候选项。

错误修复:

  • 根据当前实例区域刷新无效的活动、突袭、联盟、种田和档案选择,同时保留有效选项。
  • 保存配置更改时,根据最终软件包名称原子性地拒绝跨区域活动选择。

增强:

  • 在运行时配置更新和 API 读取之间共享活动选择刷新逻辑,且不修改已持久化的配置数据。

文档:

  • 为配置 API 和模块配置系统编写文档,说明实例隔离的活动候选项、刷新行为和验证规则。

测试:

  • 增加后端、模拟服务以及覆盖四个区域的端到端测试,验证活动候选项隔离、选择刷新、原子性验证和软件包更改。
Original summary in English

Summary by Sourcery

Align campaign candidate selection across the runtime, configuration API, mock service, and task UI with each instance's package region.

New Features:

  • Return instance-specific campaign event candidates from the configuration API and use them in the task configuration UI.

Bug Fixes:

  • Refresh invalid campaign, raid, coalition, farming, and archive selections according to the current instance region while preserving valid choices.
  • Reject cross-region campaign selections atomically using the final package name when saving configuration changes.

Enhancements:

  • Share campaign selection refresh logic between runtime configuration updates and API reads without mutating persisted configuration data.

Documentation:

  • Document instance-isolated campaign candidates, refresh behavior, and validation rules for the configuration API and module configuration system.

Tests:

  • Add backend, mock-service, and four-region end-to-end coverage for campaign candidate isolation, selection refresh, atomic validation, and package changes.

复用运行器的活动迁移规则,为配置 API 返回实例级候选,并以同批最终包名校验保存。同步前端、内存模拟服务、四服回归用例及模块文档。
@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Sorry @Beatrice-betty, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 15 hours and 57 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@github-actions

Copy link
Copy Markdown

⏳ CI 检查进行中,报告将在完成后更新。

@Beatrice-betty
Beatrice-betty merged commit 9b16193 into wess09:dev Oct 22, 2026
9 of 10 checks passed
@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown

审阅者指南

本 PR 将活动候选和旧选择刷新统一为基于实例包名的配置规则,使后端运行器、配置 API、模拟服务和 WebUI 在四服场景下保持一致;API 返回实例级候选,读取仅内存刷新失效选择,保存按同批最终包名原子校验,并以单元、模拟服务和 Playwright 回归用例覆盖事务与界面行为。

实例级活动配置时序图

sequenceDiagram
    participant UI as WebUI
    participant API as ConfigService
    participant Rules as CampaignRules
    participant Store as ConfigStore

    UI->>API: config.get(instance)
    API->>Store: read(instance)
    Store-->>API: raw configuration
    API->>Rules: refresh_campaign_events(values, args)
    Rules-->>API: refreshed in-memory values
    API->>Rules: campaign_event_options(values, args)
    Rules-->>API: package-specific options
    API-->>UI: values + options
    UI->>UI: use options[path] for task controls
Loading

活动选择原子校验时序图

sequenceDiagram
    participant UI as WebUI
    participant API as ConfigService
    participant Rules as CampaignRules
    participant Store as ConfigStore

    UI->>API: config.patch(instance, changes)
    API->>API: apply changes to transaction copy
    API->>Rules: campaign_event_options(final values, args)
    Rules-->>API: final package candidates
    alt selected campaign is not a candidate
        API-->>UI: INVALID_PARAMS
        Note over Store: No fields are persisted
    else selection is valid
        API->>Rules: refresh_campaign_events(final values, args)
        API->>Store: commit transaction
        Store-->>API: saved configuration
        API-->>UI: values + options
    end
Loading

按包名刷新活动流程图

flowchart TD
    A[Read instance PackageName] --> B[Map package to server with to_server]
    B --> C[Load option_server candidates]
    C --> D{Existing selection is valid?}
    D -->|Yes| E[Preserve selection]
    D -->|No| F[Use first candidate]
    E --> G[Return instance-scoped options]
    F --> G
    G --> H[WebUI renders task selector]
Loading

文件级变更

Change Details Files
将活动迁移与候选选择规则抽为按实例包名计算的共享逻辑,并让配置读取、更新和保存使用同一套规则。
  • 按 PackageName 经 to_server() 选择 CN/EN/JP/TW 候选,auto 保持 CN 回退,不依赖 ServerName、语言或全局服务器。
  • 读取时仅在内存副本刷新失效活动;多候选保留有效选择,作战档案仅替换 campaign_main。
  • 配置 API 返回按字段路径组织的实例级 options,并在同批最终包名下校验显式活动选择,跨服选择拒绝整批事务。
module/config/config_updater.py
module/api/config_service.py
使 WebUI 根据配置 API 提供的实例候选渲染活动字段,并扩展内存模拟服务以匹配后端行为。
  • 任务配置控件优先使用 config.options 覆盖共享 schema 的四服候选。
  • 模拟服务按实例包名生成候选、刷新旧选择,并对同批保存执行跨服校验与原子失败。
  • 更新前端配置类型以携带可选的 options 映射。
frontend/src/pages/TaskConfig.tsx
frontend/src/api/types.ts
frontend/mock/state.mjs
补充覆盖四服隔离、迁移、事务一致性和前端展示的回归测试。
  • 验证读取刷新与运行器结果一致,且不写回磁盘、不改变 revision。
  • 验证多活动时保留有效选择、切换包名刷新失效选择,并隔离不同实例。
  • 验证跨服选择与其他字段的混合提交整体拒绝,以及包名和活动字段任意顺序均按最终包名校验。
  • 通过四服 Playwright 场景确认页面仅展示当前服务器候选并可保存后重新加载。
tests/test_campaign_config_options.py
frontend/mock/state.test.mjs
frontend/e2e/mock.spec.ts
记录实例级活动候选、读取刷新和保存校验的配置与 WebUI API 契约。
  • 说明配置 API 的 options 返回结构及前端任务页使用方式。
  • 明确读操作只改内存副本,不修改磁盘内容、修改时间或 revision。
docs/modules/config.md
docs/modules/webui/api.md

提示与命令

与 Sourcery 互动

  • 触发新的审阅: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 根据审阅评论创建 GitHub issue: 回复审阅评论,请 Sourcery 根据该评论创建 issue。也可以回复 @sourcery-ai issue 来创建 issue。
  • 生成拉取请求标题: 在拉取请求标题中的任意位置输入 @sourcery-ai,即可随时生成标题。也可以在拉取请求中评论 @sourcery-ai title,随时重新生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中需要插入摘要的位置输入 @sourcery-ai summary,即可随时生成摘要。也可以在拉取请求中评论 @sourcery-ai summary,随时重新生成摘要。
  • 生成审阅者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时重新生成审阅者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已处理完所有评论且不想再看到它们,这会很有用。
  • 关闭所有 Sourcery 审阅: 在拉取请求中评论 @sourcery-ai dismiss,即可关闭所有现有的 Sourcery 审阅。如果你想从头开始进行新的审阅,这尤其有用——别忘了评论 @sourcery-ai review 来触发新的审阅!

自定义体验

访问你的控制面板,可以:

  • 启用或停用审阅功能,例如 Sourcery 生成的拉取请求摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、移除或编辑自定义审阅说明。
  • 调整其他审阅设置。

获取帮助

Original review guide in English

Reviewer's Guide

本 PR 将活动候选和旧选择刷新统一为基于实例包名的配置规则,使后端运行器、配置 API、模拟服务和 WebUI 在四服场景下保持一致;API 返回实例级候选,读取仅内存刷新失效选择,保存按同批最终包名原子校验,并以单元、模拟服务和 Playwright 回归用例覆盖事务与界面行为。

Sequence diagram for instance-scoped campaign configuration

sequenceDiagram
    participant UI as WebUI
    participant API as ConfigService
    participant Rules as CampaignRules
    participant Store as ConfigStore

    UI->>API: config.get(instance)
    API->>Store: read(instance)
    Store-->>API: raw configuration
    API->>Rules: refresh_campaign_events(values, args)
    Rules-->>API: refreshed in-memory values
    API->>Rules: campaign_event_options(values, args)
    Rules-->>API: package-specific options
    API-->>UI: values + options
    UI->>UI: use options[path] for task controls
Loading

Sequence diagram for atomic campaign selection validation

sequenceDiagram
    participant UI as WebUI
    participant API as ConfigService
    participant Rules as CampaignRules
    participant Store as ConfigStore

    UI->>API: config.patch(instance, changes)
    API->>API: apply changes to transaction copy
    API->>Rules: campaign_event_options(final values, args)
    Rules-->>API: final package candidates
    alt selected campaign is not a candidate
        API-->>UI: INVALID_PARAMS
        Note over Store: No fields are persisted
    else selection is valid
        API->>Rules: refresh_campaign_events(final values, args)
        API->>Store: commit transaction
        Store-->>API: saved configuration
        API-->>UI: values + options
    end
Loading

Flow diagram for campaign refresh by package name

flowchart TD
    A[Read instance PackageName] --> B[Map package to server with to_server]
    B --> C[Load option_server candidates]
    C --> D{Existing selection is valid?}
    D -->|Yes| E[Preserve selection]
    D -->|No| F[Use first candidate]
    E --> G[Return instance-scoped options]
    F --> G
    G --> H[WebUI renders task selector]
Loading

File-Level Changes

Change Details Files
将活动迁移与候选选择规则抽为按实例包名计算的共享逻辑,并让配置读取、更新和保存使用同一套规则。
  • 按 PackageName 经 to_server() 选择 CN/EN/JP/TW 候选,auto 保持 CN 回退,不依赖 ServerName、语言或全局服务器。
  • 读取时仅在内存副本刷新失效活动;多候选保留有效选择,作战档案仅替换 campaign_main。
  • 配置 API 返回按字段路径组织的实例级 options,并在同批最终包名下校验显式活动选择,跨服选择拒绝整批事务。
module/config/config_updater.py
module/api/config_service.py
使 WebUI 根据配置 API 提供的实例候选渲染活动字段,并扩展内存模拟服务以匹配后端行为。
  • 任务配置控件优先使用 config.options 覆盖共享 schema 的四服候选。
  • 模拟服务按实例包名生成候选、刷新旧选择,并对同批保存执行跨服校验与原子失败。
  • 更新前端配置类型以携带可选的 options 映射。
frontend/src/pages/TaskConfig.tsx
frontend/src/api/types.ts
frontend/mock/state.mjs
补充覆盖四服隔离、迁移、事务一致性和前端展示的回归测试。
  • 验证读取刷新与运行器结果一致,且不写回磁盘、不改变 revision。
  • 验证多活动时保留有效选择、切换包名刷新失效选择,并隔离不同实例。
  • 验证跨服选择与其他字段的混合提交整体拒绝,以及包名和活动字段任意顺序均按最终包名校验。
  • 通过四服 Playwright 场景确认页面仅展示当前服务器候选并可保存后重新加载。
tests/test_campaign_config_options.py
frontend/mock/state.test.mjs
frontend/e2e/mock.spec.ts
记录实例级活动候选、读取刷新和保存校验的配置与 WebUI API 契约。
  • 说明配置 API 的 options 返回结构及前端任务页使用方式。
  • 明确读操作只改内存副本,不修改磁盘内容、修改时间或 revision。
docs/modules/config.md
docs/modules/webui/api.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 17beb046-0624-4390-98ef-5d8d8546eba6
📥 Commits

Reviewing files that changed from the base of the PR and between 9db98a7 and b555208.

📒 Files selected for processing: 10
  • docs/modules/config.md
  • docs/modules/webui/api.md
  • frontend/e2e/mock.spec.ts
  • frontend/mock/state.mjs
  • frontend/mock/state.test.mjs
  • frontend/src/api/types.ts
  • frontend/src/pages/TaskConfig.tsx
  • module/api/config_service.py
  • module/config/config_updater.py
  • tests/test_campaign_config_options.py
+----------------------------------------------------------------------------------------------------------------------------------------------------+
| There are no final decisions. No decision is cast in stone. Instead, consider each as being written in the sand at the beach, and plan for change. |
+----------------------------------------------------------------------------------------------------------------------------------------------------+
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant