Skip to content

ANSI escape codes displayed as literal text on Windows with wezterm + PowerShell 7 #16675

Closed as not planned

Description

@Aaron-myeh

Description

Environment

  • OS: Windows 10
  • Terminal: wezterm
  • Shell: PowerShell 7.4.7
  • Bun version: 1.3.10
  • Node.js: Works correctly
    Problem
    When running opencode-cli on Windows with wezterm terminal, ANSI escape codes are displayed as literal text instead of being rendered as colors/styles.
    Example of corrupted output:
    m┃H Build [
    38; ssion - 2026-03-09T02:30:38.791Z █ 2
    0m 8
    ;238m续 3
    8;2 55m [
    12;4H
    ;
    30m█ 3
    0;30;30m█ 4
    8;2;3 m█
    The escape sequences like [38;2;255;255;255m, [30m, [48;2;30;30;30m
    should render colors, but are shown as plain text.
    Reproduction Steps

1. Install Bun on Windows

2. Use wezterm as terminal

3. Run any Bun-based CLI with colored output

bun -e "console.log('\x1b[31mRed\x1b[0m')"

Expected: "Red" in red color

Actual: "[31mRed[0m" as literal text

What I've Tried

  1. ✅ Node.js works correctly:
    node -e "console.log('\x1b[31mRed\x1b[0m')"

    Output: Red (in red color)

  2. ❌ Setting FORCE_COLOR:
    $env:FORCE_COLOR = "1"

    No effect

  3. ❌ Setting TERM variables:
    $env:TERM = "xterm-256color"
    $env:COLORTERM = "truecolor"

    No effect

  4. ❌ UTF-8 encoding:
    chcp 65001

    No effect

  5. ❌ Modified wezterm.lua:
    config.set_environment_variables = {
    TERM = 'xterm-256color',
    COLORTERM = 'truecolor',
    }
    No improvement.

  6. ✅ PowerShell native colors work:
    Write-Host "Red" -ForegroundColor Red

    Works correctly

  7. ❌ Both opencode versions affected:

    • npx opencode - same issue
    • npx oh-my-opencode - same issue

Environment Variables Check
$env:TERM # xterm-256color ✓
$env:COLORTERM # truecolor ✓
$env:TERM_PROGRAM # WezTerm ✓
chcp # 65001 (UTF-8) ✓

All settings appear correct.
Root Cause Analysis

  • Node.js correctly detects the terminal as TTY and renders ANSI codes
  • Bun appears to not properly handle ANSI escape sequences on Windows + wezterm
  • The issue is specific to Bun on Windows with wezterm (not reproducible with Node.js)

Expected Behavior
ANSI escape codes should render as colors/styles, matching Node.js behavior.
Actual Behavior
ANSI escape codes are printed as literal text, making the UI unreadable.
Suggested Fix
Bun should properly detect Windows terminals (wezterm, Windows Terminal, etc.) and pass ANSI escape codes through correctly, similar to how Node.js handles them.

Plugins

No response

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Activity

  1. github-actions commented on Mar 9, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please review these issues to see if they cover the same problem before continuing. If your issue is distinct, feel free to clarify what makes it different.

  2. adminxxt commented on Jun 18, 2026

    @adminxxt

    Has it been resolved? How to solve @Aaron-myeh
    

  3. github-actions commented on Aug 18, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions