Skip to content

Fix code review bugs, add 20 edge case tests#12

Merged
twokidsCarl merged 1 commit intomainfrom
fix/code-review-bugs
Apr 8, 2026
Merged

Fix code review bugs, add 20 edge case tests#12
twokidsCarl merged 1 commit intomainfrom
fix/code-review-bugs

Conversation

@twokidsCarl
Copy link
Copy Markdown
Owner

@twokidsCarl twokidsCarl commented Apr 8, 2026

Summary

  • 7 bug fixes from code review: missing return, uninitialized var, missing rescue blocks, exception hierarchy
  • 20 new tests (85 total): edge cases for smart routing, history, tab completion, /source

Bug fixes

Bug Severity Fix
handle_smart_input missing return Critical Added return on handle_llm calls
@saved_input uninitialized Critical Init in constructor
InputHandler.completions no rescue Medium Wrapped in begin/rescue
handle_tab_completion no rescue Medium Added rescue block
eval_ruby misses SystemExit High Added to rescue clause
build_right unused width param Low Removed param
/source condition too narrow Medium Match all error types

Test plan

  • 85 TUI tests passing
  • CI green

🤖 Generated with Claude Code

Summary by CodeRabbit

发行说明

  • 错误修复

    • 增强了代码执行的错误处理,防止特定异常导致应用意外中止
    • 改进了自动完成和源代码查询功能的稳定性,现在能更优雅地处理异常情况
    • 修复了制表符补全过程中可能导致界面崩溃的问题
  • 重构

    • 简化了状态栏的内部实现,删除了未使用的参数
  • 测试

    • 扩展了测试覆盖范围,包括输入路由、代码求值、历史导航和补全功能

Bug fixes from code review:
- Fix missing return in handle_smart_input (MVU tuple broken)
- Initialize @saved_input to prevent history navigation crash
- Add rescue to InputHandler.completions (stale binding safety)
- Add rescue to handle_tab_completion (never crash TUI)
- Catch SystemExit in eval_ruby (user code calling exit)
- Remove unused width param from StatusBar.build_right
- Fix /source fallback condition (match all error types, not just "not found")
- Wrap baseline_methods init in rescue

20 new tests (85 total):
- Smart routing: NameError on single-word, string/array literals, MVU tuple
- History: empty history, boundary, saved input preservation
- Tab: empty prefix, no matches, slash command completion
- /source: REPL-defined method fallback
- eval_ruby: SyntaxError/NameError catch, success case
- Baseline methods: new method detection
- StatusBar: model name, scroll hint
- /help: alignment, removed commands, hints

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 8, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 85accc4a-4b0d-4658-8a5d-37b4662234ca

📥 Commits

Reviewing files that changed from the base of the PR and between 3d126ac and 54a7106.

📒 Files selected for processing (7)
  • lib/claw/tui/agent_executor.rb
  • lib/claw/tui/input_handler.rb
  • lib/claw/tui/model.rb
  • lib/claw/tui/status_bar.rb
  • lib/claw/version.rb
  • spec/claw/tui/model_spec.rb
  • spec/claw/tui/snapshot_spec.rb

Walkthrough

此PR改进了TUI的异常处理机制,使eval、补全和源代码查询对异常更具弹性,调整了多个组件的控制流,更新了状态栏方法签名,并扩展了测试覆盖范围,版本号随之更新。

Changes

Cohort / File(s) Summary
异常处理加强
lib/claw/tui/agent_executor.rb, lib/claw/tui/input_handler.rb
eval_ruby 现在捕获 SystemExit 以防止用户代码调用 exit 时终止执行;input_handler 的补全生成添加了防御性 begin/rescue 块来处理 bindingmemory 访问的异常。
Model控制流重构
lib/claw/tui/model.rb
初始化时添加 @saved_input 实例变量;handle_slash/source 路径改为匹配任何 :error 类型而非仅限错误消息;handle_smart_input 直接返回 handle_llm 结果;handle_tab_completion 添加异常处理以防TUI崩溃;baseline_methods 采用容错方式初始化。
方法签名更新
lib/claw/tui/status_bar.rb
build_right 方法移除未使用的 width 参数,调用处相应调整。
版本及测试更新
lib/claw/version.rb, spec/claw/tui/model_spec.rb, spec/claw/tui/snapshot_spec.rb
BUILD常数更新至 20260407-008;添加智能输入路由、Ruby求值、输入历史导航、Tab补全、源代码回退、baseline方法检测的单元测试;添加状态栏模型名称、帮助系统消息、滚动提示的快照测试。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/code-review-bugs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@twokidsCarl twokidsCarl merged commit b01faf7 into main Apr 8, 2026
3 of 4 checks passed
@twokidsCarl twokidsCarl deleted the fix/code-review-bugs branch April 8, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant