Files
buzz/mobile/lib
Matt Toohey bf34af139f fix(mobile): remove a mention chip whole on an iOS Backspace
On the iPhone simulator the second Backspace after a picked `@Bob `
still turned the chip into plain `@Bo` with the chooser open, and the
agent chip into `@Scou`, from the hardware key and the on-screen delete
key alike (recommendation 2, second half). The widget test passed
because it fed the deletion as one collapsed-caret update, the shape
Android sends. A scratch harness on the simulator showed iOS reports a
Backspace as two editing updates: the character before the caret is
selected first (`@Bob` 4,4 to 3,4), then that selection is removed with
the caret at its start (`@Bo` 3,3). The controller snapped the first
update to the whole chip (0,4), so the deletion formatter saw a
non-collapsed old selection and, by the rule that an edit over a
selection replaces exactly that selection, left `@Bo` alone.

The controller now records the platform's own selection whenever a snap
widens it to a chip. A deletion that removes exactly that recorded
range, caret at its start, is the platform deleting what it selected, and
it widens to the whole chip and its binding like a caret deletion does.
Any other edit over a selection is unchanged: typed text replaces the
snapped selection and Cut removes only what it copies, since the two are
otherwise indistinguishable (`@Helper Bot typing` selected and `@` typed
reads the same as deleting everything after the `@`). The first press
still removes only the trailing space, as buzz-app does.

Tests: the chip journey's Backspace helper now sends the two updates iOS
sends, so it fails on the old code with `hi @Bo` and passes with the
fix, for the person and the agent chip; the selection-replacement test
keeps its typed text. `dart format`, `flutter analyze`, `just
file-size-check` and the full mobile `flutter test` suite pass. On the
iPhone 17 simulator (iOS 27.2) with the harness, two hardware
Backspaces after `@Bob ` and after `@Scout ` leave an empty composer
with the chooser closed, and the on-screen delete key does the same.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
2026-11-19 15:39:07 +11:00
..