Skip to content

TUI: hide container stdout by default #5156

Closed

Description

@shykes

Context

Now that we have an awesome TUI merged, and soon released (yay!) I think we can finally make progress on an old topic: container output streams (stdout and stderr); pipeline output; and the difference between them.

Problem

The current situation: there is no difference. If your container prints something (anything!), the user will see it in the TUI. If the TUI prints anything about the status of a step, a possible error... It came from the stdout of a container.

In my opinion, that is not ideal, we should change it.

  1. Most of the stdout and stderr of a container is noise, unless there's an error, in which case you want to go back and investigate some of it.
  2. The value of the TUI is diminished by having to show so much noisy logging by default.
  3. The important questions ("what's the status of this step? Why did it fail?") are difficult to answer, because the answer is drowned in an ocean of logs, with no way to extract it semantically.

Solution

With this awesome new TUI and the scaffolding behind it, I think now is a good time to start changing this, incrementally.

  • Step 1 (the title of this issue): hide stdout/stderr by default. You can still see everything with a flag; and in case of error, maybe it all gets dumped to you (or maybe it doens't, and you just re-run it with the verbose flag)
  • Step 2: we add an API for steps to explicitly send status, error etc. Data from that API is displayed prominently, by default.
  • Step 3: over time access to raw logs becomes less and less important - everything you need is surfaced in the step status and error API; You only look at the raw logs very occasionally, when a) you're debugging and b) step status/error wasn't enough to find the answer (should be rare).

In my opinion, the sooner we agree on step 1 and implement it, the smoother the transition will be for users.

Activity

  1. shykes commented on May 19, 2023

    @shykes
    ContributorAuthor

    FYI @vito

  2. vito commented on May 19, 2023

    @vito
    Contributor

    Here's the current state of things (as of #5151):

    • While things are running, only failed and/or actively running commands show their output.
      • Completed commands are collapsed so you can stay focused on the bird's eye view and not get distracted by noisy output of "boring" successful commands.
    • Failed and actively running commands are always pushed to the end of the output, so you never have to scroll around to find interesting things among a sea of logs.
    • Only on the final render, i.e. after everything has completed, all output is displayed. The point of this is just to have everything available in the scrollback if you want to read it.
      • Any failed commands will still be at the bottom.

    One thing I want users to not have to worry about is "oh crap, I saw that briefly print something interesting, but now it's hidden away, and I didn't run with --verbose, and I don't know if that will ever happen again." Teaching users to always pass --verbose as a result of this experience would be something to avoid. (edit: but there are other ways to mitigate that, for example storing a local cache of output and letting them go back and replay.)

  3. gerhard commented on May 30, 2023

    @gerhard
    Contributor

    I can see that you have already thought about this @vito. Do we want to do something about this in a follow-up TUI - v0.6.0 patch release?

  4. vito commented on May 30, 2023

    @vito
    Contributor

    Just wanted to make sure we're all on the same page as to how things currently work before figuring out next steps. I did give a lot of thought to some of the concerns brought up in the original description, so there's a bit of nuance to the implementation. :)

    I don't meant to be a conversation-halter if we still want the experience to be changed for more fundamental reasons. For example the OP's steps 2 and 3 suggest stdout and stderr may someday be too low-level, instead replaced by higher-level outputs explicitly set via the API. That may still be valid in its own right, but I would suggest dogfooding a bit more and confirming the listed problems are real if they are the sole motivation.

  5. added this to the milestone on May 31, 2023
  6. vito commented on Jun 23, 2023

    @vito
    Contributor

    Circling back to this after a bit of dogfooding dagger do, I agree that it would be nice to hide all the noise.

    My current idea is to add a focus: true flag to WithExec that will bubble up to the TUI. We can have dagger do respect it by default, which makes sense to me as its goal is to be a higher-level dagger run.

    So in dagger do with focus: true used sparingly you would see something like this instead:

    asciicast

    In the above example, two WithExecs are given focus: true. Normally you would probably have only one.

    I'm not a 100% fan of the API, though, it's kind of clunky to type:

    	result := nixResult(ctx,
    		nixBase(ctx).
    			WithMountedDirectory("/src", drv).
    			WithMountedDirectory("/flake", flake).
    			WithExec([]string{"nix", "build", "-f", "/src/image.nix"},
    				dagger.ContainerWithExecOpts{
    					Focus: true,
    				}))

    Maybe it's worth having sugar for it? Or maybe there's some other way to approach this. 🤔

  7. shykes commented on Jun 23, 2023

    @shykes
    ContributorAuthor

    What if we did it at the pipeline level?

    • Add an option to Pipeline to configure the focus behavior. Possible values could be FocusFirstExec to focus the first exec operation, FocusLastExec, FocusNone, FocusAllExec.
    • Default would be FocusLastExec which would match the most common patterns IMO, but I could be wrong
    • Also encourages the use of Pipeline to control what is presented to the user
  8. vito commented on Jun 26, 2023

    @vito
    Contributor

    @shykes I like that line of thinking; it'd be great if you didn't have to remember to set a flag.

    Worth noting that our own tests run two commands that I think we would want to see the output of:

    1. gotestsum ./..., to run our tests with pretty output and generate a report
    2. gotestsum tool slowest to report the slowest tests

    I suppose we would have to use FocusAllExec and put them in their own pipeline to set that flag. We've talked about having dagger do automatically place commands in a pipeline reflecting the command hierarchy, so having to set up another pipeline nested beneath might feel a little redundant; I'm not sure what I would name it.

    Could still make sense as a sane default but I'll keep thinking.


    Here's an idea:

    type Container {
      "All subsequent commands will be focused."
      focus: Container!
    
      "All subsequent commands will be unfocused."
      unfocus: Container!
    }

    I like that this could be a pattern implemented by all APIs, as opposed to just container execs. It's also easy to sprinkle into a call chain to debug something.

  9. removed this from the milestone on Jul 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions