MCPcopy Create free account
hub / github.com/diillson/chatcli / RestoreCookedMode

Function RestoreCookedMode

cli/coder/tty_reset.go:40–55  ·  view source on GitHub ↗

RestoreCookedMode is the exported entry-point that callers outside the coder package use to reset the controlling terminal to canonical (cooked, echo-on) mode. Used by the agent loop at the start of every ReAct run to recover from a prior go-prompt teardown that may have left the TTY in raw mode (no

()

Source from the content-addressed store, hash-verified

38// (occasionally-broken-on-resume) behavior, which is what we are
39// trying to improve.
40func RestoreCookedMode() bool {
41 if runtime.GOOS == "windows" || sttyPath == "" {
42 return false
43 }
44 tty, err := os.OpenFile("/dev/tty", os.O_RDWR, 0)
45 if err != nil {
46 return false
47 }
48 defer func() { _ = tty.Close() }()
49
50 cmd := exec.Command(sttyPath, "sane")
51 cmd.Stdin = tty
52 cmd.Stdout = tty
53 cmd.Stderr = tty
54 return cmd.Run() == nil
55}

Callers 1

RunMethod · 0.92

Calls 2

CloseMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected