Skip to content

fix: prompt panel height and esc key forwarding - #6

Merged
MartianGreed merged 1 commit into
mainfrom
fix/prompt-and-esc
Jan 28, 2026
Merged

MartianGreed merged 1 commit into
mainfrom
fix/prompt-and-esc

Conversation

@MartianGreed

Copy link
Copy Markdown
Owner

Summary

  • Fix prompt panel unbounded height growth by using textarea's actual configured height instead of recalculating from newline count
  • Forward esc key to Claude sessions when in Urgent, Active, or Thinking state
  • Improve multi-line paste handling timing in SendKeysToPane

Test plan

  • Build passes: make build
  • Tests pass: make test
  • Manual test: paste 15+ lines in prompt mode, verify panel stays bounded
  • Manual test: press esc when session is Urgent/Active/Thinking, verify it forwards to Claude

🤖 Generated with Claude Code

@greptile-apps

greptile-apps Bot commented Jan 27, 2026

Copy link
Copy Markdown

Greptile Overview

Greptile Summary

This PR fixes two UI issues and improves paste handling reliability. The prompt panel height calculation now uses the textarea's configured height property instead of recalculating from newline count, preventing unbounded growth. The esc key is now forwarded to Claude sessions when they're in Urgent, Active, or Thinking states, allowing users to cancel operations. The multi-line paste timing has been improved with longer delays (50ms + 30ms vs 10ms) and the double-Enter threshold lowered from 3+ lines to 2+ lines.

Key Changes:

  • Prompt panel height now bounded by textarea's configured max height (10 lines)
  • Esc key forwarding implemented for interactive Claude states
  • Paste detection improved with better timing and lower threshold

Confidence Score: 4/5

  • This PR is safe to merge with low risk - changes are focused bug fixes
  • The changes are well-contained fixes for specific UI issues. The prompt height fix correctly uses the textarea's configured height. The esc key forwarding logic is sound and properly checks session state. The paste timing changes increase delays which reduces risk. The only minor concern is the lowered double-Enter threshold (2+ vs 3+ lines) which could affect single-line inputs with newlines, but this appears intentional for improved paste detection.
  • internal/tmux/client.go warrants testing with 2-line inputs to verify the lowered double-Enter threshold works as expected

Important Files Changed

Filename Overview
internal/tui/view.go Fixed prompt panel height calculation to use textarea's configured height instead of recalculating from content
internal/tui/model.go Added esc key forwarding to Claude sessions when in Urgent, Active, or Thinking states
internal/tmux/client.go Improved multi-line paste timing with increased delays and separated Enter commands

Sequence Diagram

sequenceDiagram
    participant User
    participant TUI as TUI Model
    participant Textarea
    participant Tmux as Tmux Client
    participant Claude as Claude Session
    
    Note over User,Claude: Esc Key Forwarding Flow
    User->>TUI: Press 'esc' key
    TUI->>TUI: Check if session selected
    TUI->>TUI: Check session state<br/>(Urgent/Active/Thinking)
    TUI->>Tmux: SendKeysToPaneRaw("Escape")
    Tmux->>Claude: Forward Escape key
    TUI->>TUI: addActivity("Sent Escape")
    
    Note over User,Claude: Prompt Panel Height Fix
    User->>TUI: Enter prompt mode
    TUI->>Textarea: SetHeight(calculated)
    TUI->>TUI: View() renders UI
    TUI->>Textarea: Height() - get configured height
    Note right of TUI: Uses textarea's actual<br/>configured height instead<br/>of recalculating from content
    TUI->>User: Display bounded panel
    
    Note over User,Claude: Multi-line Paste Flow
    User->>TUI: Submit multi-line prompt
    TUI->>Tmux: SendKeysToPane(session, pane, text)
    Tmux->>Claude: send-keys -l {text}
    Tmux->>Tmux: Sleep 50ms
    Tmux->>Claude: send-keys Enter
    alt 2+ lines (newline count >= 1)
        Tmux->>Tmux: Sleep 30ms
        Tmux->>Claude: send-keys Enter (2nd)
    end
    Tmux-->>TUI: Return success
Loading

@MartianGreed
MartianGreed force-pushed the fix/prompt-and-esc branch 2 times, most recently from be29e4c to 0ccdd20 Compare January 28, 2026 09:13
@MartianGreed
MartianGreed merged commit fd6cb32 into main Jan 28, 2026
3 checks passed
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