github / github/copilot-cli

[Bug] CLI downgrades TERM from xterm-256color to xterm-color — diff highlighting has no colors

Aberta
#2,902 0 comentários 0 reações 0 responsáveis Ver no GitHub
area:terminal-rendering area:tools
Linguagem predominante
Shell
Estrelas
11.2k
Forks
1.9k
Merge médio
14h 16min
PRs com merge (30d)
6

Descrição

### Describe the bug

The Copilot CLI binary overrides `TERM=xterm-256color` to `TERM=xterm-color` (8 colors) when spawning its bash subshells. This causes diff highlighting to show **no colors at all** — only `+`/`-` markers are visible with no red/green background highlighting, making it impossible to review changes.

### Screenshot

Image

> The diff shows `+` and `-` markers but no red/green color highlighting. All text is the same color, making it very difficult to identify changes.

### Evidence

The parent copilot process inherits the correct TERM from the terminal:
```
Parent copilot process: TERM=xterm-256color, COLORTERM=truecolor
Child bash subprocess: TERM=xterm-color, COLORTERM=truecolor
```

Verified via `ps -p -E` — the parent has `xterm-256color`, but the spawned `bash --norc --noprofile` subprocess gets `xterm-color` (only 8 colors).

### Impact

- Diff output shows `+` and `-` markers but **zero color highlighting** (no red/green backgrounds)
- All CLI themes tested (`default`, `high-contrast`, `dim`, `colorblind`) show the same issue
- Development workflow is blocked — cannot visually review proposed changes
- This works correctly on Windows, where TERM is not overridden

### Environment

- **Copilot CLI version:** 1.0.34 (binary at `/opt/homebrew/Caskroom/copilot-cli/1.0.32/copilot`)
- **OS:** macOS (Darwin, Apple Silicon)
- **Terminals tested:** Ghostty 1.3.1, macOS Terminal.app — same result in both
- **Terminal multiplexer:** Zellij (but TERM is correct before CLI overrides it)
- **Shell:** zsh (CLI spawns `bash --norc --noprofile`)

### Steps to reproduce

1. On macOS, confirm terminal has `TERM=xterm-256color` (e.g. Ghostty, iTerm2, Terminal.app)
2. Launch `copilot`
3. Ask Copilot to edit any file
4. Observe the diff preview — no color highlighting on added/removed lines
5. Verify inside the CLI session: `echo $TERM` shows `xterm-color` instead of the terminal's `xterm-256color`

### Expected behavior

The CLI should preserve the terminal's TERM value (`xterm-256color`) or at minimum use `COLORTERM=truecolor` (which IS correctly inherited) for rendering decisions. Diff highlighting should show colored backgrounds for added/removed lines.

### Related issues

- #1813 — Diff highlights entire line (users there at least have colors)
- #1818 — Diff highlight colors broken (fixed, but those users had colors too)
- #1847 — Code diffs hard to see in dark mode (fixed)
- #2216 — Low contrast text selection

Guia de contribuição

Abrir o guia de contribuição

Direção de pesquisa

Reproduzir no macOS com TERM=xterm-256color e inspecionar o ambiente passado ao subprocesso bash --norc --noprofile iniciado pelo binário copilot. Rastrear onde TERM muda de xterm-256color para xterm-color e, em seguida, verificar se o processo filho preserva o valor do terminal e se diff previews volta a exibir com cores as linhas adicionadas e removidas.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
bash, macos, shell
Domínio
cli, operating-systems
Tipo de issue
Bug
Dificuldade
3/5
Tempo estimado
1-2 dias
Status de atividade
Pouca atividade
Clareza
Razoavelmente clara
Facilidade para iniciantes
58/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.