[PR #556] fix: don't re-capture console in restoreOriginalConsole #617

Open
opened 2026-03-02 23:47:22 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/556
Author: @murrayju
Created: 1/19/2026
Status: 🔄 Open

Base: mainHead: fix/restore-original-console


📝 Commits (1)

  • d72f22c fix: don't re-capture console in restoreOriginalConsole

📊 Changes

1 file changed (+0 additions, -2 deletions)

View changed files

📝 packages/core/src/console.ts (+0 -2)

📄 Description

Summary

The restoreOriginalConsole method was calling setupConsoleCapture() after restoring the original console, which immediately re-captured it. This prevented console.log output from appearing after renderer.destroy() was called.

Problem

When using createCliRenderer and then calling renderer.destroy(), any console.log statements after the destroy call would not appear in the terminal. This is because:

  1. renderer.destroy() calls this._console.destroy()
  2. Which calls deactivate()
  3. Which calls restoreOriginalConsole()
  4. restoreOriginalConsole restores global.console but then immediately calls setupConsoleCapture() which re-captures it

Solution

Remove the errant setupConsoleCapture() call from restoreOriginalConsole() so that deactivating the console capture actually restores normal console behavior.

Testing

After this fix, the following pattern works correctly:

const renderer = await createCliRenderer({ exitOnCtrlC: true });
// ... use renderer ...
renderer.destroy();
console.log('This message now appears!'); // Previously was captured and lost

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/556 **Author:** [@murrayju](https://github.com/murrayju) **Created:** 1/19/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/restore-original-console` --- ### 📝 Commits (1) - [`d72f22c`](https://github.com/anomalyco/opentui/commit/d72f22c22e7a2b4bb16f6e670924269eed2f02b4) fix: don't re-capture console in restoreOriginalConsole ### 📊 Changes **1 file changed** (+0 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/console.ts` (+0 -2) </details> ### 📄 Description ## Summary The `restoreOriginalConsole` method was calling `setupConsoleCapture()` after restoring the original console, which immediately re-captured it. This prevented `console.log` output from appearing after `renderer.destroy()` was called. ## Problem When using `createCliRenderer` and then calling `renderer.destroy()`, any `console.log` statements after the destroy call would not appear in the terminal. This is because: 1. `renderer.destroy()` calls `this._console.destroy()` 2. Which calls `deactivate()` 3. Which calls `restoreOriginalConsole()` 4. `restoreOriginalConsole` restores `global.console` but then immediately calls `setupConsoleCapture()` which re-captures it ## Solution Remove the errant `setupConsoleCapture()` call from `restoreOriginalConsole()` so that deactivating the console capture actually restores normal console behavior. ## Testing After this fix, the following pattern works correctly: ```typescript const renderer = await createCliRenderer({ exitOnCtrlC: true }); // ... use renderer ... renderer.destroy(); console.log('This message now appears!'); // Previously was captured and lost ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#617
No description provided.