feat: collapsible, reorderable categories with draggable actions#2
Merged
Conversation
Categories view gains drag-and-drop and persistent collapse: - model: add `collapsed` to Slider/ButtonCategory (serde default), saved in the profile. Card order is the Vec order, so reordering persists. - glue: handlers for toggle-collapse, reorder-category (move card to an insertion index), and move-line (relocate an action/stream within or between categories of the same kind), each with the index-shift math. - UI: a collapse chevron per card; ⠿ grip handles on category headers and action rows drive a hand-rolled drag (Slint has no native DnD). Drop targets are hit-tested from the global pointer vs each element's absolute-position, with an accent drop-line indicator and a dimmed source. Geometry reads are ternary-guarded so absolute-position is only touched during an active drag — reading it at init recurses through text layout. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds collapsible/reorderable category cards and draggable action/stream rows to the categories view. State is persisted in the profile via a new collapsed flag and the existing Vec order. Hand-rolled drag-and-drop is implemented in Slint using absolute-position hit-testing guarded by ternaries to avoid recursion during initial layout.
Changes:
- Adds
collapsed: bool(serde default) toSliderCategory/ButtonCategoryand propagates it throughCategorySummaryto the UI. - Adds three new callbacks (
toggle-category-collapse,reorder-category,move-line) with Rust handlers (reorder_by_id,move_line) that handle index-shift math and persist the preset. - Rewrites the category card layout to include a chevron toggle, drag grips for cards and rows, drop-mark indicators, and ternary-guarded
absolute-positionreads.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/model.rs | Adds collapsed field to both category structs and updates a test constructor. |
| src/main.rs | Updates seed CategorySummary literals with collapsed: false. |
| src/glue.rs | Wires three new callbacks; adds reorder_by_id and move_line helpers; includes collapsed in pushed summaries. |
| ui/app.slint | Adds collapsed to CategorySummary, introduces DropMark, drag state, grips, hit-test logic, and forwards new callbacks. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three requested enhancements to the categories view (sliders & buttons):
What changed
collapsedflag added toSliderCategory/ButtonCategory(serde default, so existing profiles load fine). Card order is theVecorder, so reordering persists automatically; assignments key off id, not position, so reordering is purely cosmetic.toggle-category-collapse,reorder-category(move a card to an insertion index), andmove-line(relocate an action/stream within or between categories), each with the index-shift math, then persist + re-push.absolute-position, shown with an accent drop-line and a dimmed source row/card.Implementation note
absolute-positionreads are ternary-guarded so they only execute during an active drag. Readingabsolute-positionin a binding evaluated at init recurses through text layout (Recursion detectedpanic) — and Slint's&&does not short-circuit the operand away, so the guard must be a? :, not&&.Known limitations (hand-rolled DnD)
Testing
cargo buildclean;cargo testpasses.🤖 Generated with Claude Code