Luigit
repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by admin

quickshell/nuguland/features/noko/fixtures/load.qml

Raw
import QtQuick
import QtQuick.Window
import Quickshell
import "../../.." as N
import "../../../features/noko" as NokoFeature

// `just load-test noko`: the registry entry's own panel and focus overlay, bound
// to the noko double the load harness overlays. The panel renders the double's
// scrollable history; then the entry's bar emphasis and focus overlay follow the
// double through a capture that starts, streams words and stops, an armed wake
// word, and missing assets. No engine, microphone, compositor, input, or pixels.
ShellRoot {
    id: root

    readonly property N.FeatureEntry feature: registry.popup("noko")
    property int step: 0
    // The overlaid double's fixture surface; production Noko has no setMissingAssets.
    readonly property var nokoDouble: registry.noko

    function finish(): void {
        const panel = panelLoader.item as NokoFeature.NokoPanel;
        const overlay = overlayLoader.item as NokoFeature.NokoFocusOverlay;
        if (!panel || !overlay)
            return;
        const history = panel.scrollView;
        if (root.step === 0 && root.feature.width === 640 && root.feature.height === 560 && root.feature.barLabel === "noko" && !root.feature.barStrong && root.feature.barRole === "ui.focus" && !root.feature.barBusy && !root.feature.focusOverlayShown && panel.nokoService.historyEntries.length === 12 && history.contentHeight > history.height) {
            root.step = 1;
            root.nokoDouble.trigger();
        } else if (root.step === 1 && root.feature.barBusy && root.feature.barActive && root.feature.barRole === "ui.accent" && root.feature.focusOverlayShown && overlay.phase === "starting" && overlay.words === "") {
            root.step = 2;
            root.nokoDouble.beginListening();
            root.nokoDouble.hear("the newest words stay visible");
        } else if (root.step === 2 && overlay.phase === "capturing" && overlay.words === "the newest words stay visible" && panel.nokoService.liveText === overlay.words) {
            root.step = 3;
            root.nokoDouble.trigger();
            root.nokoDouble.setWakeEnabled(true);
        } else if (root.step === 3 && !root.feature.barBusy && root.feature.barActive && !root.feature.barStrong && root.feature.barRole === "ui.accent" && root.feature.barIcon === "\u{F036C}" && root.feature.barTitle === "noko dictation · microphone on" && !root.feature.focusOverlayShown) {
            root.step = 4;
            root.nokoDouble.setWakeEnabled(false);
            root.nokoDouble.setMissingAssets(true);
        } else if (root.step === 4 && !root.feature.barBusy && root.feature.barStrong && root.feature.barRole === "warning" && root.feature.barLabel === "noko" && !root.feature.focusOverlayShown && overlay.phase === "" && !panel.nokoService.ready) {
            console.log("load noko: PASS");
            Qt.quit();
        }
    }

    N.Theme {
        id: nuguTheme
    }

    N.Registry {
        id: registry

        theme: nuguTheme
    }

    // Plain Window: Quickshell windows set input masks the offscreen platform rejects.
    Window {
        width: 608
        height: 640
        visible: true
        color: "transparent"

        Loader {
            id: panelLoader

            width: parent.width
            height: 528
            sourceComponent: root.feature ? root.feature.panel : null
        }

        Loader {
            id: overlayLoader

            y: 528
            width: parent.width
            height: 112
            sourceComponent: root.feature ? root.feature.focusOverlay : null
        }
    }

    Timer {
        interval: 25
        running: true
        repeat: true
        onTriggered: root.finish()
    }

    Timer {
        interval: 5000
        running: true
        onTriggered: {
            console.error("ERROR load noko: the entry never followed the double");
            Qt.quit();
        }
    }
}