{"record":{"id":"7c8aa9da1d877842","repo":"plandex-ai/plandex","slug":"failed-to-read-keypress-s","errorCode":null,"errorMessage":"failed to read keypress: %s","messagePattern":"failed to read keypress: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/term/prompt.go","lineNumber":81,"sourceCode":"\n\tif err != nil && err.Error() == \"user quit prompt\" {\n\t\tos.Exit(0)\n\t}\n\n\treturn res, err\n}\n\nfunc GetUserKeyInput() (rune, keyboard.Key, error) {\n\tif err := keyboard.Open(); err != nil {\n\t\treturn 0, 0, fmt.Errorf(\"failed to open keyboard: %s\", err)\n\t}\n\tdefer func() {\n\t\t_ = keyboard.Close()\n\t}()\n\n\tchar, key, err := keyboard.GetKey()\n\tif err != nil {\n\t\treturn 0, 0, fmt.Errorf(\"failed to read keypress: %s\", err)\n\t}\n\n\treturn char, key, nil\n}\n\nfunc ConfirmYesNo(fmtStr string, fmtArgs ...interface{}) (bool, error) {\n\tcolor.New(ColorHiMagenta, color.Bold).Printf(fmtStr+\" (y)es | (n)o\", fmtArgs...)\n\tcolor.New(ColorHiMagenta, color.Bold).Print(\"> \")\n\n\tchar, key, err := GetUserKeyInput()\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to get user input: %s\", err)\n\t}\n\n\t// ctrl+c == no\n\tif key == keyboard.KeyCtrlC {\n\t\treturn false, nil\n\t}","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/term/prompt.go#L63-L99","documentation":"GetUserKeyInput wraps failures from keyboard.GetKey — the terminal was successfully put in raw mode but reading a keystroke failed. This is rarer than open failure and usually indicates the input stream closed or a low-level read error.","triggerScenarios":"keyboard.GetKey() returns an error: stdin EOF (terminal closed, Ctrl+D on some platforms), read interrupted fatally, or device error during raw read.","commonSituations":"Terminal window closed while prompt waits; stdin detached mid-prompt; unusual terminal emulators or tmux/screen edge cases interrupting the raw read.","solutions":["Re-run the command; transient read interruptions usually don't recur","Make sure the terminal stays open while the prompt is active","Check tmux/screen/SSH connection stability if running remotely","If reproducible, test in a plain terminal without multiplexers to isolate the cause"],"exampleFix":"null","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt := 0; attempt < 2; attempt++ {\n    char, key, err := term.GetUserKeyInput()\n    if err == nil { use(char, key); break }\n    if attempt == 1 { return fmt.Errorf(\"keypress unavailable: %w\", err) }\n}","preventionTips":["Keep the terminal open while prompts are active","Check tmux/screen/SSH stability for remote sessions","Retest in a plain terminal to rule out emulator quirks"],"tags":["go","keyboard","terminal","stdin"],"backgroundTag":"keypress-read-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}