#1631·jcode

Mermaid/images fall back to text inside herdr >=0.9.3 (KITTY_WINDOW_ID stripped, TERM_PROGRAM=herdr not detected)

Author: nanocortexCreated Oct 1, 2026Updated Oct 1, 2026

Summary

Since herdr v0.9.3, mermaid diagrams and inline images inside herdr panes fall back to text ("Your terminal cannot render inline images; showing a text fallback."), even when the outer terminal is kitty and herdr's terminal.kitty_graphics = true (the default).

Cause

herdr now sanitizes pane env (herdrdev/herdr#4461, in apply_pane_terminal_env): it removes KITTY_WINDOW_ID (and other host handles) and sets TERM=xterm-256color, TERM_PROGRAM=herdr. Separately, herdrdev/herdr#4561 added native kitty graphics passthrough to capable outer terminals.

jcode's infer_protocol_from_env (crates/jcode-tui-mermaid/src/mermaid_runtime.rs) only returns Kitty on KITTY_WINDOW_ID or kitty/ghostty in TERM/TERM_PROGRAM, and the picker uses Fast mode (no DA1/graphics probe) by default, so inside herdr it now gets env_protocol=None.

Log evidence (same machine, kitty outer terminal):

2026-09-30 ... Mermaid picker init: mode=Fast multiplexer=herdr env_protocol=Some(Kitty)   # herdr fork build, KITTY_WINDOW_ID inherited
2026-10-01 ... Mermaid picker init: mode=Fast multiplexer=herdr env_protocol=None          # herdr 0.9.3

kitten icat renders correctly in the same herdr pane once KITTY_WINDOW_ID=1 is exported, so passthrough works. Only detection is missing.

Suggested fix

Treat TERM_PROGRAM=herdr (or HERDR_ENV=1) as Kitty-capable, or probe graphics support when the multiplexer is herdr. herdr exposes no env signal for whether kitty passthrough is active for the current client, so a probe (JCODE_MERMAID_PICKER_PROBE=1 path) might be the safest default for herdr.

Workaround

bash
if [[ "$HERDR_ENV" == 1 && -z "$KITTY_WINDOW_ID" ]]; then export KITTY_WINDOW_ID=1; fi

Versions: jcode v0.89.3, herdr v0.9.3, kitty on macOS (aarch64). Related: #1529.