1jehuang / 1jehuang/jcode

[Windows Terminal] Native mermaid/inline image rendering via Sixel (WT_SESSION detection missing)

Open
#955 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

autonomous: no bug enhancement priority: medium triage: needs-decision
Dominant language
Rust
Stars
19.9k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
30

Description

Problem

On Windows Terminal, inline images (mermaid diagrams, LaTeX, image attachments) fall back to the Unicode half-block text renderer with the note
│ "Your terminal cannot render inline images; showing a text fallback." even though Windows Terminal 1.22+ natively supports Sixel graphics,
│ including passthrough of image sequences from console apps through ConPTY.

Root cause

crates/jcode-tui-mermaid/src/mermaid_runtime.rs::infer_protocol_from_env recognizes wezterm / kitty / ghostty / handterm / iterm and TERM containing "sixel", but Windows Terminal sets none of these (it exposes only WT_SESSION, WT_PROFILE_ID, WT_WINDOW_ID), so the picker stays on the Halfblocks fallback. The CLI-side detection in crates/jcode-terminal-image/src/display.rs::ImageProtocol::detect has the same gap.

Verified end-to-end

  • Environment: Windows Terminal Preview 1.25 (bundled OpenConsole), Windows 10/11.
  • Method: force the Sixel branch with set TERM=sixel-256color && jcode, then render a flowchart.
  • Result: the flowchart renders natively via Sixel, clearly readable, with no fallback note. jcode logs:
    Mermaid picker init: mode=Fast multiplexer=none env_protocol=Some(Sixel).
    The same flow without the TERM override logs env_protocol=None and shows the half-block fallback.
  • Minor quality note: node text is slightly blurry due to Windows Terminal scaling Sixel images to whole-cell boundaries. Likely improvable by rendering at measured pixel sizes (mmdr size API), not a blocker.

Proposed change

Add Windows Terminal detection to the fast env-based path, e.g. in infer_protocol_from_env:

if WT_SESSION is set -> return ProtocolType::Sixel and mirror it in the CLI crate's ImageProtocol::detect (without the ImageMagick requirement used by its Sixel path, since ratatui-image encodes Sixel itself).

Considerations:

  • Requires Windows Terminal >= 1.22 (Sixel support; older versions would render raw Sixel bytes). Consider gating on a capability probe or documenting the minimum version.
  • Verify inline mermaid diagrams in chat and side panel under WT 1.22+: placeholder geometry, scroll/resize behavior, session restore.

Workarounds today

set TERM=sixel-256color && jcode in Windows Terminal enables native rendering immediately.

  • Alacritty cannot be fixed app-side: it supports no image protocol at all.

Related

  • Halfblock fallback note: TERMINAL_IMAGE_FALLBACK_NOTE in crates/jcode-tui-mermaid/src/mermaid_content.rs

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with infer_protocol_from_env in crates/jcode-tui-mermaid/src/mermaid_runtime.rs and ImageProtocol::detect in crates/jcode-terminal-image/src/display.rs, then review the existing Sixel and environment detection paths. Verify Windows Terminal 1.22+ renders inline mermaid images without the half-block fallback, including chat and side-panel resize, scrolling, and session restore behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.