From b38ea09c97c794a04e503adfdbbad4afe96a6018 Mon Sep 17 00:00:00 2001 From: Matt Van Horn <455140+mvanhorn@users.noreply.github.com> Date: Thu, 12 Nov 2026 01:38:26 -0800 Subject: [PATCH 1/2] fix(preferences_dialog): explain default keyring recovery for the Linux MCP token The message now covers accepting the unlock prompt and creating a default keyring in Passwords and Keys. Added tests cover both errors, the recovery text, retry visibility, disabled client controls, and the transition back to Off. Additional assertions preserve the distinct service and portal error messages, and a changelog entry records the fix. Fixes #4106 --- linux/changelog.d/4106.fixed.md | 1 + .../app/src/ui/preferences_dialog/mcp_page.rs | 53 +++++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 linux/changelog.d/4106.fixed.md diff --git a/linux/changelog.d/4106.fixed.md b/linux/changelog.d/4106.fixed.md new file mode 100644 index 0000000000..4aa9fecba3 --- /dev/null +++ b/linux/changelog.d/4106.fixed.md @@ -0,0 +1 @@ +The MCP token error omitted the steps to create a default keyring. diff --git a/linux/crates/app/src/ui/preferences_dialog/mcp_page.rs b/linux/crates/app/src/ui/preferences_dialog/mcp_page.rs index ea77fd3664..bb1bbd5e98 100644 --- a/linux/crates/app/src/ui/preferences_dialog/mcp_page.rs +++ b/linux/crates/app/src/ui/preferences_dialog/mcp_page.rs @@ -305,9 +305,9 @@ pub(crate) fn failure_text(failure: &McpFailure) -> String { /// server cannot do without it. fn keyring_text(error: &SecretError) -> String { match error { - SecretError::Locked | SecretError::UnlockDismissed => { - crate::i18n::gettext("The keyring is locked, so the access token cannot be read. Unlock it and try again.") - } + SecretError::Locked | SecretError::UnlockDismissed => crate::i18n::gettext( + "The keyring is locked, so the access token cannot be read. Unlock the keyring, accept its prompt and try again. With automatic login, GNOME may have no default keyring yet: create one in Passwords and Keys and make it the default.", + ), SecretError::ServiceUnavailable { .. } => crate::i18n::gettext( "No keyring is running, so the access token cannot be kept. Start a keyring and try again.", ), @@ -395,6 +395,40 @@ mod tests { runtime.shutdown(); } + #[test] + fn locked_token_status_explains_default_keyring_recovery() { + for error in [SecretError::Locked, SecretError::UnlockDismissed] { + let text = status_text(&McpStatus::Failed(McpFailure::Keyring(error))); + + assert!(text.contains("The keyring is locked, so the access token cannot be read.")); + assert!(text.contains("Unlock the keyring, accept its prompt and try again.")); + assert!(text.contains( + "With automatic login, GNOME may have no default keyring yet: create one in Passwords and Keys and make it the default." + )); + } + } + + #[gtk4::test] + fn locked_token_row_shows_recovery_and_retry() { + let settings = MemorySettings::new(); + let page = bound_page(&settings, None); + let imp = page.imp(); + + for error in [SecretError::Locked, SecretError::UnlockDismissed] { + page.show_status(McpStatus::Failed(McpFailure::Keyring(error))); + + let subtitle = imp.status_row.subtitle().expect("the failure status"); + assert!(subtitle.contains("create one in Passwords and Keys and make it the default.")); + assert!(imp.retry_button.is_visible()); + assert!(!imp.client_group.is_sensitive()); + + page.show_status(McpStatus::Off); + + assert_eq!(imp.status_row.subtitle().as_deref(), Some("Off")); + assert!(!imp.retry_button.is_visible()); + } + } + #[test] fn each_failure_has_its_own_sentence() { let failures = [ @@ -409,6 +443,7 @@ mod tests { }, McpFailure::Keyring(SecretError::Locked), McpFailure::Keyring(SecretError::ServiceUnavailable { detail: String::new() }), + McpFailure::Keyring(SecretError::PortalUnavailable { detail: String::new() }), McpFailure::NoRandomness, McpFailure::Interrupted(String::new()), ]; @@ -416,5 +451,17 @@ mod tests { assert_eq!(texts.len(), failures.len()); assert!(failure_text(&McpFailure::PortInUse(4000)).contains("4000")); + assert_eq!( + status_text(&McpStatus::Failed(McpFailure::Keyring( + SecretError::ServiceUnavailable { detail: String::new() } + ))), + "No keyring is running, so the access token cannot be kept. Start a keyring and try again." + ); + assert_eq!( + status_text(&McpStatus::Failed(McpFailure::Keyring( + SecretError::PortalUnavailable { detail: String::new() } + ))), + "The secret portal is unavailable, so the access token cannot be kept. Check that xdg-desktop-portal and a keyring are running." + ); } } From 11ead9b4dc3d6f55bb5e5a9d3a13ee4789f6eb6d Mon Sep 17 00:00:00 2001 From: Ngo Quoc Dat Date: Thu, 12 Nov 2026 22:42:17 +0700 Subject: [PATCH 2/2] fix(linux): share default-keyring recovery advice across locked-keyring errors map_error returns SecretError::Locked for a missing default keyring on every secret read, so the advice now appends from one shared gettext helper on the API-key, saved-password, duplicate-connection and save surfaces, not only the MCP token. --- linux/changelog.d/4106.fixed.md | 1 - linux/changelog.d/4234.fixed.md | 1 + .../app/src/services/secret_save_report.rs | 15 ++++++++---- .../crates/app/src/ui/assistant/error_text.rs | 24 ++++++++++++++++--- .../app/src/ui/error_text/saved_connection.rs | 3 ++- linux/crates/app/src/ui/error_text/secret.rs | 14 +++++++---- .../app/src/ui/preferences_dialog/mcp_page.rs | 6 +++-- .../app/src/ui/session_window/connections.rs | 6 ++++- 8 files changed, 53 insertions(+), 17 deletions(-) delete mode 100644 linux/changelog.d/4106.fixed.md create mode 100644 linux/changelog.d/4234.fixed.md diff --git a/linux/changelog.d/4106.fixed.md b/linux/changelog.d/4106.fixed.md deleted file mode 100644 index 4aa9fecba3..0000000000 --- a/linux/changelog.d/4106.fixed.md +++ /dev/null @@ -1 +0,0 @@ -The MCP token error omitted the steps to create a default keyring. diff --git a/linux/changelog.d/4234.fixed.md b/linux/changelog.d/4234.fixed.md new file mode 100644 index 0000000000..36c8a9745a --- /dev/null +++ b/linux/changelog.d/4234.fixed.md @@ -0,0 +1 @@ +Locked-keyring errors omitted the steps to create a default keyring. diff --git a/linux/crates/app/src/services/secret_save_report.rs b/linux/crates/app/src/services/secret_save_report.rs index 29afb40a2c..b5309cdb79 100644 --- a/linux/crates/app/src/services/secret_save_report.rs +++ b/linux/crates/app/src/services/secret_save_report.rs @@ -175,13 +175,9 @@ impl SecretSaveReport { } } - // The Secret portal answers a missing default keyring the same way as a locked one - // (linux/docs/troubleshooting.md, Flatpak connections). fn remedy(&self) -> Option { match Reason::of(&self.error) { - Reason::Locked => Some(gettext( - "Unlock the keyring, accept its prompt and try again. With automatic login, GNOME may have no default keyring yet: create one in Passwords and Keys and make it the default.", - )), + Reason::Locked => Some(keyring_locked_recovery()), Reason::NoKeyring => Some(match self.error { SecretError::PortalUnavailable { .. } => { gettext("Install xdg-desktop-portal and your desktop’s keyring, then log out and in.") @@ -193,6 +189,15 @@ impl SecretSaveReport { } } +/// The way out of a locked keyring, shared by every surface that reads or saves a secret. The +/// Secret portal answers a missing default keyring the same way as a locked one, so the advice +/// covers both (linux/docs/troubleshooting.md, Flatpak connections). +pub(crate) fn keyring_locked_recovery() -> String { + gettext( + "Unlock the keyring, accept its prompt and try again. With automatic login, GNOME may have no default keyring yet: create one in Passwords and Keys and make it the default.", + ) +} + /// A session's credentials whose saves are reported. A secret typed at a reconnect prompt is /// stored by the session's health monitor, which only logs a refusal. pub(crate) struct ReportingCredentials { diff --git a/linux/crates/app/src/ui/assistant/error_text.rs b/linux/crates/app/src/ui/assistant/error_text.rs index 0864a2edf0..b8c1167e47 100644 --- a/linux/crates/app/src/ui/assistant/error_text.rs +++ b/linux/crates/app/src/ui/assistant/error_text.rs @@ -83,9 +83,11 @@ fn with_server_words(sentence: String, server: Option<&str>) -> String { /// assistant cannot do without it. fn keyring_text(error: &SecretError) -> String { match error { - SecretError::Locked | SecretError::UnlockDismissed => { - crate::i18n::gettext("The keyring is locked, so the API key cannot be read. Unlock it and try again.") - } + SecretError::Locked | SecretError::UnlockDismissed => format!( + "{} {}", + crate::i18n::gettext("The keyring is locked, so the API key cannot be read."), + crate::services::secret_save_report::keyring_locked_recovery(), + ), SecretError::ServiceUnavailable { .. } => crate::i18n::gettext( "No keyring is running, so the API key cannot be read or kept. Start a keyring and try again.", ), @@ -167,4 +169,20 @@ mod tests { assert_eq!(text, "Add your OpenAI API key in Preferences."); } + + #[test] + fn a_locked_key_explains_default_keyring_recovery() { + for error in [SecretError::Locked, SecretError::UnlockDismissed] { + let text = setup_error_text(&AiSetupError::Keyring(error)); + + assert!( + text.starts_with("The keyring is locked, so the API key cannot be read."), + "{text}" + ); + assert!( + text.contains("create one in Passwords and Keys and make it the default."), + "{text}" + ); + } + } } diff --git a/linux/crates/app/src/ui/error_text/saved_connection.rs b/linux/crates/app/src/ui/error_text/saved_connection.rs index a2390271b2..4f927fb507 100644 --- a/linux/crates/app/src/ui/error_text/saved_connection.rs +++ b/linux/crates/app/src/ui/error_text/saved_connection.rs @@ -55,7 +55,8 @@ mod tests { fn each_failure_says_what_happened() { assert_eq!( saved_connection_error_message(&SavedConnectionError::Secret(SecretError::Locked)), - "The keyring is locked. Unlock it and try again." + "The keyring is locked. Unlock the keyring, accept its prompt and try again. With automatic login, \ + GNOME may have no default keyring yet: create one in Passwords and Keys and make it the default." ); assert_eq!( saved_connection_error_message(&SavedConnectionError::NotFound(Uuid::nil())), diff --git a/linux/crates/app/src/ui/error_text/secret.rs b/linux/crates/app/src/ui/error_text/secret.rs index be75b0b9f9..20480d17de 100644 --- a/linux/crates/app/src/ui/error_text/secret.rs +++ b/linux/crates/app/src/ui/error_text/secret.rs @@ -10,10 +10,16 @@ pub(super) fn secret_message(error: &tablepro_core::credentials::SecretError) -> SecretError::PortalUnavailable { .. } => crate::i18n::gettext( "The secret portal is unavailable, so saved passwords cannot be read inside the sandbox. Check that xdg-desktop-portal and a keyring are running, or enter the password by hand.", ), - SecretError::Locked => crate::i18n::gettext("The keyring is locked. Unlock it and try again."), - SecretError::UnlockDismissed => { - crate::i18n::gettext("The keyring stayed locked because the unlock prompt was dismissed.") - } + SecretError::Locked => format!( + "{} {}", + crate::i18n::gettext("The keyring is locked."), + crate::services::secret_save_report::keyring_locked_recovery(), + ), + SecretError::UnlockDismissed => format!( + "{} {}", + crate::i18n::gettext("The keyring stayed locked because the unlock prompt was dismissed."), + crate::services::secret_save_report::keyring_locked_recovery(), + ), SecretError::InvalidEncoding => { crate::i18n::gettext("The stored password is not readable text. Enter it again to replace it.") } diff --git a/linux/crates/app/src/ui/preferences_dialog/mcp_page.rs b/linux/crates/app/src/ui/preferences_dialog/mcp_page.rs index bb1bbd5e98..16f833db85 100644 --- a/linux/crates/app/src/ui/preferences_dialog/mcp_page.rs +++ b/linux/crates/app/src/ui/preferences_dialog/mcp_page.rs @@ -305,8 +305,10 @@ pub(crate) fn failure_text(failure: &McpFailure) -> String { /// server cannot do without it. fn keyring_text(error: &SecretError) -> String { match error { - SecretError::Locked | SecretError::UnlockDismissed => crate::i18n::gettext( - "The keyring is locked, so the access token cannot be read. Unlock the keyring, accept its prompt and try again. With automatic login, GNOME may have no default keyring yet: create one in Passwords and Keys and make it the default.", + SecretError::Locked | SecretError::UnlockDismissed => format!( + "{} {}", + crate::i18n::gettext("The keyring is locked, so the access token cannot be read."), + crate::services::secret_save_report::keyring_locked_recovery(), ), SecretError::ServiceUnavailable { .. } => crate::i18n::gettext( "No keyring is running, so the access token cannot be kept. Start a keyring and try again.", diff --git a/linux/crates/app/src/ui/session_window/connections.rs b/linux/crates/app/src/ui/session_window/connections.rs index 5101608445..45fdc15bc8 100644 --- a/linux/crates/app/src/ui/session_window/connections.rs +++ b/linux/crates/app/src/ui/session_window/connections.rs @@ -1514,7 +1514,11 @@ mod tests { assert_eq!( toasts(), - ["The connection could not be duplicated. The keyring is locked. Unlock it and try again."] + [ + "The connection could not be duplicated. The keyring is locked. Unlock the keyring, accept its \ + prompt and try again. With automatic login, GNOME may have no default keyring yet: create one \ + in Passwords and Keys and make it the default." + ] ); }