Skip to content

Claude's answers, rendered: Markdown, math, charts and diagrams drawn in the Claude Code terminal. Independent project, not affiliated with Anthropic.

TypeScript claude-code-mod

Background: draw only with CLAUDE_CODE_FORCE_TERMINAL_IMAGES as well as IUI_FORCE (the session's TERM is xterm-256color, so the engine draws only with it)

razorback169f75ff77342c
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a5e5753..27366f6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,7 +12,7 @@ All releases of Intelligent UI for Claude Code (`cc-intelligent-ui`). Claude Cod
### Fixed
-- **Background sessions with `IUI_FORCE=1`.** A background session (`claude --bg`, `claude attach`) now tries to show pictures when `IUI_FORCE=1` is set, also when the daemon started in tmux. Before, it never showed pictures. ([#2](https://github.com/razorback16/cc-intelligent-ui/issues/2))
+- **Background sessions with `IUI_FORCE=1`.** A background session (`claude --bg`, `claude attach`) now shows pictures when `IUI_FORCE=1` and `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` are set, also when the daemon started in tmux. Without both, answers stay text, because Claude Code draws no pictures there. Before, it never showed pictures. ([#2](https://github.com/razorback16/cc-intelligent-ui/issues/2))
## 0.3.4 (2026-10-25)
diff --git a/docs/install.md b/docs/install.md
index de4880d..d4ece8e 100644
--- a/docs/install.md
+++ b/docs/install.md
@@ -24,7 +24,7 @@
- The mod uses them only where it cannot read the terminal. On your own computer, the terminal's settings win. `/iui details` shows `terminal font JetBrains Mono (IUI_FONT)` and `mode dark (auto, from IUI_MODE)`.
- **Warp and WezTerm (not yet):** they do not draw kitty pictures with Unicode placeholders. Support comes when [warpdotdev/warp#16312](https://github.com/warpdotdev/warp/pull/16312) and [wezterm/wezterm#7924](https://github.com/wezterm/wezterm/pull/7924) are merged.
- **Not supported:** Konsole (no Unicode placeholders), Alacritty, Terminal.app, Windows Terminal, GNOME Terminal and other VTE terminals, foot, VS Code, Tabby, Hyper and JetBrains terminals (no kitty pictures).
-- **Background sessions** (agent view, forks, `claude attach`): no pictures by default. A background session has the variables of the daemon, not of your terminal. Set `IUI_FORCE=1` in the session's environment to try. When the terminal is on another computer, also set `IUI_INLINE=1` (the daemon has no `SSH_CONNECTION`).
+- **Background sessions** (agent view, forks, `claude attach`): no pictures by default. A background session has the variables of the daemon, not of your terminal. A background session runs with `TERM=xterm-256color`, so Claude Code draws pictures there only with `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1`. Set it and `IUI_FORCE=1` where the daemon starts (the first `claude --bg` or `claude agents` starts it, and a running daemon keeps its variables: `claude daemon stop --any` stops it). When the terminal is on another computer, also set `IUI_INLINE=1` (the daemon has no `SSH_CONNECTION`).
Where pictures cannot show, you see the normal text. `/iui details` tells you why.
diff --git a/hooks/lib/terminal.ts b/hooks/lib/terminal.ts
index 4b9e49f..bbd02d9 100644
--- a/hooks/lib/terminal.ts
+++ b/hooks/lib/terminal.ts
@@ -282,13 +282,16 @@ export function needsSetup(o: { iterm: boolean; herdr: boolean; draws: boolean;
// Whether the engine draws pictures here; elsewhere an Image shows only its
// alt, so the text is better. Claude Code turns kitty graphics on by itself
// only for kitty and Ghostty; any other terminal draws only when
-// CLAUDE_CODE_FORCE_TERMINAL_IMAGES is set. In a background session (its
-// variables are the daemon's), tmux or screen (the engine does not wrap them
-// for passthrough) only IUI_FORCE tries. Over ssh
+// CLAUDE_CODE_FORCE_TERMINAL_IMAGES is set. A background session runs with
+// TERM=xterm-256color (its other variables are the daemon's), so the engine
+// draws there only with that variable, and the mod only with IUI_FORCE too.
+// In tmux or screen (the engine does not wrap them for passthrough) only
+// IUI_FORCE tries. Over ssh
// TERM_PROGRAM and KITTY_WINDOW_ID do not come through, so TERM tells; the
// pictures then go as bytes (Env.inline), as the terminal can't read our files.
export function canDrawIn(env: { program: string; term: string; kitty: boolean; tmux: boolean; ssh: boolean; background: boolean; engineForced: boolean; modForced: boolean }): boolean {
- if (env.background || env.tmux) return env.modForced
+ if (env.background) return env.modForced && env.engineForced
+ if (env.tmux) return env.modForced
if (env.engineForced || env.modForced) return true
if (env.ssh) return /ghostty|kitty/i.test(env.term)
return /ghostty/i.test(env.program + env.term) || /kitty/i.test(env.term) || env.kitty
diff --git a/hooks/register.tsx b/hooks/register.tsx
index 5cc65fc..27f1e91 100644
--- a/hooks/register.tsx
+++ b/hooks/register.tsx
@@ -1162,7 +1162,7 @@ export const register: Register = on => {
? `this terminal draws pictures${ready.inline ? (S.isRemote ? ' (over ssh, sent as bytes)' : ' (sent as bytes: IUI_INLINE)') : ''}`
: S.isHerdr && S.setupNeeded
? 'Claude Code draws no pictures in herdr until CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1 is set when it starts (run /iui setup), so answers stay text'
- : 'Claude Code draws no pictures here (it does in kitty and Ghostty, in iTerm2 3.6+, Rio 0.5.27+ and herdr with CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1, over ssh when TERM names kitty or Ghostty or with that variable; in tmux, screen or a background session only with IUI_FORCE=1; not in WezTerm, Warp, Konsole or others), so answers stay text'
+ : 'Claude Code draws no pictures here (it does in kitty and Ghostty, in iTerm2 3.6+, Rio 0.5.27+ and herdr with CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1, over ssh when TERM names kitty or Ghostty or with that variable; in tmux or screen only with IUI_FORCE=1, in a background session only with IUI_FORCE=1 and CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1; not in WezTerm, Warp, Konsole or others), so answers stay text'
// In herdr: its version, the terminal it runs in and where that came from (and flip mode).
const herdr = S.isHerdr ? `terminal ${herdrText(S.herdrVersion, S.herdrHost, S.herdrClient ? (S.herdrBy === 'front' ? 'front' : 'client') : 'server', isFlipHere(ready))}: ` : ''
await clipWayReady()
diff --git a/tests/draw.test.ts b/tests/draw.test.ts
index b60f34e..890d168 100644
--- a/tests/draw.test.ts
+++ b/tests/draw.test.ts
@@ -19,11 +19,12 @@ test('tmux and screen draw no pictures, even with the engine forced; only IUI_FO
expect(canDrawIn({ ...base, tmux: true, modForced: true })).toBe(true)
})
-test('a background session draws pictures only with IUI_FORCE, also with tmux in its TERM', () => {
+test('a background session draws pictures only with IUI_FORCE and CLAUDE_CODE_FORCE_TERMINAL_IMAGES, also with tmux in its TERM', () => {
expect(canDrawIn({ ...base, program: 'ghostty', background: true })).toBe(false)
expect(canDrawIn({ ...base, term: 'xterm-kitty', background: true, engineForced: true })).toBe(false)
- expect(canDrawIn({ ...base, term: 'xterm-kitty', background: true, modForced: true })).toBe(true)
- expect(canDrawIn({ ...base, term: 'tmux-256color', tmux: true, background: true, modForced: true })).toBe(true)
+ expect(canDrawIn({ ...base, term: 'xterm-kitty', kitty: true, background: true, modForced: true })).toBe(false)
+ expect(canDrawIn({ ...base, background: true, modForced: true, engineForced: true })).toBe(true)
+ expect(canDrawIn({ ...base, term: 'tmux-256color', tmux: true, background: true, modForced: true, engineForced: true })).toBe(true)
})
test('pictures go as bytes over ssh, or as IUI_INLINE says when it is set', () => {
@@ -298,8 +299,8 @@ const props = (text: string) => ({ text, isFirstOfReply: true }) as any
const images = (tree: any): any[] =>
tree && typeof tree === 'object' ? [...(tree.type === 'Image' ? [tree] : []), ...(tree.children ?? []).flatMap(images)] : []
-test('in a background session with IUI_FORCE and IUI_INLINE, a page goes as PNG bytes', async ($, on) => {
- const { clock } = world(on, { CLAUDE_CODE_SESSION_KIND: 'bg', TERM: 'tmux-256color', IUI_FORCE: '1', IUI_INLINE: '1' })
+test('in a background session with IUI_FORCE, CLAUDE_CODE_FORCE_TERMINAL_IMAGES and IUI_INLINE, a page goes as PNG bytes', async ($, on) => {
+ const { clock } = world(on, { CLAUDE_CODE_SESSION_KIND: 'bg', TERM: 'tmux-256color', IUI_FORCE: '1', CLAUDE_CODE_FORCE_TERMINAL_IMAGES: '1', IUI_INLINE: '1' })
const ran = await $.command.run({ command: 'iui', args: 'details' } as any)
expect(ran.text).toContain('sent as bytes: IUI_INLINE')
const ui = await $.ui.mount(message('bg-1', 'Some **bold** text.'))