Skip to content

Messages can be reached from the keyboard: ↑ and ↓ select one in the timeline, Return opens its menu - #294

Merged
pitis merged 3 commits into
mainfrom
feat/arrow-keys-messages
Nov 29, 2026
Merged

pitis merged 3 commits into
mainfrom
feat/arrow-keys-messages

Conversation

@pitis

@pitis pitis commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

What changed

The timeline is one Tab stop, and from it the keyboard reaches every message and its actions (the owner's decision of 2026-11-29 in the issue):

  • Tab reaches the timeline (a Tab stop of its own; the controls inside messages stay stops too), which selects the newest message (or the top one in view when scrolled back), or brings back into view the one still selected (Esc or another chat drops it). An empty chat's timeline isn't a stop.
  • ↑ / ↓ select the previous / next message and scroll it into view a row at a time: the selected row asks the list to show it (GPUI's autoscroll) when it is drawn partly below the view, together with one pixel of the next row so the next ↓ finds that one drawn too; a row above the view, or not drawn at all, goes to the top of the timeline; the newest scrolls to the end, so the timeline follows new messages again.
  • The selection is a band of the accent at 20% behind the message's line (avatar, sender's name, bubble, reactions), 2 px above and below it and 8 px past its sides, 8 corners. It shows only while the timeline (or the menu opened from it) has the keys, and the row is the timeline's active descendant, aria_selected, so a screen reader reads its label ("who: what. when") as the current item. The timeline itself is a List labelled "Messages".
  • Return, and off macOS the menu key or ⇧F10, open the selected message's menu, the same build_menu as its right-click and … menus (React ▸, Reply, Edit, Copy, Retry, Delete for Everyone…), drawn 4 under the bubble from its outer edge and kept in the window; a selection scrolled out of view comes back first. Closed, it gives the keys back to the timeline, unless the item took them (Reply and Edit go to the composer); it also closes as its keys go elsewhere (Tab, a shortcut, its row scrolled away).
  • Esc clears the selection and gives the keys to the composer, where ↑ in the empty field still edits our last message; in a chat without a composer (a request) the keys stay. ⌥↑ / ⌥↓ still switch chats, and a control inside a message (a reaction pill) keeps its own Return and ↑.
  • A click in the timeline still leaves the keys where they were (the composer keeps them), as on a pressable.
  • --snapshot gains selected (Ana's long message selected) and selected-menu (its menu open).
  • PRODUCT.md (accessibility) and DESIGN.md (timeline, accent, keyboard paths) say so.

Code: app/actions/mod.rs (selection state, timeline_key, step_selection, open_message_menu), app/actions/view.rs (with_keys for the timeline, the band, the reveal, the menu under the bubble), app/view.rs (the row marks itself selected).

Why

#284 left a message's hover buttons and right-click menu pointer-only (GPUI gives no Tab stops to hidden elements). The owner chose ↑↓ in the timeline over a Tab stop per button.

Choices to look at

  • Colour: the band is the accent at 20% (as the picked mention's 30%), not the selection grey: in dark the selection grey (#3A3A3C) is the incoming bubble's (#3B3B3D), so a grey band would swallow the bubble. Say if it should be the grey anyway.
  • // shortcut: a selected message out of view below goes to the top of the timeline, not the bottom (MessageScrollerState scrolls only to a row's top, and only a drawn row can ask the list for more). This happens only when the timeline was scrolled away from the selection with the pointer; ↑↓ from a selection in view always scroll a row at a time.
  • Reply and Edit show in the menu in a chat without a composer (a request), as in its right-click menu already; picking them gives the keys to a composer that isn't there. Say if they should be hidden there.
  • Not checked live: a screen reader reading the selected message (GPUI's test window builds no accessibility tree; the row is the focused timeline's active descendant by construction).
  • Not done, not asked: the selected message's hover buttons don't show (its menu has their actions); a file's own Save As… stays pointer-only (its Open is the file's pressable).

How it was tested

Window tests in actions::window_tests, each written first and failing on the base (Tab never reaches messages), or for the review's fixes on the code before them; each fix was also taken out again to see its test fail:

  • tab_reaches_the_timeline_where_up_and_down_move_the_selection: Tab selects the newest (drawn selected), ↑↑ / ↓↓↓ move and stop at the newest; a click in the timeline leaves the composer the keys and hides the selection; ⌥↓ from the timeline opens Ana's chat.
  • the_selected_message_is_brought_into_view: 71 messages; 40 × ↑ then 40 × ↓, the selected row inside the timeline after each, never jumping to the top on the way down (fails without the reveal, without the autoscroll, and without the extra pixel).
  • return_opens_the_selected_messages_actions_under_it_and_they_work: the newest's menu stays in the window and Esc closes it alone (keys and selection stay in the timeline); on Ana's message the menu is drawn under her bubble on her side; Copy copies and gives the keys back to the timeline; Reply replies ("Replying to Ana Popescu"), the composer has the keys and the selection no longer shows.
  • the_menu_closes_when_its_keys_go_elsewhere: ⌘K with the menu open closes it.
  • a_selection_out_of_view_comes_back_for_the_keys_and_its_menu: scrolled away, Return brings the row back with its menu; Tab back brings it into view; its row scrolled away under the open menu closes the menu and keeps the keys in the timeline.
  • scrolled_back_the_timeline_takes_the_keys_on_a_message_in_view: the top one in view, not the newest.
  • return_and_up_on_a_control_in_a_message_are_the_controls: on a reaction pill, Return opens who reacted, no message menu, and ↑ leaves the selection.
  • esc_in_a_chat_without_a_composer_leaves_the_keys_in_the_timeline.
  • esc_gives_the_keys_back_to_the_composer_where_up_edits_our_last: Esc clears the selection, the composer has the keys, ↑ there edits our last message.
  • Unit actions::tests::return_opens_a_messages_menu_and_off_macos_the_menu_key_and_shift_f10_too: both systems.

make format && make check on the branch merged with origin/main (4e5b0ae): 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 (396 + 553 tests, 4 ignored as before).

Snapshots (cargo run -p hush-desktop --features snapshot -- --snapshot <dir>), looked at on 3bb6645 and again on 4e5b0ae: selected-light/selected-dark (Ana's long message on the band; in dark the grey incoming bubble stays distinct on it), selected-menu-light/selected-menu-dark (React ▸, Reply, Copy under her bubble, the band still shown), file-menu (a file's right-click menu still opens over the timeline), chat.

Closes #286

The timeline is one Tab stop. Taking the keys it selects the newest
message (or the top one in view); up and down move the selection and
scroll it into view a row at a time; Return, or off macOS the menu key or
Shift+F10, opens the message's menu under its bubble; Esc gives the keys
back to the composer, where up still edits our last message. The
selected row is the timeline's active descendant, so a screen reader
reads it, and a band of the accent shows it while the timeline has the
keys. A click in the timeline leaves the keys where they were.
…ts keys go

Return on a selected message scrolled out of view brings its row back
before opening the menu, so the menu is drawn and has the keys; the
timeline taking the keys again brings back the one still selected. The
menu opened from the keys closes when they go elsewhere (Tab, a
shortcut, its row scrolled away), handing them to the timeline if they
fell to the window. Esc in a chat without a composer leaves the keys in
the timeline. The focus listener is kept with the state it serves, and
the menu-key check takes the system so both are tested. Tests: Esc in the
menu, a control's own Return and up, the timeline scrolled back, the
menu under an incoming bubble and inside the window. Comments and
DESIGN.md say what the code draws.
@pitis

pitis commented Nov 29, 2026

Copy link
Copy Markdown
Owner Author

Review (/pr-review-toolkit:review-pr: code, tests, comments, silent failures)

No Critical findings in the code. Every Important finding is fixed in d483e5e. The gate (make format && make check) passes on that commit merged with origin/main (4e5b0ae).

Each new test was run before its fix. Each fix was then removed one at a time to check that its test fails without it (named M1 to M5 below).

Important: fixed

  1. Return on a selected message scrolled out of view lost the keys (code review and silent-failure review).
    • The menu was built and given the keys, but it is drawn inside its row, which wasn't drawn. The keys fell to the window, and nothing showed.
    • Fix: the selected row now records each frame whether it was drawn (Shown, actions/mod.rs). When it wasn't, Return first scrolls it to the top, so the next frame draws the row and its menu together.
    • Test: a_selection_out_of_view_comes_back_for_the_keys_and_its_menu, which fails without the scroll (M1).
  2. Coming back to the timeline left a kept selection out of view (code review and test review).
    • The selection is kept while the keys are elsewhere: after Reply, a click into the composer, or Tab. When the keys came back, nothing brought it back into view.
    • Fix: the timeline's focus listener also brings a kept selection back into view when its row wasn't drawn.
    • Test: the same one, which fails without the fix (M2).
  3. The menu opened from the keys stayed open after its keys went elsewhere (code review and silent-failure review).
    • Tab, a shortcut such as ⌘K or ⌘F, or its row scrolling away all left it open. Esc no longer reached it, and the band stayed.
    • Fix: it now closes when focus leaves it. Its subscription is kept with the menu and dies with it. Its React submenu doesn't count as leaving, since the submenu is inside it.
    • If its row went and the keys fell to the window, they go back to the timeline.
    • It stays open while the window is inactive, and is still open when the window comes back.
    • Tests: the_menu_closes_when_its_keys_go_elsewhere, and the last part of the out-of-view test. Both fail without the fix (M3).
    • Declined, the suggested key on the menu so it is drawn only under its own message: the menu now closes as soon as its keys go, so the selection can't move while it is open.
  4. Esc in a chat without a composer sent the keys nowhere (silent-failure review and code review).
    • Message requests, invitations, join requests and blocked chats have no composer.
    • Fix: Esc isn't taken there, so the keys and the selection stay in the timeline.
    • Test: esc_in_a_chat_without_a_composer_leaves_the_keys_in_the_timeline, which fails without the fix (M5).
  5. No test covered a control inside a message keeping its own keys (test review).
    • Test: return_and_up_on_a_control_in_a_message_are_the_controls. With a reaction pill focused, Return opens who reacted and opens no message menu, and ↑ doesn't move the selection. It fails without the timeline's is_focused guard (M4).
  6. Esc with the menu open was untested (test review).
    • The Return test now covers it: the menu closes, the keys and the selection stay in the timeline, and the composer doesn't get the keys.
  7. The menu key and ⇧F10 were only checked to be off, on macOS (test review).
    • opens_menu now takes the system, so the unit test checks both systems on any machine.
  8. "The top message in view when scrolled back" was untested (test review).
    • Test: scrolled_back_the_timeline_takes_the_keys_on_a_message_in_view.
  9. Comments and DESIGN.md said things the code doesn't do (comment review).
    • The band's doc said "as the picked mention's", which is 30%, not 20%, and "across the timeline".
    • The menu's doc said "as the … button's".
    • DESIGN.md said the band is "8 from the timeline's sides". It is drawn 8 past the message's line, which is 20 from the timeline's edges.
    • DESIGN.md and PRODUCT.md now say that the selection is kept and brought back, that it shows while the timeline or its menu has the keys, "Return (off macOS the menu key or ⇧F10 too)", "a Tab stop of its own", and Esc's behaviour in a request.
    • beside, timeline_key, step_selection (0 keeps the selection), the focus listener's reason for deferring, and the module docs are reworded.

Suggestions

  • Done:
    • The "message menu" selector is now on the drawn menu, not its placeholder.
    • The Return test now opens the menu on Ana's incoming message (under her bubble, on her side) and checks that the newest's menu stays inside the window.
    • The focus listener's Subscription is kept in Actions, so a restart no longer leaves an orphan listener.
    • The demo selection uses expect.
    • The ⌥↓ check now asserts that Ana's chat opens.
    • The Esc test now reads actions.selected directly.
  • Declined, the newest message's menu should flip above its bubble:
    • It is shifted up to stay in the window, so it can cover the bubble.
    • The right-click menu does the same at the pointer, and the … menu's popover clamps rather than flips (gpui-base's corner positioning).
    • DESIGN.md says "kept in the window".
  • Declined, Return on a selection whose message went (it expired) should act:
    • That selection behaves as none: no band is drawn, ↑↓ start again from the newest or the top one in view, and Return does nothing.
    • A message deleted for everyone keeps its row, so its selection stays.
  • Declined, a window test for the screen-reader announcement:
    • GPUI's test window builds no accessibility tree, since its a11y_init is a no-op.
    • The row is the timeline's active descendant by construction: it sits inside the timeline's List node, which holds the keys.
    • Not checked in a live app (see below).
  • Not this PR's:
    • DESIGN.md's "Rows keep 16 from the sides" leaves out the scroller's own 12.
    • Paging into older history by ↑ is untested, because window tests have no core. The selection is keyed by message, so a prepended page keeps it.

For the owner

  • The selection's colour: the accent at 20%, not the selection grey. In dark the grey (#3A3A3C) is the incoming bubble's (#3B3B3D).
  • Reply and Edit in a chat without a composer: the menu opened from the keys shows them in a request, as the right-click menu already did. Picking them gives the keys to a composer that isn't there. Should they be hidden there?
  • Not checked live: that VoiceOver (or Narrator, Orca) reads the selected message. That needs the running app linked to a phone.

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.

Messages can be reached from the keyboard with ↑ and ↓

1 participant