[Fix] Fix room resolution and proxy configuration issues#568
Conversation
- Fix template clone room visibility check to require non-direct sessions - Move middleware setup to ready event to ensure proper initialization order - Update message_delay middleware to run after check_room instead of resolve_room - Fix room checking logic and improve comment clarity - Auto-create rooms for direct messages regardless of autoCreateRoomFromUser setting - Use ModelType.llm instead of ModelType.all when checking available models - Add chatluna_docstore table cleanup in wipe middleware These changes ensure proper room resolution for template clone rooms and fix middleware initialization timing issues that could cause inconsistent behavior.
- Add validation to reject empty proxy addresses with warning message - Fix config schema for blackList default value - Simplify proxy logging to show configured address - Improve proxy protocol error message with helpful hint - Use logical OR operator for consistent null coalescing These changes prevent runtime errors from invalid proxy configurations and provide better feedback when proxy settings are misconfigured.
Update core package version and peer dependency references across all adapter and service packages to maintain version consistency.
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Walkthrough本次变更调整了房间可见性与自动创建逻辑(含直聊场景)、消息延迟中间件的执行时序与返回、启动流程中间件初始化时机、配置项默认值声明、代理地址校验与日志,以及系统清理流程中新增表清理。 Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Gateway as 入口/事件
participant Chain as 中间件链
participant CheckRoom as check_room
participant Delay as message_delay
participant Cmd as lifecycle-handle_command
User->>Gateway: 收到消息
Gateway->>Chain: 触发处理
Chain->>CheckRoom: 校验房间
Note right of CheckRoom: 新群允许先执行命令的分支未变
CheckRoom-->>Chain: 结果/继续
Chain->>Delay: 延迟逻辑(新位置)
alt 未启用队列 或 有命令
Delay-->>Chain: CONTINUE(不延迟)
else 需延迟
Delay-->>Chain: 延时后继续
end
Chain->>Cmd: 命令处理
sequenceDiagram
autonumber
actor User
participant Resolve as resolve_room
participant Model as 模型查询(LLM)
participant Store as 房间存储
User->>Resolve: 进入/发送消息
Resolve->>Model: 查询可用模型 (type=LLM)
Model-->>Resolve: 可用/不可用
alt 直聊 或 autoCreateRoomFromUser=true
Resolve->>Store: 创建私有/主房间 (clone template)
Note right of Resolve: 设置 roomMasterId、visibility、name 等
else 已存在或无需创建
Resolve-->>User: 使用既有房间
end
Resolve-->>User: 返回房间信息
sequenceDiagram
autonumber
participant App as 应用入口
participant Ready as ready 回调
participant MW as setupMiddleware
participant Proxy as setupProxy / setGlobalProxyAddress
App->>Ready: 启动完成
Ready->>MW: 初始化中间件(新时机)
Ready->>Proxy: 初始化代理
Proxy-->>Ready: 日志输出/校验(空值早退/协议提示)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
Comment |
Summary of ChangesHello @dingyi222666, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request delivers a series of critical bug fixes and minor enhancements aimed at improving the stability and functionality of the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a series of important bug fixes and improvements, particularly around room resolution, middleware initialization, and proxy configuration. The changes are well-targeted and address the described issues effectively. I have one suggestion in packages/core/src/utils/request.ts to make the proxy address validation logic more concise and robust. Overall, this is a solid set of fixes that enhances the stability and usability of the plugin.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/core/src/config.ts (1)
100-102: 移除嵌套 default(false),仅保留外层 default(false)
在 packages/core/src/config.ts 第 100 行,将blackList: Schema.computed(Schema.boolean().default(false)).default(false)改为
blackList: Schema.computed(Schema.boolean()).default(false)以保持与其他 Schema.computed 用法(一层 default)一致。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (26)
packages/azure-openai-adapter/package.jsonis excluded by!**/*.jsonpackages/claude-adapter/package.jsonis excluded by!**/*.jsonpackages/core/package.jsonis excluded by!**/*.jsonpackages/deepseek-adapter/package.jsonis excluded by!**/*.jsonpackages/dify-adapter/package.jsonis excluded by!**/*.jsonpackages/doubao-adapter/package.jsonis excluded by!**/*.jsonpackages/embeddings-service/package.jsonis excluded by!**/*.jsonpackages/gemini-adapter/package.jsonis excluded by!**/*.jsonpackages/hunyuan-adapter/package.jsonis excluded by!**/*.jsonpackages/image-renderer/package.jsonis excluded by!**/*.jsonpackages/image-service/package.jsonis excluded by!**/*.jsonpackages/long-memory/package.jsonis excluded by!**/*.jsonpackages/mcp-client/package.jsonis excluded by!**/*.jsonpackages/ollama-adapter/package.jsonis excluded by!**/*.jsonpackages/openai-adapter/package.jsonis excluded by!**/*.jsonpackages/openai-like-adapter/package.jsonis excluded by!**/*.jsonpackages/plugin-common/package.jsonis excluded by!**/*.jsonpackages/qwen-adapter/package.jsonis excluded by!**/*.jsonpackages/rwkv-adapter/package.jsonis excluded by!**/*.jsonpackages/search-service/package.jsonis excluded by!**/*.jsonpackages/shared/package.jsonis excluded by!**/*.jsonpackages/spark-adapter/package.jsonis excluded by!**/*.jsonpackages/variable-extension/package.jsonis excluded by!**/*.jsonpackages/vector-store-service/package.jsonis excluded by!**/*.jsonpackages/wenxin-adapter/package.jsonis excluded by!**/*.jsonpackages/zhipu-adapter/package.jsonis excluded by!**/*.json
📒 Files selected for processing (8)
packages/core/src/chains/rooms.ts(1 hunks)packages/core/src/config.ts(1 hunks)packages/core/src/index.ts(2 hunks)packages/core/src/middlewares/chat/message_delay.ts(2 hunks)packages/core/src/middlewares/room/check_room.ts(2 hunks)packages/core/src/middlewares/room/resolve_room.ts(2 hunks)packages/core/src/middlewares/system/wipe.ts(1 hunks)packages/core/src/utils/request.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/core/src/utils/request.ts (2)
packages/core/src/index.ts (1)
logger(38-38)packages/core/src/utils/error.ts (1)
ChatLunaError(13-41)
🔇 Additional comments (10)
packages/core/src/middlewares/system/wipe.ts (1)
46-46: 无需添加额外错误处理
chatluna_docstore表已在ChatLunaPlugin的ctx.database.extend('chatluna_docstore', …)中定义并注册,确保在清理中间件执行前必然存在,与其他表的处理方式一致。批准该更改。packages/core/src/utils/request.ts (2)
80-83: 代理地址验证逻辑正确。新增的空地址校验可以有效防止无效代理配置,并通过警告日志提示用户。早期返回避免了后续不必要的处理。
90-90: 错误提示信息改进得当。添加了 "Try add http:// or socks" 的提示,能够更好地指导用户修正代理协议配置错误。
packages/core/src/middlewares/room/check_room.ts (1)
18-18: 注释优化,无功能性变更。仅对中文注释进行了微调,逻辑保持不变。
Also applies to: 27-27
packages/core/src/middlewares/chat/message_delay.ts (2)
31-32: 显式返回 CONTINUE 提升了代码可读性。明确返回状态并添加注释说明忽略命令执行或延时未开启的情况,使逻辑更清晰。
130-130: 确认message_delay与check_room顺序兼容
message_delay仅依赖context.command和config.messageQueue,不使用context.options.room且无其他中间件依赖该锚点,顺序调整后功能保持一致。packages/core/src/index.ts (2)
79-79: 中间件初始化时机调整合理。将
setupMiddleware移至ready事件处理函数内执行,确保中间件在所有组件初始化完成后再设置,修复了时序问题。这与 PR 目标中提到的"将中间件初始化移至 ready 事件"一致。
146-148: 请确认 setGlobalProxyAddress 的空字符串处理
config.proxyAddress在 schema 中默认值为'',而||会把所有假值(包括空字符串)回退到ctx.http.config.proxyAgent。请检查packages/core/src/index.ts中setGlobalProxyAddress(约第80–83行)在接收到空字符串时是否已做早期返回,避免行为差异。packages/core/src/middlewares/room/resolve_room.ts (2)
150-151: 正确的模型类型检查将模型可用性检查从
ModelType.all改为ModelType.llm是正确的。聊天功能只需要 LLM 模型,使用ModelType.all会包含嵌入模型等不相关类型,可能导致误判。
170-225: 确认直聊场景始终创建私有房间并移除冗余判断
config.autoCreateRoomFromUser || session.isDirect逻辑确保直聊场景(session.isDirect = true)无论配置如何均走私有房间分支,else 分支仅用于群聊模板克隆。- else 分支内对
session.isDirect的嵌套三元判断在此条件下恒为 false,可删除以简化逻辑。- 请确认预期行为:直聊会话仅创建
visibility = 'private',群聊才创建visibility = 'template_clone'。
This PR fixes critical issues with room resolution logic, middleware initialization, and proxy configuration validation.
Bug Fixes
Other Changes