Skip to content

feat(core): back button event on Android, closes #8142 - #6

Open
tomerqodo wants to merge 2 commits into
coderabbit_full_base_featcore_back_button_event_on_android_closes_8142_pr6from
coderabbit_full_head_featcore_back_button_event_on_android_closes_8142_pr6
Open

feat(core): back button event on Android, closes #8142#6
tomerqodo wants to merge 2 commits into
coderabbit_full_base_featcore_back_button_event_on_android_closes_8142_pr6from
coderabbit_full_head_featcore_back_button_event_on_android_closes_8142_pr6

Conversation

@tomerqodo

@tomerqodo tomerqodo commented Jan 30, 2026

Copy link
Copy Markdown

Benchmark PR from agentic-review-benchmarks#6

Summary by CodeRabbit

Release Notes

  • New Features
    • Mobile app plugin now supports back button press event detection and handling on Android devices.
    • New onBackButtonPress listener API enables custom back button interactions with navigation state awareness.
    • Added exit command to terminate the application.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This pull request implements Android back button event handling for Tauri apps across multiple layers. Changes include a new Android plugin managing back navigation, Kotlin/Rust platform-specific code, JavaScript listener API, updated permissions, and a dependency update to wry 0.53.4 with linux-body support.

Changes

Cohort / File(s) Summary
Changelog Entries
.changes/android-app-plugin.md, .changes/back-button-press-api.md
Added two changelog entries documenting the new mobile app plugin and onBackButtonPress API features.
Android Kotlin Implementation
crates/tauri/mobile/android-codegen/TauriActivity.kt, crates/tauri/mobile/android/src/main/java/app/tauri/AppPlugin.kt
Introduced AppPlugin with back button event handling that either navigates WebView history or emits back-button events to JavaScript based on listener registration; added handleBackNavigation property to TauriActivity.
Android Plugin Utilities
crates/tauri/mobile/android/src/main/java/app/tauri/plugin/Plugin.kt
Added hasListener() method to query listener presence for events.
Rust Plugin Setup
crates/tauri/build.rs, crates/tauri/src/app/plugin.rs
Added register_listener and remove_listener commands to core:app plugin; added Android-specific AppPlugin struct and initialization logic.
Permissions Documentation
crates/tauri/permissions/app/autogenerated/reference.md
Added four new permission entries for allow/deny of register_listener and remove_listener commands.
JavaScript API
packages/api/src/app.ts
Introduced onBackButtonPress() listener function and OnBackButtonPressPayload type for handling back button events from JavaScript.
Dependency & Cleanup
crates/tauri-runtime-wry/Cargo.toml, crates/tauri/src/path/android.rs, crates/tauri/scripts/bundle.global.js
Updated wry to 0.53.4 and added linux-body feature; cleaned up unused Android path imports; reformatted JavaScript bundle.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Activity as Android Activity
    participant AppPlugin as AppPlugin<br/>(Kotlin)
    participant WebView as WebView
    participant Runtime as Tauri Runtime<br/>(JS/Rust)

    User->>Activity: Press back button
    Activity->>AppPlugin: onBackPressed callback
    AppPlugin->>AppPlugin: hasListener("back-button")?
    alt Listener registered
        AppPlugin->>AppPlugin: Check canGoBack state
        AppPlugin->>Runtime: emit back-button event<br/>(canGoBack payload)
        Runtime->>Runtime: JS handler receives event
        Runtime->>WebView: Handle in app logic
    else No listener
        AppPlugin->>WebView: goBack() if history exists
        alt WebView history available
            WebView->>WebView: Navigate back
        else No history
            AppPlugin->>Activity: System back press
            Activity->>Activity: Pop back stack
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Back buttons hop through Android's door,
Events whisper what they're for,
Listeners catch them, signals flow,
From Kotlin deep to JS below,
Navigation magic, smooth and true! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.41% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding a back button event feature for Android platform, and references the closed issue #8142.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch coderabbit_full_head_featcore_back_button_event_on_android_closes_8142_pr6

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant