fix(github): 修复 watchers 显示错误 & feat(webui): 新增 autostart_bot 配置#70
Conversation
- GitHub API 的 watchers_count 实际等于 stargazers_count(历史遗留) - 真正的 watchers(订阅数)应使用 subscribers_count 字段 - 更新 GitHubRepoInfo.watchers 类型为 int | None - 补充测试验证 watchers 和 subscribers 字段正确性 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
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 (2)
📝 WalkthroughWalkthroughThree independent changes: widen GitHub repo watchers to nullable and remap parsing; add WebUI autostart config, load it, wire startup (marker + config), document and test; refactor chat job lifecycle, shutdown, non-stream job flow, and add related tests. ChangesWatchers Field Nullability Update
WebUI Autostart Bot
Chat Job Manager & WebChat lifecycle
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 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 |
- 新增 [webui].autostart_bot 配置项(默认 false,保持现有行为) - on_startup 钩子中:自动恢复标记优先,标记不存在时按配置自动启动 - 启动失败只记录日志,不阻塞 WebUI 启动;与自动恢复机制互不冲突 - 同步更新 config_class/domains 配置流转与 WebUISettings 数据模型 - 同步更新文档:CLAUDE.md、configuration/webui-guide/deployment/usage - 补充测试:test_webui_settings(7) + test_webui_autostart(5) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/webui/app.py`:
- Around line 230-239: The startup code in on_startup uses blocking
Path.exists()/Path.unlink() on the marker variable; replace those direct
filesystem calls with the async-safe helpers from src/Undefined/utils/io.py
(e.g., the provided async exists/check and delete/unlink functions) so the event
loop is not blocked. Import and await the async helper(s) instead of calling
Path.exists() and Path.unlink(missing_ok=True), preserve the logic flow (if
marker exists then delete and await bot.start() and return), and ensure the
helper call honors the "missing_ok" semantics or guard with an awaited existence
check before deletion.
🪄 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: aa04f467-075a-40f0-b4f4-12237d6beafc
📒 Files selected for processing (12)
CLAUDE.mdconfig.toml.exampledocs/configuration.mddocs/deployment.mddocs/usage.mddocs/webui-guide.mdsrc/Undefined/config/config_class.pysrc/Undefined/config/load_sections/domains.pysrc/Undefined/config/webui_settings.pysrc/Undefined/webui/app.pytests/test_webui_autostart.pytests/test_webui_settings.py
✅ Files skipped from review due to trivial changes (4)
- CLAUDE.md
- docs/usage.md
- docs/deployment.md
- docs/configuration.md
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@docs/webui-guide.md`:
- Line 125: Remove the trailing spaces inside inline code spans used in the
docs: change code spans like `/faq `, `/changelog `, `/cl `, `/h ` and `/h [命令名]
[-t]` so they do not include internal trailing spaces; either remove the space
from the backtick-delimited code (e.g. `/faq`) or preserve the “末尾空格” meaning in
surrounding prose (e.g. “以空格结尾的 `/faq`”) to satisfy markdownlint MD038 and keep
the same semantic guidance; update all occurrences where those exact inline
spans appear.
🪄 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: 7615606c-4fee-4203-aae5-a509446ac6bf
📒 Files selected for processing (5)
config.toml.exampledocs/configuration.mddocs/usage.mddocs/webui-guide.mdsrc/Undefined/webui/app.py
✅ Files skipped from review due to trivial changes (2)
- docs/usage.md
- docs/configuration.md
🚧 Files skipped from review as they are similar to previous changes (2)
- config.toml.example
- src/Undefined/webui/app.py
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 1
🤖 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 `@docs/webui-guide.md`:
- Line 125: Remove the trailing spaces inside inline code spans used in the
docs: change code spans like `/faq `, `/changelog `, `/cl `, `/h ` and `/h [命令名]
[-t]` so they do not include internal trailing spaces; either remove the space
from the backtick-delimited code (e.g. `/faq`) or preserve the “末尾空格” meaning in
surrounding prose (e.g. “以空格结尾的 `/faq`”) to satisfy markdownlint MD038 and keep
the same semantic guidance; update all occurrences where those exact inline
spans appear.
🪄 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: 7615606c-4fee-4203-aae5-a509446ac6bf
📒 Files selected for processing (5)
config.toml.exampledocs/configuration.mddocs/usage.mddocs/webui-guide.mdsrc/Undefined/webui/app.py
✅ Files skipped from review due to trivial changes (2)
- docs/usage.md
- docs/configuration.md
🚧 Files skipped from review as they are similar to previous changes (2)
- config.toml.example
- src/Undefined/webui/app.py
🛑 Comments failed to post (1)
docs/webui-guide.md (1)
125-125:
⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove spaces inside inline code spans to satisfy markdownlint (MD038).
Line 125 uses inline code with trailing spaces (e.g.
`/faq `), which triggers MD038 and can render inconsistently. Keep the “末尾空格”语义 in prose instead of code-span whitespace.Suggested doc tweak
-- 输入框开头输入 `/` 时会从后端 `/api/v1/commands?scope=webui` 获取当前可用斜杠命令并在输入框上方展开补全面板。面板按命令名、别名、说明和用法即时筛选,支持点击选择,也支持方向键选择、`Enter` / `Tab` 填入;直接手打 `/faq `、`/changelog ` 或 alias `/cl ` 这类复合命令后,会切换为子命令补全并显示具体用法。命令数据尚未返回时面板显示“正在加载可用命令”,不会提前显示“未找到匹配命令”;输入 `/h ` 这类已命中 alias 但命令本身没有声明子命令的内容时,会显示命令帮助块,包含说明、用法、示例和别名,例如 `/h [命令名] [-t]`,便于继续补参数;只有命令或子命令确实没有匹配项时才显示无匹配提示。命令清单按 WebChat 的虚拟私聊执行身份过滤,因此不会提示当前 WebUI 会话实际不可用的命令。 +- 输入框开头输入 `/` 时会从后端 `/api/v1/commands?scope=webui` 获取当前可用斜杠命令并在输入框上方展开补全面板。面板按命令名、别名、说明和用法即时筛选,支持点击选择,也支持方向键选择、`Enter` / `Tab` 填入;直接手打 `/faq`(后接空格)、`/changelog`(后接空格)或 alias `/cl`(后接空格)这类复合命令后,会切换为子命令补全并显示具体用法。命令数据尚未返回时面板显示“正在加载可用命令”,不会提前显示“未找到匹配命令”;输入 `/h`(后接空格)这类已命中 alias 但命令本身没有声明子命令的内容时,会显示命令帮助块,包含说明、用法、示例和别名,例如 `/h [命令名] [-t]`,便于继续补参数;只有命令或子命令确实没有匹配项时才显示无匹配提示。命令清单按 WebChat 的虚拟私聊执行身份过滤,因此不会提示当前 WebUI 会话实际不可用的命令。📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.- 输入框开头输入 `/` 时会从后端 `/api/v1/commands?scope=webui` 获取当前可用斜杠命令并在输入框上方展开补全面板。面板按命令名、别名、说明和用法即时筛选,支持点击选择,也支持方向键选择、`Enter` / `Tab` 填入;直接手打 `/faq`(后接空格)、`/changelog`(后接空格)或 alias `/cl`(后接空格)这类复合命令后,会切换为子命令补全并显示具体用法。命令数据尚未返回时面板显示"正在加载可用命令",不会提前显示"未找到匹配命令";输入 `/h`(后接空格)这类已命中 alias 但命令本身没有声明子命令的内容时,会显示命令帮助块,包含说明、用法、示例和别名,例如 `/h [命令名] [-t]`,便于继续补参数;只有命令或子命令确实没有匹配项时才显示无匹配提示。命令清单按 WebChat 的虚拟私聊执行身份过滤,因此不会提示当前 WebUI 会话实际不可用的命令。🧰 Tools
🪛 LanguageTool
[uncategorized] ~125-~125: 您的意思是“"不"全面”?
Context: ...ommands?scope=webui` 获取当前可用斜杠命令并在输入框上方展开补全面板。面板按命令名、别名、说明和用法即时筛选,支持点击选择,也支持方向键选择、...(BU)
[uncategorized] ~125-~125: 您的意思是“"不"全”?
Context: ...angelog或 alias/cl ` 这类复合命令后,会切换为子命令补全并显示具体用法。命令数据尚未返回时面板显示“正在加载可用命令”,不会提前显示“...(BU)
[uncategorized] ~125-~125: 您的意思是“"不"参数”?
Context: ...助块,包含说明、用法、示例和别名,例如/h [命令名] [-t],便于继续补参数;只有命令或子命令确实没有匹配项时才显示无匹配提示。命令清单按 WebCha...(BU)
🪛 markdownlint-cli2 (0.22.1)
[warning] 125-125: Spaces inside code span elements
(MD038, no-space-in-code)
[warning] 125-125: Spaces inside code span elements
(MD038, no-space-in-code)
[warning] 125-125: Spaces inside code span elements
(MD038, no-space-in-code)
[warning] 125-125: Spaces inside code span elements
(MD038, no-space-in-code)
🤖 Prompt for 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. In `@docs/webui-guide.md` at line 125, Remove the trailing spaces inside inline code spans used in the docs: change code spans like `/faq `, `/changelog `, `/cl `, `/h ` and `/h [命令名] [-t]` so they do not include internal trailing spaces; either remove the space from the backtick-delimited code (e.g. `/faq`) or preserve the “末尾空格” meaning in surrounding prose (e.g. “以空格结尾的 `/faq`”) to satisfy markdownlint MD038 and keep the same semantic guidance; update all occurrences where those exact inline spans appear.Source: Linters/SAST tools
- app.py: 使用 async_io.exists/delete_file 替代阻塞的 Path 操作 避免 on_startup 中的 marker.exists() 和 marker.unlink() 阻塞事件循环 - webui-guide.md: 移除 inline code 中的 trailing spaces (MD038) 将 `/faq `、`/changelog `、`/cl `、`/h ` 改为无空格形式 并在周围文本说明末尾需带空格的语义 - tests: 补充测试文件模块级 docstring,提升 docstring coverage Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- route non-stream WebChat requests through the job manager - cancel WebChat jobs and title tasks on runtime shutdown - prevent duplicate title jobs and cancelled events - add regression tests and update API docs Tests: - uv run pytest tests/test_runtime_api_chat_jobs.py tests/test_runtime_api_chat_history.py tests/test_webchat_conversations.py tests/test_runtime_api_chat_stream.py tests/test_webui_runtime_chat_frontend.py - uv run ruff check src/Undefined/api/routes/chat.py src/Undefined/api/webchat_store.py src/Undefined/api/app.py src/Undefined/api/_openapi.py tests/test_runtime_api_chat_history.py tests/test_runtime_api_chat_jobs.py tests/test_webchat_conversations.py Co-authored-by: Codex <noreply@openai.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/chat.py`:
- Around line 353-354: The shutdown currently awaits asyncio.gather(*tasks,
return_exceptions=True) with no timeout, which can hang if a
cancellation-resistant task blocks; wrap this wait in a bounded timeout (e.g.,
SHUTDOWN_TASK_TIMEOUT) and after the timeout cancel any still-pending tasks.
Specifically, replace the direct await of asyncio.gather(*tasks,
return_exceptions=True) with a pattern that (1) attempts await
asyncio.wait_for(asyncio.gather(*tasks, return_exceptions=True),
timeout=SHUTDOWN_TASK_TIMEOUT), (2) on asyncio.TimeoutError iterates over the
original tasks, calls task.cancel() for pending ones, and finally awaits
asyncio.gather(*tasks, return_exceptions=True) again to ensure cancellation
completes; keep SHUTDOWN_TASK_TIMEOUT configurable and reference the existing
tasks variable and the gather call when making the 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: f8e98cbc-0a8b-4b89-a014-6457ee56a613
📒 Files selected for processing (13)
docs/management-api.mddocs/openapi.mddocs/webui-guide.mdsrc/Undefined/api/_openapi.pysrc/Undefined/api/app.pysrc/Undefined/api/routes/chat.pysrc/Undefined/api/webchat_store.pysrc/Undefined/webui/app.pytests/test_runtime_api_chat_history.pytests/test_runtime_api_chat_jobs.pytests/test_webchat_conversations.pytests/test_webui_autostart.pytests/test_webui_settings.py
✅ Files skipped from review due to trivial changes (1)
- docs/management-api.md
🚧 Files skipped from review as they are similar to previous changes (3)
- src/Undefined/webui/app.py
- tests/test_webui_settings.py
- tests/test_webui_autostart.py
- add a configurable WebChat shutdown task timeout - recancel pending job tasks after shutdown wait timeout - cover cancellation-resistant task shutdown behavior Tests: - uv run pytest tests/test_runtime_api_chat_jobs.py - uv run ruff check src/Undefined/api/routes/chat.py tests/test_runtime_api_chat_jobs.py Co-authored-by: Codex <noreply@openai.com>
🎯 本 PR 包含的功能
1. 修复 GitHub Watchers 显示错误
问题描述
GitHub 仓库卡片渲染时,watchers 数量总是等于 stars 数量。
根本原因
GitHub API 的历史遗留设计:
watchers_count字段实际上等于stargazers_count(星标数)subscribers_count字段中修复内容
watchers改为使用subscribers_countwatchers类型改为int | None2. 新增 WebUI Auto-start Bot 功能
功能描述
新增
[webui].autostart_bot配置项,WebUI 启动时可自动拉起 bot 进程,无需手动点击启动按钮。实现内容
配置层:
config.toml.example: 新增autostart_bot = false配置项及中英文注释webui_settings.py: 增加字段解析与类型定义config_class.py/domains.py: 同步配置流转逻辑层:
webui/app.py:on_startup()钩子中实现自动启动逻辑文档层:同步更新 5 个文档文件
CLAUDE.mddocs/configuration.mddocs/webui-guide.mddocs/deployment.mddocs/usage.md测试层:新增 12 个测试用例
tests/test_webui_settings.py: 配置解析测试(7 个)tests/test_webui_autostart.py: 自动启动逻辑测试(5 个)配置示例
关键特性
false,保持现有行为,向后兼容✅ 测试验证
📊 改动统计
🔀 分支状态
develop分支最新更改(feat(webchat))🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Tests