Skip to content

Conversation

@limwa
Copy link

@limwa limwa commented Nov 11, 2025

Fixes #248.

Changes

Core

  • Adds new exitSignals option to renderer, which specifies a list of signals that the renderer should destroy itself upon receiving.
    • The handlers are mounted when the renderer is created or resumed, and are unmounted when the renderer is suspended.
  • The exit handler is now run on the beforeExit event. The exit event does not allow for more tasks to be added to the event loop, and thus the Bun.sleep(200) call would be effectively ignored, preventing the captured logs from being dumped.

React

  • Deduplicates repeated logic between the createRoot and render methods.
  • Exposes the renderer on the render methods to make it easier to implement external lifecycle control.

Solid

  • Exposes the renderer on the render methods to make it easier to implement external lifecycle control.
  • Applies the changes from chore(react): replace render method with createRoot #270 to the @opentui/solid package as well. This is helpful for lifecycle control because it inherently exposes the renderer (the user has to create one beforehand).
    • A createRoot method already exists in the solid-js package, which could create some confusion. Should I rename it? Open to suggestions!
    • Also updated all @opentui/solid examples and README.md to reflect the new API.

@limwa limwa force-pushed the feat/improve-lifecycle-management branch from c99c0b0 to 03b09d2 Compare November 11, 2025 20:13
@limwa limwa marked this pull request as draft November 11, 2025 20:25
@limwa limwa force-pushed the feat/improve-lifecycle-management branch from 03b09d2 to 06abe6f Compare November 11, 2025 20:35
@limwa limwa marked this pull request as ready for review November 11, 2025 20:35
@limwa limwa force-pushed the feat/improve-lifecycle-management branch from 06abe6f to 3dbe570 Compare November 11, 2025 20:35
@kommander
Copy link
Collaborator

Thanks for looking into this. This makes sense. Only thing I need to work with this is the engine for the Timeline. We could just let the renderer have an engine getter (engine was just for the lack of better naming, can be renamed), which lazily creates an engine instance and attaches it to the renderer and the useTimeline hook can use renderer.engine instead of the global one. Then it should work. I don't think that is test covered currently I am afraid.

@limwa limwa force-pushed the feat/improve-lifecycle-management branch from 677d841 to 5ca7270 Compare November 11, 2025 23:35
@limwa
Copy link
Author

limwa commented Nov 11, 2025

Also changed the exitHandler to run on beforeExit instead of exit. On exit, the capture dumping would not run because the runtime does not allow for more tasks to be scheduled on the event loop at that point. Using the beforeExit event fixes that problem!

@kommander
Copy link
Collaborator

Nice, I'll take it for a quick spin in the morning and check what I need to do for opencode, but this should be fine.

@kommander
Copy link
Collaborator

Sorry I've broken this

@limwa
Copy link
Author

limwa commented Nov 12, 2025

Sorry I've broken this

I'll take a look at it tomorrow, no worries!

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.

Importing OpenTUI stops Effect from properly running teardown hooks

3 participants