Reopen the wifi passphrase prompt after a wrong saved password (#6584)

* fix: reopen wifi passphrase prompt after a wrong saved password

A failed first connection attempt leaves the network profile saved, so the
network shows up as known. Clicking it again reconnects with the stored
wrong PSK and fails with WifiAuthTimeout, but the inline passphrase prompt
only reopened on NoSecrets, leaving no way to re-enter the password short
of forgetting the network.

Treat an auth timeout on a protected network as a wrong saved passphrase
and reopen the prompt; connectWithPsk overwrites the stored PSK on submit.

Fixes #6582

* Scope the wifi passphrase reprompt to panel-initiated connects

Background auto-connect retries also fire connectionFailed; without a
gate they would pop the passphrase prompt open unbidden, stealing focus
and wiping a passphrase mid-entry when another network fails.

For the gate to see the failure, the action safety-net timer must
outlast NetworkManager's 25s supplicant timeout -- at 15s it cleared the
action state before WifiAuthTimeout arrived, so a wrong saved password
showed "Timed out connecting" instead of "Wrong password". Bump it to
30s.

Also share the one ConnectionFailReason map between the Model.js
helpers instead of building a second partial copy inline.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: David Heinemeier Hansson <david@hey.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Alonso David De León Rodarte
2026-08-07 17:17:10 +02:00
committed by GitHub
co-authored by Claude Fable 5 David Heinemeier Hansson
parent d2b090f8fc
commit f490b69a20
3 changed files with 47 additions and 13 deletions
+13 -1
View File
@@ -322,6 +322,17 @@ function networkFailureReason(reason, reasons) {
return "Failed to connect"
}
// Whether a failed connect should reopen the passphrase prompt. NoSecrets
// always means credentials are missing. An auth timeout on a protected
// network means the saved passphrase is wrong (the same profile a first
// failed attempt leaves behind as "known"), so the user needs a chance to
// re-enter it -- connectWithPsk overwrites the stored PSK on submit.
function shouldRepromptPassphrase(reason, isProtected, reasons) {
var r = reasons || {}
if (reason === r.NoSecrets) return true
return !!isProtected && reason === r.WifiAuthTimeout
}
if (typeof module !== "undefined") {
module.exports = {
parseNetworkStatus: parseNetworkStatus,
@@ -348,6 +359,7 @@ if (typeof module !== "undefined") {
wifiSectionTitle: wifiSectionTitle,
isProtected: isProtected,
enterpriseConnectScript: enterpriseConnectScript,
networkFailureReason: networkFailureReason
networkFailureReason: networkFailureReason,
shouldRepromptPassphrase: shouldRepromptPassphrase
}
}
+29 -12
View File
@@ -98,6 +98,16 @@ Panel {
property string passwordText: ""
property string identityText: ""
// ConnectionFailReason values as a plain object, so Model.js helpers stay
// pure JS and Node-testable.
readonly property var connectionFailReasons: ({
NoSecrets: ConnectionFailReason.NoSecrets,
WifiAuthTimeout: ConnectionFailReason.WifiAuthTimeout,
WifiNetworkLost: ConnectionFailReason.WifiNetworkLost,
WifiClientDisconnected: ConnectionFailReason.WifiClientDisconnected,
WifiClientFailed: ConnectionFailReason.WifiClientFailed
})
// True while any wifi action is mid-flight. Rows
// disable themselves on this so clicks on the other rows don't silently
// no-op against runNetworkAction's serialized guard.
@@ -700,13 +710,11 @@ Panel {
}
function networkFailureReason(reason) {
return Model.networkFailureReason(reason, {
NoSecrets: ConnectionFailReason.NoSecrets,
WifiAuthTimeout: ConnectionFailReason.WifiAuthTimeout,
WifiNetworkLost: ConnectionFailReason.WifiNetworkLost,
WifiClientDisconnected: ConnectionFailReason.WifiClientDisconnected,
WifiClientFailed: ConnectionFailReason.WifiClientFailed
})
return Model.networkFailureReason(reason, connectionFailReasons)
}
function shouldRepromptPassphrase(reason, isProtected) {
return Model.shouldRepromptPassphrase(reason, isProtected, connectionFailReasons)
}
function checkActionCompletion(network) {
@@ -882,7 +890,11 @@ Panel {
Timer {
id: actionTimeout
interval: 15000
// Must outlast NetworkManager's 25s supplicant timeout: a wrong saved
// PSK fails with WifiAuthTimeout at ~25s, and that failure has to land
// while the action is still tracked to show "Wrong password" and reopen
// the passphrase prompt.
interval: 30000
repeat: false
onTriggered: {
if (!root.actionKind) return
@@ -1567,8 +1579,12 @@ Panel {
Connections {
target: row.net ? row.net.network : null
function onConnectionFailed(reason) {
// Background auto-connect retries fire this too; only reprompt for
// the connect started from this panel. Checked before
// failNetworkAction, which clears the action state.
var ours = root.actionKind === "connect" && root.actionSsid === (row.net.ssid || "")
root.failNetworkAction(row.net.network, reason)
if (reason === ConnectionFailReason.NoSecrets) root.openPasswordPrompt(row.net.ssid)
if (ours && root.shouldRepromptPassphrase(reason, row.isProtected)) root.openPasswordPrompt(row.net.ssid)
}
function onConnectedChanged() {
if (row.net) root.checkActionCompletion(row.net.network)
@@ -1750,9 +1766,10 @@ Panel {
}
}
// Inline passphrase prompt — only shown when we hit a protected network
// we don't have saved credentials for. Submitting (Enter or the check
// button) fires connect; Esc cancels back to the row.
// Inline passphrase prompt — shown when we hit a protected network we
// don't have saved credentials for, or when a connect fails because the
// saved passphrase is wrong. Submitting (Enter or the check button) fires
// connect; Esc cancels back to the row.
Item {
id: passwordPanel
visible: row.isPasswordOpen