Skip to content

Filter installed dependencies from installed list - #244

Merged
graeme merged 3 commits into
mainfrom
filter-installed-dependencies
Sep 22, 2026
Merged

graeme merged 3 commits into
mainfrom
filter-installed-dependencies

Conversation

@graeme

@graeme graeme commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

The Installed tab lists every installed package, including everything Homebrew pulled in as a dependency, so the ones you asked for are buried. This adds a "Hide dependencies" switch above the list that narrows it to packages installed on request.

Closes #232, which asks for a "Leaves" view. This filters on installedOnRequest, matching brew leaves --installed-on-request rather than plain brew leaves.

Continues #160 by @stybo, whose commit is preserved here with authorship intact. Two commits build on it:

  • Use a switch for Hide dependencies. A mini switch reads as a persistent mode rather than a one-off action, matching the tab's other always-visible control, the scope picker. Its label is localised with a translator comment.
  • Persist Hide dependencies across launches. The setting now survives relaunch, following the existing SelfUpgradePreferences pattern: an InstalledPreferences protocol in BrewRepositoryInterfaces, a UserDefaultsInstalledPreferences adapter in BrewRepositories, a stub for tests and previews, and injection from BrewApp through an environment entry. The view model exposes it as a computed property over that observable dependency, so SwiftUI tracking survives without the view model owning storage. The defaults key carries the usual UI-testing prefix, so a test run cannot write into the real preferences.

Validation

macOS 26.5 on Apple silicon, Xcode 26.5, Swift 6.3.2.

  • scripts/test: passed, 1118 tests in 135 suites, plus 30 in 4 for BrewUILint.
  • mint run swiftformat --lint . and mint run swiftlint lint --strict: clean.
  • BrewUILint over Homebrew, HomebrewUpgradeHelper and Sources: clean.
  • scripts/localize verify and scripts/localize sync --check: catalogs in sync.
  • xcodebuild -scheme Brew: builds.
  • Not run: scripts/test-ui, VoiceOver and keyboard checks.

New tests cover seeding from preferences, write-through, filtering, composition with scope and search, selection fallback and restore, and the UserDefaults adapter.

  • I followed the conventions and workflow, checked for duplicate PRs and kept this change focused.
  • I added regression coverage for bug fixes or explained why automated coverage is impractical, and reported the relevant validation above.

Screenshots

Before After
Screenshot 2026-09-23 at 12 04 09 am Screenshot 2026-09-23 at 12 03 33 am

AI assistance

  • AI was used to generate or assist with generating this PR.

Claude Opus 5 via Claude Code wrote the switch and persistence commits and this description. I chose the approach, reviewed every line and ran the checks above.

🤖 Generated with Claude Code

@graeme
graeme requested review from MikeMcQuaid and a lite review from Copilot September 22, 2026 14:02

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The UI-test helper has a critical compile issue, and the preferences test contains an unsafe force-unwrap.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity · 1 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds a persistent “Hide dependencies” switch to the Installed tab, filtering packages by installedOnRequest.

Changes:

  • Adds filtering, selection handling, and persistence.
  • Wires UserDefaults preferences through the app environment.
  • Adds localization, accessibility IDs, fixtures, and tests.
File Summary
Tests/​BrewRepositoriesTests/​UserDefaultsInstalledPreferencesTests.swift Tests preference persistence. Moderate (3 votes): avoid force-unwrapping UserDefaults(suiteName:).
Tests/​BrewFeatureInstalledTests/​SelfUpgradeCaskExclusionTests.swift Updates view-model construction.
Tests/​BrewFeatureInstalledTests/​InstalledViewModelTestsSupport.swift Adds preference injection support.
Tests/​BrewFeatureInstalledTests/​InstalledViewModelTests.swift Updates view-model initialization.
Tests/​BrewFeatureInstalledTests/​InstalledViewModelHideDependenciesTests.swift Tests filtering and selection behavior.
Tests/​BrewFeatureInstalledTests/​InstalledFeatureTestSupport.swift Adds test preference support.
Tests/​BrewAccessibilityIDTests/​AXIDTests.swift Verifies accessibility identifiers.
Sources/​BrewRepositoryInterfaces/​Protocols/​InstalledPreferences.swift Defines the preferences protocol.
Sources/​BrewRepositoryInterfaces/​Fakes/​InstalledPreferencesStubs.swift Adds test and preview stubs.
Sources/​BrewRepositories/​UserDefaultsInstalledPreferences.swift Implements UserDefaults persistence.
Sources/​BrewFeatureInstalled/​Views/​InstalledUpgradesColumns.swift Injects preferences into the feature.
Sources/​BrewFeatureInstalled/​Views/​InstalledPackagesView.swift Adds the Hide dependencies switch. Nit (2 votes): add deterministic UI coverage using a dependency fixture.
Sources/​BrewFeatureInstalled/​ViewModels/​InstalledViewModel.swift Applies filtering and selection fallback.
Sources/​BrewFeatureInstalled/​Resources/​Localizable.xcstrings Adds localized switch text.
Sources/​BrewCoreTestSupport/​BrewPackageFixtures.swift Supports dependency-status fixtures.
Sources/​BrewAppEnvironment/​RepositoryEnvironment.swift Adds the preferences environment entry.
Sources/​BrewAccessibilityID/​AXID.swift Adds the switch accessibility identifier.
Homebrew/​BrewApp.swift Wires production preferences and test prefixes.
BrewUITests/​Screens/​InstalledScreen.swift Adds UI-test switch helpers. Critical (1 vote): BrewUIElement does not define tap, so this helper will not compile.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread BrewUITests/Screens/InstalledScreen.swift Outdated
Comment thread Sources/BrewFeatureInstalled/Views/InstalledPackagesView.swift
stybo and others added 3 commits September 23, 2026 00:11
Replace the checkbox with a mini switch and rename the accessibility
case to match; the wire string is unchanged.

Also collapse AXIDTests' static-identifier check into a pairs table
to bring it back under SwiftLint's function body limit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Add an InstalledPreferences protocol (BrewRepositoryInterfaces), a
UserDefaults adapter (BrewRepositories) and an in-memory stub, wired
through the environment like the self-upgrade preferences. The view
model's hideDependencies is now computed over the injected preferences,
so the existing filter and selection tests are unchanged.

BrewApp.init() was at SwiftLint's body-length limit, so the installed
repository construction is collapsed onto one line to make room.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@graeme
graeme force-pushed the filter-installed-dependencies branch from 350f1eb to a169e57 Compare September 22, 2026 14:15
@graeme
graeme enabled auto-merge September 22, 2026 14:16
@graeme
graeme merged commit 06ee742 into main Sep 22, 2026
8 checks passed
@graeme
graeme deleted the filter-installed-dependencies branch September 22, 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.

Add "Leaves"

4 participants