Skip to content

fix(processlist): show Windows priority classes as labels in the NI column (#3672) - #3673

Merged
nicolargo merged 1 commit into
nicolargo:developfrom
ntdatt812:fix/windows-nice-labels-3672
Aug 26, 2026
Merged

nicolargo merged 1 commit into
nicolargo:developfrom
ntdatt812:fix/windows-nice-labels-3672

Conversation

@ntdatt812

Copy link
Copy Markdown
Contributor

Closes #3672.

What was wrong

On Windows psutil reports the Win32 priority class in nice, not a nice value. The class values are neither ordered nor small — 32 is normal while 32768 is above normal — so the NI column showed a five-digit number that means nothing as a nice value and overflows a column formatted {:>3}.

What this does

Renders the six classes as the short labels Windows itself uses, in the TUI and the WebUI alike, exactly as the issue specifies:

value label psutil constant
256 RT REALTIME_PRIORITY_CLASS
128 Hi HIGH_PRIORITY_CLASS
32768 AN ABOVE_NORMAL_PRIORITY_CLASS
32 No NORMAL_PRIORITY_CLASS
16384 BN BELOW_NORMAL_PRIORITY_CLASS
64 Lo IDLE_PRIORITY_CLASS

I checked those six values against psutil on the machine rather than copying them, and the test asserts the map against the constants themselves when it runs on Windows — so a psutil change fails the test instead of quietly rendering a raw number again.

Three things it deliberately does not change:

  • The API. nice stays the raw value, so sorting, exports and any consumer of /api/*/processlist are untouched. Only the two display layers translate.
  • The alert. get_nice_alert() still receives the number. The nice_* limits in glances.conf are POSIX nice values, so matching a label against them would silence them — there is a test pinning that.
  • Unknown classes. An unmapped value falls through to its number rather than disappearing, so a class Windows adds later stays visible.

ProgramlistPlugin inherits _get_process_curses_nice, so the program view is covered by the same change.

Verification

Windows 11, Python 3.14, psutil 7.2.2.

tests/test_core.py     47 passed, 6 skipped
ruff check / format    clean on both changed Python files

The new test_010b_processes_nice_windows_labels patches WINDOWS both ways, so both branches run on every OS rather than only on a Windows runner.

Mutation-checked, after confirming each edit actually applied:

display_nice never maps          -> 1 failed
map applied on every platform    -> 1 failed   (the POSIX assertions catch it)
alert given the label            -> 1 failed

The third one exists because the "alert keeps the raw value" claim above is a comment, and a comment nothing tests is just a hope.

About the rebuilt bundle

public/glances.js is regenerated, since every .vue commit in the history ships it.

Worth flagging how it was produced, because my first attempt was wrong. Building on a Windows checkout injected CRLF into the HTML-comment string literals webpack inlines, which changed the bundle in places unrelated to this fix. I set core.autocrlf=false, re-checked out the tree, and confirmed that an unmodified build then reproduces the committed public/glances.js byte for byte before rebuilding with the change. So the bundle delta here is only this change, and browser.js is untouched.

WebUI

eslint on the changed component reports 0 net new issues — 5 errors / 75 warnings before and after, all pre-existing in that file.

…olumn

psutil reports the Win32 priority *class* for `nice` on Windows, not a nice
value. Those numbers are neither ordered nor small — 32 is normal while 32768 is
*above* normal — so the NI column showed a five-digit number that is meaningless
as a nice value and does not fit its 3-character width.

Render the six classes as the short labels Windows itself uses, in the TUI and
the WebUI alike:

  256 RT   128 Hi   32768 AN   32 No   16384 BN   64 Lo

Only the rendering changes. The API keeps the raw value, so sorting and any
consumer of `/api/*/processlist` are untouched, and `get_nice_alert()` still
receives the number: the `nice_*` limits in glances.conf are POSIX nice values,
and matching a label against them would silence them. An unmapped class falls
through to its number rather than disappearing, so a class Windows adds later
stays visible.

ProgramlistPlugin inherits `_get_process_curses_nice`, so the program view is
covered by the same change.

Closes nicolargo#3672.
@nicolargo
nicolargo merged commit 46fb62c into nicolargo:develop Aug 26, 2026
17 of 19 checks passed
@nicolargo

Copy link
Copy Markdown
Owner

Thanks for the PR @ntdatt812 !

Merged into develop.

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.

[Windows] In TUI and WebUI, Nice level is not displayed correctly

2 participants