Skip to content

Allow configuring default sort column for the processviewer widget via meta key #3284

@mackenzieclark

Description

@mackenzieclark

Summary

The processviewer widget's default sort is hardcoded to CPU descending. There's no way to configure a different default — every fresh processviewer block opens sorted by CPU, and the user has to manually click another column header (e.g. Memory) every time. The sort preference doesn't persist across block recreations either, since it's stored only in a runtime atom rather than block meta.

For users who primarily care about a non-CPU column (memory hogs being the obvious case), CPU is a poor default to be locked into.

Current behavior

In frontend/app/view/processviewer/processviewer.tsx:113-114:

this.sortByAtom = jotai.atom<SortCol>("cpu");
this.sortDescAtom = jotai.atom<boolean>(true);

Hardcoded. The SortCol type at line 32 already enumerates all valid columns:

type SortCol = "pid" | "command" | "user" | "cpu" | "mem" | "status" | "threads";

On Windows the visible columns are PID / Command / CPU% / Memory (status, user, threads are hidden via hideOnPlatform), so the meaningful defaults a Windows user would want are one of those four. Other platforms get all seven.

Request

Please add meta keys to control the initial sort, e.g.:

  • processviewer:sortby — one of the SortCol values ("pid" | "command" | "user" | "cpu" | "mem" | "status" | "threads"), default "cpu"
  • processviewer:sortdesc — bool, default true

So a user can put this in their widgets.json to override the default processviewer widget to sort by memory:

"defwidget@processviewer": {
    "display:order": -1,
    "icon": "list-tree",
    "label": "processes",
    "blockdef": {
        "meta": {
            "view": "processviewer",
            "processviewer:sortby": "mem",
            "processviewer:sortdesc": true
        }
    }
}

Manual click-to-resort behavior would still work as today; the meta keys only control the initial state of the atoms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions