Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/features/system/fixtures/resource-probe.qml

Raw
import QtQuick
import Quickshell
import Quickshell.Io
import Quickshell.Services.Notifications
import "../../.." as N
import "../../../features/system" as SystemFeature

Scope {
    id: root
    property int dispatches: 0
    // Screenshot reports from niri; ui-test waits for each before going on.
    property int notices: 0
    NotificationServer {
        onNotification: root.notices++
    }
    N.Theme {
        id: fixtureTheme
    }
    SystemFeature.Resources {
        id: resourceBackend
        popupOpen: true
        powerProfiles: null
        identity: ({
                host: "synthetic-probe"
            })
        identityLoaded: true
        slowRefreshMs: 250
        onAgentDispatched: root.dispatches++
    }
    PanelWindow {
        id: window
        visible: true
        anchors {
            top: true
            bottom: true
            left: true
            right: true
        }
        exclusionMode: ExclusionMode.Ignore
        color: "#242424"
        SystemFeature.SystemPanel {
            id: panel
            anchors.fill: parent
            anchors.margins: 16
            theme: fixtureTheme
            resourceService: resourceBackend
        }
    }
    IpcHandler {
        target: "uiTest"
        function act(id: string): void {
            resourceBackend.runIssueAgent(id);
        }
        function snapshot(): string {
            return JSON.stringify({
                popupOpen: resourceBackend.popupOpen,
                // Full 100-event payloads exceed qs IPC response capacity.
                // Poll counts here; verify every event in the actual prompt file.
                issues: resourceBackend.issues().map(issue => Object.assign({}, issue, {
                        events: undefined,
                        occurrences: issue.context ? (issue.events || [issue.context]).length : 0
                    })),
                incidentStatus: resourceBackend.incidentStatus,
                pending: resourceBackend.agentPending,
                agentError: resourceBackend.agentError,
                dispatches: root.dispatches,
                notices: root.notices,
                action: resourceBackend.lastAction
            });
        }
    }
}