Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

revise API, enforce single root invariant, support zoomed interactive vertices #11

Merged
merged 41 commits into from
Aug 28, 2023

Conversation

vito
Copy link
Owner

@vito vito commented Aug 16, 2023

This PR has grown a bit over time, and now includes 3 major changes:

Revised API

  • The previous async UI.RenderLoop has been replaced with a more conventional synchronous callback-based Run API. This comes after Progrock has taken more responsibility in handling stdio. A synchronous callback flow makes it easier to defer restoring the terminal state, and also seems to result in cleaner code.
  • RecorderToContext => ToContext
  • RecorderFromContext => FromContext
  • NewPassthroughRecorder has been removed (see next point)

Single root invariant

In complicated applications like Dagger we want to be able to emit progress at various layers of the stack, such as early initialization. But we also wanted to set labels on the "root" group, and some of those labels required that initialization was already done, forcing into an uncomfortable situation where we needed either multiple "root" groups or to emit progress without a group at all (NewPassthroughRecorder).

Dealing with both of those latter situations in the UI proved to be really clumsy. Fundamentally the notion of "mutliple roots" is pretty nasty for clients to have to deal with, and the notion of "ungrouped vertices" is similarly confounding. So there's a new invariant: all root groups have the same ID.

After dogfooding this has really simplified a lot of code. Technically there can be multiple root groups with different start/stop intervals and different labels, but that can be handled at the application layer. Nothing actually respects group start/stop timestamps at the moment, but being able to distinguish the intervals might be valuable in some contexts. Root group labels can probably all be merged into one set of labels.

Zoomed interactive sessions

Progrock now supports "Zoomed" vertices, which - while running - will take over the UI content while still being rendered above the status bar, so you can still see activity happening in the background. The goal here is to support things like dagger shell or dagger run bass (i.e. a REPL).

Zoomed vertices can return an optional io.Writer for accepting user input. Progrock will intelligently switch from passing user input to the Bubbletea UI model (for e.g. scrolling or pressing q to quit) and sending user input to the currently zoomed vertex, supporting full-blown keyboard/mouse interaction in a nested shell for example.

This might be expanded in the future to support full-blown tmux-style pane switching.

vito added 16 commits August 15, 2023 11:51
Signed-off-by: Alex Suraci <[email protected]>
bubbletea registers its own signal handler and exits, whereas before we
relied on tea.Quit to call interrupt.
to my surprise, bubbletea already seems to cap the View result to the
terminal height, which is kind of what you want, since we're abandoning
scrollability. will revisit later
just to verify output going past scrollback
this param was always true in practice. it may have originally been how
to toggle console mode, but console mode works entirely differently now.
it seems more useful to treat this as an interactive on/off, so it can
be disabled for things that require interaction, like REPLs or shells.

along the way:

* go back to viewport-based rendering
* render chrome in the same loop as the regular render loop, so that we
  can take its height into account when rendering. this fixed a couple
  TODOs for hardcoding "- 2".
* use persistent buffer for the render loop, likely major perf low
  hanging fruit
vito added 13 commits August 24, 2023 23:50
A single root seems like a valuable property to simplify a ton of
things. Technically this means you might see multiple "intervals" of the
root group, but the last one should be the outermost one.
complete vtx on command exit
previous implementation was an obvious hackjob, just rendering all
zoomed vertices, which would have generated garbage
The async RenderLoop API was pretty complicated to use. Everything gets
a lot simpler when you pass a callback instead, because you can just
wrap it in a defer to restore the terminal to "cooked" mode, integrate
the callback lifecycle into the Model, and just print the final render
after the program exits.
@vito vito changed the title add support for "zoomed" vertices revise API, enforce single root invariant, support zoomed interactive vertices Aug 28, 2023
Just use NewRecorder now that we have the "single root" invariant.
@vito vito merged commit 6d4d217 into main Aug 28, 2023
@vito vito deleted the zoom-zoom branch August 28, 2023 17:36
@vito vito mentioned this pull request Aug 29, 2023
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.

1 participant