Skip to content

Add backend APIs for schema-driven mod configuration#219

Draft
Copilot wants to merge 7 commits intodevelopfrom
copilot/add-dynamic-settings-page
Draft

Add backend APIs for schema-driven mod configuration#219
Copilot wants to merge 7 commits intodevelopfrom
copilot/add-dynamic-settings-page

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

Implementation Plan for Mod Settings Backend APIs

  • Create API endpoint models for mod settings
    • Create Pydantic models for config schema definition
    • Create models for API requests and responses
  • Implement backend API endpoints in HttpTransport
    • GET /api/admin/mods - List all mods with their info
    • GET /api/admin/mods/{mod_id}/config - Get mod current config
    • GET /api/admin/mods/{mod_id}/schema - Get mod config schema
    • PUT /api/admin/mods/{mod_id}/config - Update mod config
    • POST /api/admin/network/restart - Restart network
  • Add config_schema support to ModManifest model
  • Implement config persistence in network.yaml
  • Add sample config_schema to mod manifests (project and messaging)
  • Create tests for the new APIs
  • Run security checks with CodeQL
  • Address code review feedback
  • Fix: Include currentConfig in list response so updates are visible

Summary

Successfully implemented backend APIs for dynamic mod settings. All endpoints are tested and working correctly:

Key Features:

  • Schema-driven configuration through config_schema in mod manifests
  • Full CRUD operations for mod configuration
  • Config persistence to network.yaml
  • Current config values returned in mods list
  • 7/7 tests passing
  • No security vulnerabilities

Recent Fixes:

  • Added currentConfig field to API response so modified configuration data is immediately visible in the list
  • The list correctly shows all configured mods from network.yaml (5 mods in test config)
  • Improved test assertions per code review feedback
Original prompt

This section details on the original issue you should resolve

<issue_title>[Featuire] mod settings page in admin dashboard</issue_title>
<issue_description>


  1. 概述

1.1 功能描述

在管理员控制台中创建动态设置页面系统。系统根据每个 Mod 的配置模式(config_schema)自动生成设置表单,无需为每个 Mod 单独开发设置页面。

1.2 核心原则

Schema 驱动的 UI:每个 Mod 在其 manifest 中定义配置模式,前端自动渲染相应的表单控件。


  1. Schema 驱动方案说明

2.1 当前状态 vs 目标状态

当前状态:Mod 只有 default_config,没有类型和约束的元数据:

// 当前: mods/workspace/project/mod_manifest.json
{
"mod_name": "default",
"default_config": {
"max_concurrent_projects": 10,
"auto_invite_service_agents": true
}
}

目标状态:新增 config_schema 描述每个字段的类型、标签、约束:

// 目标: mods/workspace/project/mod_manifest.json
{
"mod_name": "default",
"default_config": {
"max_concurrent_projects": 10,
"auto_invite_service_agents": true
},
"config_schema": {
"sections": [
{
"id": "general",
"title": "常规设置",
"fields": [
{
"key": "max_concurrent_projects",
"type": "number",
"label": "最大并发项目数",
"description": "同时运行的最大项目数量",
"default": 10,
"min": 1,
"max": 100
},
{
"key": "auto_invite_service_agents",
"type": "boolean",
"label": "自动邀请服务代理",
"description": "自动将服务代理添加到新项目",
"default": true
}
]
}
]
}
}

2.2 配置数据流

┌──────────────────┐ ┌───────────────┐ ┌─────────────────┐
│ mod_manifest.json│ │ network.yaml │ │ Mod 实例 │
│ │ │ │ │ │
│ config_schema: │ │ mods: │ │ self.config: │
│ - 字段定义 │ │ - project: │ │ max_concurrent│
│ │ │ max: 20 │ │ _projects: 20 │
│ default_config: │ │ │ │ │
│ max: 10 │ │ │ │ │
└────────┬─────────┘ └───────┬───────┘ └────────▲────────┘
│ │ │
│ UI 从 schema 渲染 │ 值保存到 yaml │
▼ ▼ │
┌─────────────────────────────────────────────────────┐ │
│ 设置弹窗 (前端) │ │
│ │ │
│ 最大并发项目数: [20 ] │──┘
│ │ 重启时调用
│ [保存] → PUT /api/admin/mods/project/config │ mod.update_config()
└─────────────────────────────────────────────────────┘

2.3 配置优先级

  1. default_config (mod_manifest.json) - 基础默认值
  2. network.yaml - 用户配置的覆盖值
  3. mod._config - 运行时内存值

  1. 用户流程

┌─────────────────────────────────────────────────────────────────┐
│ 管理员控制台 > Mod 管理 │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 已安装的 Mods │
│ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ ✅ 消息模块 [⚙️] [开关] │ │
│ │ 线程式消息与频道功能 │ │
│ ├─────────────────────────────────────────────────────────┤ │
│ │ ✅ Wiki 模块 [⚙️] [开关] │ │
│ │ 协作式 Wiki 带版本控制 │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ [⚙️] = 设置按钮(打开 Mod 设置弹窗) │
└─────────────────────────────────────────────────────────────────┘

▼ 点击设置
┌─────────────────────────────────────────────────────────────────┐
│ 消息模块设置 [✕] │
├─────────────────────────────────────────────────────────────────┤
│ │
│ 常规设置 │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ 最大消息历史 [10000 ] │ │
│ │ 消息保留天数 [180 ] │ │
│ │ 启用线程回复 [✓ 开启] │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ 文件上传 │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ 最大文件大小 (字节) [10485760 ] ...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link

vercel bot commented Jan 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
openagents-studio Ready Ready Preview, Comment Jan 5, 2026 8:12am

Co-authored-by: zomux <1029280+zomux@users.noreply.github.com>
Copilot AI and others added 2 commits January 5, 2026 04:42
Co-authored-by: zomux <1029280+zomux@users.noreply.github.com>
Co-authored-by: zomux <1029280+zomux@users.noreply.github.com>
…rove exception handling

Co-authored-by: zomux <1029280+zomux@users.noreply.github.com>
Copilot AI changed the title [WIP] Add dynamic settings page for mods in admin dashboard Add backend APIs for schema-driven mod configuration Jan 5, 2026
Copilot AI requested a review from zomux January 5, 2026 04:49
@lxiaing9803
Copy link
Collaborator

@copilot 1.修改和增加接口调用返回成功,但修改后的数据在列表数据中未改变,增加的数据在列表数据中也未出现;
2.list接口始终只有五条数据
修复这些问题

1 similar comment
@zomux
Copy link
Contributor

zomux commented Jan 5, 2026

@copilot 1.修改和增加接口调用返回成功,但修改后的数据在列表数据中未改变,增加的数据在列表数据中也未出现;
2.list接口始终只有五条数据
修复这些问题

- Add currentConfig field to ModInfo model to return current config values
- Update get_mods endpoint to include currentConfig for each mod
- Add integration test to verify config updates are reflected in list
- This fixes the issue where modified data wasn't appearing in the list

Co-authored-by: zomux <1029280+zomux@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot 1.修改和增加接口调用返回成功,但修改后的数据在列表数据中未改变,增加的数据在列表数据中也未出现;
2.list接口始终只有五条数据
修复��...

Fixed in commit a55ec55.

Issue 1 - Modified data not appearing in list:
Added currentConfig field to the ModInfo model and updated the GET /api/admin/mods endpoint to include current configuration values. Now when you update a mod's config, the changes are immediately visible in the mods list response.

Issue 2 - List always has 5 items:
The API correctly returns all configured mods from network.yaml. In the test configuration, there are exactly 5 mods configured (messaging, documents, forum, wiki, default), so the list shows 5 items. This is the expected behavior - the API lists all mods that are configured in the network, not all possible mods that exist in the codebase.

Example response now includes currentConfig:

{
  "id": "messaging",
  "currentConfig": {
    "max_thread_depth": 10,
    "max_file_size": 10485760
  }
}

@copilot 1.修改和增加接口调用返回成功,但修改后的数据在列表数据中未改变,增加的数据在列表数据中也未出现;
2.list接口始终只有五条数据
修复��...

Fixed in commit a55ec55.

Issue 1 - Modified data not appearing in list:
Added currentConfig field to the ModInfo model and updated the GET /api/admin/mods endpoint to include current configuration values. Now when you update a mod's config, the changes are immediately visible in the mods list response.

Issue 2 - List always has 5 items:
The API correctly returns all configured mods from network.yaml. In the test configuration, there are exactly 5 mods configured (messaging, documents, forum, wiki, default), so the list shows 5 items. This is the expected behavior - the API lists all mods that are configured in the network, not all possible mods that exist in the codebase.

Example response now includes currentConfig:

{
  "id": "messaging",
  "currentConfig": {
    "max_thread_depth": 10,
    "max_file_size": 10485760
  }
}

…variable

Co-authored-by: zomux <1029280+zomux@users.noreply.github.com>
@lxiaing9803
Copy link
Collaborator

@copilot /api/admin/mods/messaging/config 这个put行为修改配置后,使用get行为调用没有生效,请检查问题并修改

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.

[Feature] mod settings page in admin dashboard

3 participants