Skip to content

feat: add a lot more tui functionality#2635

Open
samchouse wants to merge 1 commit into
cachix:mainfrom
samchouse:main
Open

feat: add a lot more tui functionality#2635
samchouse wants to merge 1 commit into
cachix:mainfrom
samchouse:main

Conversation

@samchouse
Copy link
Copy Markdown

@samchouse samchouse commented Mar 18, 2026

This PR changes the native process manager to use PTY's instead of log streaming which allows more complex UIs (qr codes, colors, etc) to be rendered properly. It properly shuts processes down instead of them surviving. Adds support for providing input into a process, such as interacting with Expo. Fixes flickering issues.

needs cachix/iocraft#1

Disclaimer: this PR was entirely done by AI but I've been using it locally without issue

More in depth summary by AI:

Summary

  • Move process rendering in the TUI closer to real terminal behavior instead of treating everything as plain appended logs
  • Add direct keyboard interaction with selected processes from inside the TUI
  • Improve how process output is shown in both collapsed previews and expanded views
  • Make stop/restart flows more explicit and reusable for manually managed processes
  • Tighten PTY lifecycle handling so interactive processes behave more reliably during resize, restart, and shutdown

Key changes

TUI process rendering

  • Process activities now maintain terminal state so output that relies on ANSI control sequences, cursor movement, and screen updates is rendered more faithfully
  • Richer output handling is used across process views instead of only relying on line-buffered logs, which makes active services feel less like static log streams
  • Process status banners and lifecycle updates are integrated into the rendered output more cleanly so state transitions are easier to follow

Interactive process input

  • A selected process can now be focused for input from the TUI with F12
  • Once focused, key presses are forwarded to the underlying PTY instead of being handled only as TUI navigation
  • Input forwarding includes normal character input plus control, alt, navigation, and editing keys so terminal-driven tools can be interacted with more naturally
  • The same focus/input model is carried into the expanded process view so interaction is consistent between overview and detail modes

Expanded and collapsed process views

  • The expanded process view now works against terminal-backed process state instead of only a plain-text log representation
  • Expanded view behavior is improved for live output by keeping a follow mode and adapting better when content is still actively changing
  • Expanded view selection/copy behavior is updated to work with the richer rendered content model
  • Collapsed previews now better represent ANSI-heavy process output, including styled content, while still stripping destructive control behavior that would break the layout
  • Preview rendering is width-aware, making the condensed process view more readable and less noisy

Process lifecycle and controls

  • Process lifecycle handling is expanded with a reusable Stopped state instead of treating manually stopped processes the same as never-started ones
  • Stopping a process now moves through an explicit Stopping state before settling into Stopped, which makes the UI reflect that transition more clearly
  • Restart flows now account for processes that are active, never started, or manually stopped, so TUI controls behave more predictably across states
  • Manual stop/restart actions also preserve and reuse process activity state more cleanly instead of forcing everything through a fresh registration path

PTY and process supervision changes

  • PTY-backed process execution is used more directly, which gives the TUI better control over process I/O and terminal behavior
  • PTY instances are resized when the terminal changes size so interactive programs can adapt properly to the current viewport
  • Raw process output is captured separately so terminal state can be updated without losing the existing log stream behavior used elsewhere in the UI
  • Stop/restart handling is tightened so PTY-backed processes are torn down and recreated more deliberately during file-change restarts and manual control actions
  • Shutdown behavior is improved so child processes are cleaned up more consistently rather than being left behind by partial teardown behavior

UI polish and behavior

  • Main-view scrolling behavior is more deliberate, including page/home/end navigation support around the activity list
  • Input focus and selected activity state are tracked separately, which helps distinguish between navigating the TUI and interacting with a live process
  • Exit/final-render behavior is cleaned up so the TUI leaves the terminal in a better state and presents a cleaner final snapshot when appropriate
  • tmux gets a lower frame-rate cap to reduce unnecessary redraw pressure in environments where higher refresh rates are less useful

@domenkozar
Copy link
Copy Markdown
Member

domenkozar commented Mar 19, 2026

This is very welcome! High-level overview:

  • Processes now run in PTYs instead of piped log streams, so rich terminal output (colors, QR codes,
    ANSI UIs) renders correctly
  • Users can focus a process with F12 and send keyboard input to it (useful for interactive tools like
    Expo)
  • Expanded and collapsed process views are completely reworked to render from virtual terminal state
    rather than plain text logs
  • Process lifecycle gets explicit Stopped/Stopping states with cleaner shutdown that no longer leaves
    orphaned child processes

I think it might be worth splitting this up. A decision we need to make if we really want PTY to be the default, because that complicates writing logs, which are now mixed with terminal codes.

We definitely should allow it at least as an option, like processes.XXX.is_pty

@samchouse
Copy link
Copy Markdown
Author

Sure, I can work on adding the option to use PTYs, but I think opt out is the better way to do it since it renders like the process expects it to. The previous one would lose a bunch of logs for mean (QR code in Expo, among other things) which I don't think is a great default experience.

If you let me know how you wanna split the PR into others I can also work on that.

@domenkozar
Copy link
Copy Markdown
Member

@sandydoo thoughts on making pty the default for processes?

@samchouse samchouse force-pushed the main branch 2 times, most recently from 4593098 to c63d624 Compare March 28, 2026 23:02
@samchouse
Copy link
Copy Markdown
Author

samchouse commented Mar 28, 2026

@domenkozar I added the option and set it to default for now. The PR also no longer needs my fork of iocraft and has been updated to main.

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.

2 participants