Skip to content

fix(backends): make composer glyph strip locale-invariant#370

Open
zachlandes wants to merge 1 commit into
kunchenguid:mainfrom
zachlandes:fm/composer-glyph-locale
Open

fix(backends): make composer glyph strip locale-invariant#370
zachlandes wants to merge 1 commit into
kunchenguid:mainfrom
zachlandes:fm/composer-glyph-locale

Conversation

@zachlandes

Copy link
Copy Markdown

Problem

The composer-state readers in the cmux, herdr, and orca backends stripped a leading prompt glyph with ${stripped#?}.
Under a C/POSIX locale that removes a single byte, leaving two stray bytes of the three-byte behind, so an idle composer (for example the ❯ Type a message... ghost placeholder) was misread as pending instead of empty.

Fix

Match and strip the exact glyph literal (${stripped#'❯'} and so on), then trim any following whitespace.
Applied to cmux, herdr, and orca, which share the pattern; herdr additionally keeps its prompt glyph.
Each adapter's existing glyph set is preserved exactly as it stands on current main.

Test

Adds a colocated LC_ALL=C regression test that asserts the idle ghost placeholder still reads empty, so a refactor back to byte-count stripping cannot regress silently on C/POSIX-locale hosts.
Verified directly: the test fails (pending) against the old byte-strip and passes (empty) with the fix.
shellcheck bin/*.sh bin/backends/*.sh tests/*.sh is clean.

Context

This bug was surfaced by the no-mistakes test step while validating an unrelated PWD-normalization change; it is split out here as its own single-purpose PR against current main.

The composer-state readers stripped a leading prompt glyph with
${stripped#?}, which removes a single byte under a C/POSIX locale and
leaves two stray bytes of the three-byte ❯ behind, so an idle composer
was misread as pending. Match and strip the exact glyph literal instead,
then trim any following whitespace. cmux, herdr, and orca share the
pattern; herdr additionally keeps its › prompt glyph.

Add a colocated LC_ALL=C regression test asserting the idle ghost
placeholder still reads empty, so a refactor back to byte-count stripping
cannot regress silently on C/POSIX-locale hosts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant