beetbox/beets

Regression in 2.0.0: import UI is useless in ligth theme

catap opened this issue · 8 comments

Problem

When someoen uses non dark theme, like me for last couple of weeks, it leads to almost not usefull UI.

See:

image

This is regression was introduced by #3721

You may reproduce it by using this xterm theme: https://github.com/janoamaral/Xresources-themes/blob/master/light/PaperColor.Xresources

Setup

  • OS: OpenBSD-current
  • Python version: 3.11.9
  • beets version: 2.0.0
  • Turning off plugins made problem go away (yes/no):

My configuration (output of beet config) is:

lyrics:
    bing_lang_from: []
    auto: yes
    sources: musixmatch genius tekstowo google
    google_API_key: REDACTED
    google_engine_ID: REDACTED
    bing_client_secret: REDACTED
    bing_lang_to:
    genius_api_key: REDACTED
    fallback:
    force: no
    local: no
    synced: no
    dist_thresh: 0.1
directory: /mnt/diskstation/music
asciify_paths: yes

import:
    move: yes
fetchart:
    sources: filesystem coverart itunes amazon albumart lastfm
    lastfm_key: REDACTED
    auto: yes
    minwidth: 0
    maxwidth: 0
    quality: 0
    max_filesize: 0
    enforce_ratio: no
    cautious: no
    cover_names:
    - cover
    - front
    - art
    - album
    - folder
    store_source: no
    high_resolution: no
    deinterlace: no
    cover_format:
    google_key: REDACTED
    google_engine: 001442825323518660753:hrh5ch1gjzm
    fanarttv_key: REDACTED
musicbrainz:
    user: catap
    pass: REDACTED
mbcollection:
    auto: yes
    remove: yes
    collection: 04540b29-ba5e-4e0e-82e8-161035854aa4
convert:
    copy_album_art: yes
    auto: no
    format: flac
    formats:
        copy_m4a:
            command: ffmpeg -i $source -y -vn -c:a copy $dest
            extension: m4a
        aac:
            command: ffmpeg -i $source -y -vn -acodec aac -aq 1 $dest
            extension: m4a
        alac:
            command: ffmpeg -i $source -y -vn -acodec alac $dest
            extension: m4a
        flac: ffmpeg -i $source -y -vn -acodec flac $dest
        mp3: ffmpeg -i $source -y -vn -aq 2 $dest
        opus: ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest
        ogg: ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest
        wma: ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest
    dest:
    pretend: no
    link: no
    hardlink: no
    threads: 4
    id3v23: inherit
    max_bitrate:
    auto_keep: no
    tmpdir:
    quiet: no
    embed: yes
    paths: {}
    no_convert: ''
    never_convert_lossy_files: no
    album_art_maxwidth: 0
    delete_originals: no
    playlist:
paths:
    default: '%the{$albumartist}/$album%aunique{}/$track $title'
    singleton: Non-Album/$artist/$title
    comp: Compilations/$album%aunique{}/$track $title

# --------------- Plugins ---------------

plugins: convert duplicates edit embedart fetchart fuzzy info lastgenre lyrics mbcollection mbsubmit mbsync missing the
duplicates:
    album: no
    checksum: ''
    copy: ''
    count: no
    delete: no
    format: ''
    full: no
    keys: []
    merge: no
    move: ''
    path: no
    tiebreak: {}
    strict: no
    tag: ''
embedart:
    maxwidth: 0
    auto: yes
    compare_threshold: 0
    ifempty: no
    remove_art_file: no
    quality: 0
edit:
    albumfields: album albumartist
    itemfields: track title artist album
    ignore_fields: id path
fuzzy:
    prefix: '~'
    threshold: 0.7
lastgenre:
    whitelist: yes
    min_weight: 10
    count: 1
    fallback:
    canonical: no
    source: album
    force: yes
    auto: yes
    separator: ', '
    prefer_specific: no
    title_case: yes
mbsubmit:
    format: $track. $title - $artist ($length)
    threshold: medium
    picard_path: picard
the:
    the: yes
    a: yes
    format: '{0}, {1}'
    strip: no
    patterns: []
missing:
    count: no
    total: no
    album: no

@arsaboo yes, I can. But this bug can be reproduced with default setting of Xterm.

Do you have a suggested fix for this @catap? It seems relatively easy to change from a user's settings. Perhaps a change of the default colours for people who haven't set it specifically?

I think that default settings should be useful for both dark and light themes, at least it was true before 2.0.0

Just for records, here how it looks at default settings of xterm:

image

The next step, I've tried to use lightgray instead of white as it state in docs. But I can't, it leads to:

