MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / detectTerminalImageSupport

Function detectTerminalImageSupport

cli/src/utils/terminal-images.ts:17–50  ·  view source on GitHub ↗
(
  env: CliEnv = getCliEnv(),
)

Source from the content-addressed store, hash-verified

15 * Detect which image protocol the terminal supports
16 */
17export function detectTerminalImageSupport(
18 env: CliEnv = getCliEnv(),
19): TerminalImageProtocol {
20 if (cachedProtocol !== null) {
21 return cachedProtocol
22 }
23
24 // Check for iTerm2
25 if (env.TERM_PROGRAM === 'iTerm.app') {
26 cachedProtocol = 'iterm2'
27 return cachedProtocol
28 }
29
30 // Check for Kitty
31 if (
32 env.TERM === 'xterm-kitty' ||
33 env.KITTY_WINDOW_ID !== undefined
34 ) {
35 cachedProtocol = 'kitty'
36 return cachedProtocol
37 }
38
39 // Check for Sixel support (less common)
40 if (
41 env.TERM?.includes('sixel') ||
42 env.SIXEL_SUPPORT === 'true'
43 ) {
44 cachedProtocol = 'sixel'
45 return cachedProtocol
46 }
47
48 cachedProtocol = 'none'
49 return cachedProtocol
50}
51
52/**
53 * Check if terminal supports inline images

Callers 3

supportsInlineImagesFunction · 0.85
renderInlineImageFunction · 0.85

Calls 1

getCliEnvFunction · 0.90

Tested by

no test coverage detected