Files
amethyst/amethyst
Claude 8b4220019a fix(ime): close the two remaining stuck-padding paths
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
2026-08-05 17:40:03 +00:00
..
2026-07-28 10:52:38 -04:00