Skip to content

Top: fixes false showTypes mismatch when baseline was not prepared - #2776

Merged
CarterLi merged 1 commit into
fastfetch-cli:devfrom
BlueCatsz:fix/top-unprepared-showtypes
Dec 2, 2026
Merged

CarterLi merged 1 commit into
fastfetch-cli:devfrom
BlueCatsz:fix/top-unprepared-showtypes

Conversation

@BlueCatsz

Copy link
Copy Markdown
Contributor

Summary

ffDetectTopProcesses() currently checks options->showTypes != preparedTypes unconditionally before checking startTick == 0.

When baseline preparation is skipped — for instance, when a top module is gated by "condition": {"succeeded": true} in printJsonConfig() — both startTick and preparedTypes stay 0. That caused even a single top module requesting CPU or disk counters to fail immediately with:

Top Processes: `top` modules with different `showTypes` cannot share a run

and made the lazy if (startTick == 0) { ffPrepareTopProcesses(options->showTypes); } fallback below it unreachable.

Moving the options->showTypes != preparedTypes check into the else branch of if (startTick == 0) lets an unprepared top module initialize its baseline on first use while still rejecting genuine showTypes mismatches across modules.

Before (on dev ef7c04e38, config {"modules":["os",{"type":"top","waitTime":50,"condition":{"succeeded":true}}]}):

OS: CachyOS x86_64
Top Processes: `top` modules with different `showTypes` cannot share a run

After:

OS: CachyOS x86_64
Top Processes 1: ...
Top Processes 2: ...

AI-assisted development disclosure: prepared with AI assistance; all builds, tests, and live scenarios were verified locally on CachyOS x86_64.

Changes

  • Move the options->showTypes != preparedTypes guard in ffDetectTopProcesses() (src/detection/top/top.c) into the else branch of if (startTick == 0).
  • Add a Bugfixes: entry in CHANGELOG.md.

Testing

  • cmake --build build -j (local CMake configured with -DENABLE_VULKAN=OFF because vulkan-headers is not installed): clean build, 0 warnings/errors.
  • ctest --test-dir build --output-on-failure: 21/21 tests passed.
  • Verified 5 live runtime scenarios with ./build/fastfetch:
    1. Single top with condition.succeeded: prints OS and real Top Processes rows cleanly.
    2. Two condition.succeeded top modules with different showTypes (["cpu"] then ["disk"]): first prints processes, second reports Top Processes: `top` modules with different `showTypes` cannot share a run.
    3. Two prepared top modules (["cpu"] then ["disk"]): mismatch error preserved.
    4. ["memory"] top followed by condition.succeeded ["cpu"] top: both print cleanly.
    5. presets/ci.jsonc exited 0 (excluding environment-unavailable Vulkan/DBus/network checks) and -s os:top --format json output valid JSON.

Checklist

  • I have tested my changes locally.

When ffPrepareTopProcesses() is skipped (for instance, when a top module is gated by condition.succeeded), startTick and preparedTypes remain 0. Previously ffDetectTopProcesses() checked options->showTypes != preparedTypes before checking startTick == 0, causing even a single top module to fail and leaving the lazy ffPrepareTopProcesses() fallback unreachable. Move the mismatch check into the else branch of if (startTick == 0) so lazy preparation runs when no baseline exists while real mismatches across modules still error.
@CarterLi
CarterLi merged commit 0f02542 into fastfetch-cli:dev Dec 2, 2026
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.

2 participants