shouldQuerySynchronizedOutput determines whether the terminal should be queried for various capabilities. This function checks for terminals that are known to support mode 2026, while excluding SSH sessions which may be unreliable, unless it's a known-good terminal like Windows Terminal. The funct
(environ uv.Environ)
| 1037 | // - Terminals with TERM_PROGRAM set (except Apple Terminal) and not in SSH sessions |
| 1038 | // - Specific terminal types: ghostty, wezterm, alacritty, kitty, rio |
| 1039 | func shouldQuerySynchronizedOutput(environ uv.Environ) bool { |
| 1040 | termType := environ.Getenv("TERM") |
| 1041 | termProg, okTermProg := environ.LookupEnv("TERM_PROGRAM") |
| 1042 | _, okSSHTTY := environ.LookupEnv("SSH_TTY") |
| 1043 | _, okWTSession := environ.LookupEnv("WT_SESSION") |
| 1044 | |
| 1045 | return (!okTermProg && !okSSHTTY) || |
| 1046 | okWTSession || |
| 1047 | (okTermProg && !strings.Contains(termProg, "Apple") && !okSSHTTY) || |
| 1048 | strings.Contains(termType, "ghostty") || |
| 1049 | strings.Contains(termType, "wezterm") || |
| 1050 | strings.Contains(termType, "alacritty") || |
| 1051 | strings.Contains(termType, "kitty") || |
| 1052 | strings.Contains(termType, "rio") |
| 1053 | } |
| 1054 | |
| 1055 | // Run initializes the program and runs its event loops, blocking until it gets |
| 1056 | // terminated by either [Program.Quit], [Program.Kill], or its signal handler. |