Add extension filter and sort controls to status panel #63

Merged
Christoph merged 1 commit from filter into main 2026-10-02 20:15:18 +00:00
Owner

This change adds a filter-and-sort UI for the Status panel and the underlying filtering/sorting logic.

Summary

  • Adds a filter button to the status toolbar that opens a floating dialog to: choose a sort key (default, name, ext), pick sort direction (ascending/descending), toggle visibility per file extension, and reset filters.
  • Implements file-extension extraction, comparison, and integration with the existing status tree builder so visible files and tree ordering respect the selected filters and sort settings.
  • Shows a helpful "no files match the filter" message when lanes are non-empty but all files are filtered out.
  • Adds CSS styles for the filter button, menu, extension list and segment buttons, and updates i18n messages for the new UI.

Important implementation notes (from the diff)

  • UI: StatusPanel.svelte

    • New state variables: hiddenExtensions, sortKey, sortDescending, and menu positioning (filterMenuOpen, filterMenuX, filterMenuY).
    • New functions: fileExtension, compareFiles, applyFilterAndSort, toggleExtensionVisible, clearStatusFilters, and toggleFilterMenu.
    • The status tree builder and sorter now accept a sort key and direction: buildStatusTree(..., key, direction) and sortStatusTree(..., key, direction).
    • Derived values: availableExtensions, filtersActive, unstagedFiles, stagedFiles, treeDirection, and unstagedTree/stagedTree are computed to incorporate filtering and sorting.
    • The filter menu markup is conditionally rendered when filterMenuOpen and includes extension counts, checkboxes, sort controls and a reset button.
    • Escape key handling closes the filter menu as well as the context menu; opening the filter menu closes the status context menu.
  • Styling: src/app.css adds styles for .status-filter-btn, .status-filter-menu, .status-seg, .status-ext-list, .status-ext-row, .status-ext-box, and related classes to match the new menu UI.

  • i18n: src/lib/messages.ts adds message keys used by the filter UI (labels, hints, and reset text).

Behavioral details you can verify from the diff

  • Files with no extension are represented with an internal NO_EXTENSION key and are sorted to appear before extensions when sorting by extension ascending.
  • Hiding an extension updates the visible lists and trees by filtering with applyFilterAndSort.
  • Sorting by ext groups by extension then falls back to filename ordering; sorting by name or default preserves name-based ordering.
  • The filter menu positions itself near the filter button and is removed/closed when the context menu closes or on Escape.

Testing

No test execution results were provided.

Recommended manual checks for the reviewer

  1. Open the Status panel and click the funnel button: the filter dialog should appear near the button.
  2. Verify the extension list shows extension names with counts; toggling an extension hides/shows files with that extension in both staged and unstaged lanes.
  3. Change sort key to Extension and toggle ascending/descending — the tree/list order should reflect extension grouping and direction.
  4. Use the reset button to clear hidden extensions and restore default sorting.
  5. Verify when the repository has files but all are filtered out the lanes display the status.filterNoMatch message rather than the empty-lane message.
  6. Press Escape to confirm the filter menu closes (and that context-menu interactions still work as before).
  7. Resize the window and ensure the filter menu remains within viewport bounds.

Notes / Risks

  • This is UI and client-side sorting/filtering only; no server-side or API changes were made.
  • The change adds new message keys; confirm translations or fallback text as needed.
  • No automated test run results are included in this change; consider adding focused unit or UI tests for fileExtension, compareFiles, and applyFilterAndSort if desired.

No reviewer action beyond code review is required unless translations need updating or additional tests should be added.

This change adds a filter-and-sort UI for the Status panel and the underlying filtering/sorting logic. Summary - Adds a filter button to the status toolbar that opens a floating dialog to: choose a sort key (`default`, `name`, `ext`), pick sort direction (ascending/descending), toggle visibility per file extension, and reset filters. - Implements file-extension extraction, comparison, and integration with the existing status tree builder so visible files and tree ordering respect the selected filters and sort settings. - Shows a helpful "no files match the filter" message when lanes are non-empty but all files are filtered out. - Adds CSS styles for the filter button, menu, extension list and segment buttons, and updates i18n messages for the new UI. Important implementation notes (from the diff) - UI: `StatusPanel.svelte` - New state variables: `hiddenExtensions`, `sortKey`, `sortDescending`, and menu positioning (`filterMenuOpen`, `filterMenuX`, `filterMenuY`). - New functions: `fileExtension`, `compareFiles`, `applyFilterAndSort`, `toggleExtensionVisible`, `clearStatusFilters`, and `toggleFilterMenu`. - The status tree builder and sorter now accept a sort key and direction: `buildStatusTree(..., key, direction)` and `sortStatusTree(..., key, direction)`. - Derived values: `availableExtensions`, `filtersActive`, `unstagedFiles`, `stagedFiles`, `treeDirection`, and `unstagedTree`/`stagedTree` are computed to incorporate filtering and sorting. - The filter menu markup is conditionally rendered when `filterMenuOpen` and includes extension counts, checkboxes, sort controls and a reset button. - Escape key handling closes the filter menu as well as the context menu; opening the filter menu closes the status context menu. - Styling: `src/app.css` adds styles for `.status-filter-btn`, `.status-filter-menu`, `.status-seg`, `.status-ext-list`, `.status-ext-row`, `.status-ext-box`, and related classes to match the new menu UI. - i18n: `src/lib/messages.ts` adds message keys used by the filter UI (labels, hints, and reset text). Behavioral details you can verify from the diff - Files with no extension are represented with an internal `NO_EXTENSION` key and are sorted to appear before extensions when sorting by extension ascending. - Hiding an extension updates the visible lists and trees by filtering with `applyFilterAndSort`. - Sorting by `ext` groups by extension then falls back to filename ordering; sorting by `name` or `default` preserves name-based ordering. - The filter menu positions itself near the filter button and is removed/closed when the context menu closes or on Escape. Testing No test execution results were provided. Recommended manual checks for the reviewer 1. Open the Status panel and click the funnel button: the filter dialog should appear near the button. 2. Verify the extension list shows extension names with counts; toggling an extension hides/shows files with that extension in both staged and unstaged lanes. 3. Change sort key to `Extension` and toggle ascending/descending — the tree/list order should reflect extension grouping and direction. 4. Use the reset button to clear hidden extensions and restore default sorting. 5. Verify when the repository has files but all are filtered out the lanes display the `status.filterNoMatch` message rather than the empty-lane message. 6. Press Escape to confirm the filter menu closes (and that context-menu interactions still work as before). 7. Resize the window and ensure the filter menu remains within viewport bounds. Notes / Risks - This is UI and client-side sorting/filtering only; no server-side or API changes were made. - The change adds new message keys; confirm translations or fallback text as needed. - No automated test run results are included in this change; consider adding focused unit or UI tests for `fileExtension`, `compareFiles`, and `applyFilterAndSort` if desired. No reviewer action beyond code review is required unless translations need updating or additional tests should be added.
Add an interactive filter/sort menu to the status panel that lets users:
- hide files by extension and see counts per extension (toggleable list)
- choose sorting by default/name/extension and ascending/descending
- reset filters and sorting

Implementation details:
- New UI: funnel button with active dot, popup menu, reset button and related accessibility attributes; new empty-state text when filters hide all files.
- Sorting/filtering logic: add fileExtension, compareFiles, applyFilterAndSort; sortStatusTree and buildStatusTree signatures updated to accept sort key/direction; changedFiles derivations now produce availableExtensions, filtersActive, filtered/staged lists and trees.
- Small behavior tweaks: Escape closes the filter menu; context menu closing also closes filter menu.
- Added CSS for the menu and controls and new i18n message keys for labels and hints.
Sign in to join this conversation.
No description provided.