Skip to content

Hush's own small controls can be reached with Tab and pressed with Return or Space, and every dialog keeps Tab and takes Esc - #284

Merged
pitis merged 6 commits into
mainfrom
feat/keyboard-everywhere
Nov 29, 2026
Merged

pitis merged 6 commits into
mainfrom
feat/keyboard-everywhere

Conversation

@pitis

@pitis pitis commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

What changed

  • pressable() (app/view.rs), one way for a control of Hush's own to take the keys, the way gpui-component's buttons do: it gives the control a focus handle that is a Tab stop, the theme's focus ring (gpui-component's focus_ring_style, the ring its own buttons and fields draw) while the control has the keys, and a mouse-down that leaves the keys where they were (as gpui-component's Button does), so a click doesn't take the keys from the composer. GPUI already presses a focused element with a click listener when Return or Space is let go. Pressable forwards InteractiveElement/Styled/ParentElement, so a call site only wraps its div().id(…) and keeps its chain (its click, a context menu, a popover's trigger).
  • Made pressable, each already with an id, a role and a label:
    • notice actions: View Safety Number, Reset Secure Session…;
    • the reaction pill (Return/Space open who reacted, through the popover's own keys) and the picker's reactions and "+";
    • poll options (votable ones only) and End poll;
    • the colour and wallpaper swatches;
    • stickers and the picker's pack tabs;
    • the error banner's ✕, the sidebar's Offline "Retry";
    • files: a photo (open, or download), a file's row (open, or download), a recording's play/pause and its download, a sticker's download;
    • and the rest of the same kind: the reply/edit bar's ⓧ, a failed send's Retry, the link preview (open) and the draft preview's ✕, a tray file's ⓧ, Archived Chats, "All Chats" in a chat's search, a spoiler (now with role Button, "Reveal spoiler"), view-once's View/Download, a story's link and Play video.
  • Dialogs: the view-once look now keeps Tab inside (focus_trap around the photo and its Close, and around the video's card); the history transfer takes Esc as Continue Without History once it has failed, and ignores it while it waits or runs, so a stray Esc doesn't give the history up (owner's decision; it already trapped Tab).
  • Layout touches, only so the ring isn't clipped: a photo's clip moves to an inner frame (the control around it has the same size and corners); the stories' 9:16 card clips only for a text story (a video's card has nothing that spills); Archived Chats is the row inside the list's margin; the sticker picker's tabs are inset 3 and its grid 3 with a 7 gap (was 8), four to a row still.
  • A file's control keeps the keys while it downloads and decodes, so the next Tab goes on from it; a download's label follows its state (Download, Downloading, Retry).
  • A pressable takes no focus from any mouse button, so a click or a right-click (and its menu) leaves the keys where they were. Trigger (a popover's trigger in our own look) takes any element.
  • --snapshot gains focused: the chat colour picker with its first swatch reached by Tab.
  • PRODUCT.md's accessibility section and DESIGN.md (shared pieces, the history transfer) say so.

Left as they are, each already reachable another way: the chat list's rows and the search's hits (⌥↑↓, ⌘1–9, the arrows in the search), the mention picker's rows (↑↓ and Return in the composer), the stories' chat list (↑↓ in the stories window), and the Send button (Return).

Not done: a message's hover buttons (React, Reply, More) show under the pointer only, and GPUI doesn't lay out a hidden element's Tab stops, so the keyboard still can't reach them, nor the message menu they open. The picker's reactions take the keys once it's open. Reaching them needs a choice for the owner (see below).

Why

Found while writing DESIGN.md (#267): about 20 of Hush's own small controls took a click only, and two dialogs didn't keep Tab or take Esc.

How it was tested

Window tests, one per kind of control, each written first and failing on the base (Tab never reaches …, Tab stays in the look, the core was asked to end the transfer), passing after:

  • view::the_error_banners_close_is_pressed_from_the_keyboard (Return)
  • events::a_notices_action_is_pressed_from_the_keyboard (Space: the safety number shows)
  • actions::a_reaction_pill_opens_who_reacted_from_the_keyboard (Return)
  • actions::the_pickers_reaction_is_pressed_from_the_keyboard (Space: the picker closes)
  • polls::a_polls_option_is_voted_for_from_the_keyboard (Return: the vote reaches the core)
  • options::a_swatch_is_chosen_from_the_keyboard (Return: the change reaches the core)
  • stickers::a_sticker_is_sent_from_the_keyboard (Return: the picker closes)
  • files::a_files_download_is_pressed_from_the_keyboard (Return, on the photo and on the failed file: the download reaches the core)
  • view_once::tab_stays_in_the_look_close_included (photo and video: Tab stays in, and Return on Close closes it)
  • view::esc_continues_without_the_history_only_once_the_transfer_failed (Esc while waiting or downloading asks the core nothing; after a failure the core reports NoHistory)

Added in review, each failing on the code before its fix:

  • files::a_click_on_a_file_presses_it_and_leaves_the_keys_in_the_composer (a click still presses; a click or a right-click and Esc leave the composer the keys)
  • files::a_download_pressed_from_the_keyboard_keeps_the_keys_while_it_comes

The tests find the focused control by a focused <id> debug selector the ring sets (recorded only in debug builds with snapshot, as the app's other debug selectors).

make format && make check on the branch merged with origin/main (at f1051bd, after review and the owner's Esc decision): cargo fmt --check pass; cargo clippy --all-targets -D warnings pass, and with --features hush-desktop/snapshot pass; cargo test --features hush-desktop/snapshot pass (376 + 546 tests, 4 ignored as before).

Snapshots (cargo run -p hush-desktop --features snapshot -- --snapshot <dir>), looked at: focused-light/focused-dark (the first swatch with the theme's ring, the same ring gpui-component's buttons draw), sticker-picker (four to a row still, with room for the ring), files (the photos keep their size, corners and clip after the clip moved inside), story-video (the card keeps its corners unclipped), chat-style, events, polls, stickers, reply.

For the owner

  • A message's React, Reply and More buttons are still pointer-only. Reaching them from the keyboard needs a choice: a Tab stop on each of them in every message shown (three per message, shown while one has the keys), or a way to move between messages (↑↓ in the timeline) that brings up the focused message's buttons.

Closes #272

A shared pressable() gives a small control a Tab stop, the theme's focus
ring while it has the keys, and Return/Space to press it; a click leaves
the keys where they were. Notice actions, reaction pills and picker, poll
options, swatches, stickers, the banner's close, file downloads and the
rest of the click-only controls use it. The view-once look keeps Tab
inside, and Esc in the history transfer is Continue Without History.
…ps them, rings have room

A pressable takes no focus from any mouse button, so a right-click's menu
hands the keys back to the composer. A file's control stays a tab stop
while it downloads and decodes. Archived Chats is the row inside the
list's margin, and the sticker picker's tabs and grid leave room for the
ring. Tests: a click and a right-click keep the composer's keys, a
download keeps the keys, the view-once trap holds Close for the photo and
the video. One said() helper.
@pitis

pitis commented Nov 29, 2026

Copy link
Copy Markdown
Owner Author

Review (/pr-review-toolkit:review-pr: code, tests, comments and types)

No Critical findings. Every Important finding is fixed in 43ee8ef; the gate (make format && make check) passes on it merged with origin/main (18b82dc).

Important: fixed

  1. A right-click on a pressable took the keys from the composer (comments/types review). GPUI's focus-on-mouse-down has no button filter, and pressable only prevented it for the left button. Inside a message (every one has a right-click menu), the control took focus, the menu handed the keys back to it on close, and its ring showed. Fix: on_any_mouse_down prevents it (app/view.rs). Test: files::a_click_on_a_file_presses_it_and_leaves_the_keys_in_the_composer (a right-click and Esc leave the composer the keys). It fails with the left-only guard.
  2. Nothing tested that a click still presses a control and leaves the keys where they were (tests review). The same test clicks the photo still to download: the download reaches the core and the composer keeps the keys.
  3. A keyboard download sent the keys back to the window's start (code review). Once pressed, a file went Downloading and drew its control without pressable, so its focus handle went and the next Tab started over. Fix: a file's control stays a tab stop while it downloads or decodes, and presses only when there's something to download (keeps_keys, app/files/view.rs). A file that can't be had takes no keys. Test: files::a_download_pressed_from_the_keyboard_keeps_the_keys_while_it_comes, which fails before the fix.
  4. Archived Chats' ring was clipped by the chat list (code review). The control was the full-width padding box. Fix: the row inside the list's margin is the control (with 8 corners for its ring), and the margin stays outside (app/chats/view.rs).
  5. The sticker picker's rings were clipped (code review). The pack tabs sat at the top-left of a horizontal scroll, and the grid's first column sat at the left of a vertical one. Fix: the tabs' row is padded 3/3/5 instead of 0/0/8 (same height), and the grid has a 3 inset with a 7 gap instead of 8, so four 72 cells still fit in 312 (app/stickers/view.rs). Checked in the sticker-picker snapshot.
  6. The view-once trap test passed even if Close wasn't reachable, and didn't cover the video (tests review). It now presses Return after the Tabs and expects the look closed, for the photo and for the video (view_once::tab_stays_in_the_look_close_included).

Suggestions

  • Done: a download's label follows its state (Download, Downloading, Retry). The comments on Pressable's forwarding, the photo's clip and the poll test are reworded. The focused <id> selector taking the photo's file-N slot is noted where file-N is set. Duplicate said in polls.rs removed. The reaction and sticker tests' messages say "pressed", not "reacted"/"sent" (without a core they prove the press, not the send).
  • PRODUCT.md now also says right-click menus are pointer-only.
  • Declined, a focused chosen swatch's border takes the ring colour: that is how gpui-component's ring treats every bordered control, its own included. The swatch stays marked chosen for the screen reader, and its ring comes back once the keys move on.
  • Declined, mark "Resetting…" disabled for the screen reader: GPUI has no public disabled setter for a div (gpui-base's is crate-private). The label already says it is resetting.
  • Declined, an older said copy in chats.rs: it isn't this PR's.

For the owner (product decisions, unchanged)

  • Esc in the history transfer is Continue Without History at every stage, as the issue asks, so an Esc mid-transfer gives the history up. Say if it should ask first, or work only after a failure.
  • A message's hover buttons (React, Reply, More) and right-click menus are still pointer-only, so the reaction picker opens only from the pointer, though its reactions then take the keys. Reaching them needs a choice: Tab stops on every message's buttons, or moving between messages with ↑↓.

…er failed

While the transfer waits for the phone or runs, Esc does nothing, so a
stray key doesn't give the history up; after a failure Esc is Continue
Without History, as the button there.
@pitis

pitis commented Nov 29, 2026

Copy link
Copy Markdown
Owner Author

Owner's decision applied in 5bcb39c: Esc on the history transfer works only once the transfer has failed (Continue Without History, as the button there); while it waits for the phone or runs, Esc does nothing and the history is kept. Test first: view::esc_continues_without_the_history_only_once_the_transfer_failed failed on the old handler (Esc while waiting ended the transfer) and passes now. PRODUCT.md and DESIGN.md say so. make check passes on the branch merged with origin/main (f1051bd).

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.

Every control in the app can be reached from the keyboard

1 participant