MCPcopy Create free account
hub / github.com/Thunder-Compute/thunder-cli / IsInteractive

Function IsInteractive

tui/term.go:21–41  ·  view source on GitHub ↗

IsInteractive returns true when stdout is a TTY and the session is suitable for Bubble Tea TUI rendering. Commands use this to decide between interactive TUI and plain-text output paths.

()

Source from the content-addressed store, hash-verified

19// is suitable for Bubble Tea TUI rendering. Commands use this to
20// decide between interactive TUI and plain-text output paths.
21func IsInteractive() bool {
22 if forceNonInteractive || !termx.IsTerminal(os.Stdout.Fd()) {
23 return false
24 }
25 if runtime.GOOS == "windows" {
26 // On Windows, Bubble Tea reads from CONIN$. If stdin isn't a console
27 // (redirected, piped, or spawned by a GUI launcher without a real
28 // conhost), the read fails with "No process is on the other end of
29 // the pipe." Checking stdin is a terminal avoids that.
30 return termx.IsTerminal(os.Stdin.Fd())
31 }
32 // On Unix, Bubble Tea opens /dev/tty for input. Verify it's accessible
33 // to avoid "device not configured" errors in sandboxed environments
34 // where stdout is a PTY but no controlling terminal exists.
35 f, err := os.Open("/dev/tty")
36 if err != nil {
37 return false
38 }
39 f.Close()
40 return true
41}

Callers 10

runPortsForwardFunction · 0.92
RunStatusFunction · 0.92
runSnapshotListFunction · 0.92
runDeleteFunction · 0.92
runConnectWithOptionsFunction · 0.92
runModifyFunction · 0.92
runCreateFunction · 0.92
runSnapshotCreateFunction · 0.92
runSnapshotDeleteFunction · 0.92
RunWithBusySpinnerFunction · 0.85

Calls 2

OpenMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected