Skip to content

LR-BEHAV-SIDEBAR-KEYS: the keys' model for the left sidebar: the mode, its cursor and its ring (no caller yet) - #3179

Open
nledford wants to merge 2 commits into
storytold:mainfrom
nledford:sidebar-keys-model
Open

nledford wants to merge 2 commits into
storytold:mainfrom
nledford:sidebar-keys-model

Conversation

@nledford

@nledford nledford commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Off main.

Problem

Nothing in the left sidebar can be reached or told apart from the keys: no row takes focus, and the only key the panel reads is Esc during a drag. Keyboard in Sidebar (a mode that gives the keys to the sidebar) needs a core that knows which row the keys are on, what each key asks of it and when the mode ends, before any row is wired to it.

Change

The tested core of Keyboard in Sidebar, crates/ui-egui/src/panels/side_keys.rs, with no caller yet: the sidebar's wiring is the next PR (the module's doc names it).

  • The mode and its cursor: the cursor starts on the row of what is shown and is the sidebar's own (not egui's focus, so Tab order and the accessibility audit are untouched). ↑ ↓ Home End Page Up Page Down move over the rows drawn last frame, including rows that are out of sight; → unfolds or steps in, ← folds or steps out to the parent then the section's header; Enter and Space ask a row to be chosen as a click chooses it; typing goes to the next row whose name starts so, the same letter again to the one after; F2 opens the rename dialog of a row that has a name of its own.
  • Who owns the keys: while the mode is on, keys without Cmd, Ctrl or Alt are the sidebar's (of the Shift ones only Shift+Tab and typed capitals). The mode ends on Esc and Tab (also with Shift; Tab hands egui's focus to nothing, so the keys go back to the photos), on a click outside the sidebar, when a field takes the keys, and when the sidebar is no longer drawn. A dialog, a menu and a drag keep the keys meanwhile.
  • A smart album drawn as "⚠ name" is found by its name; a Local folder listed twice is two rows.
  • state.rs: five small fields for the mode, the cursor and its grace frames; left/sections.rs and left.rs make SECTION_HEADER reachable from panels; two new strings (the hint toast and "This row has no name to change") in all 17 catalogs.

Not in this PR: the sidebar's rows reporting to the core, View ▸ Keyboard in Sidebar, the shortcut, and the native macOS menu giving up its accelerators (the next PR). Choosing several rows with Shift+arrows is not planned here (it needs the multi-select UI).

How it was checked

  • cargo xtask ci passed at 493fc74fb5 in the hosted CI gate (all 8 steps). (hosted CI gate passed at 493fc74)
  • Checked locally at 493fc74fb5 (macOS, on main 472560b309): cargo check --workspace --all-targets, cargo clippy with -D warnings and cargo fmt, cargo xtask parity and cargo test -p lightcraft-ui-egui -- side_keys (28 passed); the full cargo xtask ci is the hosted CI gate's.
  • A test that fails without this change: the 28 tests in tests/side_keys.rs draw a stand-in sidebar the way the real one will call the core (begin, note_row / note_open / note_unseen / chosen / ring per row) and press keys frame by frame; they cover navigation, choosing, fold and unfold, type-ahead, F2, every way the mode ends, stale rows, the keys when a dialog or a drag is open, Local twins and the warning mark. Each fix has a test seen failing without it: a_key_in_the_second_frame_acts_from_the_shown_row, the_frame_the_mode_comes_on_in_takes_no_key, left_and_right_fold_unfold_and_step_in_and_out and a_sidebar_hidden_meanwhile_starts_afresh fail on Sidebar: the left sidebar from the keyboard #1245's version of the core and pass here; esc_and_tab_give_the_keys_back, tab_with_no_rows_gives_the_keys_back_without_moving_the_focus, typing_finds_a_smart_album_flagged_with_a_warning_by_its_name (which also types a space inside a flagged name) and a_local_folder_listed_twice_out_of_sight_is_two_rows fail on this core before its last fixes (Tab leaving egui's focus on a control, the warning mark, Local twins out of sight).
  • Not a visible change yet: nothing calls the core, so the app was not run.
  • Review: fresh reviewer at 493fc74 (delta of 2057121: the rebase onto main; it found one P2, F2 offering Rename on a built-in Local place, which main's menu no longer offers; fixed in 493fc74 with a test and read by a second reviewer: no finding)

Screenshots

Not a visible change; the next PR has them.

Merging

Checklist

  • No new panic path in non-test code: no unwrap / expect / panic!, no indexing or unchecked arithmetic on a number from a file, a person or an agent (get, checked_mul, NaN and char boundaries handled)
  • New text on screen goes through tr() and has its key in crates/ui-egui/locales/*.json; a new shortcut is free in docs/library-shortcuts.md
  • The feature's rows in docs/parity-checklist.md and its entry in docs/gaps.md are updated, honestly (🟡 when it is partial), in the same commit
  • New code has a caller: no command, module or setting that nothing reaches yet (the core is tested through a stand-in sidebar; the next PR calls it from the real sidebar)
  • Every new image, icon or other asset has its entry in assets/ATTRIBUTION.md; no font or media files added
  • Ready to merge (otherwise open it as a draft)

Summary by CodeRabbit

  • New Features
    • Navigate sidebar rows with the keyboard, move between parents and children, jump through the list, select items, and expand or collapse sections.
    • Find rows by typing part of their names, open supported rename dialogs, and follow a visible cursor showing the current selection.
  • Localization
    • Added translations in multiple languages for sidebar keyboard guidance, scan-limit notices, and messages shown when a row has no editable name.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The pull request adds a crate-visible sidebar keyboard-navigation module with transient UI state, key handling, row tracking, and tests. It also adds or updates translations for sidebar keyboard guidance and related messages across locale files.

Changes: Sidebar keyboard navigation

Layer / File(s) Summary
Navigation state and module surface
crates/ui-egui/src/state.rs, crates/ui-egui/src/panels.rs, crates/ui-egui/src/panels/left.rs, crates/ui-egui/src/panels/left/sections.rs, crates/ui-egui/src/panels/left/local.rs
Adds transient navigation fields to UiState, declares the side_keys module, and exposes sidebar symbols within the crate.
Key ownership and navigation
crates/ui-egui/src/panels/side_keys.rs
Adds key-ownership checks, keyboard navigation, type-ahead matching, focus handling, and F2 rename dispatch for supported row types.
Row tracking and cursor updates
crates/ui-egui/src/panels/side_keys.rs
Records visible and unseen rows, applies pending choice and fold actions, updates the cursor, scrolls it into view, and draws its ring.
Navigation tests and locale strings
crates/ui-egui/src/tests.rs, crates/ui-egui/src/tests/side_keys.rs, crates/ui-egui/locales/*.json
Adds test coverage for navigation, key ownership, rename handling, and cursor behavior. Locale files add or update translations for sidebar guidance and related messages.

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Other

Possibly related issues

Suggested reviewers: aiongg, skylartaylor

Merge Risk: Minimal · up to 493fc

This change adds sidebar keyboard-navigation code that nothing calls yet, so users should see no change. It is low risk to merge now. The real sidebar wiring is planned for a follow-up PR and should be reviewed there.

Security architecture risk: Minimal · up to 86c6e

The keyboard-navigation model is not yet connected to the application. The reviewed changes do not currently enable additional row actions, intercept keyboard input, or persist navigation state.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The inspected navigation change has no active production input-to-action path at this head. Its current reach is limited to compiled model code, transient state declarations, and the test harness; a later integration change would require reassessing effective action reachability.

Trust Boundaries and Controls

  • observed — Input ownership is an explicit eligibility decision rather than an unconditional key handler. The stand-in harness exercises interruption by dialogs, menus, drags, focused fields, dismissal, and sidebar disappearance; this supports the model contract but does not establish future production integration behavior.

Hardening Proposals

  • proposed — When production wiring is added, explicitly assign responsibility for cursor revalidation on library changes, type-ahead reset or retention on re-entry, and frame ordering of initialization and row hooks. The current row-reset function does not clear the application cursor, and type-ahead can survive short mode interruptions; these are future integration checks, not active security findings.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title describes the sidebar keyboard navigation core and states that it has no caller yet.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • 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

Commits

Reviewing files that changed from the base of the PR and between 2057121 and 493fc74.

Files selected for processing: 23

  • crates/ui-egui/locales/cs.json
  • crates/ui-egui/locales/de.json
  • crates/ui-egui/locales/es.json
  • crates/ui-egui/locales/fi.json
  • crates/ui-egui/locales/fr.json
  • crates/ui-egui/locales/id.json
  • crates/ui-egui/locales/it.json
  • crates/ui-egui/locales/ja.json
  • crates/ui-egui/locales/ka.json
  • crates/ui-egui/locales/pl.json
  • crates/ui-egui/locales/pt-br.json
  • crates/ui-egui/locales/ru.json
  • crates/ui-egui/locales/sv.json
  • crates/ui-egui/locales/uk.json
  • crates/ui-egui/locales/vi.json
  • crates/ui-egui/locales/zh-hans.json
  • crates/ui-egui/locales/zh-hant.json
  • crates/ui-egui/src/panels/left.rs
  • crates/ui-egui/src/panels/left/local.rs
  • crates/ui-egui/src/panels/side_keys.rs
  • crates/ui-egui/src/state.rs
  • crates/ui-egui/src/tests.rs
  • crates/ui-egui/src/tests/side_keys.rs
Files skipped from review as they are similar to previous changes: 17

  • crates/ui-egui/locales/id.json
  • crates/ui-egui/locales/pt-br.json
  • crates/ui-egui/locales/uk.json
  • crates/ui-egui/locales/sv.json
  • crates/ui-egui/locales/vi.json
  • crates/ui-egui/locales/fi.json
  • crates/ui-egui/locales/ja.json
  • crates/ui-egui/locales/it.json
  • crates/ui-egui/locales/pl.json
  • crates/ui-egui/locales/es.json
  • crates/ui-egui/locales/cs.json
  • crates/ui-egui/locales/de.json
  • crates/ui-egui/locales/fr.json
  • crates/ui-egui/locales/ka.json
  • crates/ui-egui/locales/zh-hans.json
  • crates/ui-egui/locales/ru.json
  • crates/ui-egui/locales/zh-hant.json

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

…, its cursor and its ring

The tested core of Keyboard in Sidebar, with no caller yet: which row the keys are on, what each key asks of it, and how the mode ends. Its tests draw a stand-in sidebar the way the real one will call it.

Four things the tests found: a header that a key folded or unfolded is noted as it is now, so a second key in the next frame does not undo the first; the mode's "just came on" memory is reset when the mode goes off, so the frame it comes on in takes no key on every entry (before, only on the first); the starting cursor is placed before the keys are read, so a key in the first frame that has rows acts from the shown row instead of being dropped; and a sidebar that was not drawn for a while forgets its old rows, so the mode asked for again starts from the row shown now.

@eliets2 eliets2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First-pass review notes (automated; combined from specialist angles: user experience). Please treat as suggestions and verify before acting.

Summary: This pull request adds the tested core of Keyboard in Sidebar in crates/ui-egui/src/panels/side_keys.rs, with no caller yet. It defines a sidebar-owned cursor and ring, navigation and choosing keys, type-ahead, F2 rename, key ownership while the mode is on, and the conditions that end the mode, plus supporting state, visibility, strings, and tests.

Logical units:

  • Mode, cursor, navigation, choosing, type-ahead, and F2 in side_keys.rs
  • Key ownership and mode-exit conditions, including dialogs, menus, and drags keeping the keys
  • Five state fields in state.rs and SECTION_HEADER visibility from panels
  • Two new strings in all 17 catalogs
  • 28 tests in tests/side_keys.rs

Findings:

  • [user experience] crates/ui-egui/src/panels/side_keys.rs, begin() / keys() / no_focus_move(): Tab and Esc end the mode by surrendering egui focus to nothing, so keyboard focus is lost instead of moving to the photos grid. Fix: move focus to the photos view or the last photo control on exit.
  • [user experience] crates/ui-egui/src/panels/side_keys.rs, cursor in app.ui.sidebar_cursor: the cursor is not egui focus and is not exposed to assistive technology, so a screen-reader user gets no row name, position, or expanded state when the cursor moves. Fix: announce the focused row, e.g. via focus or an aria-live update.
  • [user experience] crates/ui-egui/src/panels/side_keys.rs, keys(), PAGE = 10: Page Up / Page Down always move 10 rows regardless of how many rows are visible, which can overshoot the viewport and disorient the user. Fix: move by the number of rows that fit in the panel height.
  • [user experience] crates/ui-egui/src/panels/side_keys.rs, begin(), hint toast: the only explanation of the mode is a toast shown once per session for 6 — the note is truncated in the source and states no concrete fix.

Overlaps: None listed.

Verdict: needs changes. The 3 most important points are: focus is lost to nothing on Tab/Esc exit instead of moving to the photos grid; the cursor is not exposed to assistive technology, so row name, position, and expanded state are not announced; and Page Up / Page Down move a fixed 10 rows regardless of visible rows, overshooting the viewport.

@nledford

nledford commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

@eliets2 thanks for the first-pass notes. I checked each point against the current head and changed nothing in this PR:

  • Tab and Esc leave nothing focused: that is the intended hand-back. The photos have no egui focus of their own; with nothing focused, the app's photo shortcuts (P, the arrows, the ratings) act on the grid, which is what "the keys go back to the photos" means in side_keys.rs (begin, no_focus_move). Giving the grid a focus ring and moving focus onto it would be a separate keyboard-focus feature, not part of this model.
  • Screen readers and the cursor: right, the cursor is not egui focus. This PR has no caller yet (it is the tested core), so nothing is drawn or announced by it. The rows that LR-BEHAV-SIDEBAR-KEYS: the left sidebar from the keyboard (stacked on #3179) #3180 wires up report their role, name and selected state through widget_info and the ring is a registered widget, but announcing the row the cursor moves to is not done there either. I'll treat that as an open accessibility question for the wiring part rather than something this PR can fix.
  • Page Up / Page Down move 10 rows: correct, PAGE is a fixed count, and it is what the module documents. Paging by the rows that fit would need each row's height and the panel's, which only the drawing part has, so it belongs with LR-BEHAV-SIDEBAR-KEYS: the left sidebar from the keyboard (stacked on #3179) #3180 if at all.
  • The hint toast: the note was cut off, so I can't tell what change you meant. The toast only explains the mode the first time it is entered in a session; after that the ring says it.

This branch has not been deployed

No deployments
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.

2 participants