TUI: 优化交互布局与终端兼容性 - #4
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the kuncode-cli TUI rendering to a more responsive, low-noise layout, improving narrow-terminal behavior and terminal interoperability (NO_COLOR + bracketed paste), while expanding regression coverage around rendering and input editing.
Changes:
- Reworked UI shell into header/body/plan/composer/footer panes with a
Themeabstraction and improved plan/approval visibility on small terminals. - Updated conversation rendering to a timeline-like presentation with exact char-boundary wrapping and a scrollbar indicator.
- Improved input UX (bracketed paste + newline insertion) and added/updated TUI regression tests; documented keybindings in the README.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Documents TUI keybindings, including multiline input and NO_COLOR behavior. |
| crates/kuncode-cli/src/tui/ui/conversation.rs | Refactors conversation rendering (wrapping, headings, scrollbar, truncation helpers) and updates tests. |
| crates/kuncode-cli/src/tui/ui.rs | Introduces responsive layout, Theme, plan/approval/composer rendering changes, and additional layout tests. |
| crates/kuncode-cli/src/tui/app/input.rs | Adds atomic bracketed-paste insertion with newline normalization + tests. |
| crates/kuncode-cli/src/tui/app.rs | Adds NO_COLOR gating, activity animation frames, and tightens approval key handling + tests. |
| crates/kuncode-cli/src/tui.rs | Enables bracketed paste, routes paste events into the editor, and adds Ctrl+J newline support + tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .iter() | ||
| .filter(|task| task.status == TodoStatus::Completed) | ||
| .count(); | ||
| let inner_width = area.width.saturating_sub(2).max(1); |
| if approval.deny_session.is_some() { | ||
| actions.push(("d", "本次会话拒绝")); | ||
| } | ||
| actions.push(("Esc", "取消任务")); |
|
Review 结论:建议先修复以下两项再合并。
现有 Copilot 关于计划栏多减 2 列宽度的评论也成立,但属于较低优先级的视觉截断问题。 本地验证: |
- 鼠标捕获与 bracketed paste 改由 RAII guard 管理:panic 展开时也会 关闭,避免退回 shell 后粘贴出现 ESC[200~ 等控制序列 - 输入恰好填满一行时,光标推进到下一视觉行行首而非覆盖末字符; input_height 同步为该行预留高度 - 计划栏仅有顶部边框,行宽不再多减 2 列 - 审批面板不再响应未在 UI 中提示的裸 c 键;保留 Esc 与全局 Ctrl+C Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
已在 d23a73d 中处理全部评审意见:
本地验证: |
tracing 的 callsite interest 缓存是进程级全局状态:两个并行测试各自 via with_default 安装不同过滤级别的订阅器时,Dispatch 创建触发的缓存 重建窗口会让 padded_off_level_remains_disabled 偶发读到 debug 过滤器 而失败。让交换订阅器的测试共持一把互斥锁。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- PageUp/PageDown 在审批弹窗打开时仍滚动会话区:决定授权前常需回看 上文,且鼠标滚轮本就不受弹窗影响,按键行为与之对齐 - 空闲态未绑定的 Ctrl 组合键(如 Ctrl+K)不再把字面字母插入输入框 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
补充:已用真实 DeepSeek key 对评审修复做了实机验证,并追加一个交互优化提交 5cfe126。 实机验证(tmux 驱动 TUI,deepseek-v4-pro)
追加优化 5cfe126
均有配套测试; |
Windows 上 crossterm 把 AltGr 上报为 LEFT_CTRL+RIGHT_ALT,欧洲键盘
布局用 AltGr 输入 @ { [ € 等字符会带 CONTROL|ALT 修饰,此前的
CONTROL 守卫会把它们静默丢弃。改为仅拦截纯 Ctrl 组合。
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
概要
NO_COLOR、命名 ANSI 颜色及 bracketed paste,退出时可靠恢复终端状态Ctrl+J插入换行,粘贴内容规范化并保持光标语义为什么独立提交
TUI 改动与 Provider 协议及可信配置没有实现依赖。独立 PR 可以避免扩大 Provider PR 的审核范围,并允许界面改动单独合并或回退。
验证
cargo fmt --all -- --checkcargo clippy --workspace --all-targets -- -D warningscargo check --workspace --all-targetscargo test --workspace(515 passed,2 ignored:真实 DeepSeek API 测试)RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps