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

Introduce new help view to display information on any view #243

Closed
wants to merge 6 commits into from

Conversation

bIgBV
Copy link

@bIgBV bIgBV commented Dec 25, 2021

As a part of addressing #225 , I'm introducing a new floating pane which can show information relevant to the current in focus pane. This can include shortcuts, key bindings and glossary information when using symbols and emojis..

@@ -164,6 +171,17 @@ impl View {
}
}
}
_ => {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that this is unreachable. I guess I will have to create a new ViewState state to indicate that the help state is present. I think as long as I store what the previous state was, I can go back to it when esc (or any other key) is pressed.

@bIgBV bIgBV changed the title Introduce new help view to display information on any view [WIP] Introduce new help view to display information on any view Dec 25, 2021
@bIgBV
Copy link
Author

bIgBV commented Dec 28, 2021

Does anyone have thoughts on what the contents of the help popup should be in different views? For now I'm working on the mechanism to pump the information from the view to the popup. This is what it looks like currently:

image

@hawkw
Copy link
Member

hawkw commented Dec 28, 2021

@bIgBV this is awesome, thanks for working on this!

As for what should be displayed in the help text:

  • I think we should probably display the controls for the current view, even though they're also displayed in the header...perhaps once the help text feature is merged, we should consider hiding the controls from the header by default, and just display what key is needed to open the help text?
  • It could be useful to explain the meanings of different emojis/symbols in the current view?
  • Eventually, the same popup system could maybe be used for displaying detailed descriptions of warnings, but that's something we would add later (since we don't have a system for associating help with warnings yet...)

@bIgBV
Copy link
Author

bIgBV commented Dec 28, 2021

  • I think including the controls and what the symbols mean in a given page in the popup would be a good start.
  • And I love the idea of displaying the meaning behind/expanding on warnings in the future. And it should be fairly straightforward to extend this to perform that function.

.margin(0);

let content_area = content_layout
.constraints([layout::Constraint::Length(height)])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to create an area within the popup to render the text into, which would be responsive, but doing it like this doesn't seem to be working.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what isn't working, exactly? is the problem that the text isn't wrapping?

.constraints([layout::Constraint::Length(height)])
.split(popup_area)[0];

let display_text = Paragraph::new(content).block(styles.border_block().title("Help"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want the text to wrap, you need to call .wrap() on the Paragraph:

Suggested change
let display_text = Paragraph::new(content).block(styles.border_block().title("Help"));
let display_text = Paragraph::new(content)
.block(styles.border_block().title("Help"))
.wrap(Wrap { trim: true });

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was exactly what I was looking for. Thanks!

@bIgBV
Copy link
Author

bIgBV commented Jan 4, 2022

@hawkw got the text in the help popup to wrap properly (thanks again for the suggestion).

image

I also updated the text in the detail views to be (slightly) less generic. I think this is in a good place to be merged and I could separately open a new PR once we finalize the content of the help text for different views.

@bIgBV bIgBV marked this pull request as ready for review January 4, 2022 20:59
@bIgBV bIgBV changed the title [WIP] Introduce new help view to display information on any view Introduce new help view to display information on any view Jan 8, 2022
@hawkw
Copy link
Member

hawkw commented Mar 9, 2022

@bIgBV sorry it took me so long to look at this, I'd really like to actually give it a review now. It looks like this branch is now out of date with main, can I get you to rebase or merge main?

bIgBV added 5 commits March 12, 2022 11:06
We want to display the help popop in the current view, no matter
whichever it might be. This is because we might have distinct help
infomation per view. Therefore, the help view being displayed is
unrelated to any state in which the console as a whole is.

We handle this by separating the rendering of the help popup from the
state of the application.
For now I just copied the controls sections in the table for this.
@bIgBV bIgBV requested a review from a team as a code owner March 12, 2022 19:08
@bIgBV
Copy link
Author

bIgBV commented Mar 12, 2022

@hawkw no worries. I just rebased this branch on top of main.

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it took me such a long time to review this, but it looks like a good start. I had some small suggestions.

Thanks for working on this! If you no longer have the time to continue working on it, I could make the remaining suggested changes myself and go ahead and merge this branch. Let me know if you'd like that. Thanks again!

Comment on lines +32 to +36
let content = self
.help_text
.take()
.expect("help_text should be initialized")
.into();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's kind of weird to me that help_text is an Option that we have to take here? Is there a reason the render method has to take an &mut self? It could just take self --- this isn't a trait method or anything.

Comment on lines +28 to +29
_area: layout::Rect,
_state: &mut State,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason this has these arguments, when it doesn't use them? since this isn't a trait method, I think we should just not take these arguments just because they are passed to other views' render methods.

Suggested change
_area: layout::Rect,
_state: &mut State,

@@ -168,32 +177,56 @@ impl View {
update_kind
}

fn handl_help_popup(&mut self, event: crossterm::event::Event) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: should probably be

Suggested change
fn handl_help_popup(&mut self, event: crossterm::event::Event) {
fn handle_help_popup(&mut self, event: crossterm::event::Event) {

Comment on lines +184 to +185
}
if self.show_help_toggle && !input::is_help_toggle(&event) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, take it or leave it: if we used if ... else if, we could avoid the second call to input::is_help_toggle:

Suggested change
}
if self.show_help_toggle && !input::is_help_toggle(&event) {
} else if self.show_help_toggle {

@@ -168,32 +177,56 @@ impl View {
update_kind
}

fn handl_help_popup(&mut self, event: crossterm::event::Event) {
if input::is_help_toggle(&event) {
// TODO: Pause state if we are about to show the help toggle
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably do this before merging?

Comment on lines +201 to +221
help_content = HelpView::new(TableListState::<TasksTable>::render_help_content(
&self.styles,
));
}
ViewState::ResourcesList => {
self.resources_list
.render(&self.styles, frame, area, state, ());
help_content = HelpView::new(
TableListState::<ResourcesTable>::render_help_content(&self.styles),
);
}
ViewState::TaskInstance(ref mut view) => {
let now = state
.last_updated_at()
.expect("task view implies we've received an update");
view.render(&self.styles, frame, area, now);
help_content = HelpView::new(TaskView::render_help_content(&self.styles));
}
ViewState::ResourceInstance(ref mut view) => {
view.render(&self.styles, frame, area, state);
help_content = HelpView::new(ResourceView::render_help_content(&self.styles));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice that this will construct the help content for each view every time we render a screen, even if we're not showing the help window. That seems a little bit inefficient, since we have to allocate a big vec and a bunch of strings.

I think it might be more efficient to add a second match self.state inside of the if self.show_help_toggle box, and only build the help text if we are actually going to display a help box. That might make the method a bit longer, but I think it's worth doing to avoid having to format the help text when we're not going to display it...

@@ -267,6 +267,10 @@ impl TaskView {
frame.render_widget(fields_widget, fields_area);
frame.render_widget(percentiles_widget, percentiles_area);
}

pub(in crate::view) fn render_help_content(_styles: &view::Styles) -> Spans<'static> {
Spans::from(vec![Span::raw("A view to diplay help data for a task")])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this also include controls?

@hawkw hawkw mentioned this pull request Apr 30, 2022
@hawkw
Copy link
Member

hawkw commented Apr 30, 2022

@bIgBV quick ping — still interested in working on this?

@bIgBV
Copy link
Author

bIgBV commented May 11, 2022

@hawkw I completely missed my notifications on this. While I'm still interested in working on this, my job has kept me pretty busy, and will keep doing so for the next couple of weeks. So if you can pull in my changes and add the ones you suggested on top of that, please go for it!

@erwanor
Copy link

erwanor commented Sep 21, 2022

@bIgBV Hey, would you feel comfortable giving me write access to your fork repo ("Adding contributors" in settings). Otherwise, I'd need to start a fork from scratch and apply your changes etc. which might get a bit gnarly, and we'd lose this convo history.

@bIgBV
Copy link
Author

bIgBV commented Sep 22, 2022

@erwanor I've sent you an invitation.

hds added a commit that referenced this pull request May 31, 2023
Adds a help modal which is available on every view. The help help modal
can be accessed by pressing `?` and overlays the current view. To leave
the help modal, the user can press `?` or `Esc`.

This PR is based on #243 originally authored by @bIgBV. The previous PR
has been dormant for around a year.

Currently the help modal only displays a vertical list of controls. This
is the same information that is available in the controls widget on each
view.

Here is an example of the tasks view with the help view modal active:

```text
connection: http://localhost:6669/ (CONNECTED)
views: t = tasks, r = resources
controls: select column (sort) = ←→ or h, l, scroll = ↑↓ or k, j,
view details = ↵, invert sort (highest/lowest) = i, scroll to top = gg,
scroll to bottom╭Help──────────────────────────────────────────╮t = q
╭Warnings───────│controls:                                     │───────────────╮
│⚠ 1 tasks have │  select column (sort) = ←→ or h, l           │               │
╰───────────────│  scroll = ↑↓ or k, j                         │───────────────╯
╭Tasks (12) ▶ Ru│  view details = ↵                            │───────────────╮
│Warn  ID  State│  invert sort (highest/lowest) = i            │t      Location│
│       19 ▶    │  scroll to top = gg                          │::task console-│
│       22 ⏸   │  scroll to bottom = G                        │::task console-│
│⚠ 1    23 ⏸   │  toggle pause = space                        │::task console-│
│       24 ⏸   │  toggle help = ?                             │::task console-│
│       25 ⏸   │  quit = q                                    │::task console-│
│       74 ⏹   │                                              │::task console-│
│       75 ⏸   │                                              │::task console-│
│       77 ⏸   │                                              │::task console-│
│       78 ⏸   ╰──────────────────────────────────────────────╯::task console-│
│       79 ⏹     wait      11s    4ms   56µs    11s 2     tokio::task console-│
╰──────────────────────────────────────────────────────────────────────────────╯
```

However, the idea is that the help modal can provide contextual
information depending on the view and the state of the application being
observed. This will allow us to provide more details about any lints
which are currently triggering and also to reduce the height of the
current controls widget to just one line (perhaps optionally) as the
full list of controls can be accessed from the help view.

Co-authored-by: bIgBV <[email protected]>
hds added a commit that referenced this pull request May 31, 2023
Adds a help modal which is available on every view. The help help modal
can be accessed by pressing `?` and overlays the current view. To leave
the help modal, the user can press `?` or `Esc`.

This PR is based on #243 originally authored by @bIgBV. The previous PR
has been dormant for around a year.

Currently the help modal only displays a vertical list of controls. This
is the same information that is available in the controls widget on each
view.

Here is an example of the tasks view with the help view modal active:

```text
connection: http://localhost:6669/ (CONNECTED)
views: t = tasks, r = resources
controls: select column (sort) = ←→ or h, l, scroll = ↑↓ or k, j,
view details = ↵, invert sort (highest/lowest) = i, scroll to top = gg,
scroll to bottom╭Help──────────────────────────────────────────╮t = q
╭Warnings───────│controls:                                     │───────────────╮
│⚠ 1 tasks have │  select column (sort) = ←→ or h, l           │               │
╰───────────────│  scroll = ↑↓ or k, j                         │───────────────╯
╭Tasks (12) ▶ Ru│  view details = ↵                            │───────────────╮
│Warn  ID  State│  invert sort (highest/lowest) = i            │t      Location│
│       19 ▶    │  scroll to top = gg                          │::task console-│
│       22 ⏸    │  scroll to bottom = G                        │::task console-│
│⚠ 1    23 ⏸    │  toggle pause = space                        │::task console-│
│       24 ⏸    │  toggle help = ?                             │::task console-│
│       25 ⏸    │  quit = q                                    │::task console-│
│       74 ⏹    │                                              │::task console-│
│       75 ⏸    │                                              │::task console-│
│       77 ⏸    │                                              │::task console-│
│       78 ⏸    ╰──────────────────────────────────────────────╯::task console-│
│       79 ⏹      wait      11s    4ms   56µs    11s 2     tokio::task console-│
╰──────────────────────────────────────────────────────────────────────────────╯
```

However, the idea is that the help modal can provide contextual
information depending on the view and the state of the application being
observed. This will allow us to provide more details about any lints
which are currently triggering and also to reduce the height of the
current controls widget to just one line (perhaps optionally) as the
full list of controls can be accessed from the help view.

Co-authored-by: bIgBV <[email protected]>
hds added a commit that referenced this pull request May 31, 2023
Adds a help modal which is available on every view. The help help modal
can be accessed by pressing `?` and overlays the current view. To leave
the help modal, the user can press `?` or `Esc`.

This PR is based on #243 originally authored by @bIgBV. The previous PR
has been dormant for around a year.

Currently the help modal only displays a vertical list of controls. This
is the same information that is available in the controls widget on each
view.

Here is an example of the tasks view with the help view modal active:

```text
connection: http://localhost:6669/ (CONNECTED)
views: t = tasks, r = resources
controls: select column (sort) = ←→ or h, l, scroll = ↑↓ or k, j,
view details = ↵, invert sort (highest/lowest) = i, scroll to top = gg,
scroll to bottom╭Help──────────────────────────────────────────╮t = q
╭Warnings───────│controls:                                     │───────────────╮
│⚠ 1 tasks have │  select column (sort) = ←→ or h, l           │               │
╰───────────────│  scroll = ↑↓ or k, j                         │───────────────╯
╭Tasks (12) ▶ Ru│  view details = ↵                            │───────────────╮
│Warn  ID  State│  invert sort (highest/lowest) = i            │t      Location│
│       19 ▶    │  scroll to top = gg                          │::task console-│
│       22 ⏸    │  scroll to bottom = G                        │::task console-│
│⚠ 1    23 ⏸    │  toggle pause = space                        │::task console-│
│       24 ⏸    │  toggle help = ?                             │::task console-│
│       25 ⏸    │  quit = q                                    │::task console-│
│       74 ⏹    │                                              │::task console-│
│       75 ⏸    │                                              │::task console-│
│       77 ⏸    │                                              │::task console-│
│       78 ⏸    ╰──────────────────────────────────────────────╯::task console-│
│       79 ⏹      wait      11s    4ms   56µs    11s 2     tokio::task console-│
╰──────────────────────────────────────────────────────────────────────────────╯
```

However, the idea is that the help modal can provide contextual
information depending on the view and the state of the application being
observed. This will allow us to provide more details about any lints
which are currently triggering and also to reduce the height of the
current controls widget to just one line (perhaps optionally) as the
full list of controls can be accessed from the help view.

Co-authored-by: bIgBV <[email protected]>
hds added a commit that referenced this pull request May 31, 2023
Adds a help modal which is available on every view. The help help modal
can be accessed by pressing `?` and overlays the current view. To leave
the help modal, the user can press `?` or `Esc`.

This PR is based on #243 originally authored by @bIgBV. The previous PR
has been dormant for around a year.

Currently the help modal only displays a vertical list of controls. This
is the same information that is available in the controls widget on each
view.

Here is an example of the tasks view with the help view modal active:

```text
connection: http://localhost:6669/ (CONNECTED)
views: t = tasks, r = resources
controls: select column (sort) = ←→ or h, l, scroll = ↑↓ or k, j,
view details = ↵, invert sort (highest/lowest) = i, scroll to top = gg,
scroll to bottom╭Help──────────────────────────────────────────╮t = q
╭Warnings───────│controls:                                     │───────────────╮
│⚠ 1 tasks have │  select column (sort) = ←→ or h, l           │               │
╰───────────────│  scroll = ↑↓ or k, j                         │───────────────╯
╭Tasks (12) ▶ Ru│  view details = ↵                            │───────────────╮
│Warn  ID  State│  invert sort (highest/lowest) = i            │t      Location│
│       19 ▶    │  scroll to top = gg                          │::task console-│
│       22 ⏸    │  scroll to bottom = G                        │::task console-│
│⚠ 1    23 ⏸    │  toggle pause = space                        │::task console-│
│       24 ⏸    │  toggle help = ?                             │::task console-│
│       25 ⏸    │  quit = q                                    │::task console-│
│       74 ⏹    │                                              │::task console-│
│       75 ⏸    │                                              │::task console-│
│       77 ⏸    │                                              │::task console-│
│       78 ⏸    ╰──────────────────────────────────────────────╯::task console-│
│       79 ⏹      wait      11s    4ms   56µs    11s 2     tokio::task console-│
╰──────────────────────────────────────────────────────────────────────────────╯
```

However, the idea is that the help modal can provide contextual
information depending on the view and the state of the application being
observed. This will allow us to provide more details about any lints
which are currently triggering and also to reduce the height of the
current controls widget to just one line (perhaps optionally) as the
full list of controls can be accessed from the help view.

Co-authored-by: bIgBV <[email protected]>
hds added a commit that referenced this pull request Jun 6, 2023
Adds a help modal which is available on every view. The help help modal
can be accessed by pressing `?` and overlays the current view. To leave
the help modal, the user can press `?` or `Esc`.

This PR is based on #243 originally authored by @bIgBV. The previous PR
has been dormant for around a year.

Currently the help modal only displays a vertical list of controls. This
is the same information that is available in the controls widget on each
view.

Here is an example of the tasks view with the help view modal active:

```text
connection: http://localhost:6669/ (CONNECTED)
views: t = tasks, r = resources
controls: select column (sort) = ←→ or h, l, scroll = ↑↓ or k, j,
view details = ↵, invert sort (highest/lowest) = i, scroll to top = gg,
scroll to bottom╭Help──────────────────────────────────────────╮t = q
╭Warnings───────│controls:                                     │───────────────╮
│⚠ 1 tasks have │  select column (sort) = ←→ or h, l           │               │
╰───────────────│  scroll = ↑↓ or k, j                         │───────────────╯
╭Tasks (12) ▶ Ru│  view details = ↵                            │───────────────╮
│Warn  ID  State│  invert sort (highest/lowest) = i            │t      Location│
│       19 ▶    │  scroll to top = gg                          │::task console-│
│       22 ⏸    │  scroll to bottom = G                        │::task console-│
│⚠ 1    23 ⏸    │  toggle pause = space                        │::task console-│
│       24 ⏸    │  toggle help = ?                             │::task console-│
│       25 ⏸    │  quit = q                                    │::task console-│
│       74 ⏹    │                                              │::task console-│
│       75 ⏸    │                                              │::task console-│
│       77 ⏸    │                                              │::task console-│
│       78 ⏸    ╰──────────────────────────────────────────────╯::task console-│
│       79 ⏹      wait      11s    4ms   56µs    11s 2     tokio::task console-│
╰──────────────────────────────────────────────────────────────────────────────╯
```

However, the idea is that the help modal can provide contextual
information depending on the view and the state of the application being
observed. This will allow us to provide more details about any lints
which are currently triggering and also to reduce the height of the
current controls widget to just one line (perhaps optionally) as the
full list of controls can be accessed from the help view.

Co-authored-by: bIgBV <[email protected]>
hds added a commit that referenced this pull request Jun 6, 2023
Adds a help modal which is available on every view. The help help modal
can be accessed by pressing `?` and overlays the current view. To leave
the help modal, the user can press `?` or `Esc`.

This PR is based on #243 originally authored by @bIgBV. The previous PR
has been dormant for around a year.

Currently the help modal only displays a vertical list of controls. This
is the same information that is available in the controls widget on each
view.

Here is an example of the tasks view with the help view modal active:

```text
connection: http://localhost:6669/ (CONNECTED)
views: t = tasks, r = resources
controls: select column (sort) = ←→ or h, l, scroll = ↑↓ or k, j,
view details = ↵, invert sort (highest/lowest) = i, scroll to top = gg,
scroll to bottom╭Help──────────────────────────────────────────╮t = q
╭Warnings───────│controls:                                     │───────────────╮
│⚠ 1 tasks have │  select column (sort) = ←→ or h, l           │               │
╰───────────────│  scroll = ↑↓ or k, j                         │───────────────╯
╭Tasks (12) ▶ Ru│  view details = ↵                            │───────────────╮
│Warn  ID  State│  invert sort (highest/lowest) = i            │t      Location│
│       19 ▶    │  scroll to top = gg                          │::task console-│
│       22 ⏸    │  scroll to bottom = G                        │::task console-│
│⚠ 1    23 ⏸    │  toggle pause = space                        │::task console-│
│       24 ⏸    │  toggle help = ?                             │::task console-│
│       25 ⏸    │  quit = q                                    │::task console-│
│       74 ⏹    │                                              │::task console-│
│       75 ⏸    │                                              │::task console-│
│       77 ⏸    │                                              │::task console-│
│       78 ⏸    ╰──────────────────────────────────────────────╯::task console-│
│       79 ⏹      wait      11s    4ms   56µs    11s 2     tokio::task console-│
╰──────────────────────────────────────────────────────────────────────────────╯
```

However, the idea is that the help modal can provide contextual
information depending on the view and the state of the application being
observed. This will allow us to provide more details about any lints
which are currently triggering and also to reduce the height of the
current controls widget to just one line (perhaps optionally) as the
full list of controls can be accessed from the help view.

Co-authored-by: bIgBV <[email protected]>
@hds
Copy link
Collaborator

hds commented Aug 29, 2023

As no further progress had been made on this PR, a new one was opened (#432) inspired by it and has now been merged.

@hds hds closed this 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.

4 participants