The choose-fonts kitten queries the terminal for the user's foreground and
background colors at startup by sending a DCS request. The terminal responds
with separate DCS response strings — one per field — which arrive
asynchronously through on_query_response.
The background handler unconditionally called draw_screen() after storing its
value. If the terminal's DCS response for "background" arrived before the
response for "foreground", draw_screen() fired with text_style.Foreground
still at its Go zero value ("").
The font list preview (list.go) only guarded against empty Background, not
empty Foreground, so it passed the check and sent a render_family_samples
command to the Python backend with foreground="". The backend's to_color('')
raised ValueError: Invalid color name: '', crashing the kitten.
The faces pane (faces.go) launched a render_family_samples goroutine
unconditionally when its preview cache was empty, with no guard at all.
Fix
---
1. ui.go — Only trigger draw_screen() from the foreground or background
handler when the counterpart field is already populated, so the UI
never renders with a partial TextStyle.
2. list.go — Require both Foreground and Background to be non-empty
before rendering the font preview, not just Background alone.
3. faces.go — Skip the render_family_samples goroutine if either color
field is still empty. The preview cache stays empty, so the next
redraw (triggered when the counterpart query response arrives, or
by on_wakeup) retries with full colors.
slices.Insert(cmd, 1, "-O", "check") writes into cmd's backing array
when there is spare capacity (cap(cmd) >= len(cmd)+2). check_cmd points
at the shifted array, but cmd's slice header is unchanged: reading
cmd[:insertion_point] later returns "-O", "check", ... where the
original prefix used to be. run_control_master, forward_remote_control,
and the final ssh exec all build their argvs from this corrupted prefix.
Repro: share_connections=yes, forward_remote_control=yes, and enough
ssh_args to push cmd past Go's slice-growth threshold (kitten ssh -v
host does it). With the ControlMaster already up you'll see
"Multiplexing command already specified"; otherwise it fails with
"Failed to start SSH ControlMaster" and a stray -O check left in the
cmdline.
In highlight_mark(), mark_text was sliced using byte-based indexing
(mark_text[:len(hint)] and mark_text[len(hint):]). Since len(hint)
equals the rune count (hint is always ASCII), but len(mark_text) is a
byte count, this could slice in the middle of a multi-byte UTF-8
sequence (e.g. CJK characters), producing an invalid byte sequence
rendered as the Unicode replacement character (�).
Fix by converting mark_text to []rune first, then slicing at rune
boundaries. The hint is ASCII so len(hint) == rune count, requiring
no conversion on the hint side.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>