Opened 3 years ago

Last modified 2 months ago

#18708 new enhancement

Welcome page

Reported by: atagar Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Nyx Version:
Severity: Normal Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

I've been impressed at how much Nyx users miss. Hell, I've met longtime users that didn't even know you could press left/right for additional pages. They thought Nyx had just one!

To be fair Nyx's discoverability sucks. I've tried to keep the most important information simple so it can be displayed on a single line...

m: menu, p: pause, h: page help, q: quit

But maybe we should show a one-time popup to first time Nyx users that explains how Nyx works. We could then persist a 'shown' flag in their home directory to suppress future popups.

Child Tickets

Change History (10)

comment:1 Changed 3 months ago by aegis2501

Hello, could I help with this?

comment:2 Changed 3 months ago by atagar

Hi aegis2501. Certainly, this isn't very high on my todo list so if you'd care to give this a whirl that would be great!

comment:3 Changed 3 months ago by aegis2501

Would this be appropriate?

https://github.com/aegis2501/nyx/blob/master/nyx/popups.py

I have added a popup that is displayed when nyx is started for the first time.
It is currently blank as I thought I should consult you first.

comment:4 Changed 3 months ago by atagar

Looks good! Thanks aegis2501, only thoughts are...

if CONFIG['shown_welcome'] is False:

This works, but rather be "if not CONFIG['shown_welcome']". For a description of what's up (and why you should generally avoid the 'is' keyword) please see...

https://trac.torproject.org/projects/tor/ticket/27350#comment:3

Also, this should not be done in draw's while loop since this is a one-time notice. Please also invert this so the preference is 'show_welcome'. This way users can set 'show_welcome true' in their nyxrc if they'd like to always see the prompt.

config.set('shown_welcome', 'true')

We also need to save the configuration, otherwise this won't be a one-time prompt (this flag will always be 'false' when starting). This will take a little work because we presently have two configurations...

This flag is going to necessitate a third category.

  • Persisted settings from Nyx's last run (~/.nyx/runtime_cache).

Besides this flag we will likely end up using this to remember changes made as we run (for instance sort ordering, logging filters, etc).

One complication is that we'll need to keep these separate from the other settings. Presently we load user and built-in preferences into the same configuration object. This works because built-in preferences are read-only...

built-in preference loading: https://gitweb.torproject.org/nyx.git/tree/nyx/__init__.py#n167
user preference loading: https://gitweb.torproject.org/nyx.git/tree/nyx/starter.py#n73

As such we'll want a new pair of helper methods in nyx/__init__.py, their rough psudo code looking something like...

RUNTIME_PREFERNCES = stem.util.conf.Config()

@uses_settings
def runtime_preference(user_config, key):
  if key in user_config:
    # if the user explicitly specifies this in their user configuration
    # it always takes precedence

    return user_config.get(key)
  else:
    return RUNTIME_PREFERNCES.get(key)

def save_runtime_preference(key, value):
  runtime_preference_path = data_directory(runtime_cache)

  RUNTIME_PREFERNCES.set(key, value)
  RUNTIME_PREFERNCES.save(runtime_preference_path)

One last thing is that we'll want to add test coverage for this popup when it's fully implemented (test/popups.py has examples we can follow).

Sorry! Kinda silly this reply is longer than the code ya wrote. I completely forgot we'd need runtime preferences for this. :P

If this gives you any trouble or you'd prefer for me to take care of that side of it just say the word and I'll whip it up.

comment:5 in reply to:  4 Changed 3 months ago by aegis2501

Replying to atagar:

Looks good! Thanks aegis2501, only thoughts are...

if CONFIG['shown_welcome'] is False:

This works, but rather be "if not CONFIG['shown_welcome']". For a description of what's up (and why you should generally avoid the 'is' keyword) please see...

https://trac.torproject.org/projects/tor/ticket/27350#comment:3

Also, this should not be done in draw's while loop since this is a one-time notice. Please also invert this so the preference is 'show_welcome'. This way users can set 'show_welcome true' in their nyxrc if they'd like to always see the prompt.

config.set('shown_welcome', 'true')

We also need to save the configuration, otherwise this won't be a one-time prompt (this flag will always be 'false' when starting). This will take a little work because we presently have two configurations...

This flag is going to necessitate a third category.

  • Persisted settings from Nyx's last run (~/.nyx/runtime_cache).

Besides this flag we will likely end up using this to remember changes made as we run (for instance sort ordering, logging filters, etc).

One complication is that we'll need to keep these separate from the other settings. Presently we load user and built-in preferences into the same configuration object. This works because built-in preferences are read-only...

built-in preference loading: https://gitweb.torproject.org/nyx.git/tree/nyx/__init__.py#n167
user preference loading: https://gitweb.torproject.org/nyx.git/tree/nyx/starter.py#n73

As such we'll want a new pair of helper methods in nyx/__init__.py, their rough psudo code looking something like...

RUNTIME_PREFERNCES = stem.util.conf.Config()

@uses_settings
def runtime_preference(user_config, key):
  if key in user_config:
    # if the user explicitly specifies this in their user configuration
    # it always takes precedence

    return user_config.get(key)
  else:
    return RUNTIME_PREFERNCES.get(key)

def save_runtime_preference(key, value):
  runtime_preference_path = data_directory(runtime_cache)

  RUNTIME_PREFERNCES.set(key, value)
  RUNTIME_PREFERNCES.save(runtime_preference_path)

One last thing is that we'll want to add test coverage for this popup when it's fully implemented (test/popups.py has examples we can follow).

Sorry! Kinda silly this reply is longer than the code ya wrote. I completely forgot we'd need runtime preferences for this. :P

If this gives you any trouble or you'd prefer for me to take care of that side of it just say the word and I'll whip it up.


No need to apologise, I'll work on it.

comment:6 Changed 3 months ago by aegis2501

Hello, I've made the changes you suggested:

https://github.com/aegis2501/nyx/blob/master/nyx/__init__.py

Apologies for the delay, I've been a bit busy lately.
Please let me know if there is anything I overlooked or need to clean up.
Still need to add test coverage too :)

comment:7 Changed 2 months ago by aegis2501

Could you give me some pointers as to what you would like to see in the welcome page?

comment:8 Changed 2 months ago by atagar

Hi aegis2501, sorry about the long delay. I've been busy with our Stem 1.7 release.

Your change looks great. I'll probably tweak this a tad so runtime preferences are lazily created when needed and not invoked in the main() method but those are just details. I wouldn't mind merging what you have here as-is if you'd like and circle back when I have time.

As for what to include on the welcome popup honestly I'm not entirely sure. We should indicate features of Nyx newcomers might not know about. For instance...

  • You can use arrow keys to see additional pages of data.
  • You can press 'm' to navigate options in a menu.
  • You can customize nyx through a nyxrc.

These are all things I was amazed to hear new nyx users were surprised to discover. I'm not sure though what well to tell folks. Maybe we should reach out to tor-relays@ to ask our relay operating community what they found most confusing when first using Nyx and what they wish they had in a welcome page?

comment:9 Changed 2 months ago by aegis2501

Hello, I've added in your bullet points. To be honest, I think they're sufficient, since the part about being able to navigate with the arrow keys was the one that escaped users the most.

Otherwise I am pretty much done and would be happy to hand the rest off to you if that's ok :)

comment:10 Changed 2 months ago by atagar

Great, thanks aegis2501! Certainly, I'd be happy to handle it from here. Thanks for the help!

Note: See TracTickets for help on using tickets.