mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2026-08-12 09:13:23 +00:00
Two exits still popped a composer while the IME was mid-animation — the race that strands imePadding() at keyboard height app-wide. 1. Top-bar X and Post. KeyboardAwareBackHandler only guards the back gesture; ActionTopBar wired both buttons straight to nav.popBack(), with nothing dismissing the keyboard first. Tapping either while typing reproduced the original bug exactly. The earlier fix leaned on the back arrow as the "always-available exit" without noticing it was also a race source. 2. A ~250ms hole in the back gate. It read the animated WindowInsets.ime, which stays above zero for the whole close animation — a window in which the IME had already stopped consuming back but the handler was still disabled, so a second back fell through to the NavController and popped without ever running onBack. That silently dropped the draft the handler exists to save: nothing else saves it, onCleared() only closes the writing assistant and there is no autosave. Both are the same underlying requirement — serialize the IME and window animations instead of overlapping them — so both now route through one helper, rememberAfterKeyboardCloses(): keyboard down, the action runs inline and nothing changes; keyboard up, clear focus, hide, wait for the inset to actually reach zero, then act. The wait is bounded so a stale inset (the very failure being guarded) can never trap the user on screen, and re-entrant calls are dropped since the deferral widens the window for a double-tap on Post to fire twice. The back gate now reads WindowInsets.imeAnimationTarget, which flips to zero the moment the hide begins, so back keeps reaching onBack throughout the animation. Re-enabling that early means onBack can fire mid-animation, which is exactly what the helper absorbs. Not covered: this is verified by compile and the unit suite only. The race reproduces on release builds on a device, which this environment cannot run. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LfUMGWYu2uTSyh17JJonfN