v0.5.2
发布日期:2026-06-09
概述
本版本聚焦于 TUI 中多项关键 UX 问题的修复:配置流程缺陷(子菜单表单被重置、/model 多步流程崩溃)、配置不完整时的优雅处理、改进的命令检测(仅完全匹配 / 前缀才视为命令)、以及视觉修复(消息末尾多余空行、换行随终端 resize 自适应)。
提交记录
[7c63063] chore: bump version to 0.5.2, update dependencies, remove env var fallbacks
将所有 crate 版本更新至 0.5.2,升级依赖项(async-openai 0.41.0、ratatui 0.30.1、uuid 1.23.3、chrono 0.4.45 等),并从配置加载中移除 OPENROUTER_* / OPENCODE_MODEL 环境变量回退——配置现在完全来自 ~/.oy-ai-agent/config.toml。
涉及文件:
Cargo.lock | 159 ++++++++++++++++++++++++++++++++--------------
Cargo.toml | 16 ++---
oy-code-cli/src/lib.rs | 27 +++-----
oy-tui/src/load_config.rs | 22 +++----
4 files changed, 139 insertions(+), 85 deletions(-)
[cffbaa7] fix: prevent submenu ModelForm from being reset by cleanup code
当从 /settings 子菜单中选择 /base-url、/api-key、/model-name 或自定义 context 时,execute_submenu_item 会将 app_mode 设为 ModelForm,但随后立即被无条件的清理代码重置为 Normal。添加 return; 语句防止清理代码覆盖 ModelForm 模式,使输入表单保持打开状态。
涉及文件:
oy-tui/src/app.rs | 4 ++++
1 file changed, 4 insertions(+)
[78a5ce8] fix: clear input buffer on command execution and fix /model multi-step flow
- 在
execute_command开头清空self.input和cursor_pos,防止命令执行后残留文本(/settings、/model)出现在输入区域。 - 将
/modelstep 0 标题从"API Base URL:"改为"API Base URL (step 1/4):",使其不匹配handle_key_model_form中的is_single检查,从而让 4 步表单(url → key → model → context)正常工作,而不是在第一步后就短路退出。
涉及文件:
oy-tui/src/app.rs | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[a5930e5] fix: prevent panic when API config is incomplete at startup and runtime
- 添加
config_is_complete()辅助函数检查api_key、base_url、model。 - 在会话恢复和全新启动两条路径中保护 agent 启动——配置不完整时跳过 agent 初始化,而不是 panic。
- 当 agent 因缺少配置无法启动时,显示欢迎提示消息。
- 保护
switch_reasoning_effort、switch_context_capacity和switch_single_setting:仅在所有必要字段都已配置时才重启 agent;否则保存配置并显示帮助消息。
涉及文件:
oy-tui/src/app.rs | 112 +++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 89 insertions(+), 23 deletions(-)
[7cb7256] fix: only treat exact /-prefixed input matches as commands, otherwise send as prompt
- 将
execute_command改为使用精确命令名匹配(c.name == trimmed),而非前缀匹配(c.name.starts_with(input))。 - 移除输入不匹配时的
"Unknown command"回退消息。 execute_command现在返回bool:true表示识别为命令。- 在
handle_key_normal中,当/开头的输入不是已知命令时,回退为普通 prompt 发送给 agent。 - 这使得类似
/path/1/2 check xxx或/model fix xxx的提示能作为普通 prompt 工作,而非被拒绝。
涉及文件:
oy-tui/src/app.rs | 64 ++++++++++++++++++++++++++++---------------------------
1 file changed, 33 insertions(+), 31 deletions(-)
[75f107f] fix: only enter CommandSelector mode when /-prefixed input matches known commands
此前,任何长度大于 1 的 / 开头输入都会进入 CommandSelector 模式,即使没有命令匹配(如 /12)。这导致 Enter 被 CommandSelector 的空匹配处理程序静默消耗,阻止了输入作为 prompt 发送。
现在仅在存在实际命令匹配时才进入 CommandSelector 模式。不匹配的 / 开头输入停留在 Normal 模式,并在按下 Enter 时正确发送为 prompt。
涉及文件:
oy-tui/src/app.rs | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
[12149ac] fix: correct message line counting and auto-scroll on terminal resize
- 在
visual_default_count中,将内容传入render_markdown前应用trim_end(),与to_lines()的做法保持一致。防止尾部空白/换行使视觉行数膨胀,导致消息底部出现大面积空白区域。 - 在
App结构体中添加last_chat_widthCell<u16>字段,用于跟踪每帧渲染时聊天区域的宽度。当终端 resize 导致宽度变化时,强制 auto-scroll 到底部,使msg_heights和Paragraph::wrap使用新尺寸重新计算,让换行自适应当前终端大小。
涉及文件:
oy-tui/src/app.rs | 3 +++
oy-tui/src/message.rs | 5 +++--
oy-tui/src/ui.rs | 9 +++++++++
3 files changed, 15 insertions(+), 2 deletions(-)
What's Changed
- Fix v0.5.2 by @cherish-ltt in #7
Full Changelog: v0.5.1...v0.5.2