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

[cli] Reimplement the interactive renderer #11200

Merged
merged 4 commits into from Nov 8, 2022

Commits on Nov 8, 2022

  1. [cli] Reimplement the interactive renderer

    The display pipleline looks like this:
    
           ╭──────╮
           │Engine│
           ╰──────╯
              ⬇ engine events
       ╭────────────────╮
       │Progress Display│
       ╰────────────────╯
              ⬇ display events: ticks, resource updates, system messages
       ╭─────────────────╮
       │Progress Renderer│
       ╰─────────────────╯
              ⬇ text
          ╭────────╮
          │Terminal│
          ╰────────╯
    
    The existing implementation of the interactive Progress Renderer is broken
    into two parts, the display renderer and the message renderer. The display
    renderer converts display events into progress messages, each of which
    generally represents a single line of text at a particular position in
    the output. The message renderer converts progress messages into screen
    updates by identifying whether or not the contents of a particular
    message have changed and if so, re-rendering its output line. In
    somewhat greater detail:
    
       ╭────────────────╮
       │Display Renderer│
       ╰────────────────╯
              ⬇ convert resource rows into a tree table
              ⬇ convert the tree table and system messages into lines
              ⬇ convert each line into a progress message with an index
       ╭────────────────╮
       │Message Renderer│
       ╰────────────────╯
              ⬇ if the line identified in a progress message has changed,
              ⬇ go to that line on the terminal, clear it, and update it
          ╭────────╮
          │Terminal│
          ╰────────╯
    
    This separation of concerns is unnecessary and makes it difficult to
    understand where and when the terminal is updated. This approach also
    makes it somewhat challenging to change the way in which the display
    interacts with the terminal, as both the display renderer and the
    message renderer need to e.g. understand terminal dimensions, movement,
    etc.
    
    These changes reimplement the interactive Progress Renderer using a
    frame-oriented approach. The display is updated at 60 frame per second.
    If nothing has happened to invalidate the display's contents (i.e. no
    changes to the terminal geometry or the displayable contents have occurred),
    then the frame is not redrawn. Otherwise, the contents of the display
    are re-rendered and redrawn.
    
    An advantage of this approach is that it made it relatively simple to
    fix a long-standing issue with the interactive display: when the number
    of rows in the output exceed the height of the terminal, the new
    renderer clamps the output and allows the user to scroll the tree table
    using the up and down arrow keys.
    pgavlin committed Nov 8, 2022
    Copy the full SHA
    27fb276 View commit details
    Browse the repository at this point in the history
  2. Copy the full SHA
    ecb88da View commit details
    Browse the repository at this point in the history
  3. make tidy

    pgavlin committed Nov 8, 2022
    Copy the full SHA
    7d17bba View commit details
    Browse the repository at this point in the history
  4. Copy the full SHA
    0e8d3e4 View commit details
    Browse the repository at this point in the history