Skip to content

fix: Sort archive contents in Quick Look - #374

Open
knu wants to merge 3 commits into
sarensw:mainfrom
knu:fix/quicklook-sorting
Open

knu wants to merge 3 commits into
sarensw:mainfrom
knu:fix/quicklook-sorting

Conversation

@knu

@knu knu commented Oct 25, 2026 •

Copy link
Copy Markdown

What & why

Quick Look displays entries in archive order, and clicking a column header does not sort them. This shares the app's sorting rules with the preview, defaults to folders first and names ascending, and enables sorting by name, packed size, size, and modification date. The header accepts the first mouse event so clicks also work in Finder's non-key Quick Look panel. Reordering preserves expanded folders and selected items, including when browsing nested archives.

AI disclosure: Codex is the primary author of this change. I manually checked the shared Quick Look harness and confirmed that the behavior looks correct.

How it was verified

I tested the Debug app's Quick Look harness alongside the installed release. I also ran automated mouse-event checks in Finder's Quick Look panel with the existing defaultArchive.zip fixture. These cover initial sorting, both directions of all four headers, and preservation of expansion and selection. I selected the Debug extension for this check and restored both extension elections to their original state afterward.

Before and after snapshots below render the actual pre-fix and post-fix AppKit outline controllers with the existing defaultArchive.zip fixture. The folder is expanded in both views. Before the fix, a file precedes the folder and README.md precedes NestedArchive.zip; afterward, folders come first and names sort naturally within each folder.

Before After
Before sorting fix After sorting fix

The actual Finder-hosted preview after clicking the Name header, with README.md still selected and its folder still expanded:

Finder Quick Look after clicking the Name header

AppKit regression tests cover the initial order, click acceptance in a non-key panel, both directions of all four columns, preservation of expansion and selection, and first expansion of a nested archive. Existing archive-state and search tests also pass.

swift test --package-path Modules --filter 'ArchiveState|ArchivePreviewSorting|Search'
Test run with 96 tests in 47 suites passed.

swift test --package-path Modules --filter ArchivePreviewSortingTests
Test run with 4 tests in 2 suites passed.

xcodebuild -quiet -scheme MacPacker -configuration Debug -derivedDataPath .tmp/DerivedData build
Exit status: 0

scripts/check-architectures.sh --arm64-only .tmp/DerivedData/Build/Products/Debug/MacPacker.app
17 Mach-O files checked, every one has an arm64 slice.

Checklist

  • Verification evidence is included above
  • Add the changelog item below to Config/products/macpacker.json when a new version block is available
  • AI involvement disclosed, if AI was the primary author

Changelog

Add a new version block for this item. The latest block is already tagged.

{
  "type": "fix",
  "title": {
    "en": "Sort files in Quick Look",
    "zh-Hans": "在 Quick Look 中排序文件",
    "fr": "Trier les fichiers dans Quick Look",
    "de": "Dateien in Quick Look sortieren",
    "it": "Ordinare i file in Quick Look",
    "ja": "Quick Lookでファイルを並べ替え",
    "fa": "مرتب‌سازی فایل‌ها در Quick Look",
    "pl": "Sortowanie plików w Quick Look",
    "pt-BR": "Ordenar arquivos no Quick Look",
    "ru": "Сортировка файлов в Quick Look",
    "uk": "Сортування файлів у Quick Look",
    "es-MX": "Ordenar archivos en Quick Look",
    "ko": "Quick Look에서 파일 정렬",
    "nl": "Bestanden sorteren in Quick Look",
    "tr": "Quick Look'ta dosyaları sıralama",
    "vi": "Sắp xếp tệp trong Quick Look",
    "ar": "ترتيب الملفات في Quick Look",
    "ca": "Ordena els fitxers al Quick Look",
    "el": "Ταξινόμηση αρχείων στο Quick Look",
    "nb": "Sorter filer i Quick Look",
    "zh-TW": "在 Quick Look 中排序檔案"
  },
  "issues": [
    "374"
  ]
}

