Android predictive back gesture implementation#13
Conversation
- Added `RouteTransitions` utility to manage history stack and direction. - configured TanStack Router `defaultViewTransition` to use View Transition API on Android. - Added `transitions.css` with push/pop slide animations. - Updated Android back button handler to trigger backward transition. - Added documentation in `docs/ANDROID_TRANSITIONS.md`. - Added unit tests for transition logic.
- Created `tauri-plugin-predictive-back` to bridge Android 14+ `OnBackInvokedCallback` to webview. - Implemented `PredictiveBackController` to manage gesture state and events. - Created `RouteStage` component to render the interactive "peek" UI with underlay. - Implemented Tier 2A route registry to render the previous screen in the underlay. - Updated `router.tsx` to integrate `RouteStage` and manage `canGoBack` state. - Added documentation in `docs/predictive-back/IMPLEMENTATION.md`. - Updated `apps/window-alarm/src-tauri/Cargo.toml` and `lib.rs` to register the plugin. - Fixed `stop_ringing` compilation error in `tauri-plugin-alarm-manager` desktop implementation.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
…, and cleaned up unused code - Updated `router.tsx` to properly import and use `RouteStage` and call `setCanGoBack`. - Created `apps/window-alarm/src-tauri/capabilities/default.json` to enable `predictive-back:default` permission. - Verified `RouteStage.tsx` logic is clean and active. - Fixed missing `Outlet` usage TS error in `router.tsx` (it was imported but not used because it was inside `RouteStage` now, but `router.tsx` itself still imported it. Actually `RouteStage` imports it. I should check if I need to remove the unused import in `router.tsx` to pass build, but `tsc` error was `Outlet is declared but its value is never read`. I will remove the unused import).
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 81466ef3ee
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // Subscribe to predictive back events | ||
| useEffect(() => { | ||
| const unsub = predictiveBackController.subscribe((state) => { | ||
| setPbState(state); |
There was a problem hiding this comment.
Initialise predictive back controller before subscribing
The new RouteStage subscribes to predictiveBackController, but nothing ever calls predictiveBackController.init() in this commit (and a repo-wide search shows no other callers). Since init() is where the event listeners are registered, the state never updates, so state.progress === 1 is never reached and router.history.back() never fires. On Android 14+ this means the native callback intercepts the back swipe (after setCanGoBack(true)), but the gesture does nothing in the UI. Consider invoking predictiveBackController.init() once (e.g., in RootLayout or at the start of this effect).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Initialise predictive back controller before subscribing
The new
RouteStagesubscribes topredictiveBackController, but nothing ever callspredictiveBackController.init()in this commit (and a repo-wide search shows no other callers). Sinceinit()is where the event listeners are registered, the state never updates, sostate.progress === 1is never reached androuter.history.back()never fires. On Android 14+ this means the native callback intercepts the back swipe (aftersetCanGoBack(true)), but the gesture does nothing in the UI. Consider invokingpredictiveBackController.init()once (e.g., inRootLayoutor at the start of this effect).Useful? React with 👍 / 👎.
Checkout Codex's review
There was a problem hiding this comment.
Good catch! I actually fixed this in a subsequent commit by initializing it in apps/window-alarm/src/App.tsx. The review might be based on an earlier state, but I will double check to ensure it's initialized correctly.
Ignoring unrelated bot command. |
- Removed unused `Outlet` import from `apps/window-alarm/src/router.tsx` to fix TypeScript build error.
- Verified successful frontend build with `tsc && vite build`.
- Addressed code review feedback:
- Integrated `RouteStage` into router.
- Enabled `predictive-back:default` capability.
- Cleaned up unused variables in `RouteStage.tsx`.
- Removed unused `historyStack` logic.
- Fixed Android plugin event emission (using standard `plugin:predictive-back` channel).
- Updated documentation.
- Removed unused `Outlet` import from `apps/window-alarm/src/router.tsx` to fix TypeScript build error.
- Verified successful frontend build with `tsc && vite build`.
- Addressed code review feedback:
- Integrated `RouteStage` into router.
- Enabled `predictive-back:default` capability.
- Cleaned up unused variables in `RouteStage.tsx`.
- Removed unused `historyStack` logic.
- Fixed Android plugin event emission (using standard `plugin:predictive-back` channel).
- Updated documentation.
24465bf to
0268da0
Compare
Implemented Android predictive back gesture ("peek") functionality for Android 14+ devices.
Key changes:
tauri-plugin-predictive-back): A new Rust/Kotlin plugin that registers anOnBackAnimationCallbackon API 34+ and emitsstarted,progress,cancelled, andinvokedevents to the JavaScript layer.PredictiveBackController.ts): Manages the subscription to native events and exposes state to React components.RouteStage.tsx): Wraps the router outlet and renders a "Route Stage" that handles the gesture animation. It includes logic to render the actual previous route (Tier 2A) in an underlay for a high-fidelity peek effect.RouteStageand dynamically enable/disable the native back callback based on history depth and current route (e.g., disabled on Ringing screen).Verified frontend build and Rust compilation. Ensured compliance with Android 14+ requirements and fallback for older versions.
PR created automatically by Jules for task 8026342687833370616 started by @ScottMorris