Skip to content

LR-BEHAV-MULTISELECT: the model for choosing several sidebar rows with Cmd/Ctrl+click and Shift+click - #2707

Closed
nledford wants to merge 0 commit into
storytold:mainfrom
nledford:sidebar-multiselect-model
Closed

nledford wants to merge 0 commit into
storytold:mainfrom
nledford:sidebar-multiselect-model

Conversation

@nledford

@nledford nledford commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Off main.

Problem

The sidebars' lists (albums, folders, keywords, dates, the Keyword List) choose one row at a time. Choosing several with Cmd/Ctrl+click and Shift+click needs one rule that every list answers the same way, and that rule is the part that is easy to get wrong: which rows a Shift+click takes when a folder is closed, where a range starts from after a menu or an agent changed what is chosen, and which rows a context menu acts on. If each list works it out for itself, they drift apart.

Change

First of the parts of #1955 (the sidebar multi-select), split out so that each can be reviewed on its own. This one is the model only, and nothing calls it yet, so nothing changes on screen. Its module doc names the feature that will use it.

  • New crates/ui-egui/src/multi_select.rs: Click::of (the keys held: plain, Cmd/Ctrl, Shift, Cmd/Ctrl+Shift), click (what a click makes of the rows chosen), targets (what a context menu acts on: every row chosen when it is opened on one of several chosen, else that row alone) and ListRows (a list's rows as drawn in the last frame, and the anchor).
  • Rows are kept in the order chosen, the last of them being the one a single-row action takes (Rename…, Edit…).
  • A range runs from the row last clicked without Shift (else the row chosen last) to the clicked row, over the rows of open levels only, so a range never takes a row inside a closed folder. Without an anchor among the rows, Shift+click chooses the row alone, like a plain click.
  • Shift+click replaces what was chosen and Cmd/Ctrl+Shift+click adds the range to it (the Finder and Explorer rule). The photo grid's Shift+click, which adds, is untouched.
  • One line in ui-egui/src/lib.rs for the module.

Not in this PR: the sidebar UI that calls it (menus, drags, Delete, Cut / Copy / Paste on several rows, in every language); the batch commands it acts through (album.delete, keyword.delete and the others taking several ids); showing several albums or folders at once (library.source {ids, paths}, #1153); Synchronize several folders at once. No parity row or What's New entry changes, since there is nothing to see yet.

How it was checked

  • cargo xtask ci: all 8 steps passed (fmt, clippy, heif, test, parity, layers, assets, wasm) on this head.
  • 8 unit tests in the module (the_keys_held_say_what_a_click_asks_for, a_plain_click_chooses_the_row_alone, cmd_click_adds_a_row_or_takes_it_away, shift_click_takes_the_rows_from_the_anchor, cmd_shift_click_adds_the_range_to_what_was_chosen, a_range_without_an_anchor_in_sight_chooses_the_row_alone, a_menu_acts_on_the_rows_chosen_only_when_opened_on_one_of_them, a_list_s_clicks_are_on_the_rows_of_the_frame_before). They cover a range up and down, a second range from the same anchor, an anchor folded away, a stale click, the anchor being the row clicked and an empty list. The module is new, so there is no earlier behavior for them to fail against.
  • Review: a fresh reviewer subagent read this head at 6ffa75d: no P1 or P2; two P3 notes on tests (a test comment that says more than its plain click asserts, and seen.clear() in begin_frame having no test of its own), left as they are.
  • Independent review of the first version: its findings (a doc that said "in sight" where scrolled-out rows must still count, the anchor described wrongly, a buffer reallocated every frame, three untested boundaries) are fixed in this commit.
  • No macOS-only path: the module has no platform code, and no hosted job beyond FreeBSD applies.

Screenshots

None: nothing on screen changes.

Merging

Checklist

  • No new UI strings
  • No panics in non-test code
  • Docs: module doc only; nothing user-visible changes
  • Ready to merge

Summary by CodeRabbit

  • New Features
    • Added multi-select behavior for lists, including single-row selection, modifier-key toggling, range selection, and adding ranges to an existing selection.
    • Range selection follows the displayed row order and keeps the clicked row as the most recently selected item.
    • Context-menu actions can apply to the full selection when the clicked row is part of a multi-row selection; otherwise, they apply to that row alone.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 6ffa75d and 2529b79.

Files selected for processing: 1
  • crates/ui-egui/src/lib.rs

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

Walkthrough

Adds a public multi_select module with modifier-based row selection, range selection, context-menu targets, and frame-based row tracking.

Changes: Sidebar row selection

Layer / File(s) Summary
Selection modes and range behavior
crates/ui-egui/src/lib.rs, crates/ui-egui/src/multi_select.rs
Exports the new module. Adds plain, toggle, range, and additive-range selection. Range selection follows drawn row order. Tests cover modifier mapping and selection behavior.
Frame tracking and context-menu targets
crates/ui-egui/src/multi_select.rs
Tracks rows across frames and selects a range anchor from the current selection. Defines context-menu target rules. Tests cover frame tracking and target selection.

Priority: Low

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

Change: Other

Suggested reviewers: echelon, aiongg

Merge Risk: Minimal · up to 2529b

The PR adds the intended reusable selection model without identified correctness or availability risks.

Architecture risk: Low · up to 2529b

The change affects 1 system.

Changed systems: crates

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — crates (service) was modified; 2 changed files map to changed impact.

Before / after behavior

  • observed — Modified behavior in crates/ui-egui/src/multi_select.rs: Adds module documentation and the Click enum, defining plain, toggle, range, and additive-range click modes.
  • observed — Modified behavior in crates/ui-egui/src/multi_select.rs: Adds Click::of, mapping Shift and command modifiers to range, additive-range, toggle, or plain selection; other modifiers alone do not change the plain-click result.
  • observed — Modified behavior in crates/ui-egui/src/multi_select.rs: Adds Chosen<K> to return selected keys in order together with an optional range anchor.
  • observed — Modified behavior in crates/ui-egui/src/multi_select.rs: Adds click, which selects only the clicked row for plain clicks; toggles it for command clicks; and, for range modes, selects rows between the anchor and clicked row in drawn order. Range mode replaces the selection, while additive range mode extends it without duplicates. If either endpoint is absent from rows, both range modes select only the clicked row and set it as anchor.
Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main change: adding a model for sidebar multi-selection with Cmd/Ctrl-click and Shift-click. It is specific and related to the changeset.
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
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

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.0)

Clippy execution timed out

Comment @coderabbitai help to get the list of available commands.

nledford added a commit to nledford/lightcraft that referenced this pull request Oct 27, 2026
nledford added a commit to nledford/lightcraft that referenced this pull request Oct 27, 2026
…lbums, folders, keywords or dates in the sidebars

The left panel's Albums, Folders, Keywords and By Date and the Keyword List call the model of storytold#2707: a click chooses a row alone, Cmd/Ctrl+click adds it or takes it away, Shift+click takes the rows between. What is chosen is what the grid shows (library.source ids/paths, library.filter keywords/dates of storytold#1153); the Keyword List's picks stay in the interface. Carries the act hunk of storytold#777 (a refused command says why), which this PR's clicks use.

Parents: storytold#1153 792ebf1 and storytold#2707 6ffa75d.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nledford added a commit to nledford/lightcraft that referenced this pull request Oct 28, 2026
nledford added a commit to nledford/lightcraft that referenced this pull request Oct 28, 2026
…lbums, folders, keywords or dates in the sidebars

The left panel's Albums, Folders, Keywords and By Date and the Keyword List call the model of storytold#2707: a click chooses a row alone, Cmd/Ctrl+click adds it or takes it away, Shift+click takes the rows between. What is chosen is what the grid shows (library.source ids/paths, library.filter keywords/dates of storytold#1153); the Keyword List's picks stay in the interface. Carries the act hunk of storytold#777 (a refused command says why), which this PR's clicks use.

Parents: storytold#1153 792ebf1 and storytold#2707 6ffa75d.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nledford
nledford force-pushed the sidebar-multiselect-model branch from 6ffa75d to 2529b79 Compare October 30, 2026 13:14
nledford added a commit to nledford/lightcraft that referenced this pull request Oct 30, 2026
nledford added a commit to nledford/lightcraft that referenced this pull request Oct 30, 2026
…lbums, folders, keywords or dates in the sidebars

The left panel's Albums, Folders, Keywords and By Date and the Keyword List call the model of storytold#2707: a click chooses a row alone, Cmd/Ctrl+click adds it or takes it away, Shift+click takes the rows between. What is chosen is what the grid shows (library.source ids/paths, library.filter keywords/dates of storytold#1153); the Keyword List's picks stay in the interface. Carries the act hunk of storytold#777 (a refused command says why), which this PR's clicks use.

Parents: storytold#1153 792ebf1 and storytold#2707 6ffa75d.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aiongg added a commit to aiongg/lightcraft that referenced this pull request Oct 31, 2026
… several sidebar rows with Cmd/Ctrl+click and Shift+click

@FredApps FredApps 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.

ReviewerA — source-read COMMENT (not an approval)

I read the head of the diff: a new multi_select module is the model for choosing several sidebar rows with Cmd/Ctrl+click and Shift+click (LR-BEHAV-MULTISELECT). The module comment states the rules: Cmd/Ctrl+click adds a row or takes it away, Shift+click takes every row from the row last clicked without Shift (else the row chosen last) to this one, the rows chosen are kept in the order chosen, and the last of them is the one an action for a single row applies to; one rule for all the sidebars' lists, so they answer alike. Putting the selection rules in a model separate from the drawing makes them unit testable, which is the right design, and the anchor rule (the row last clicked without Shift) is Lightroom's and Finder's. It is added to lib.rs as a public module, but the list says nothing uses it yet, so this is a model without callers and its value is only shown when the sidebars use it; the PR should say which follow-up wires it in. Ranges over a list that is filtered or re-sorted between clicks need the anchor to be stored as an id and not an index. I read the module comment, not the code or tests. I have not run it, and no exact-head CI result exists for this head. Nothing was run.

I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.

Status: waiting_author.

@nledford

nledford commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor Author

The multi-select stack is rebased onto current main (ebe2477) and ready as one unit; every conflict is resolved and each branch's own diff still carries only its own feature. Heads will follow in this comment's next edit.

Heads:

Checks green at each head (check, lint, the multi-select, left-panel and engine tests, rebase-check, parity). A maintainer can take the five together.

Edit: the rebuild also fixes a latent compile defect the old sidebar-cut-copy-paste head carried (album_ids called with the widened signature's arguments in the wrong order); the fix is folded into the branch.

@nledford nledford closed this Nov 2, 2026
@nledford
nledford force-pushed the sidebar-multiselect-model branch from 2529b79 to ebe2477 Compare November 2, 2026 17:15
nledford added a commit to nledford/lightcraft that referenced this pull request Nov 2, 2026
…lbums, folders, keywords or dates in the sidebars

The left panel's Albums, Folders, Keywords and By Date and the Keyword List call the model of storytold#2707: a click chooses a row alone, Cmd/Ctrl+click adds it or takes it away, Shift+click takes the rows between. What is chosen is what the grid shows (library.source ids/paths, library.filter keywords/dates of storytold#1153); the Keyword List's picks stay in the interface. Carries the act hunk of storytold#777 (a refused command says why), which this PR's clicks use.

Parents: storytold#1153 792ebf1 and storytold#2707 6ffa75d.

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

nledford commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Closing as included: the engine part of this PR is on main via fbe1225202 (Integration r3); the model code that was dropped there as dead without its callers lives on in the stack that uses it — #3106, #3107, #3108 and #2757, all rebased onto current main and ready as one unit (heads named in my comment above). This branch itself is now empty (equal to main).

@nledford

nledford commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

The 2 Nov restack closed this PR: its branch sidebar-multiselect-model was force-pushed to the main commit ebe2477108, which left it with no commit of its own. main had also dropped the model on 31 Oct (7b6e1114a0, "Integration: drop #2707 (multi-select model waits for its stack: #3106, #3107, #3108, #2757)"). The model, crates/ui-egui/src/multi_select.rs, is now part of #3106, unchanged apart from its module comment (it names its callers now), so the review of it continues there. @FredApps: anything you left on this PR about the model applies to the same file in #3106.

nledford added a commit to nledford/lightcraft that referenced this pull request Nov 6, 2026
…lbums, folders, keywords or dates in the sidebars

The left panel's Albums, Folders, Keywords and By Date and the Keyword List call the model of storytold#2707: a click chooses a row alone, Cmd/Ctrl+click adds it or takes it away, Shift+click takes the rows between. What is chosen is what the grid shows (library.source ids/paths, library.filter keywords/dates of storytold#1153); the Keyword List's picks stay in the interface. Carries the act hunk of storytold#777 (a refused command says why), which this PR's clicks use.

Parents: storytold#1153 792ebf1 and storytold#2707 6ffa75d.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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