Summary by CodeRabbit

  • New Features
    • Archive previews now open sorted by name, with folders shown before files. You can sort archive contents by column and direction, including within nested archives.
  • Bug Fixes
    • Changing the sort order now preserves the current selection and expanded folders.
    • Archive column headers respond to the first click, making sorting easier to use.

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The archive preview now starts with ascending name order and sorts children by the selected column and direction. It caches sorted children, clears the cache when sorting or archive contents change, and restores selection after sort changes. Tests cover sorting, header clicks, expansion, and selection.

Changes: Archive Preview Sorting

Layer / File(s) Summary
Sort order and child lists
Modules/Sources/Core/ArchiveState.swift, Modules/Sources/ArchivePreviewUI/ArchiveViewController.swift, Modules/Tests/CoreTests/ArchivePreviewSortingTests.swift
ArchiveState now sorts items using an explicit order and direction. The preview sets ascending name order, applies column sort descriptors to child items, and uses a header that accepts the first mouse event. Tests check initial ordering and header behavior.
Outline refresh and selection
Modules/Sources/ArchivePreviewUI/ArchiveViewController.swift, Modules/Tests/CoreTests/ArchivePreviewSortingTests.swift
The controller caches sorted children and clears the cache when state, sorting, or nested archive contents change. It restores selection after sort changes. Tests check sorting in both directions, expansion, selection, and nested archive ordering.

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

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant NSOutlineView
  participant ArchiveViewController
  participant ArchiveState
  User->>NSOutlineView: Choose a column sort descriptor
  NSOutlineView->>ArchiveViewController: Report the sort change
  ArchiveViewController->>ArchiveState: Sort items by order and direction
  ArchiveState-->>ArchiveViewController: Return sorted items
  ArchiveViewController-->>NSOutlineView: Reload sorted child rows
Loading

Possibly related issues

  • Issue 423: Reports that Quick Look archive column headers do not sort contents. This change adds sorting from the preview’s column headers.

Possibly related PRs

  • sarensw/MacPacker#440: Introduces a shared archive outline controller and changes the same Quick Look sorting behavior.
  • sarensw/MacPacker#435: Aligns Quick Look sorting and visible columns with the archive window, overlapping with this change’s default and column sorting.
  • sarensw/MacPacker#213: Adds nested archive expansion in Quick Look, which this change covers when testing sorting on first expansion.

Suggested reviewers: sarensw

Merge Risk: Minimal · up to 7bc8a · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix: Sort archive contents in Quick Look" matches the main change. The PR adds sorting of archive previews in Quick Look, using the app's sorting rules, folders-first ordering, and preserva…
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.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "fix: Sort archive contents in Quick Look" matches the main change. The PR adds sorting of archive previews in Quick Look, using the app's sorting rules, folders-first ordering, and preservation of expansion and selection. The title is short, specific, and states the primary change. The 'fix:' prefix is a conventional-commit label and does not reduce clarity.

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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 850558cb-29d7-48eb-bcbc-21bf6c05fd89
Commits

Reviewing files that changed from the base of the PR and between 22f04ea and 7bc8ac3.

Files ignored due to path filters: 3

  • assets/screenshots/quicklook-sort-after.png is excluded by !**/*.png
  • assets/screenshots/quicklook-sort-before.png is excluded by !**/*.png
  • assets/screenshots/quicklook-sort-finder.png is excluded by !**/*.png
Files selected for processing: 2

  • Modules/Sources/ArchivePreviewUI/ArchiveViewController.swift
  • Modules/Sources/Core/ArchiveState.swift

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

knu added 3 commits November 26, 2026 23:23
Quick Look displayed archive entries in storage order and had no column
sort actions.  Share the app's ordering rules, start with folders first
and names ascending, and sort each level when a column header changes.
Keep expanded folders and selected entries when reordering the outline.
Finder keeps key focus while Quick Look hosts the preview, so a standard
table header ignores clicks in the non-key panel.  Accept the first mouse
event, as the preview buttons already do, so column sorting works there.

Include the regression test and verification images from the shared UI
and the actual Finder Quick Look panel.
@knu
knu force-pushed the fix/quicklook-sorting branch from 22f04ea to 7bc8ac3 Compare November 26, 2026 14:26
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.

1 participant