fix: terminal hangs, right arrow blocking, and runaway iris processes (#142)
closes #137 - right arrow consumed the escape sequence without forwarding it, so the cursor couldn't move back right after moving left (60149a2) - p10k's instant prompt redirects stdout to a temp file that exec iris inherits, sending the overlay there instead of the terminal and looking like a dead keyboard. Reopens /dev/tty when stdout isn't a terminal (7ebbb0c) - zsh/bash autostart lacked the interactivity check fish already had, so agentic tools sourcing your rc file spawned a rogue iris that seized /dev/tty (5fe58be)
This commit is contained in:
@@ -107,6 +107,17 @@ func writeStdout(data []byte) {
|
||||
_, _ = os.Stdout.Write(data)
|
||||
}
|
||||
|
||||
func restoreStdoutTTY() {
|
||||
if term.IsTerminal(int(os.Stdout.Fd())) {
|
||||
return
|
||||
}
|
||||
tty, err := os.OpenFile("/dev/tty", os.O_WRONLY, 0)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
os.Stdout = tty
|
||||
}
|
||||
|
||||
// restoreTerminal restores the terminal state if needed
|
||||
func restoreTerminal() {
|
||||
oldStateMu.Lock()
|
||||
@@ -129,6 +140,8 @@ func syncProcessCWD(cwd string) {
|
||||
// it handles raw terminal mode to intercept keystrokes and
|
||||
// coordinates between the shell process and the suggestion overlay
|
||||
func runWrapper() {
|
||||
restoreStdoutTTY()
|
||||
|
||||
var naiveBuffer string
|
||||
var lastSubmittedCommand string
|
||||
cursorOffset := 0
|
||||
@@ -1057,6 +1070,7 @@ func runWrapper() {
|
||||
}
|
||||
continue
|
||||
}
|
||||
rawSeq := append([]byte(nil), inputSlice[i:i+navConsumed]...)
|
||||
i += navConsumed - 1
|
||||
intercepted = true
|
||||
bufferMu.Lock()
|
||||
@@ -1095,6 +1109,7 @@ func runWrapper() {
|
||||
userNavigated.Store(false)
|
||||
}
|
||||
bufferMu.Unlock()
|
||||
_, _ = ptmx.Write(rawSeq)
|
||||
isLeftRightArrow = true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user