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
Remote: IUI_FONT and IUI_MODE name the terminal font and the mode where the mod can't read them (ssh, herdr --remote)
razorback163818e20d9d10
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c6c26f5..a5e5753 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,7 @@ All releases of Intelligent UI for Claude Code (`cc-intelligent-ui`). Claude Cod- **Images that Claude reads.** When Claude opens a PNG, JPEG or WebP image with the Read tool, the image draws under the expanded Read row (ctrl+o, `--verbose`, or an unfolded group) as a small preview, as a pasted image does. The folded line (`Read 2 files`) stays as it is. Refer to [Images that Claude reads](docs/usage.md#images-that-claude-reads). ([#2](https://github.com/razorback16/cc-intelligent-ui/issues/2))- **`IUI_INLINE`.** `IUI_INLINE=1` sends pictures as data, as over ssh. `IUI_INLINE=0` makes the terminal read the files, also over ssh. Use it where the mod cannot see ssh, such as in a background session.+- **`IUI_FONT` and `IUI_MODE`.** Over ssh, and with `herdr --remote`, the mod cannot read your terminal's font or background. Set `IUI_FONT` (the font family) and `IUI_MODE` (`light` or `dark`, for the `auto` theme) in the remote computer's shell start file to name them. The mod uses them only where it cannot read the terminal, and `/iui details` names them. Refer to [Terminals](docs/install.md#terminals).### Fixeddiff --git a/docs/how-it-works.md b/docs/how-it-works.mdindex ad481ed..2d63723 100644--- a/docs/how-it-works.md+++ b/docs/how-it-works.md@@ -17,7 +17,7 @@## Text size and fonts- **Matched size.** The mod finds the terminal font and the cell size in pixels, and Typst measures both fonts, so 100% looks as large as the terminal text. Body text and code use the terminal font.-- **Font source.** The iTerm2 profile, or the Ghostty, kitty or Rio config. On Linux, else fontconfig's `monospace`. Else the theme's code font (Menlo on macOS).+- **Font source.** The iTerm2 profile, or the Ghostty, kitty or Rio config. Else `IUI_FONT` (the only source over ssh). On Linux, else fontconfig's `monospace`. Else the theme's code font (Menlo on macOS).- **The font the terminal really draws.** If the configured font is not installed, the mod follows the terminal's own fallback (for example Menlo for kitty on macOS, your fixed-pitch font for iTerm2).- **Built-in fonts.** With no font configured, Ghostty and cmux draw their own JetBrains Mono, and Rio its own Cascadia Code NF. These live inside the terminal program, so the mod copies them once per terminal version to `~/.cache/cc-intelligent-ui/fonts/`.- **Fake bold.** If the terminal font has no bold face (for example Monaco), bold text gets a thin outline, as a terminal draws it.@@ -94,9 +94,12 @@ Claude Code finds light or dark for `auto` by asking the terminal for its backgr- **cmux** also reads its own `config.ghostty`, where the cmux themes picker writes, and that theme wins. With no theme or colours set, cmux uses its adaptive default theme, and the mod follows cmux's appearance setting (`app.appearance` in `~/.config/cmux/cmux.json`).3. **The kitty config:** the `background` in `kitty.conf` and its `include` files. With `dark-theme.auto.conf`, `light-theme.auto.conf` or `no-preference-theme.auto.conf` (kitty 0.38 and later), the file for the OS appearance. With no `background`, kitty's default (dark).4. **The Rio config:** `config.toml`. With `[adaptive-theme]`, the theme for `force-theme` or the OS appearance. Else the `theme` file, else `[colors] background`, else Rio's default (dark).-5. **`COLORFGBG`**, as it was when Claude Code started.-6. **The OS appearance:** macOS Dark or Light. On Linux, the freedesktop portal's `color-scheme`, else GNOME's `color-scheme`.-7. **Dark.**+5. **`IUI_MODE`:** `light` or `dark`, when you set it.+6. **`COLORFGBG`**, as it was when Claude Code started.+7. **The OS appearance:** macOS Dark or Light. On Linux, the freedesktop portal's `color-scheme`, else GNOME's `color-scheme`.+8. **Dark.**++Over ssh, only `IUI_MODE`, `COLORFGBG` and dark: the configs and the OS appearance there are the remote computer's.The terminal comes before the OS: a dark terminal on a light Mac is dark. The mod checks every 3 s, and after a change each mode's pictures compile once. `/iui probe` sends OSC 11 and shows the raw answers, to test whether they can reach the mod.diff --git a/docs/install.md b/docs/install.mdindex c0c1620..de4880d 100644--- a/docs/install.md+++ b/docs/install.md@@ -18,6 +18,10 @@- **ssh:** works when your local terminal is kitty or Ghostty (`TERM` must come through ssh), or when you set `CLAUDE_CODE_FORCE_TERMINAL_IMAGES=1` on the remote computer. Pictures go as data, so a page over 4096 pixels on a side or over 2 MiB shows as text, and an image that large does not show.- **tmux and screen:** no pictures. Claude Code does not send pictures through them, even with the variable set. Set `IUI_FORCE=1` to try anyway.- **`IUI_INLINE`:** `IUI_INLINE=1` sends pictures as data, as over ssh; `IUI_INLINE=0` makes the terminal read the files, also over ssh. With no value, the mod sends data only over ssh (`SSH_CONNECTION` or `SSH_TTY`).+- **`IUI_FONT` and `IUI_MODE`:** over ssh, and with `herdr --remote`, the mod cannot read your terminal's font or its background. Name them in the shell start file of the remote computer (for example `~/.bashrc`):+ - `export IUI_FONT="JetBrains Mono"`: the terminal font. It must be installed on the remote computer, because Typst draws there.+ - `export IUI_MODE=dark`: `light` or `dark`, for Claude Code's `auto` theme.+ - 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`).diff --git a/docs/limitations.md b/docs/limitations.mdindex e893e2e..1ba92d4 100644--- a/docs/limitations.md+++ b/docs/limitations.md@@ -59,7 +59,7 @@## Terminals-- **Over ssh,** the mod cannot read your local terminal's config. It sizes text by the theme's code font, and `auto` uses `COLORFGBG` if ssh sends it, else dark. Pages are at most 4096 px tall. With tmux or screen on the remote computer, no pictures show.+- **Over ssh,** the mod cannot read your local terminal's config. It sizes text by `IUI_FONT`, else the theme's code font, and `auto` uses `IUI_MODE`, else `COLORFGBG` if ssh sends it, else dark (refer to [`IUI_FONT` and `IUI_MODE`](install.md#terminals)). Pages are at most 4096 px tall. With tmux or screen on the remote computer, no pictures show.- **The `auto` theme** reads the settings of iTerm2, Ghostty, kitty, Rio and cmux directly (in herdr, those of the terminal around herdr). It does not read kitty's `globinclude`, `envinclude` and `geninclude` lines, or colours set while kitty runs. In other terminals it uses `COLORFGBG` (set only when the terminal starts), then the OS appearance (on Linux, the desktop portal or the GNOME setting). A theme change in such a terminal that does not change the OS appearance is not seen. Changes show within 3 s.### herdr@@ -68,7 +68,7 @@- **Background with `auto`.** The mod asks herdr for the background (OSC 11) only at the start and when you change to a different herdr client (with `herdr --remote`, only at the start). Between those times, a background change shows only if the terminal's config or the OS appearance changes too.- **The background question can take a key.** It reads the tty for up to 0.3 s, and Claude Code reads the same tty. A key, a dialog answer, Esc or a mouse report in that moment can go to the mod and be lost. The mod does not ask within 2 s of a key in the prompt, but it cannot see dialog keys or mouse reports. A theme other than `auto` stops the question.- **Which terminal gives the font.** On macOS, the herdr client in the terminal app in front (if that app has several, the one you typed in last). If the app in front is not a terminal with a client, the mod keeps the one it used before. On Linux, the client where you typed last, which is not always the one you look at. A change shows within 1 s (on Linux up to about 9 s; a newly attached client up to 10 s).-- **When the client is not found.** With `herdr --remote`, the client is on another computer, so there is no terminal font, as over ssh. If the mod cannot read the processes (`ps`), it uses the variables of the terminal that started the herdr server. On Linux with several named herdr sessions, `lsof` cannot tell them apart, so the mod can pick a client of a different session.+- **When the client is not found.** With `herdr --remote`, the client is on another computer, so there is no terminal font, as over ssh (set `IUI_FONT`). If the mod cannot read the processes (`ps`), it uses the variables of the terminal that started the herdr server. On Linux with several named herdr sessions, `lsof` cannot tell them apart, so the mod can pick a client of a different session.- **Variables on macOS** come from `ps eww`, which does not mark where a value ends. A value of a different variable that contains text such as ` TERM=` can leak part of itself into a terminal variable. Linux reads `/proc/<pid>/environ` and does not have this problem.### herdr in iTerm2diff --git a/docs/usage.md b/docs/usage.mdindex 68928eb..6b9234e 100644--- a/docs/usage.md+++ b/docs/usage.md@@ -7,7 +7,7 @@ Intelligent UI draws Claude's answers as rendered Markdown. Only the drawing cha## What it draws- **Markdown:** headings, lists, task lists, tables, block quotes, links, footnotes and horizontal rules.-- **Code blocks** with syntax colours, in your terminal's font. The mod reads the font from iTerm2, Ghostty, kitty and Rio. Else it uses fontconfig's `monospace` on Linux, then Menlo, SF Mono or DejaVu Sans Mono.+- **Code blocks** with syntax colours, in your terminal's font. The mod reads the font from iTerm2, Ghostty, kitty and Rio. Else it uses `IUI_FONT` when you set it (over ssh, the only way to name it; refer to [Terminals](install.md#terminals)), then fontconfig's `monospace` on Linux, then Menlo, SF Mono or DejaVu Sans Mono.- **Math:** `$…$` and `$$…$$`, in LaTeX syntax.- **Images** from ``. A relative path starts from the session's folder. Remote images show as a box with the alt text.- **Live Typst:** a code block with the language `typst` (or `typ`) is drawn, not shown as code. These packages come with the mod and work offline:diff --git a/hooks/lib/api.ts b/hooks/lib/api.tsindex 6ffb5ef..6c7ec84 100644--- a/hooks/lib/api.ts+++ b/hooks/lib/api.ts@@ -19,7 +19,7 @@ export type EnvName =| 'CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC' | 'CLAUDE_CODE_FORCE_TERMINAL_IMAGES' | 'CLAUDE_CODE_SESSION_KIND' | 'CLAUDE_CODE_TMPDIR'| 'CMUX_SOCKET_PATH' | 'CMUX_SURFACE_ID' | 'CMUX_WORKSPACE_ID' | 'COLORFGBG' | 'DISABLE_AUTOUPDATER' | 'DISABLE_UPDATES' | 'DISPLAY'| 'GHOSTTY_BIN_DIR' | 'GHOSTTY_RESOURCES_DIR' | 'HERDR_ENV' | 'HOME'- | 'ITERM_PROFILE' | 'ITERM_SESSION_ID' | 'IUI_DEBUG' | 'IUI_FORCE' | 'IUI_INLINE' | 'KITTY_CONFIG_DIRECTORY' | 'KITTY_INSTALLATION_DIR' | 'KITTY_PID'+ | 'ITERM_PROFILE' | 'ITERM_SESSION_ID' | 'IUI_DEBUG' | 'IUI_FONT' | 'IUI_FORCE' | 'IUI_INLINE' | 'IUI_MODE' | 'KITTY_CONFIG_DIRECTORY' | 'KITTY_INSTALLATION_DIR' | 'KITTY_PID'| 'KITTY_WINDOW_ID' | 'LC_TERMINAL' | 'RIO_CONFIG_HOME' | 'SHELL' | 'SSH_CONNECTION' | 'SSH_TTY' | 'STY'| 'TERM' | 'TERM_PROGRAM' | 'TERM_PROGRAM_VERSION' | 'TMUX' | 'TYPST_FONT_PATHS' | 'WAYLAND_DISPLAY' | 'XDG_CONFIG_HOME' | 'XDG_CURRENT_DESKTOP' | 'ZDOTDIR'@@ -67,8 +67,10 @@ export function getenv($: EngineInterface, name: EnvName): Promise<string | undecase 'ITERM_PROFILE': return $.env.get('ITERM_PROFILE')case 'ITERM_SESSION_ID': return $.env.get('ITERM_SESSION_ID')case 'IUI_DEBUG': return $.env.get('IUI_DEBUG')+ case 'IUI_FONT': return $.env.get('IUI_FONT')case 'IUI_FORCE': return $.env.get('IUI_FORCE')case 'IUI_INLINE': return $.env.get('IUI_INLINE')+ case 'IUI_MODE': return $.env.get('IUI_MODE')case 'KITTY_CONFIG_DIRECTORY': return $.env.get('KITTY_CONFIG_DIRECTORY')case 'KITTY_INSTALLATION_DIR': return $.env.get('KITTY_INSTALLATION_DIR')case 'KITTY_PID': return $.env.get('KITTY_PID')diff --git a/hooks/lib/host.ts b/hooks/lib/host.tsindex 9f46497..fe83159 100644--- a/hooks/lib/host.ts+++ b/hooks/lib/host.ts@@ -7,7 +7,7 @@ import type { IuiTheme } from '../../types'import { CLIP_WAKE_MS, HERDR_POLL_MS, HERDR_SCAN_MS, HOST_CHECK_MS, HOST_POLL_MS, MODES, OSC11_QUIET_MS } from './settings'import { S } from './state'import { beginEpoch } from './epoch'-import { keptOsc11, luminanceOf, OSC11_TRIES, modeOfColorFgBg, modeOfLuminance, modeOfMacAppearance, parseOsc11, resolveMode, schemeOfPortal, type HostMode } from './mode'+import { keptOsc11, luminanceOf, OSC11_TRIES, modeOfColorFgBg, modeOfVar, modeOfLuminance, modeOfMacAppearance, parseOsc11, resolveMode, schemeOfPortal, type HostMode } from './mode'import {cmuxAppearanceOf, cmuxConfigOf, cmuxGhosttyConfigPath, cmuxSettingsOf, familyOfFc, GHOSTTY_DEFAULT_FONT, ghosttyBackgroundOf, ghosttyFontsOf, ghosttyHasColors,ghosttyThemePaths, ghosttyThemesOf,@@ -279,14 +279,17 @@ exit 0`// The terminal's font family: iTerm2's profile font, Ghostty's font-family,// kitty's font_family, Rio's [fonts] family; '' elsewhere or when it can't// be read. A family that the terminal does not find is the one it draws in-// its place (its own font, Menlo, or fontconfig's nearest). On Linux, when-// the terminal's config names none: fontconfig's monospace font (fc-match),-// which kitty and most terminals use.+// its place (its own font, Menlo, or fontconfig's nearest). When none is+// read (always over ssh): IUI_FONT, as installed here (as set when it is+// not). Then on Linux: fontconfig's monospace font (fc-match), which kitty+// and most terminals use.export async function termFontOf($: EngineInterface, isMac: boolean): Promise<string> {// Over ssh, a config here is not the one of the user's terminal.- if (S.isRemote) return ''- const font = await configFontOf($, isMac)- if (font || isMac) return font+ const font = S.isRemote ? '' : await configFontOf($, isMac)+ const named = font ? '' : ((await getenv($, 'IUI_FONT')) ?? '').trim()+ S.fontByVar = !!named+ if (font || named) return font || (await installedFamily($, isMac, named)) || named+ if (isMac || S.isRemote) return ''return fcFamily($, 'monospace')}@@ -529,10 +532,10 @@ async function configFontOf($: EngineInterface, isMac: boolean): Promise<string>// and kept while the sources below do not change (keptOsc11); 1. the// terminal's OSC 11 answer (off, see USE_OSC11); 2. the terminal's own// settings (iTerm2's profile, Ghostty's, kitty's or Rio's config); 3.-// COLORFGBG at start; 4. the OS appearance; 5. dark (resolveMode). The-// terminal comes before the OS: a dark terminal on a light Mac is dark.-// Over ssh, only COLORFGBG (when ssh sends it): the configs and the OS-// here are the remote computer's.+// IUI_MODE; 4. COLORFGBG at start; 5. the OS appearance; 6. dark+// (resolveMode). The terminal comes before the OS: a dark terminal on a+// light Mac is dark. Over ssh, only IUI_MODE and COLORFGBG (when ssh sends+// it): the configs and the OS here are the remote computer's.export async function readHostMode($: EngineInterface, ask = false): Promise<HostMode | null> {if (!S.isHerdr) return readOwnMode($)let answer: HostMode | null | undefined@@ -555,23 +558,24 @@ export async function osc11Due($: EngineInterface, off = S.isOff): Promise<boolereturn (await nowMs($).catch(() => Date.now())) - S.keyAt >= OSC11_QUIET_MS}-// Sources 1 to 5 of readHostMode.+// Sources 1 to 6 of readHostMode.async function readOwnMode($: EngineInterface): Promise<HostMode | null> {if (USE_OSC11) {const bg = parseOsc11((await probeOsc11($))?.reply ?? '')if (bg) return { mode: modeOfLuminance(luminanceOf(bg)), source: 'terminal', detail: 'OSC 11 background' }}- if (S.isRemote) {- const mode = modeOfColorFgBg(S.colorFgBg)- return mode ? { mode, source: 'COLORFGBG' } : null- }- const term =- (await readItermMode($).catch(() => null)) ??+ // Over ssh, a config here is not the one of the user's terminal.+ const term = S.isRemote+ ? null+ : (await readItermMode($).catch(() => null)) ??(await readGhosttyMode($).catch(() => null)) ??(await readKittyMode($).catch(() => null)) ??(await readRioMode($).catch(() => null))if (term) return term+ const set = modeOfVar(await getenv($, 'IUI_MODE'))+ if (set) return { mode: set, source: 'IUI_MODE' }const mode = modeOfColorFgBg(S.colorFgBg)+ if (S.isRemote) return mode ? { mode, source: 'COLORFGBG' } : nullif (mode) return { mode, source: 'COLORFGBG' }return readOsMode($).catch(() => null)}diff --git a/hooks/lib/mode.ts b/hooks/lib/mode.tsindex 145bb78..462d7ce 100644--- a/hooks/lib/mode.ts+++ b/hooks/lib/mode.ts@@ -21,7 +21,7 @@ export function settingOf(value: unknown): ThemeSetting {// The OS appearance, and where it was read.export type HostMode = {mode: IuiTheme- source: 'terminal' | 'herdr' | 'iTerm2' | 'Ghostty' | 'cmux' | 'kitty' | 'Rio' | 'macOS' | 'GNOME' | 'desktop portal' | 'COLORFGBG'+ source: 'terminal' | 'herdr' | 'iTerm2' | 'Ghostty' | 'cmux' | 'kitty' | 'Rio' | 'macOS' | 'GNOME' | 'desktop portal' | 'COLORFGBG' | 'IUI_MODE'detail?: string}@@ -60,6 +60,12 @@ export function modeOfColorFgBg(value: string | undefined): IuiTheme | null {return null}+// IUI_MODE: light or dark; null for anything else.+export const modeOfVar = (value: string | undefined): IuiTheme | null => {+ const v = (value ?? '').trim().toLowerCase()+ return v === 'light' || v === 'dark' ? v : null+}+// The mode to draw: a fixed setting as set; auto as the OS is, dark when it// was never read.export function resolveMode(setting: ThemeSetting, seen: HostMode | null): IuiTheme {diff --git a/hooks/lib/state.ts b/hooks/lib/state.tsindex 11574da..73be3d2 100644--- a/hooks/lib/state.ts+++ b/hooks/lib/state.ts@@ -214,6 +214,8 @@ export const S = {// Over ssh (set in setUp): the terminal's config and the OS appearance here// are the remote computer's, not those of the user's screen.isRemote: false,+ // The terminal font came from IUI_FONT (termFontOf).+ fontByVar: false,// IUI_DEBUG is set (setUp): trace lines go to the debug log.debug: false,// iTerm2 or herdr with the engine's pictures off at start: /iui setup can helpdiff --git a/hooks/register.tsx b/hooks/register.tsxindex 6113a19..5cc65fc 100644--- a/hooks/register.tsx+++ b/hooks/register.tsx@@ -1153,8 +1153,8 @@ export const register: Register = on => {// A measure with no term metrics: Typst does not have the font (it would fall back).const missing = !!ready.typst && ready.metrics !== DEFAULT_METRICS && !ready.metrics.termconst font = !ready.termFont- ? `terminal font not known (${ready.isMac ? 'Menlo' : "the theme's code font"} assumed)`- : `terminal font ${ready.termFont}${missing ? " (Typst does not have this font, so the pictures use the theme's fonts)" : ''}`+ ? `terminal font not known (${ready.isMac ? 'Menlo' : "the theme's code font"} assumed${S.isRemote ? '; set IUI_FONT to name it' : ''})`+ : `terminal font ${ready.termFont}${S.fontByVar ? ' (IUI_FONT)' : ''}${missing ? " (Typst does not have this font, so the pictures use the theme's fonts)" : ''}`const typst = ready.typst ? `Typst: ${ready.typst}` : `Typst: not found (${typstHintOf(ready.isMac)})`const terminal = S.cacheProblem? `Intelligent UI draws no pictures: ${S.cacheProblem} (it never uses a shared folder instead)`diff --git a/tests/mode.test.ts b/tests/mode.test.tsindex b9fd8f1..41fe8e5 100644--- a/tests/mode.test.ts+++ b/tests/mode.test.ts@@ -444,11 +444,54 @@ for (const colorFgBg of [undefined, '0;15']) {on('fs.read', async ($: any, e: any, next: any) => (e.path.includes('kitty') ? (asked.push(e.path), { deny: 'no such file' } as any) : next(e)))const ran = await $.command.run({ command: 'iui', args: 'details' } as any)expect(ran.text).toContain(colorFgBg ? 'mode light (auto, from COLORFGBG)' : 'mode dark (auto, OS appearance not known, dark assumed)')- expect(ran.text).toContain('terminal font not known (Menlo assumed)')+ expect(ran.text).toContain('terminal font not known (Menlo assumed; set IUI_FONT to name it)')expect(asked).toEqual([])})}+// Over ssh, IUI_FONT and IUI_MODE (from the remote shell's start file) name+// what the mod can't read: IUI_MODE before COLORFGBG, the font as installed here.+test('over ssh, IUI_FONT names the terminal font and IUI_MODE the mode for auto', async ($, on) => {+ mock.store(on)+ mock.clock(on)+ mock.env(on, { HOME: '/h', TERM: 'xterm-ghostty', SSH_CONNECTION: '10.0.0.2 50000 10.0.0.1 22', COLORFGBG: '15;0', IUI_FONT: ' JetBrains Mono ', IUI_MODE: 'Light' })+ on('config.list', async () => ({ value: [{ key: 'theme', value: 'auto' }] as any }))+ const ok = (stdout: string, exitCode = 0) => ({ value: { exitCode, stdout, stderr: '', isStdoutTruncated: false, isStderrTruncated: false } })+ const families: string[] = []+ on('process.run', async ($: any, e: any, next: any) => {+ const argv: string[] = e.argv+ if (argv[0] === 'sh' && /cc-intelligent-ui-/.test(argv.join(' '))) return ok('/tmp/mdp\nDarwin\n')+ if (argv[0] === 'osascript' && argv.includes('JetBrains Mono')) return (families.push(argv.at(-1)!), ok('yes\n'))+ return next(e)+ })+ const ran = await $.command.run({ command: 'iui', args: 'details' } as any)+ expect(ran.text).toContain('mode light (auto, from IUI_MODE)')+ expect(ran.text).toContain('terminal font JetBrains Mono (IUI_FONT)')+ expect(families).toEqual(['JetBrains Mono'])+})++// Where the mod reads the terminal (here kitty's config), the variables wait.+test("on this computer, the terminal's own font and mode win over IUI_FONT and IUI_MODE", async ($, on) => {+ mock.store(on)+ mock.clock(on)+ mock.env(on, { HOME: '/h', TERM: 'xterm-kitty', KITTY_WINDOW_ID: '1', IUI_FONT: 'Courier', IUI_MODE: 'light' })+ on('config.list', async () => ({ value: [{ key: 'theme', value: 'auto' }] as any }))+ const ok = (stdout: string, exitCode = 0) => ({ value: { exitCode, stdout, stderr: '', isStdoutTruncated: false, isStderrTruncated: false } })+ on('process.run', async ($: any, e: any, next: any) => {+ const argv: string[] = e.argv+ if (argv[0] === 'sh' && /cc-intelligent-ui-/.test(argv.join(' '))) return ok('/tmp/mdp\nDarwin\n')+ if (argv[0] === 'osascript') return ok('yes\n')+ return next(e)+ })+ const files: Record<string, string> = { '/h/.config/kitty/kitty.conf': 'font_family Iosevka\nbackground #101010\n' }+ on('fs.exists', async ($: any, e: any, next: any) => (e.path.includes('kitty') ? { value: e.path in files } : next(e)))+ on('fs.read', async ($: any, e: any, next: any) => (e.path in files ? { value: files[e.path] } : e.path.includes('kitty') ? ({ deny: 'no such file' } as any) : next(e)))+ const ran = await $.command.run({ command: 'iui', args: 'details' } as any)+ expect(ran.text).toContain('mode dark (auto, from kitty')+ expect(ran.text).toContain('terminal font Iosevka')+ expect(ran.text).not.toContain('IUI_')+})+// cmux (Ghostty inside) with no colours in the Ghostty config: its adaptive// default theme follows cmux's appearance; turned off, Ghostty's dark default.// A theme in cmux's own config (its themes picker) wins.