MCPcopy Create free account
hub / github.com/Facets-cloud/flow / Detect

Function Detect

internal/spawner/spawner.go:73–102  ·  view source on GitHub ↗

Detect returns the backend that SpawnTab will use for the current process environment. Exposed so callers (and tests) can inspect the choice without spawning.

()

Source from the content-addressed store, hash-verified

71// process environment. Exposed so callers (and tests) can inspect the
72// choice without spawning.
73func Detect() Backend {
74 if Override != "" {
75 return Override
76 }
77 if os.Getenv("ZELLIJ") != "" {
78 return BackendZellij
79 }
80 if os.Getenv("KITTY_WINDOW_ID") != "" || os.Getenv("TERM") == "xterm-kitty" {
81 return BackendKitty
82 }
83 if v := os.Getenv("FLOW_TERM"); v != "" {
84 switch Backend(v) {
85 case BackendITerm, BackendTerminal, BackendZellij, BackendKitty, BackendWarp, BackendGhostty:
86 return Backend(v)
87 }
88 // Unknown value falls through to TERM_PROGRAM detection.
89 }
90 switch os.Getenv("TERM_PROGRAM") {
91 case "Apple_Terminal":
92 return BackendTerminal
93 case "iTerm.app":
94 return BackendITerm
95 case "WarpTerminal":
96 return BackendWarp
97 case "ghostty":
98 return BackendGhostty
99 default:
100 return BackendITerm
101 }
102}
103
104// SpawnTab opens a tab in the auto-detected backend. The contract
105// matches every backend's SpawnTab.

Callers 9

SpawnTabFunction · 0.85
FocusSessionFunction · 0.85
TestDetectFromEnvFunction · 0.85
TestOverrideBeatsEnvFunction · 0.85
TestDetectZellijFunction · 0.85
TestDetectKittyFunction · 0.85

Calls 1

BackendTypeAlias · 0.85

Tested by 7

TestDetectFromEnvFunction · 0.68
TestOverrideBeatsEnvFunction · 0.68
TestDetectZellijFunction · 0.68
TestDetectKittyFunction · 0.68