opentui icon indicating copy to clipboard operation
opentui copied to clipboard

Default console is not restored on destroy

Open veracioux opened this issue 4 weeks ago • 1 comments

I did something like:

await new Promise<void>((resolve) => render(() => {
  const r = useRenderer()
  setTimeout(() => { r.destroy(); resolve() }, 500)
  return <box><text>test</text></box>
})

console.log("test") // Doesn't print

I looked at this method but I don't understand it: https://github.com/veracioux/opentui/blob/931535a0b8a8d9dcb712f186ed9979ee14c0e968/packages/core/src/console.ts#L151

Don't these two snippets cancel each other out?

    if (this._originalConsole) {
      global.console = this._originalConsole
    }
    this.setupConsoleCapture()

veracioux avatar Nov 10 '25 19:11 veracioux

That is confusing me as well. However the global.console replacement is capturing everything into a buffer, while the "override" just wraps the log/info/warn/error methods and caches it for display. One is probably redundant. The console needs some work.

kommander avatar Nov 13 '25 08:11 kommander