Skip to content

fix(cli): preserve terminal scrollback buffer during run command#2042

Merged
maxprilutskiy merged 2 commits intolingodotdev:mainfrom
gmpaliwal07:fix/preserve-terminal-scrollback
Mar 15, 2026
Merged

fix(cli): preserve terminal scrollback buffer during run command#2042
maxprilutskiy merged 2 commits intolingodotdev:mainfrom
gmpaliwal07:fix/preserve-terminal-scrollback

Conversation

@gmpaliwal07
Copy link
Copy Markdown
Contributor

@gmpaliwal07 gmpaliwal07 commented Mar 11, 2026

Summary

Replace \x1Bc with \x1b[2J\x1b[H to preserve terminal scrollback buffer during lingo.dev run.

Changes

  • Replace full terminal reset sequence \x1Bc with screen-only clear \x1b[2J\x1b[H in renderClear() in packages/cli/src/cli/utils/ui.ts

Testing

  • Filled terminal with 100 lines of scrollback history
  • Ran lingo.dev run — scrollback preserved after fix ✅
  • All 554 tests pass locally

Visuals

Before fix (scrollback wiped):
https://github.com/user-attachments/assets/aac277e5-f4d6-4d54-b3ed-3c73f595c5c6

After fix (scrollback preserved):
https://github.com/user-attachments/assets/fae72cea-051d-4d07-88f4-05b942d338a5

Checklist

  • Changeset added (if version bump needed)
  • Tests cover business logic (not just happy path)
  • No breaking changes (or documented below)

Closes #2011

Summary by CodeRabbit

  • Bug Fixes
    • Improved terminal behavior in the CLI run command to preserve scrollback buffer, allowing users to review output history after execution.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc359a22-f1d0-4342-ab14-192ee4f59154

📥 Commits

Reviewing files that changed from the base of the PR and between 92c1e77 and 2f3374b.

📒 Files selected for processing (2)
  • .changeset/bright-lions-suffer.md
  • packages/cli/src/cli/utils/ui.ts

📝 Walkthrough

Walkthrough

A changelog entry documents a patch release fixing a CLI bug where the terminal scrollback buffer was being cleared. The UI utility's terminal clear function is updated to preserve scrollback by using a screen-only clear ANSI sequence instead of a full reset command.

Changes

Cohort / File(s) Summary
Changelog Entry
.changeset/bright-lions-suffer.md
New patch release documentation for lingo.dev CLI fix addressing terminal scrollback preservation during run command.
CLI UI Utilities
packages/cli/src/cli/utils/ui.ts
Modified renderClear function to use ANSI escape sequence \x1b[2J\x1b[H instead of console.log("\x1Bc"), clearing only the visible screen while preserving scrollback history.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

A curious hare fixed a terminal woe,
Where scrollback would vanish like fresh winter snow.
With ANSI sequences, now small and precise,
The history remains—oh, what a nice device! 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: replacing the terminal reset to preserve scrollback during the run command.
Description check ✅ Passed The description follows the template with all required sections completed: summary, changes, testing (including manual verification and test suite confirmation), visuals (before/after), and checklist items checked.
Linked Issues check ✅ Passed The PR directly addresses the objective in #2011 by replacing the terminal reset sequence to preserve scrollback history, with evidence of testing and confirmation that the fix works.
Out of Scope Changes check ✅ Passed All changes are directly related to the stated objective: the ANSI sequence modification in ui.ts, the changelog entry, and no unrelated modifications are present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gmpaliwal07
Copy link
Copy Markdown
Contributor Author

@vrcprl @maxprilutskiy any feedback or improvements needed in this ??

@maxprilutskiy
Copy link
Copy Markdown
Contributor

@gmpaliwal07 great work! 👏

@gmpaliwal07
Copy link
Copy Markdown
Contributor Author

@maxprilutskiy thank you

@maxprilutskiy maxprilutskiy merged commit a759e16 into lingodotdev:main Mar 15, 2026
5 checks passed
gmpaliwal07 added a commit to gmpaliwal07/lingo.dev that referenced this pull request Mar 17, 2026
vrcprl pushed a commit that referenced this pull request Apr 17, 2026
Co-authored-by: Max Prilutskiy <5614659+maxprilutskiy@users.noreply.github.com>
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.

Please don't nuke scrollback when using CLI 🙏

2 participants