Conversation
Code Review for PR #198: Add configurable Shift+Enter behaviorSummaryThis PR adds a configurable Shift+Enter behavior setting that allows users to choose between sending LF (newline) for multi-line input or CR (same as Enter). The implementation is clean and follows existing patterns in the codebase. Strengths
Issues & RecommendationsCritical: Missing Terminal Interface MethodThe current implementation only configures the keyEncoder at the UI layer but does not follow the established pattern of going through the Terminal interface. This creates an architectural inconsistency. Current pattern for altSendsEscape:
Recommended fix:
Why this matters: The Terminal interface serves as the contract between the UI layer and the terminal emulation logic. All settings that affect terminal behavior should go through this interface for consistency and future extensibility. Minor: String constant validationThe shiftEnterBehavior setting uses string values without validation or constants. Consider adding an enum for type safety, though the current implementation handles unexpected values gracefully with the else branch. Testing RecommendationsAdditional test cases to consider:
Code Quality Assessment
RecommendationApproval with minor architectural fix requested The PR is well-implemented and follows most existing patterns. However, I recommend addressing the architectural inconsistency by adding the Terminal interface method before merging. This ensures the codebase maintains a consistent architecture pattern. Great work overall! The feature is useful and the implementation is clean. |
Code Review for PR #198: Configurable Shift+Enter BehaviorOverall, this is a well-implemented feature that adds useful functionality matching iTerm2 behavior. The code follows existing patterns, is properly documented, and includes UI integration. Here's my detailed feedback: ✅ Strengths
🔍 Issues & Recommendations1. Potential State Synchronization Bug (Medium Priority)In LaunchedEffect(settings.shiftEnterBehavior, settings.altSendsEscape) {
// Configure local key encoder
keyEncoder.setShiftEnterSendsNewline(shiftEnterNewline)
keyEncoder.setAltSendsEscape(settings.altSendsEscape)
// Configure terminal's internal encoder
terminal.setShiftEnterSendsNewline(shiftEnterNewline)
terminal.setAltSendsEscape(settings.altSendsEscape)
}Problem: The Recommendation: This should work correctly, but for clarity and consistency with existing code patterns (like 2. Missing Null Safety Check (Low Priority)In selectedOption = when (settings.shiftEnterBehavior) {
"newline" -> "Newline (iTerm2 style)"
else -> "Same as Enter"
}Problem: If a user manually edits Recommendation: Add validation in the 3. Code Duplication in LaunchedEffect (Low Priority)The keyEncoder.setShiftEnterSendsNewline(shiftEnterNewline)
keyEncoder.setAltSendsEscape(settings.altSendsEscape)
terminal.setShiftEnterSendsNewline(shiftEnterNewline)
terminal.setAltSendsEscape(settings.altSendsEscape)Recommendation: This is fine for now, but consider adding a comment explaining why both need to be configured (the comment at line 265-266 is good but could be more specific about when each encoder is used). 4. Consistency with Existing Code (Minor Observation)Looking at the existing code, I notice that For Shift+Enter, you're setting the default in the Recommendation: Add a comment linking the default in 🧪 Testing Suggestions
🔒 Security & Performance
📝 Minor Suggestions
✅ VerdictThis PR is ready to merge with minor suggestions for future improvement. The implementation is solid, follows existing patterns, and solves the reported issue (#196). The concerns raised above are mostly about edge cases and documentation—none are blocking. Recommended Action: Approve and merge after author reviews the suggestions (especially #1 about state synchronization, which is more of a clarification than a bug). Great work! 🎉 |
- Add shiftEnterBehavior setting with two options: - "newline": Send LF (0x0A) for multi-line input (iTerm2 style, default) - "same-as-enter": Send CR (0x0D) like regular Enter - Add setShiftEnterSendsNewline() to Terminal interface and BossTerminal - Add setShiftEnterSendsNewline() method to TerminalKeyEncoder - Add dropdown in Settings UI under Behavior → Keyboard - Configure both local and terminal key encoders from settings - Also wire up altSendsEscape setting (was defined but not connected) - Add comments linking default values between TerminalKeyEncoder and TerminalSettings - Add validation for invalid settings.json values in UI Closes #196 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Code Review: Shift+Enter Behavior ConfigurationSummaryThis PR implements configurable Shift+Enter behavior, allowing users to choose between sending a newline (LF, iTerm2 style) or behaving like regular Enter (CR). The implementation is clean, well-documented, and follows the project's established patterns. ✅ Strengths
🔍 Code Quality ObservationsMinor: Validation HandlingIn selectedOption = when (settings.shiftEnterBehavior) {
"newline" -> "Newline (iTerm2 style)"
"same-as-enter" -> "Same as Enter"
else -> "Newline (iTerm2 style)" // Invalid value defaults to newline
}Consideration: Since settings are persisted to JSON, a corrupted/manually-edited settings file could contain invalid values. The current approach (silent default) is reasonable, but you could optionally log a warning or normalize the value on load. This is not blocking - the fallback is safe and sensible. Architecture: Dual Encoder ConfigurationThe implementation configures both // Configure local key encoder (used for keyboard input at line ~1358)
keyEncoder.setShiftEnterSendsNewline(shiftEnterNewline)
keyEncoder.setAltSendsEscape(settings.altSendsEscape)
// Configure terminal's internal encoder (via Terminal interface)
terminal.setShiftEnterSendsNewline(shiftEnterNewline)
terminal.setAltSendsEscape(settings.altSendsEscape)The comments explain this is for "architectural consistency", but based on the code analysis:
This is fine - the redundant configuration is harmless and ensures consistency if terminal emulation code later uses its own encoder. The comment explains the reasoning well. 🧪 Test CoverageMissing: No unit tests for the new functionality. Recommendation: Consider adding tests similar to // In TerminalKeyEncoderTest.kt (new file)
@Test
fun testShiftEnterDefaultSendsNewline() {
val encoder = TerminalKeyEncoder()
val bytes = encoder.getCode(VK_ENTER, InputEvent.SHIFT_MASK)
assertNotNull(bytes)
assertEquals(1, bytes.size)
assertEquals(Ascii.LF.code.toByte(), bytes[0])
}
@Test
fun testShiftEnterConfigurableBehavior() {
val encoder = TerminalKeyEncoder()
// Test newline mode (default)
encoder.setShiftEnterSendsNewline(true)
val lfBytes = encoder.getCode(VK_ENTER, InputEvent.SHIFT_MASK)
assertEquals(Ascii.LF.code.toByte(), lfBytes?.get(0))
// Test same-as-enter mode
encoder.setShiftEnterSendsNewline(false)
val crBytes = encoder.getCode(VK_ENTER, InputEvent.SHIFT_MASK)
assertEquals(Ascii.CR.code.toByte(), crBytes?.get(0))
}Not blocking - manual testing is documented in the PR, but automated tests would improve confidence and prevent regressions. 🔒 Security & Performance
📝 Suggestions for Future Work (Optional)
✅ VerdictLGTM with minor suggestions. The implementation is solid, follows project conventions, and solves the stated problem (#196). The missing tests are not blocking given the manual test plan in the PR description. Recommendation: Approve and merge. Consider adding unit tests in a follow-up PR if you want to improve coverage. Test Plan Verification:
Great work! 🚀 |
Summary
shiftEnterBehaviorsetting with two options:~/.bossterm/settings.jsonChanges
TerminalKeyEncoder.ktsetShiftEnterSendsNewline()methodTerminalSettings.ktshiftEnterBehaviorsettingTerminalSettingsOverride.ktBehaviorSettingsSection.ktProperTerminal.ktTest Plan
~/.bossterm/settings.jsonCloses #196
🤖 Generated with Claude Code