Skip to content

Pending-request notifications on Android: notification, tap opens the request, cancel when handled #1712

Backlog

Description

@smart-ssh-planner

Goal

On Android, a request that is waiting for the user while the app is in the background shows a system notification. Tapping it opens the app on the tab of the request. The notification disappears when the request ends or the app comes to the foreground.

Context

  • Pending requests: native notification and Dock/taskbar attention while the app is in the background #1709 added the PendingRequestNotifier trait (a no-op on Android so far), the notification texts, the settings and activate_pending_request(id).
  • Android host plugin crates/tauri-plugin-android-host/:
    • SessionService.kt: foreground-service notification on channel sessions (IMPORTANCE_LOW), content intent that opens the app.
    • SessionServicePlugin.kt:43: requests POST_NOTIFICATIONS once at the first session.
    • AndroidManifest.xml declares POST_NOTIFICATIONS.
    • Strings are in android/src/main/res/values/strings.xml (English only).
  • Rust bridge: crates/app-shell/src/android_service.rs (run_mobile_plugin), logic in crates/app-logic/src/background_keepalive.rs.
  • Frontend: a visibilitychange listener in apps/smart-ssh-community/frontend/src/hooks/useSessionTabs.ts:273-292 resyncs pending state after returning from the background.

Requirements

  • Android implementation of the notifier:
    • "Background" means the main activity is not resumed.
    • On request_pending in the background, with the notification setting on, post a notification on its own channel (suggested id pending_requests, IMPORTANCE_HIGH so it pops up), separate from sessions.
    • The notification id is derived from the request id.
    • Title and body come from the shared localized texts. The channel name is localized in the UI language as well.
  • Tap: a content intent opens the main activity with the request id. It then calls activate_pending_request(id), which switches to the tab.
  • Cancel the notification when its request ends, and all pending-request notifications when the activity resumes.
  • Permission: if POST_NOTIFICATIONS is not granted at the first pending request, request it once, the same way as SessionServicePlugin does. If it is denied, log once and change nothing else.
  • No approve/deny actions in the notification. The attention setting stays hidden on Android.

Acceptance Criteria

  • With the app in the background, an AI/MCP action that needs approval posts a notification on the pending_requests channel, with kind, server name and source only.
  • Tapping the notification opens the app on the tab of the request. A request without a tab only opens the app.
  • The notification is cancelled when the request ends (approved, denied, timeout, tab closed) and when the app comes to the foreground.
  • With the app in the foreground, no notification is posted.
  • Notification setting off → no notification.
  • Notification permission denied → no crash, logged once, request flow unchanged.
  • The sessions foreground notification is unchanged.
  • Unit tests for the Rust side (id mapping, foreground/background decision, cancel on end) with a fake bridge.
  • The Android build job passes.
  • Relevant automated tests pass.

Technical Notes

  • Real device behaviour (heads-up, lock screen, tap) can only be checked by hand. The reviewer lists manual test steps.
  • Keep the Kotlin in its own class (e.g. PendingRequestNotifications.kt) next to SessionService.kt.
  • No content in logs (Spec 0094).

Files: crates/tauri-plugin-android-host/android/src/main/java/dev/smartssh/androidhost/ (new class, plugin registration), crates/tauri-plugin-android-host/android/src/main/res/values/strings.xml, crates/tauri-plugin-android-host/src/, crates/app-shell/src/android_service.rs, crates/app-shell/src/ (android notifier module), docs/specs/ (pending-request notification spec)

Spec impact: update the pending-request notification spec created by #1709 (Android behaviour)

Open questions

  • Use the existing android-host plugin with its own Kotlin class (recommended: one place for Android notifications, same intent handling as SessionService), or the mobile API of tauri-plugin-notification (channels and cancel exist, but tap routing to a request id has to be checked).

Related Work

Metadata

Metadata

Assignees

No one assigned

    Labels

    app-shellenhancement

    Fields

    Priority

    P2 - Normal

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions