Skip to content

capital letters and punctuation not typed in vibe CLI since post-0.7.5 #2020

Closed

Description

@jakenvac

Is this a reproducible bug?

  • I confirm this is a reproducible bug, not a feature request, idea, question, contribution proposal, or direction check.
  • I reproduced this bug on the version and environment reported below using the exact steps provided.

Current behavior

Just from the top, this wasn't an issue on 0.7.5, but somewhere since, inputs have broken.

When using the mistral vibe cli inside herdr, I am unable to insert capital letters or punctuation (such as : etc.) I can only insert lower case letters and numbers. Seems like shift and some other keys are getting lost.

This is reproducible on e16d7d8c07a20f5ee0b4111808680bbcfd7df9ac, which was the latest commit on master at the time of writing.

I've had claude code investigate and fix the issue, and I have compiled and tested the fix myself and can confirm it works. However, I don't want to submit a PR that I don't fully understand. I'll share those details in a comment below, as this issue template doesn't really work for that.

Expected behavior

I would expect to be able to use vibe cli inside herdr. (There is no official integration or anything like that, just basic usage)

Reproduction

Run vibe cli inside herdr. (You can use a free account for testing)
Try to insert capital letters or punctuation into the prompt field. They won't appear.

Impact

I can't use vibe cli inside herdr.

Environment

  • Herdr version: e16d7d8
  • Update channel (stable or preview): preview
  • Operating system: Linux
  • Terminal: Ghostty
  • Shell, if relevant: Zsh
  • Relevant config, if any: None

Activity

  1. jakenvac commented on Jul 29, 2026

    @jakenvac
    Author

    I've had claude prepare an explanation for the fix and a diff, so that someone who does know what they're doing can take a proper look. I have tested the proposed fix, and it does work.

    I'm alright with rust, but terminal protocols etc. aren't my strength. Happy to keep researching and will submit the PR myself if I'm confident I understand it.

    Please keep in mind, everything below this is generated by claude code.


    Summary

    Typing capital letters (e.g. A) and punctuation requiring Shift (e.g. !) does
    not work when using the Mistral vibe CLI inside Herdr on any version after 0.7.5.
    The same inputs work correctly in other agent CLIs such as OpenCode.

    Environment

    • herdr: post-0.7.5 (regression not present in 0.7.5)
    • vibe: 2.22.0 (Python, uses the Textual TUI framework)
    • OS: Linux

    Root cause

    Commit e7fc85bf ("fix: preserve kitty printable key releases") changed the
    encoding priority in try_encode_csi_u / encode_terminal_key. For panes that
    push REPORT_ALL_KEYS (Kitty flag bit 3), the new code tries Kitty CSI u
    encoding before plain text encoding (kitty_first = true).

    The vibe CLI is built on Textual, which pushes this Kitty stack on startup:

    \x1b[>25u
    

    That is flags 1 | 8 | 16:

    Bit Flag Set?
    1 DISAMBIGUATE_ESCAPE_CODES yes
    2 REPORT_EVENT_TYPES no
    4 REPORT_ALTERNATE_KEYS no
    8 REPORT_ALL_KEYS yes
    16 REPORT_ASSOCIATED_TEXT yes

    Because REPORT_ALTERNATE_KEYS is absent, Herdr's alternate_shifted_codepoint
    returns None for every key. Because REPORT_ASSOCIATED_TEXT is not currently
    handled, the CSI u sequence has no third field.

    So Shift+A is encoded as:

    \x1b[97;2u      (base=97='a', modifier=2=Shift, no text field)
    

    Textual's _parse_extended_key sees codepoint 97 and no associated text. Its
    shift-reporting logic only adds a "shift" token when text is None or text.isspace(), so it yields:

    Key(key='shift+a', character=None, is_printable=False)

    character=None means Textual's input widget inserts nothing. The same problem
    applies to punctuation: Shift+1 becomes \x1b[49;2u, parsed as
    Key('shift+1', character=None) instead of Key('exclamation_mark', character='!').

    Before e7fc85bf, the old code tried encode_text_input first, which returned
    the plain byte A or !. Textual parsed those as printable characters directly.

    OpenCode works because it pushes all five Kitty flags including
    REPORT_ALTERNATE_KEYS (4). That causes the host terminal to include the
    alternate/shifted codepoint in its own sequences (e.g. \x1b[97:65;2:1u).
    Herdr re-encodes that with the alternate field, which OpenCode's full Kitty-aware
    TUI can decode correctly.

    Proposed fix

    Populate the associated text field (third ; section in the CSI u sequence)
    in try_encode_csi_u when the pane has REPORT_ASSOCIATED_TEXT set and the
    event is a press or repeat. The field carries the Unicode scalar value of the
    character that would actually be inserted.

    With the fix, Shift+A becomes:

    \x1b[97;2;65u   (base=97='a', modifier=2=Shift, text=65='A')
    

    Textual then produces:

    Key(key='A', character='A', is_printable=True)   # inserts 'A'

    And Shift+1 (with shifted_codepoint=Some('!')) becomes:

    \x1b[49;2;33u   (base=49='1', modifier=2=Shift, text=33='!')
    
    Key(key='exclamation_mark', character='!', is_printable=True)   # inserts '!'

    The change is purely additive: panes that did not request REPORT_ASSOCIATED_TEXT
    see no change to their sequences.

    Diff

    diff --git a/src/input/encode.rs b/src/input/encode.rs
    index 0ea011ed..1820e1d9 100644
    --- a/src/input/encode.rs
    +++ b/src/input/encode.rs
    @@ -5,6 +5,7 @@ use super::{KeyboardProtocol, MouseProtocolEncoding, TerminalKey};
     
     const KITTY_FLAG_REPORT_EVENT_TYPES: u16 = 0b0000_0010;
     const KITTY_FLAG_REPORT_ALTERNATE_KEYS: u16 = 0b0000_0100;
    +const KITTY_FLAG_REPORT_ASSOCIATED_TEXT: u16 = 0b0001_0000;
     
     /// Encode a key event for a PTY child using the pane's negotiated keyboard protocol.
     #[allow(dead_code)] // exercised in input unit tests; production uses TerminalRuntime helpers
    @@ -238,16 +239,48 @@ fn try_encode_csi_u(key: &TerminalKey, flags: u16) -> Option<Vec<u8>> {
     
         let modifier = kitty_modifier(mods);
     
    -    let sequence = match (alternate_shifted, event_suffix) {
    -        (Some(shifted), Some(event)) => format!("\x1b[{codepoint}:{shifted};{modifier}:{event}u"),
    -        (Some(shifted), None) => format!("\x1b[{codepoint}:{shifted};{modifier}u"),
    -        (None, Some(event)) => format!("\x1b[{codepoint};{modifier}:{event}u"),
    -        (None, None) => format!("\x1b[{codepoint};{modifier}u"),
    +    // When REPORT_ASSOCIATED_TEXT is set and the key is a press or repeat event,
    +    // include the typed text codepoint as the third field. This lets applications
    +    // that request REPORT_ALL_KEYS (but not REPORT_ALTERNATE_KEYS) recover the
    +    // actual character without having to infer it from key+modifiers. Textual-based
    +    // TUI apps (such as the Mistral vibe CLI) rely on this field to insert text.
    +    let associated_text = if flags & KITTY_FLAG_REPORT_ASSOCIATED_TEXT != 0
    +        && key.kind != crossterm::event::KeyEventKind::Release
    +    {
    +        text_codepoint_for_key(key)
    +    } else {
    +        None
    +    };
    +
    +    let sequence = match (alternate_shifted, event_suffix, associated_text) {
    +        (Some(alt), Some(ev), Some(text)) => {
    +            format!("\x1b[{codepoint}:{alt};{modifier}:{ev};{text}u")
    +        }
    +        (Some(alt), Some(ev), None) => format!("\x1b[{codepoint}:{alt};{modifier}:{ev}u"),
    +        (Some(alt), None, Some(text)) => format!("\x1b[{codepoint}:{alt};{modifier};{text}u"),
    +        (Some(alt), None, None) => format!("\x1b[{codepoint}:{alt};{modifier}u"),
    +        (None, Some(ev), Some(text)) => format!("\x1b[{codepoint};{modifier}:{ev};{text}u"),
    +        (None, Some(ev), None) => format!("\x1b[{codepoint};{modifier}:{ev}u"),
    +        (None, None, Some(text)) => format!("\x1b[{codepoint};{modifier};{text}u"),
    +        (None, None, None) => format!("\x1b[{codepoint};{modifier}u"),
         };
     
         Some(sequence.into_bytes())
     }
     
    +/// Compute the associated text codepoint for a key event — the Unicode scalar
    +/// value of the character that would actually be inserted when the key is typed.
    +/// Returns None for non-printable keys or keys whose text cannot be determined.
    +fn text_codepoint_for_key(key: &TerminalKey) -> Option<u32> {
    +    let bytes = encode_text_input(key)?;
    +    if bytes.is_empty() {
    +        return None;
    +    }
    +    let text = std::str::from_utf8(&bytes).ok()?;
    +    let ch = text.chars().next()?;
    +    Some(ch as u32)
    +}
    +
     /// Legacy terminal encoding (standard escape sequences).
     fn encode_legacy(key: TerminalKey) -> Vec<u8> {
  2. added
    akbash-triage
    and removed
    akbash-triage
    on Jul 29, 2026
  3. added
    akbash-working
    bug
    auto-fix
    and removed
    akbash-triage
    auto-fix
    akbash-working
    on Jul 29, 2026
  4. kangal-bot commented on Jul 30, 2026

    @kangal-bot
    Collaborator

    Implemented on master and queued for the next release. This is not available in a published Herdr release yet.

  5. kangal-bot commented on Aug 3, 2026

    @kangal-bot
    Collaborator

    Released in v0.8.0.

  6. added a commit that references this issue on Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugwaiting-pr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions