Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/test-fixtures/ui/resource-probe.qml

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

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