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

Implement Notification layer #2846

Closed
willmcgugan opened this issue Jun 27, 2023 · 4 comments · Fixed by #2866
Closed

Implement Notification layer #2846

willmcgugan opened this issue Jun 27, 2023 · 4 comments · Fixed by #2866
Assignees
Labels
enhancement New feature or request Task

Comments

@willmcgugan
Copy link
Collaborator

We need a notification layer which presents text notification to the user. Notification should appear on the bottom right (configurable) and disappear after a few seconds (also configurable). Multiple notifications should stack as they appear.

Widgets should have a notify method to display a notification. Something like the following:

def notify(message:str, level:Literal["info", "warning", "error"]) -> None:
    ...

Note that in the future these notifications may be displayed somewhere other than the Textual app.

Things to consider:

  • What should happen if there are many notifications in a short period of time? My gut feeling is that only a fixed number of the most recent notifications should be displayed.
  • The user should be able to dismiss dialogs. Possibly with a click and / or key binding
@davep davep added enhancement New feature or request Task labels Jun 27, 2023
@davep
Copy link
Contributor

davep commented Jun 27, 2023

On the subject of the message itself: it would be tempting to allow any sort of renderable, but because the message may end up being routed somewhere other than the Textual application itself, we should stick with a string. The exception here though is that we will allow Rich markup as that can be handled within the application, while also capable of simply bring stripped or translated into some other markup.

@davep
Copy link
Contributor

davep commented Jun 27, 2023

Early proof-of-concept, it very little code!

Screen.Recording.2023-06-27.at.16.39.04.mov

@davep
Copy link
Contributor

davep commented Jun 29, 2023

The initial version of this works fine, but is per-screen (which makes sense given that that's how Textual's DOM works). However, in further discussion, it's been decided that the notifications should work "above" the screens (in other words if you have a set of notifications visible, then push a fresh screen, those notifications should still be visible; likewise if you're a number of screens into the stack and add a notification and then pop a screen or 3 the currently-visible and still-not-expired notifications should still be visible).

The initial work will be set aside (copying some of the visual ideas over, of course) in favour of a newer App-based approach where a notification queue will be maintained by the App and as screens come and go they'll be told what to show.

@davep davep mentioned this issue Jun 30, 2023
@davep davep linked a pull request Jun 30, 2023 that will close this issue
@github-actions
Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants