fix: TUI CSI u key parsing and console escape sequence order

- TUI: Add parseCSIuBytes to handle CSI u sequences that bubbletea
  v1.3.6 returns as []byte (unknownCSISequenceMsg). Parses codepoint
  and modifier bits to reconstruct key string for hotkey routing.
- Console: Reorder escape parser checks. Check 2-byte non-CSI
  sequences first, then CSI terminator only after ESC[ introducer.
  Fixes CSI u sequences being truncated at '[' byte (0x5b).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
JiXieShi
2026-05-24 03:25:40 +08:00
parent 319ed108d8
commit b1c499b340
2 changed files with 37 additions and 2 deletions
+4 -2
View File
@@ -189,13 +189,15 @@ func RunConsole(appInst *apppkg.App) error {
break
}
escBuf = append(escBuf, nb)
if nb >= 0x40 && nb <= 0x7e {
// 2-byte non-CSI: ESC + letter (not [)
if len(escBuf) == 2 && escBuf[1] != '[' {
if flushESC(escBuf) {
return nil
}
break
}
if len(escBuf) == 2 && escBuf[1] != '[' {
// CSI terminator: final byte of ESC [ ... <char> sequence
if len(escBuf) > 2 && escBuf[1] == '[' && nb >= 0x40 && nb <= 0x7e {
if flushESC(escBuf) {
return nil
}