Traceback (most recent call last):
  File "/usr/local/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/beets/ui/__init__.py", line 1865, in main
    _raw_main(args)
  File "/usr/local/lib/python3.11/site-packages/beets/ui/__init__.py", line 1852, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/usr/local/lib/python3.11/site-packages/beets/ui/commands.py", line 1395, in import_func
    import_files(lib, paths, query)
  File "/usr/local/lib/python3.11/site-packages/beets/ui/commands.py", line 1326, in import_files
    session.run()
  File "/usr/local/lib/python3.11/site-packages/beets/importer.py", line 360, in run
    pl.run_parallel(QUEUE_SIZE)
  File "/usr/local/lib/python3.11/site-packages/beets/util/pipeline.py", line 447, in run_parallel
    raise exc_info[1].with_traceback(exc_info[2])
  File "/usr/local/lib/python3.11/site-packages/beets/util/pipeline.py", line 312, in run
    out = self.coro.send(msg)
          ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/beets/util/pipeline.py", line 171, in coro
    task = func(*(args + (task,)))
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/beets/importer.py", line 1521, in user_query
    task.choose_match(session)
  File "/usr/local/lib/python3.11/site-packages/beets/importer.py", line 949, in choose_match
    choice = session.choose_match(self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/beets/ui/commands.py", line 1040, in choose_match
    path_str = ui.colorize("import_path", path_str0)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/beets/ui/__init__.py", line 618, in colorize
    raise ValueError("no such ANSI code %s", code)
ValueError: ('no such ANSI code %s', 'lightgray')

Probably a way to fix it. First, we need to move to 4-bit ansi colors as:

modified   beets/ui/__init__.py
@@ -533,6 +533,14 @@ ANSI_CODES = {
     "magenta": 35,
     "cyan": 36,
     "white": 37,
+    "bright_black": 90,
+    "bright_red": 91,
+    "bright_green": 92,
+    "bright_yellow": 93,
+    "bright_blue": 94,
+    "bright_magenta": 95,
+    "bright_cyan": 96,
+    "bright_white": 97,
     # Background colors.
     "bg_black": 40,
     "bg_red": 41,
@@ -542,6 +550,14 @@ ANSI_CODES = {
     "bg_magenta": 45,
     "bg_cyan": 46,
     "bg_white": 47,
+    "bg_bright_black": 100,
+    "bg_bright_red": 101,
+    "bg_bright_green": 102,
+    "bg_bright_yellow": 103,
+    "bg_bright_blue": 104,
+    "bg_bright_magenta": 105,
+    "bg_bright_cyan": 106,
+    "bg_bright_white": 107,
 }
 RESET_COLOR = COLOR_ESCAPE + "39;49;00m"
 

after that I may use bright colors as:

modified   beets/config_default.yaml
@@ -122,7 +122,7 @@ ui:
         text_warning: ['bold', 'yellow']
         text_error: ['bold', 'red']
         text_highlight: ['bold', 'red']
-        text_highlight_minor: ['white']
+        text_highlight_minor: ['bright_white']
         action_default: ['bold', 'cyan']
         action: ['bold', 'cyan']
         # New Colors
@@ -130,16 +130,16 @@ ui:
         text_faint: ['faint']
         import_path: ['bold', 'blue']
         import_path_items: ['bold', 'blue']
-        added:   ['green']
-        removed: ['red']
-        changed: ['yellow']
+        added:   ['bright_green']
+        removed: ['bright_red']
+        changed: ['bright_yellow']
         added_highlight:   ['bold', 'green']
         removed_highlight: ['bold', 'red']
         changed_highlight: ['bold', 'yellow']
         text_diff_added:   ['bold', 'red']
         text_diff_removed: ['bold', 'red']
         text_diff_changed: ['bold', 'red']
-        action_description: ['white']
+        action_description: ['bright_white']
     import:
         indentation:
             match_header: 2

which leads to UI like:

image

Or, without any new collors:

ui:
    terminal_width: 80
    length_diff_thresh: 10.0
    color: yes
    colors:
        text_success: ['bold', 'green']
        text_warning: ['bold', 'yellow']
        text_error: ['bold', 'red']
        text_highlight: ['bold', 'red']
        text_highlight_minor: ['bold', 'white']
        action_default: ['bold', 'cyan']
        action: ['bold', 'cyan']
        # New Colors
        text: ['normal']
        text_faint: ['faint']
        import_path: ['bold', 'blue']
        import_path_items: ['bold', 'blue']
        added:   ['bold', 'green']
        removed: ['bold', 'red']
        changed: ['bold', 'yellow']
        added_highlight:   ['bold', 'green']
        removed_highlight: ['bold', 'red']
        changed_highlight: ['bold', 'yellow']
        text_diff_added:   ['bold', 'red']
        text_diff_removed: ['bold', 'red']
        text_diff_changed: ['bold', 'red']
        action_description: ['bold', 'white']