Skip to content

fix: Vendor single-line-log to fix terminal line-wrapping bug#2652

Closed
luismulinari wants to merge 1 commit intotrunkfrom
single-line-log-fix
Closed

fix: Vendor single-line-log to fix terminal line-wrapping bug#2652
luismulinari wants to merge 1 commit intotrunkfrom
single-line-log-fix

Conversation

@luismulinari
Copy link
Contributor

Description

Fixes a terminal display bug where progress indicators and single-line logs would stack vertically instead of updating in place when the output exceeded terminal width. This occurred because the upstream @wwa/single-line-log package is unmaintained and contains a cursor positioning bug.

Problem

The @wwa/single-line-log package uses an ANSI escape sequence (\x1b[1000D) that doesn't work correctly on most terminals when output wraps across multiple physical lines.

Solution

This PR vendors a fixed version of single-line-log locally with the fix from freeall/single-line-log#21, which replaces the problematic ANSI sequence with a carriage return (\r) for reliable cursor positioning across all terminal emulators.

Changes

  • Removed @wwa/single-line-log dependency
  • Added src/lib/cli/single-log-line.ts with MIT license preserved
  • Updated imports in:
    • src/bin/vip-sync.js
    • src/lib/cli/progress.ts
    • src/lib/media-import/progress.ts
    • src/lib/validations/sql.ts
  • Added string-width@8.1.0 as direct dependency

References

Changelog Description

Fixed

  • Fixed a bug related to terminal line-wrapping

Pull request checklist

New release checklist

Steps to Test

Outline the steps to test and verify the PR here.

Example:

  1. Check out PR.
  2. Run npm run build
  3. Run ./dist/bin/vip-cookies.js nom
  4. Verify cookies are delicious.

@luismulinari luismulinari requested a review from a team December 8, 2025 13:37
@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
npm/string-width 8.1.0 🟢 4.3
Details
CheckScoreReason
Packaging⚠️ -1packaging workflow not detected
Maintained⚠️ 00 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Binary-Artifacts🟢 10no binaries found in the repo
Code-Review🟢 3Found 9/30 approved changesets -- score normalized to 3
Security-Policy🟢 10security policy file detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Vulnerabilities🟢 100 existing vulnerabilities detected
License🟢 10license file detected
Fuzzing⚠️ 0project is not fuzzed
Signed-Releases⚠️ -1no releases found
Branch-Protection⚠️ 0branch protection not enabled on development/release branches
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0

Scanned Files

  • package.json

The @wwa/single-line-log package is unmaintained and contains a bug
that causes line clearing to fail when output wraps across multiple
physical terminal lines, resulting in stacked output.

This change vendors the fixed version locally with the fix from
freeall/single-line-log#21, which uses '\r' instead of '\x1b[1000D'
for cursor positioning to ensure consistent behavior across all
terminal emulators.

Changes:
- Remove @wwa/single-line-log dependency
- Add src/lib/cli/single-log-line.ts with MIT license preserved
- Update all imports to use local implementation
- Add string-width@8.1.0 as direct dependency

Related PR:
- freeall/single-line-log#21
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 8, 2025

} as LogFunction;

log.clear = function () {
stream.write( '\n' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't clear the last line.

@sjinks
Copy link
Member

sjinks commented Dec 8, 2025

The @wwa/single-line-log package uses an ANSI escape sequence (\x1b[1000D) that doesn't work correctly on most terminals when output wraps across multiple physical lines.

This is the standard ANSI sequence that actually works on most terminals. The only case when it does not work is when the line exceeds 1000 characters. But I do agree that the \r approach is better.

@wwa/single-line-log package is unmaintained

Are you joking? It is freeall/single-line-log that is unmaintained. freeall/single-line-log#15 was the reason to replace that package.

@sjinks
Copy link
Member

sjinks commented Dec 8, 2025

Updated in #2653

@luismulinari
Copy link
Contributor Author

The only case when it does not work is when the line exceeds 1000 characters

@sjinks, this is tricky, actually. Even if the line doesn't exceed 1000 characters, it breaks for some terminals (e.g. iTerm2, Apple_Terminal). You can simulate that with: https://github.com/freeall/single-line-log/pull/21/files#diff-13876b4beb64b9f156474dc78f9c923952a7ca210d4507b6b3135bbe244f8a60

@luismulinari
Copy link
Contributor Author

Are you joking? It is freeall/single-line-log that is unmaintained. freeall/single-line-log#15 was the reason to replace that package.

Ohhh, I'm sorry. For some reason, I missed the fork! BTW, thanks for maintaining that!

Closing the PR in favor of #2653

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.

3 participants