Skip to content

Keyboard: suggestion bar capsules (light capsule, blue undo), as on iOS 2.1 (#434) - #457

Merged
Pivii merged 2 commits into
developfrom
feat/434-suggestion-bar-redesign
Dec 2, 2026
Merged

Pivii merged 2 commits into
developfrom
feat/434-suggestion-bar-redesign

Conversation

@Pivii

@Pivii Pivii commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Sans risque : interrupteur debug éteint par défaut

Closes #434

What this was for

iOS 2.1 draws the suggestion bar as Apple's: the word Space is about to write sits in a light capsule instead of being bold, and the undo chip after a correction is a blue capsule of the same height (iOS #502, PR #1092, on by default since #1122). Android still drew the bold word and an 8 dp rounded-rectangle chip. This PR ports the iOS look, behind a debug switch that is off by default. Switch off, the bar is develop's: the classic code path draws exactly what it drew before (only its tap lambda was hoisted so both looks share it).

To test by hand

Debug build only. On: python3 -I tools/keyboard-bench/dictus_prefs.py --serial <serial> set --bool debug_suggestion_capsules true (it stops the app; show the keyboard again). Off: same with false.

  1. Light theme, French keyboard, type bonjout → bonjour in a white capsule in the centre slot, no divider beside it, words in a grey ink, no bold. Does the capsule read as a pill and not as a key?
  2. Press Space → ↶ bonjout in a pale blue capsule as tall as the white one; the bar does not jump. Tap it: bonjout comes back.
  3. Same two steps in dark (set theme dark): grey capsule, white word; dark blue undo capsule.
  4. Switch off: bold Bonjour, the classic 8 dp chip, as on develop.
  5. On the Pixel, with a large system font: a long word in the capsule shrinks before it shows « … ».

Proofs

Branch proofs/457: boards 434-light.png and 434-dark.png (columns: iOS develop with capsules | Android switch on | Android switch off; rows: word about to be corrected, then undo offered), and each capture alone (android-on-*, android-off-*, ios-on-*).

light

dark

  • Android: emulator dictus_api35 (Pixel 4 profile, 1080 × 2280), x86_64 debug build of this branch, Dictus feedback form's message field, French keyboard, bonjout then Space.
  • iOS: the captures of iOS PR #1092 (study/evidence-1092, docs/agents/evidence/1092/dictus-on-*-b.png and -c.png, iPhone 17 Pro simulator, same steps). Taken from that PR, not re-captured. On iOS the undo row also shows predictions (monsieur, tout); on the emulator the bar had none after Bonjour , so the two other slots are empty.

Colours sampled on the emulator captures: light platter (242,242,247), capsule (255,255,255), undo (220,228,248); dark platter (10,22,40), capsule (100,108,119), undo (16,34,66).

What is ported, with its iOS source

All iOS references are getdictus/dictus-ios develop at 4e29e82f, file DictusKeyboard/Views/SuggestionBarView.swift unless named.

Element iOS develop Android
Which slot gets the neutral capsule (the word Space writes) and which gets the undo capsule capsuleKind(at:), lines 240-247 capsuleKinds, the bar's bold slot (boldSlot) and slot 0 with an undo offer
Dividers 1 × 24, always laid out, hidden beside a capsule capsuleBar, lines 252-259; CapsuleMetrics.dividerWidth/Height, lines 227-228 capsuleDividerShown, alpha(0f) keeps the place
Slot tap target 36, capsule drawn inside it lines 265-268; CapsuleMetrics.capsuleHeight line 225 CAPSULE_HEIGHT = 36.dp, row height unchanged
Words 17 regular, one line, shrink to 15 before truncating capsuleText, lines 302-307; CapsuleMetrics.fontSize / minimumScale, lines 218-221 CapsuleText, 17 sp, suggestionTextScale(minScale = 15/17)
Plain slot padding 6, capsule padding 10 capsuleSlot, lines 286-296 same, in dp
Pending capsule: round ends, full slot width line 296 (Capsule().fill(pendingFill)), line 294 CircleShape, weight(1f)
Undo capsule: arrow + word, spacing 5, padding 10, accent fill 0.12 resting / 0.35 pulse, scale 1.05 capsuleUndoChip(word:), lines 312-326 CapsuleUndoChip
Undo pulse: instant rise, 0.08 s hold, 0.45 s ease back triggerUndoPulse, lines 147-157 (shared with the classic chip) same constants as the classic chip (now internal)
Accent #3D7EFF DictusCore/Sources/DictusCore/Design/DictusColors.swift, line 20 DictusColors.Accent
Inks: words black 67 % / white 58 %, dividers black 6.6 % / white 7.5 %, capsule word black 81 % / white, dark capsule white 37 % lines 332-336 capsuleInks

Intentional differences

  • Light capsule: opaque white, not white at 33 %. iOS's 33 % white lands ten levels above its light platter (226 → 236). Android's light keyboard background is lighter (#F2F2F7, 242): 33 % white gives 246, four levels, invisible. Opaque white gives thirteen levels, the closest to iOS's contrast; it stays lighter than the platter like iOS's, and Android's light keys are darker (#E8E8ED), so it does not read as a key (iOS Light haptic when a keyboard dictation inserts its text (#238) #241's trap). Dark uses iOS's ink as is.
  • The neutral capsule follows Android's bold slot. iOS marks the correction Space applies (slot 1 of .corrections) and the swiped word; Android's bold slot is already "the word Space writes" (Port dictus-ios#997: confidence margin, context and deterministic ties for trie corrections #388), so the capsule takes its place. Android has no swipe typing, so no swiped-word capsule.
  • Off by default, behind a debug DataStore key (debug_suggestion_capsules, read only when the build is debuggable, no row in Réglages). iOS has it on by default since 2.1 (KeyboardFeatureSettings.swift line 56) and always on in Release (line 245). Turning it on for everyone is a later PR.
  • Font and icon: Roboto (the system font) rather than SF; the undo arrow is the existing ic_undo vector at 15 dp for SF arrow.uturn.backward 13 pt medium (a vector has no weight).
  • Not ported, unchanged on both looks: iOS's quotes around the typed word in slot 0 and its 0.15 s fade when the words change (the classic Android bar has neither; out of this issue's scope).

Code

  • ime/.../ui/SuggestionBarCapsules.kt (new): LocalSuggestionCapsules, CapsuleSuggestionBar, CapsuleUndoChip, capsuleInks.
  • ime/.../ui/SuggestionBar.kt: draws CapsuleSuggestionBar when the switch is on; the slot tap moved into onSlotTap, shared by both; suggestionTextScale takes a minScale (default 1, so the classic bar is unchanged); the pulse constants are internal.
  • core/.../PreferenceKeys.kt: DEBUG_SUGGESTION_CAPSULES.
  • ime/.../DictusImeService.kt: reads it when debuggable and provides it to the keyboard, like debug_ios_typing_fixes.
  • tools/keyboard-bench/dictus_prefs.py: names the key in its doc (the tool already sets any boolean).
  • Feature map: typing.suggestion-capsules (iOS's ID) in typing.autocorrect.md, and kbd.suggestions in screens.md.

Display only: no change to what is suggested, what Space applies, or when.

Tests

  • flock /tmp/dictus-gradle.lock ./gradlew :core:testDebugUnitTest :ime:testDebugUnitTest :app:testDebugUnitTest lint assembleDebug: exit 0.
  • New SuggestionBarCapsulesTest (8 tests, Robolectric): which slot gets which capsule, hidden dividers, the 15/17 shrink, dividers flush with the capsule, the undo capsule still restores the word, a tap sends the same word as the classic bar, switch off draws no capsule. The existing bar tests (SuggestionBarTest, SuggestionBarBoldSlotTest, SuggestionBarLargeFontTest, AutocorrectUndoChipUiTest…) pass unchanged.
  • Not tested on a physical device. needs-physical-test is not set by the labeler (no audio path touched); the light capsule's legibility is worth Pierre's eye on the Pixel (step 1 above).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added an optional, debug-build-only capsule style for the suggestion bar. When enabled, suggestions and undo actions appear in capsules, with colors that adapt to light and dark backgrounds.
    • The setting is off by default. Suggestions remain selectable, and undo capsules continue to restore the typed word.
    • Capsule text scales down to fit longer suggestions before truncation.

Pivii and others added 2 commits December 2, 2026 21:17
…ch (refs #434)

The word Space writes sits in a neutral capsule instead of bold, the undo chip
is a blue capsule of the same height, dividers are 1 x 24 dp and hidden beside
a capsule. Read from debug_suggestion_capsules in debuggable builds only, off
by default; off, the classic bar is drawn as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Changes

The IME adds a debug-only DataStore preference for suggestion capsules. In debuggable builds, the preference enables an alternate suggestion bar with pending-word and undo capsules. The existing suggestion selection and undo actions remain available. Documentation and tests cover the switch and display behavior.

Suggestion Bar Capsules

Layer / File(s) Summary
Preference and debug-state wiring
core/src/main/java/dev/pivisolutions/dictus/core/preferences/PreferenceKeys.kt, ime/src/main/java/dev/pivisolutions/dictus/ime/DictusImeService.kt, .claude/skills/verify-dictus-android/features/*, tools/keyboard-bench/dictus_prefs.py
A boolean preference defaults to unset. The IME enables capsule state only when the app is debuggable and the preference is true, then provides that state to the keyboard UI. The documentation and preference tooling describe the switch.
Capsule presentation and interactions
ime/src/main/java/dev/pivisolutions/dictus/ime/ui/SuggestionBar.kt, ime/src/main/java/dev/pivisolutions/dictus/ime/ui/SuggestionBarCapsules.kt, ime/src/test/java/dev/pivisolutions/dictus/ime/ui/SuggestionBarCapsulesTest.kt
The suggestion bar conditionally renders three capsule-capable slots, applies text scaling and theme colors, and supports undo and suggestion selection. Tests cover capsule classification, layout, selection, undo, and the disabled state.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant DataStore
  participant DictusImeService
  participant KeyboardContent
  participant SuggestionBar
  DataStore->>DictusImeService: DEBUG_SUGGESTION_CAPSULES preference
  DictusImeService->>DictusImeService: Enable state only in debuggable builds
  DictusImeService->>KeyboardContent: Collect capsule-enabled state
  KeyboardContent->>SuggestionBar: Provide LocalSuggestionCapsules
Loading

Possibly related PRs

Merge Risk: Minimal · up to 269f9

This adds an opt-in, debug-only suggestion bar style that is off by default, so normal keyboard behavior is unchanged. The risk of merging is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a suggestion bar capsule display for the Android keyboard (light capsule for the neutral slot, blue capsule for undo), modeled on iOS 2.1. The raw summary shows the ch…
Linked Issues check Passed [#434] asks for an Android counterpart to the iOS 2.1 suggestion bar: the word about to be corrected in a light capsule, undo in a blue capsule, in light and dark mode, with the design checked against…
Out of Scope Changes check Passed All changed files relate to the #434 capsule display. SuggestionBarCapsules.kt and SuggestionBarCapsulesTest.kt implement and test the new display. SuggestionBar.kt routes slot taps through onSlotTap …
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: a suggestion bar capsule display for the Android keyboard (light capsule for the neutral slot, blue capsule for undo), modeled on iOS 2.1. The raw summary shows the changes add a debug-only, off-by-default switch, the SuggestionBarCapsules composable, the LocalSuggestionCapsules provider, and tests, all matching this title. The title's stated scope matches the changeset. Its PR number (#434) differs from the PR objectives' reference (#457), which is a metadata inconsistency and does not affect the title's relevance.

Full details: Linked Issues check

Explanation

[#434] asks for an Android counterpart to the iOS 2.1 suggestion bar: the word about to be corrected in a light capsule, undo in a blue capsule, in light and dark mode, with the design checked against Android's own look. The PR adds LocalSuggestionCapsules and CapsuleSuggestionBar/CapsuleUndoChip (SuggestionBarCapsules.kt). It selects the neutral capsule for the word Space writes (bold slot), and the blue undo capsule for slot 0 when an undo offer exists. Light and dark inks are defined in capsuleInks. The PR description records the Android-versus-iOS check: Android draws a bold word and an 8 dp chip, and the intentional differences are listed (opaque white light capsule, Roboto, ic_undo icon). The #434 request to first check Android's existing look is addressed in the description. The code is gated by debug_suggestion_capsules (read only when debuggable, default off). The issue does not require default-on behaviour, so the debug gate does not leave a coding requirement unmet. The SuggestionBarCapsulesTest suite covers slot selection, hidden dividers, text shrink, undo restoration, tap behaviour, and the switch-off path. Evidence is from the PR summary and description. I did not run the tests.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the #434 capsule display. SuggestionBarCapsules.kt and SuggestionBarCapsulesTest.kt implement and test the new display. SuggestionBar.kt routes slot taps through onSlotTap (shared by both looks), gates the capsule bar on the switch, adds a minScale parameter with default 1f so the classic bar is unchanged, and makes the undo pulse constants internal for reuse. PreferenceKeys.kt adds DEBUG_SUGGESTION_CAPSULES. DictusImeService.kt reads that key when debuggable and provides LocalSuggestionCapsules. dictus_prefs.py changes only its doc comment. The feature-map Markdown files document the switch. Each of these supports the capsule feature. The change does not alter suggestion content, Space behaviour, or timing, as the PR description states. No unrelated change was found in the summary.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b5f23c61-d1ea-411f-855a-703dd0738957
Commits

Reviewing files that changed from the base of the PR and between b9f31a6 and 269f9de.

Files selected for processing: 8

  • .claude/skills/verify-dictus-android/features/screens.md
  • .claude/skills/verify-dictus-android/features/typing.autocorrect.md
  • core/src/main/java/dev/pivisolutions/dictus/core/preferences/PreferenceKeys.kt
  • ime/src/main/java/dev/pivisolutions/dictus/ime/DictusImeService.kt
  • ime/src/main/java/dev/pivisolutions/dictus/ime/ui/SuggestionBar.kt
  • ime/src/main/java/dev/pivisolutions/dictus/ime/ui/SuggestionBarCapsules.kt
  • ime/src/test/java/dev/pivisolutions/dictus/ime/ui/SuggestionBarCapsulesTest.kt
  • tools/keyboard-bench/dictus_prefs.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

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.

Keyboard: suggestion bar redesign (light capsule, blue undo), as on iOS 2.1

1 participant