Skip to content

Pending requests: native notification and Dock/taskbar attention while the app is in the background #1709

Backlog

Description

@smart-ssh-planner

Goal

When a request is waiting for the user and the app window is not in the foreground, the app shows a native system notification. On desktop it also asks for attention: the Dock icon bounces on macOS, the taskbar button flashes on Windows, and Linux gets an urgency hint. This issue builds the shared mechanism for every pending-request kind, the desktop implementation using the existing notification plugin, the two settings and the activation path used by notification clicks. Removing delivered notifications and handling clicks on each OS follow in separate issues.

Context

  • Pending confirmations are registered and cleaned up by drop guards in crates/app-logic/src/orchestration/pending_confirmation.rs:
    • PendingConfirmation::register / wait_for_decision (:39, :114) are tab-bound.
    • RegisteredConfirmation (:190) is app-wide.
    • RegistryCleanup::drop (:241) is the single place where a waiting confirmation ends, on every path: decision, timeout, reconnect, dropped future, panic.
  • Call sites:
    • Action confirmations: orchestration/action_exec/propose.rs (prepare_decision :296, second-opinion escalation :505, await_confirmation :653).
    • MCP: crates/app-shell/src/mcp_backend.rs:164.
    • Note suggestions: orchestration/notes.rs:960, :1443.
    • Host key: crates/app-logic/src/connect/host_key_flow.rs:130, end at :263.
    • Auth prompts: crates/app-logic/src/auth_prompter.rs:115, Drop at :107.
    • AI questions: orchestration/notes.rs handle_question_asked. These are not awaited; the answer arrives as the next user message in that chat.
  • When the user denies a request, no backend event is emitted (the frontend clears its own state, apps/smart-ssh-community/frontend/src/hooks/useSessionTabs.ts:550). So "request ended" has to be hooked in Rust at the guards.
  • The only OS notification today is notify_pending_confirmation in crates/app-shell/src/mcp_backend.rs:124, called at :207. It has these problems:
    • It fires before the decision is known, so even a filter Deny or an auto-allowed action notifies.
    • Its German text is hard-coded and not localized.
    • It is never removed.
    • It is not tied to window focus.
  • Spec 0028 §9a/§11 describe this notification and its limits.
  • tauri-plugin-notification 2.4 is already a dependency (crates/app-shell/Cargo.toml:36, registered after unlock in crates/app-shell/src/lib.rs:1141/:1171). Nothing calls request_user_attention today.
  • There is no window-focus listener in Rust. The app has a single main window (startup_gate_wiring.rs:109). crates/app-shell/src/single_instance.rs:111 focus_main_window shows and focuses it.
  • Settings: whitelist in crates/app-shell/src/ui_preferences.rs:130 UiPreferenceRegistry::builtin(). Pattern to copy: frontend settings/autoReconnectSettings.ts with the backend reading the same key (crates/app-logic/src/auto_reconnect.rs:25). Settings UI is components/SettingsScreen.tsx, categories limited by ADR 0041.
  • app-logic stays Tauri-free (Spec 0084, scripts/gate.sh boundary). Follow the pattern of EventEmitter and background_keepalive::ForegroundService: a trait in app-logic, implemented in app-shell.

Requirements

  • Trait in app-logic (suggested name PendingRequestNotifier) with two calls:
    • request_pending(PendingRequest { id, kind, server_name, source, tab })
    • request_ended(id)
      kind is one of ActionConfirmation (with an action category: command / file read / file write / note update / document), Escalation, Question, NoteSuggestion, HostKey, AuthPrompt. source is AI chat or an MCP client name. The default implementation is a no-op.
  • request_pending is called only when the request is really waiting for the user:
    • action confirmations only when the decision is Confirm (not on filter Deny or auto-allow), and the same for escalations;
    • note update and shrink suggestions;
    • host key verification;
    • password and one-time-code prompts;
    • AI questions when chat-question-asked is emitted;
    • provider-requested confirmations added by Provider activity notices and provider-requested confirmations in the chat turn #1639 (a blocker of this issue), with the same rules as action confirmations.
  • request_ended is called exactly once per pending request, on every path. For confirmations: decision (approve and deny), timeout, reconnect, tab close, dropped future, panic. Implement it in the existing drop guards. For AI questions: the next user message in that chat, tab close, or chat cleared.
  • Desktop implementation in app-shell:
    • Tracks main-window focus via WindowEvent::Focused (plus minimized/hidden state).
    • On request_pending while the window is not in the foreground: if the notification setting is on, it shows a notification through tauri-plugin-notification; if the attention setting is on, it calls request_user_attention(Some(UserAttentionType::Critical)).
    • In the foreground it does nothing.
    • It clears attention (request_user_attention(None)) when the window gets focus and when the last pending request ends.
    • It keeps the set of pending request ids so that the follow-up issues can remove notifications.
  • Platform backend boundary: a small app-shell trait for the OS notification itself (show by id, remove by id, remove all) with the plugin-based implementation here. Remove is a logged no-op where the plugin cannot do it. The follow-up issues replace this implementation per OS.
  • Notification text is localized in the UI language through ui_language.rs:
    • Title "Smart SSH".
    • A body per kind with the server name and source only, e.g. EN "Approval needed: command on web-01 (via MCP client 'X')", "Question from the AI on web-01", "Host key confirmation needed for web-01", "Login prompt for web-01", "Note suggestion for web-01".
    • Never the command text, file path, file content, note text, question text, option text or prompt text.
    • The MCP client name goes through the existing normalization, with control characters and newlines removed.
  • Activation path: a Rust function activate_pending_request(id). It focuses the main window (reusing focus_main_window) and emits a new event (suggested pending-request-activated, with the tab/session id, or none for app-wide requests). It goes in event_names.rs and eventNames.ts, and npm run check-events passes. The frontend switches to that tab when the event arrives. Nothing triggers it from the OS yet; the follow-up issues wire clicks to it.
  • Remove notify_pending_confirmation from mcp_backend.rs. MCP requests go through the new mechanism like all the others.
  • Two UI preferences, both default true, registered in UiPreferenceRegistry::builtin() and read by the backend:
    • notifyPendingRequests, labelled "Notify on pending requests"
    • attentionOnPendingRequests, labelled "Bounce/flash the app icon on pending requests"
      Both appear in the Settings screen in the existing category that fits under ADR 0041, with a one-line explanation each. The attention toggle is hidden on Android. Texts are in all 25 locales and the key-parity test passes.
  • Notifications never offer approve/deny actions. A click only focuses.

