repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

fix nuguland polkit success feedback

ba998f12956dc45ccb0d39a05a21d7745b54bf60

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (3)

quickshell/nuguland/Privilege.qml

Modified
9 9 property bool completed: false
10 10 property bool authorized: false
11 11 property bool cancelled: false
12 + property bool confirming: false
13 + property bool awaitingCompletion: false
12 14 property string error: ""
13 15 property var request: ({})
14 16 property var lastAction: ({})
55 57 "completed": completed,
56 58 "authorized": authorized,
57 59 "cancelled": cancelled,
60 + "confirming": confirming,
61 + "awaitingCompletion": awaitingCompletion,
58 62 "request": request,
59 63 "error": error,
60 64 "lastAction": lastAction
70 74 completed = true;
71 75 authorized = !!granted;
72 76 cancelled = false;
77 + confirming = !!granted;
78 + awaitingCompletion = false;
73 79 error = "";
80 + if (confirming)
81 + successClose.restart();
76 84 function submit(secret) {
77 85 const length = String(secret).length;
78 86 const flow = polkitAgent ? polkitAgent.flow : null;
79 - if (flow && flow.isResponseRequired)
87 + if (flow && flow.isResponseRequired) {
88 + awaitingCompletion = true;
80 89 flow.submit(String(secret));
81 - else
90 + } else {
91 + awaitingCompletion = false;
82 92 error = "no-active-polkit-flow";
93 + }
83 94 lastAction = {
84 95 "kind": "submit",
85 96 "secretLength": length,
97 108 completed = true;
98 109 authorized = false;
99 110 cancelled = false;
111 + confirming = false;
112 + awaitingCompletion = false;
113 + successClose.stop();
100 114 error = "";
101 115 lastAction = {
102 116 "kind": "deny",
114 128 completed = false;
115 129 authorized = false;
116 130 cancelled = true;
131 + confirming = false;
132 + awaitingCompletion = false;
133 + successClose.stop();
117 134 error = "";
118 135 lastAction = {
119 136 "kind": "cancel",
127 144 completed = false;
128 145 authorized = false;
129 146 cancelled = false;
147 + confirming = false;
148 + awaitingCompletion = false;
149 + successClose.stop();
130 150 error = String(message);
131 151 lastAction = {
132 152 "kind": "fail",
140 160 completed = false;
141 161 authorized = false;
142 162 cancelled = false;
163 + confirming = false;
164 + awaitingCompletion = false;
165 + successClose.stop();
143 166 request = ({});
144 167 error = "";
145 168 lastAction = {
148 171 return stateJson();
174 + Timer {
175 + id: successClose
177 + interval: 620
178 + repeat: false
179 + onTriggered: root.confirming = false
151 182 Loader {
152 183 id: polkitAgentLoader
165 196 root.completed = false;
166 197 root.authorized = false;
167 198 root.cancelled = false;
199 + root.confirming = false;
200 + root.awaitingCompletion = false;
201 + successClose.stop();
168 202 root.error = "";
169 203 root.request = {
170 204 "app": flow ? (flow.iconName || "polkit") : "polkit",
217 + function onIsActiveChanged() {
218 + if (root.polkitAgent && !root.polkitAgent.isActive && root.active && root.awaitingCompletion)
219 + root.finish(true);
183 222 target: root.polkitAgent
186 225 Connections {
226 + function onIsCompletedChanged() {
227 + const flow = root.polkitAgent ? root.polkitAgent.flow : null;
228 + if (flow && flow.isCompleted && flow.isSuccessful)
229 + root.finish(true);
187 232 function onAuthenticationSucceeded() {
188 233 root.finish(true);

quickshell/nuguland/privilege-ui.test.mjs

Modified
2 2 import assert from "node:assert/strict";
3 3 import { readFileSync } from "node:fs";
5 5 const qml = readFileSync(new URL("./shell.qml", import.meta.url), "utf8");
6 +const privilegeQml = readFileSync(new URL("./Privilege.qml", import.meta.url), "utf8");
6 7 const start = qml.indexOf("component PrivilegeSurface: Rectangle");
7 8 const end = qml.indexOf("component NokoFocusOverlay", start);
8 9 assert.notEqual(start, -1, "PrivilegeSurface component exists");
19 20 assert.match(surface, /secretInput\.forceActiveFocus\(\)/, "password input is explicitly focused");
20 21 assert.match(surface, /id:\s*focusRetry/, "focus retry timer exists for map-time focus races");
21 22 assert.match(qml, /id:\s*privilegeSurface/, "privilege surface instance is addressable from PanelWindow");
23 +assert.match(qml, /visible:\s*privilege\.active \|\| privilege\.error\.length > 0 \|\| privilege\.confirming/, "privilege window stays up for success confirmation");
22 24 assert.match(qml, /onVisibleChanged:\s*if \(visible\)\s*Qt\.callLater\(privilegeSurface\.focusSecret\)/, "PanelWindow asks password input for focus after mapping");
25 +assert.match(privilegeQml, /property bool confirming:\s*false/, "privilege service exposes transient success confirmation state");
26 +assert.match(privilegeQml, /property bool awaitingCompletion:\s*false/, "privilege service tracks submitted flows");
27 +assert.match(privilegeQml, /id:\s*successClose/, "success confirmation auto-closes");
28 +assert.match(privilegeQml, /function onIsCompletedChanged\(\)/, "polkit completed state is handled before flow detaches");
29 +assert.match(privilegeQml, /function onIsActiveChanged\(\)/, "polkit inactive fallback finishes submitted flows");
30 +assert.match(surface, /function onConfirmingChanged\(\)/, "surface refreshes after async success state changes");
31 +assert.match(surface, /id:\s*successBanner/, "success banner exists");
32 +assert.match(surface, /authorization granted/, "success title is rendered");
33 +assert.match(surface, /text:\s*"authorized"/, "success banner text is rendered");
23 34 assert.doesNotMatch(surface, /requestIdentityCard/, "debug identity card is not rendered");
24 35 assert.doesNotMatch(surface, /actionId/, "debug polkit action id is not rendered");

quickshell/nuguland/shell.qml

Modified
521 521 objectName: "privilegeSecuritySurface"
522 522 screen: modelData
523 - visible: privilege.active || privilege.error.length > 0
523 + visible: privilege.active || privilege.error.length > 0 || privilege.confirming
524 524 color: "transparent"
525 525 exclusionMode: ExclusionMode.Ignore
526 526 WlrLayershell.layer: WlrLayer.Overlay
1399 1399 property var panelState: privilegeService ? parseJson(privilegeService.stateJson(), {
1400 1400 "request": {},
1401 1401 "privilegeSurfacePanelContract": {},
1402 - "buttons": []
1402 + "buttons": [],
1403 + "confirming": false
1403 1404 }) : ({
1404 1405 "request": {},
1405 1406 "privilegeSurfacePanelContract": {},
1406 - "buttons": []
1407 + "buttons": [],
1408 + "confirming": false
1408 1410 readonly property var request: panelState.request || ({})
1409 1411 property bool secretVisible: false
1448 1450 color: theme ? theme.withAlpha(theme.ui.backdrop, 0.94) : "black"
1449 - visible: panelState.active || panelState.error.length > 0
1451 + visible: panelState.active || panelState.error.length > 0 || panelState.confirming
1450 1452 focus: visible
1451 1453 onVisibleChanged: Qt.callLater(root.focusSecret)
1452 1454 onPanelStateChanged: if (panelState.active)
1453 1455 Qt.callLater(root.focusSecret)
1454 1456 Component.onCompleted: Qt.callLater(root.focusSecret)
1458 + Connections {
1459 + target: root.privilegeService
1461 + function onActiveChanged() {
1462 + root.refreshFrom(root.privilegeService.stateJson());
1465 + function onConfirmingChanged() {
1466 + root.refreshFrom(root.privilegeService.stateJson());
1469 + function onErrorChanged() {
1470 + root.refreshFrom(root.privilegeService.stateJson());
1456 1474 Timer {
1457 1475 id: focusRetry
1492 1510 NuguText {
1493 1511 theme: root.theme
1494 1512 variant: "title"
1495 - text: root.panelState.error && !root.panelState.active ? "authentication unavailable" : "authorization required"
1513 + text: root.panelState.confirming ? "authorization granted" : (root.panelState.error && !root.panelState.active ? "authentication unavailable" : "authorization required")
1496 1514 width: parent.width
1497 1515 elide: Text.ElideRight
1540 + Rectangle {
1541 + id: successBanner
1543 + visible: root.panelState.confirming
1544 + width: parent.width
1545 + height: visible ? 58 : 0
1546 + radius: 16
1547 + color: root.theme ? root.theme.withAlpha(root.theme.info, 0.16) : "transparent"
1548 + border.width: 1
1549 + border.color: root.theme ? root.theme.withAlpha(root.theme.info, 0.62) : "transparent"
1550 + opacity: visible ? 1 : 0
1551 + scale: visible ? 1 : 0.96
1553 + Behavior on opacity {
1554 + NumberAnimation {
1555 + duration: root.theme && root.theme.lowPowerMode ? 0 : 150
1556 + easing.type: Easing.OutCubic
1560 + Behavior on scale {
1561 + NumberAnimation {
1562 + duration: root.theme && root.theme.lowPowerMode ? 0 : 180
1563 + easing.type: Easing.OutBack
1567 + Row {
1568 + anchors.centerIn: parent
1569 + spacing: 12
1571 + Text {
1572 + anchors.verticalCenter: parent.verticalCenter
1573 + text: "✓"
1574 + color: root.theme ? root.theme.info : "white"
1575 + font.family: "IBM Plex Mono"
1576 + font.pixelSize: 20
1577 + font.bold: true
1580 + NuguText {
1581 + anchors.verticalCenter: parent.verticalCenter
1582 + theme: root.theme
1583 + variant: "title"
1584 + text: "authorized"
1585 + color: root.theme ? root.theme.info : "white"
1522 1590 PrivilegeFailureShake {
1523 1591 objectName: "failureShakeSlot"
1592 + visible: !root.panelState.confirming
1524 1593 active: root.panelState.error && root.panelState.error.length > 0
1525 1594 width: parent.width
1526 1595 height: inputColumn.implicitHeight
1656 1725 objectName: "denyCancelConfirmRow"
1726 + visible: !root.panelState.confirming
1657 1727 width: parent.width
1658 1728 spacing: 10