Skip to content

feat(preview): sort directories before files in directory preview#3343

Open
finedesignz wants to merge 1 commit into
wavetermdev:mainfrom
finedesignz:feat/directory-preview-folders-first
Open

feat(preview): sort directories before files in directory preview#3343
finedesignz wants to merge 1 commit into
wavetermdev:mainfrom
finedesignz:feat/directory-preview-folders-first

Conversation

@finedesignz
Copy link
Copy Markdown

Summary

Groups directories ahead of files in the directory preview table — the familiar Windows Explorer / VSCode ordering — while preserving the active column sort (Name or Last Modified, asc/desc) within each group. The .. entry stays pinned at the top.

Closes #2541

What changed

frontend/app/view/preview/preview-directory.tsx — after the sorted row model is computed, the non-.. rows are partitioned into directories and files via the existing row.original.isdir field, then concatenated (dirs first). This keeps TanStack Table's column sort intact inside each group and is direction-independent (folders stay first whether sorting name asc/desc or by modtime), matching native file-manager behavior.

const otherRows = [
    ...nonDotDotRows.filter((row) => row.original.isdir),
    ...nonDotDotRows.filter((row) => !row.original.isdir),
];

Notes

  • Implemented as default behavior (per the request in tsunami -- handle onSubmit and onChange for file inputs #2541). Happy to gate it behind a new preview:directoriesfirst boolean setting alongside the existing preview:defaultsort if maintainers prefer opt-in/out — say the word and I'll add the Go const, schema entry, docs row, and context-menu toggle.
  • Surgical change; FileInfo.isdir and row.original (typed FileInfo) are already used throughout this file, so it's type-safe. Did not run a full task build locally; CI will validate.

Test plan

  • Open a directory preview block; confirm folders are grouped above files.
  • Toggle Name asc/desc and Last Modified — folders remain grouped first, sort applies within each group.
  • Confirm .. is still the first row.

Group directories ahead of files in the directory preview table
(Windows Explorer / VSCode style), while preserving the active column
sort within each group. The ".." entry remains pinned to the top.

Closes wavetermdev#2541
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 30, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 30, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bb894780-2d14-4fb0-aef6-87c36bf171d2

📥 Commits

Reviewing files that changed from the base of the PR and between a5ac096 and 87acab5.

📒 Files selected for processing (1)
  • frontend/app/view/preview/preview-directory.tsx

Walkthrough

This PR modifies the preview directory component to apply Windows Explorer-style row ordering in the file browser. The TableBody component now filters out the parent directory marker ("..") and reorders the remaining rows so that all directories appear before files, while maintaining the existing table sort order within each group.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR closes #2541, but that issue concerns file input form handling (VDomFormData, VDomFileData), which is unrelated to directory sorting. Verify that #2541 is the correct issue to close. If #2541 is unrelated, link the appropriate issue or remove the 'Closes' reference.
Out of Scope Changes check ⚠️ Warning The changeset implements directory-before-files sorting, which is out of scope for issue #2541 that addresses file input form handling. Link the correct issue that requests directory sorting, or create a new issue to track this feature if one does not exist.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: sorting directories before files in the directory preview component.
Description check ✅ Passed The description is directly related to the changeset, explaining the sorting behavior, implementation details, and test plan.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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

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