fix(tui): restore backspace in AgentURL (eval field 0)#126
fix(tui): restore backspace in AgentURL (eval field 0)#126yuval-qf merged 1 commit intoqualifire-dev:mainfrom
Conversation
Summary by CodeRabbit
WalkthroughBackspace handling in the TUI evaluation form was adjusted so deletions are allowed when Changes
Sequence Diagram(s)sequenceDiagram
participant TUI
participant EvalFormCtrl as EvalFormController
note right of EvalFormCtrl #f0f8ff: Backspace handling branch updates
TUI->>EvalFormCtrl: Backspace key
EvalFormCtrl->>EvalFormCtrl: check currentField >= 0
alt currentField == 0 (AgentURL)
EvalFormCtrl->>EvalFormCtrl: ensure cursorPos > 0 && cursorPos <= len(runes) && field non-empty
alt guard passes
EvalFormCtrl->>EvalFormCtrl: remove rune at cursorPos-1
EvalFormCtrl->>TUI: update field rendering
else guard fails
EvalFormCtrl->>TUI: no-op (ignore backspace)
end
else currentField == 3 (JudgeModel)
EvalFormCtrl->>EvalFormCtrl: same cursor/rune guards and deletion
EvalFormCtrl->>TUI: update field rendering / no-op
else other fields
EvalFormCtrl->>EvalFormCtrl: existing backspace logic (unchanged)
EvalFormCtrl->>TUI: update field rendering / no-op
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 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)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/tui/internal/tui/eval_form_controller.go (1)
102-113: Backspace at cursor position 0 will cause a panic.The deletion logic for fields 0 (AgentURL) and 3 (JudgeModel) does not check if
cursorPos > 0before performingrunes[:cursorPos-1]on lines 105 and 111. If a user presses backspace when the cursor is at the beginning of the field (position 0), this will cause a slice index out of range panic.Apply this diff to fix the issue:
case 0: // AgentURL runes := []rune(m.evalState.AgentURL) - if m.evalState.cursorPos <= len(runes) { + if m.evalState.cursorPos > 0 && m.evalState.cursorPos <= len(runes) { m.evalState.AgentURL = string(runes[:m.evalState.cursorPos-1]) + string(runes[m.evalState.cursorPos:]) m.evalState.cursorPos-- } case 3: // JudgeModel runes := []rune(m.evalState.JudgeModel) - if m.evalState.cursorPos <= len(runes) { + if m.evalState.cursorPos > 0 && m.evalState.cursorPos <= len(runes) { m.evalState.JudgeModel = string(runes[:m.evalState.cursorPos-1]) + string(runes[m.evalState.cursorPos:]) m.evalState.cursorPos-- }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/tui/internal/tui/eval_form_controller.go(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: codestyle
🔇 Additional comments (1)
packages/tui/internal/tui/eval_form_controller.go (1)
114-121: LGTM! ParallelRuns backspace logic is safe.The deletion logic for field 6 (ParallelRuns) properly guards against invalid states with checks for values >= 10 and > 0 before performing operations. This prevents any potential panics or invalid states.
058f90d to
4226010
Compare
Description
Restores backspace functionality in the
AgentURLfield on the New Evaluation formType of Change
Changes Made
Modified the guard condition in the backspace handler within handleEvalFormInput function in
eval_form_controller.goRelated Issues/PRs