feat(webui): 新增定时任务管理界面#71
Conversation
Co-authored-by: GPT-5 Codex <noreply@openai.com>
Co-authored-by: GPT-5 Codex <noreply@openai.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds Runtime schedule CRUD and scheduler integration, authenticated Management/WebUI proxy routes, a WebUI Schedules tab (UI, JS, i18n, CSS), OpenAPI/docs and prompt updates, and tests covering probes, CRUD, scheduler job refresh, and WebUI proxy behavior. ChangesScheduler UI and API Feature
Sequence Diagram(s): sequenceDiagram
participant WebUI
participant ManagementProxy
participant RuntimeAPIServer
participant SchedulesHandlers
participant TaskScheduler
participant APScheduler
WebUI->>ManagementProxy: request /api/runtime/schedules (auth)
ManagementProxy->>RuntimeAPIServer: proxy /api/v1/schedules (inject X-Undefined-API-Key)
RuntimeAPIServer->>SchedulesHandlers: _schedules_create_handler(request)
SchedulesHandlers->>TaskScheduler: add_task(normalized_payload)
TaskScheduler->>APScheduler: schedule job
APScheduler-->>TaskScheduler: job registered
TaskScheduler-->>SchedulesHandlers: created task
SchedulesHandlers-->>RuntimeAPIServer: 201 serialized task
RuntimeAPIServer-->>ManagementProxy: 201 passthrough
ManagementProxy-->>WebUI: 201 response
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2409e214f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/Undefined/api/routes/schedules.py`:
- Around line 354-360: build_schedules_summary currently returns objects missing
the required "running" field when the scheduler is absent or doesn't expose
list_tasks; update the early return shapes to include running so the probe
always returns available/count/running. Specifically, in build_schedules_summary
use the ctx.scheduler check and the callable(list_tasks) check to return
{"available": False, "count": 0, "running": 0} (instead of omitting running) so
consumers always see the expected shape.
- Around line 412-417: The code currently treats an explicitly provided empty
task_id as falsy and auto-generates a new id; change this so that if body is a
dict and "task_id" is present but is an empty string you reject the request
instead of generating one. Update the logic around raw_task_id/task_id to:
extract raw_task_id from body, if "task_id" in body and raw_task_id is an empty
string raise the appropriate validation/HTTP error, otherwise if raw_task_id is
truthy call _parse_task_id(raw_task_id), else generate the random id as before;
reference raw_task_id, task_id and _parse_task_id when applying this change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: fa4df561-1522-4736-b5e3-3434dfdefe4f
📒 Files selected for processing (24)
docs/cognitive-memory.mddocs/management-api.mddocs/openapi.mddocs/usage.mddocs/webui-guide.mdres/prompts/undefined.xmlres/prompts/undefined_nagaagent.xmlsrc/Undefined/api/_openapi.pysrc/Undefined/api/app.pysrc/Undefined/api/routes/schedules.pysrc/Undefined/api/routes/system.pysrc/Undefined/utils/scheduler.pysrc/Undefined/webui/routes/_runtime.pysrc/Undefined/webui/static/css/components.csssrc/Undefined/webui/static/css/responsive.csssrc/Undefined/webui/static/js/i18n.jssrc/Undefined/webui/static/js/main.jssrc/Undefined/webui/static/js/schedules.jssrc/Undefined/webui/templates/index.htmltests/test_runtime_api_probes.pytests/test_runtime_api_schedules.pytests/test_scheduler_self_instruction.pytests/test_system_prompt_constraints.pytests/test_webui_management_api.py
背景
这个 PR 为 WebUI 补齐定时任务管理能力,让运行中的 Undefined 可以直接在管理端查看、创建、编辑和删除 scheduler 任务,不再依赖手动调用工具或直接改运行态数据。同时补上 Runtime API 与 WebUI 代理层,保证 WebUI 登录态与 Runtime API Key 的边界仍然清晰。
主要变更
WebUI 定时任务管理
scheduler.call_self)Runtime API 与 WebUI 代理
GET /api/v1/schedulesPOST /api/v1/schedulesGET /api/v1/schedules/{task_id}PATCH /api/v1/schedules/{task_id}DELETE /api/v1/schedules/{task_id}/api/v1/management/runtime/schedules.../api/runtime/schedules...X-Undefined-API-Key,避免把 Runtime API Key 暴露给浏览器。调度器行为修复
Scheduler.update_task()支持更新和清空target_id、target_type、max_executions。scheduler.call_self被识别成多工具任务的问题,API 与前端都会将其识别为自我督办并回填self_instruction。提示词与记忆查阅
undefined.xml和undefined_nagaagent.xml中的记忆查阅规则。cognitive.*。memory.list找到 UUID。文档
docs/openapi.md:补充 schedules API、请求/响应结构和示例。docs/management-api.md:补充 WebUI Runtime schedules 代理说明。docs/usage.md:补充 scheduler 工具说明。docs/webui-guide.md:补充定时任务界面说明。docs/cognitive-memory.md:补充主动查阅记忆的使用建议。测试
tests/test_runtime_api_schedules.py覆盖 Runtime schedules API。tests/test_webui_management_api.py覆盖 WebUI 代理鉴权、URL 编码和路由注册。tests/test_runtime_api_probes.py覆盖 schedules 能力探针。tests/test_scheduler_self_instruction.py覆盖自我督办序列化与执行参数。tests/test_system_prompt_constraints.py锁定记忆查阅提示词规则。兼容性与安全边界
scheduler.call_self时识别为self_instruction,避免误判普通多工具任务。验证
本分支开发过程中跑过以下验证:
uv run pytest tests/uv run pytest tests/test_runtime_api_schedules.py tests/test_webui_management_api.py tests/test_runtime_api_probes.py tests/test_scheduler_self_instruction.py tests/test_scheduled_task_unit.pyuv run pytest tests/test_runtime_api_schedules.py tests/test_webui_management_api.py tests/test_scheduler_self_instruction.py tests/test_scheduled_task_unit.pyuv run pytest tests/test_system_prompt_constraints.pyuv run ruff check .uv run ruff format --check .uv run mypy .npm run checkuv build --wheel备注
origin/develop(c850edbb)变基。develop包含 3 个提交:342efe81 feat(webui): add scheduled tasks management2c269a5b fix(webui): handle legacy schedule task editingb2409e21 fix(prompts): encourage active memory lookupSummary by CodeRabbit
New Features
Documentation
Other