v0.8.0 — Session 加载、HTML 导出与键盘冲突修复
Release date: 2026-06-15
功能特性
CLI: oy session {path} 子命令
- commit
ba4c262 - 新增
oy session {path}子命令,通过oy-code-cli的Commands枚举注册。 - 加载有效 session:调用
load_session_messages验证文件,有效则启动 TUI 恢复对话。 - 无效文件友好提示:非 session 文件输出
❌ 'xxx' is not a valid OY session file.+ℹ️ No new conversation will be created.,不创建新对话。 - 向后兼容:原有的
--session/-s标志位保持不变,行为不受影响。 - 代码复用:提取
validate_session_file共享辅助函数,消除run_session_path与run_session_command之间的重复代码。
TUI: /output-session-to-html 命令
- commit
1262918 - 新增
/output-session-to-html斜杠命令,将当前会话的所有 ChatMessage 导出为自包含 HTML 文件。 - HTML 模板:使用 Rust 静态字符串模板(非 LLM 生成),内联 CSS/JS,无外部依赖。
- 侧边栏:消息列表(点击滚动到对应消息)、角色筛选按钮(All / System / User / AI / Tool)、搜索框。
- 主区域:完整对话历史,按角色使用不同颜色区分(System=灰色、User=蓝色、Assistant=绿色、Tool=紫色、Thinking=黄绿)。
- AI Thinking:
reasoning_content使用<details>标签默认折叠。 - Dark/Light 模式:切换按钮,默认 light,通过
localStorage持久化用户偏好。 - 安全防护:所有用户/AI 内容经
html_escape转义,防 XSS。 - 导出路径:保存到当前目录
.oy-agent-output/sessions-output/html/oy_session_{unix_timestamp}.html,目录自动创建。 - 新增
oy-tui/src/html_export.rs模块,包含 14 个单元测试。
Bug 修复
方向键冲突 — ↑/↓ 改为 Alt+↑/Alt+↓ 切换历史
- commit
715c310 - 问题:之前
↑/↓同时承担「光标移动」和「user prompt 历史浏览」两个职责,导致多行输入时光标操作与历史导航冲突。 - 解决方案:将历史浏览功能迁移到
Alt+↑/Alt+↓(Mac 上为⌥↑/⌥↓),↑/↓仅保留光标移动功能。 - Alt+↑:进入历史模式 / 翻更旧的 prompt。
- Alt+↓:翻更新的 prompt / 归位清空 input。
- 状态栏提示:使用
#[cfg(target_os = "macos")]平台感知显示。
Alt+Enter 平台感知提示
- commit
7aeec4a - 状态栏中
Alt+Enter改为平台感知显示:macOS 显示⌥Enter,Windows/Linux 显示Alt+Enter。 - 与已有的
⌥↑/⌥↓ history/Alt+↑/Alt+↓ history保持一致。
HTML 导出路径优化
- commit
5171451 - 将
/output-session-to-html的导出路径从当前目录改为.oy-agent-output/sessions-output/html/。 - 目录不存在时自动创建(
create_dir_all),创建失败时显示错误信息。
完整提交日志
ba4c262 feat(cli): add 'oy session <path>' subcommand for loading session files
1262918 feat(tui): add /output-session-to-html command for exporting chat to HTML
715c310 fix(tui): change history navigation from arrow keys to Alt+Up/Alt+Down to resolve cursor conflict
7aeec4a fix(tui): add platform-specific hint for Alt+Enter (⌥Enter on macOS)
5171451 fix(tui): change HTML export path to .oy-agent-output/sessions-output/html/ with auto-create dir
What's Changed
- v0.8.0 — Session 加载、HTML 导出与键盘冲突修复 by @cherish-ltt in #12
Full Changelog: v0.7.1...v0.8.0