Skip to content

Conversation

@pyramation
Copy link
Contributor

Summary

Fixes humanizeKeySequences() in @inquirerer/test to not replace standalone ESC bytes (\u001b), which was breaking ANSI code stripping in downstream consumers.

The standalone ESC byte is the start of all ANSI escape codes (e.g., \u001b[97m for white text). When humanizeKeySequences() replaced \u001b with <ESCAPE>, it converted ANSI codes like \u001b[97m into <ESCAPE>[97m, which cleanAnsi() could no longer strip. This caused test snapshots in constructive to contain raw ANSI styling codes instead of clean output.

The fix:

  • Removes the standalone ESC mapping from the key sequence replacements
  • Changes the data structure from Record to ordered array to ensure longer sequences (like \u001b[A for UP_ARROW) are replaced before shorter ones could interfere

Review & Testing Checklist for Human

  • Verify that removing standalone ESC replacement doesn't break any existing tests that expected <ESCAPE> in output
  • After publishing, test in constructive repo that the snapshot tests in packages/cli/__tests__/cli.test.ts now pass with clean ANSI-stripped output
  • Confirm the array ordering (longer sequences first) is correct for all edge cases

Test plan: After merging and publishing, update constructive's @inquirerer/test dependency and run pnpm test in packages/cli to verify snapshots no longer contain ANSI escape codes.

Notes

This is a prerequisite fix for migrating constructive's test utilities to use @inquirerer/test. The migration PR in constructive is blocked on this fix being published.

Link to Devin run: https://app.devin.ai/sessions/e5018850caff45ce8a126331548d69bc
Requested by: Dan Lynch (@pyramation)

The standalone ESC byte (\u001b) was being replaced with '<ESCAPE>' which
broke ANSI code stripping. ANSI escape codes like \u001b[97m (white text)
need to remain intact so cleanAnsi() can strip them.

This fix removes the standalone ESC mapping while keeping all the longer
key sequences (UP_ARROW, DOWN_ARROW, DELETE, etc.) which don't conflict
with ANSI styling codes.
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 89b3440 into main Dec 27, 2025
36 checks passed
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.

2 participants