Acceptance Criteria

  • PendingRequestNotifier trait in app-logic. Unit tests with a recording fake show exactly one request_pending and one request_ended for each kind:
    • action confirmation approved, denied, timed out, reconnect, tab closed, future dropped
    • escalation
    • note suggestion and note shrink
    • host key accepted and rejected
    • auth prompt answered and cancelled
    • AI question answered by the next user message, and tab closed
  • An action denied by the filter or allowed without confirmation produces no request_pending (test).
  • With the window not focused and both settings on, a pending request shows a notification and calls request_user_attention(Critical). With the window focused, neither happens. Covered by tests against a fake window/notification backend.
  • Attention is cleared on window focus and when the last pending request ends (test).
  • Each setting off disables only its own effect (test). Both default to on.
  • Notification bodies contain only kind, server name and source. A test with a command, a file path and a question text containing a marker string asserts that the marker never appears in title or body. An MCP client name with a newline and control characters is sanitized (test).
  • Notification text follows the UI language (test for EN and DE).
  • activate_pending_request(id) focuses the main window and emits pending-request-activated. The frontend switches to the tab of that request (frontend test), and an app-wide request only focuses.
  • notify_pending_confirmation is gone. An MCP-proposed action that needs confirmation notifies through the new path.
  • Settings screen shows both toggles (attention toggle not on Android), localized in all 25 locales.
  • On Android the notifier is a no-op in this issue (no crash, no change in behaviour).
  • THREAT-MODEL.md describes the new notification: content limits, no approve/deny from notifications, untrusted client name.
  • Relevant automated tests pass (cargo test, frontend tests, npm run check-events, scripts/gate.sh).

Technical Notes

  • Security-relevant area:
    • Confirmation path in crates/app-logic/src/orchestration/ and mcp_backend.rs. Security invariants 1, 3, 9, 11 and 14 apply: a notification must never approve anything, and its content must never leak secrets or command content.
    • Spec 0094 / ADR 0086: no content in default logs. Notification errors are logged without the body.
    • The PR updates THREAT-MODEL.md (AGENTS.md, CI job threat-model-note).
  • The hook into the guards must not change when or how a confirmation resolves. It is purely an observer; a panicking or slow notifier must not block or alter the decision. Call it without holding registry locks.
  • Desktop limits of tauri-plugin-notification (no removal of delivered notifications, no click callback) are expected here. The follow-up issues add native backends behind the boundary from this issue.
  • Data model: two new UI preference keys, no migration.

Files: crates/app-logic/src/orchestration/pending_confirmation.rs, crates/app-logic/src/orchestration/action_exec/propose.rs, crates/app-logic/src/orchestration/notes.rs, crates/app-logic/src/connect/host_key_flow.rs, crates/app-logic/src/auth_prompter.rs, crates/app-logic/src/state.rs, crates/app-logic/src/ (new pending_request_notifier module), crates/app-logic/src/event_names.rs, crates/app-shell/src/mcp_backend.rs, crates/app-shell/src/lib.rs, crates/app-shell/src/ui_preferences.rs, crates/app-shell/src/single_instance.rs, crates/app-shell/src/ (new pending_request_notifications module), apps/smart-ssh-community/frontend/src/api/eventNames.ts, apps/smart-ssh-community/frontend/src/hooks/useSessionTabs.ts, apps/smart-ssh-community/frontend/src/settings/, apps/smart-ssh-community/frontend/src/components/SettingsScreen.tsx, apps/smart-ssh-community/frontend/src/locales/, docs/specs/, docs/specs/0028-mcp-server-integration.md, THREAT-MODEL.md, docs/codemap.md

Spec impact: new (pending-request notifications), update 0028 (§9a and §11 point to the new spec)

Open questions

  • Where the AI-question end is detected: in the backend on the next user message of that session (recommended, keeps the trait the single source) or from the frontend via a command. Recommendation: backend, in the chat-turn start.

Related Work

Activity

  1. added this to the 0.9.0 milestone on Dec 4, 2026
  2. added
    enhancement
    frontend
    on Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app-shellenhancementfrontendmcp

    Fields

    Priority

    P2 - Normal

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions