Skip to content

refactor: remove dead code and reduce redundancy project-wide#4

Merged
BlackHole1 merged 5 commits into
mainfrom
refactor/whole-project-cleanup
Jun 30, 2026
Merged

refactor: remove dead code and reduce redundancy project-wide#4
BlackHole1 merged 5 commits into
mainfrom
refactor/whole-project-cleanup

Conversation

@BlackHole1

Copy link
Copy Markdown
Member

A whole-project audit (dead code, redundancy, and missing abstractions) turned up only low-risk cleanups — the codebase was already healthy and no load-bearing Mission Control logic was changed. This branch applies the verified findings: a net −60 lines across 17 files, with every commit building at zero warnings and the full test suite green.

Dead code removed (zero references anywhere in Sources/ or Tests/, compiler/test-verified):

  • 16 unused DS design tokens — the whole Radius enum, Spacing.xxl, several Size/Window tokens, Palette.danger, Font.chip, and Motion.toggle/resultDwell. Size.overlayButton also duplicated OverlayGeometry.buttonSize, which stays the single source of truth.
  • EventTap.isRunning, the variadic AppKitStrings.string overload, WindowInfo.title (parsed from kCGWindowName but never read), WindowCapabilities.hasAny (test-only), and UpdateChannel's unused Identifiable/CaseIterable/id — each with its tests updated in lockstep.

Redundancy and abstraction:

  • Extracted View.settingsFooter() to replace six inline copies of the section-footer styling, and routed the debug screenshot path through the existing View.localized(with:) helper instead of re-rolling the locale-injection trio.
  • In MissionControlEngine, grouped two repeated statement runs into clearOverlayContent() and resetSettleState(). These are behavior-preserving — no value, order, or control-flow change — and were applied only where the statements were exactly consecutive; the distinct per-site comments at each settle reset are preserved.

Tests:

  • OverlaySettingsTests.lenientDecode now omits keys so it actually exercises the decodeIfPresent ?? default fallback it was named for; it previously set every key and was just a second round-trip decode.
  • De-duplicated the repeated main-display rect literal, tightened restartEngine() to private, and fixed the Log.swift diagnostics doc-comment to follow the project's /usr/bin/log … --info rule.

MissionControlEngine is hot-path overlay code. The changes there are provably behavior-preserving and pass build + tests, but per the project's on-screen-verification rule a final manual Mission Control pass (hover → click → re-tile) is worth doing before merge.

Dead tokens with zero references anywhere in Sources/ or Tests/: Spacing.xxl,
the entire Radius enum, Size.{rowIcon,overlayButton,updateHeaderIcon,progressBar},
Window.{aboutWidth,updateWidth,updateHeight}, Palette.danger, Font.chip,
Motion.{toggle,resultDwell}. Size.overlayButton duplicated OverlayGeometry.buttonSize
(the value the live overlay lays out against), which remains the single source of truth.

Build: zero warnings.
Confirmed-dead, zero production consumers (compiler/tests verified):
- EventTap.isRunning (no consumer)
- AppKitStrings.string variadic CVarArg overload (only single-arg form used)
- WindowInfo.title (parsed from kCGWindowName but never read) + 7 test call sites
- WindowCapabilities.hasAny (test-only) + its test
- UpdateChannel: drop Identifiable/CaseIterable/id (no Picker/ForEach consumer;
  UpdateController uses only the kept static funcs) + its test

Build+tests: zero warnings, all green.
- OverlaySettingsTests.lenientDecode now omits showMinimize/showZoom so the
  init(from:) `decodeIfPresent ?? true` fallback is actually exercised
  (the old blob set all three keys, so it was just a second round-trip decode).
- WindowInfoTests: extract the duplicated main-display CGRect into a
  `mainDisplay` property; the empty-displays case is untouched.

make test: all green, zero warnings.
…fix Log doc

- Add View.settingsFooter() and use it in General/Updates/Shortcuts panes,
  replacing the 6x inline .font(DS.Font.sectionFooter).foregroundStyle(.secondary)
  (render byte-identical).
- showSettingsForScreenshot() reuses View.localized(with:) instead of hand-rolling
  the same environment(\.locale)/.id trio.
- restartEngine() is now private (only called within AppState).
- Log.swift doc example now uses /usr/bin/log ... --info --style compact per the
  CLAUDE.md diagnostics rule (bare `log` is a zsh builtin).

make build: zero warnings.
Behavior-preserving dedup in the Mission Control engine (no value, order, or
control-flow change — only grouping repeated statement runs into private helpers):
- clearOverlayContent(): the orderOut + geometry=nil + currentActions=[] triple,
  applied at the two sites where it is exactly consecutive (repositionOverlay
  guard #1, hideOverlay). Left inline where not a clean match: repositionOverlay
  guard #2 (uses the unwrapped local window), endSession (hovered=nil interleaves).
- resetSettleState(): the layoutSettled/stableTicks/sinkWatchTicks reset, at
  beginSession/resyncSession/endSession; the distinct per-site comments are
  preserved on the call lines.

make build + make test: zero warnings, all green.
@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0fd39e9b-cb89-4b69-b937-4ce15c13f31a

📥 Commits

Reviewing files that changed from the base of the PR and between 60f55f2 and 1104df6.

📒 Files selected for processing (17)
  • Sources/CloseUp/AppDelegate.swift
  • Sources/CloseUp/AppState.swift
  • Sources/CloseUp/Localization/AppKitStrings.swift
  • Sources/CloseUp/MissionControl/MissionControlEngine.swift
  • Sources/CloseUp/UI/DesignSystem.swift
  • Sources/CloseUp/UI/Settings/GeneralSettingsPane.swift
  • Sources/CloseUp/UI/Settings/ShortcutsSettingsPane.swift
  • Sources/CloseUp/UI/Settings/UpdatesSettingsPane.swift
  • Sources/CloseUpKit/Diagnostics/Log.swift
  • Sources/CloseUpKit/MissionControl/EventTap.swift
  • Sources/CloseUpKit/MissionControl/WindowCapabilities.swift
  • Sources/CloseUpKit/MissionControl/WindowInfo.swift
  • Sources/CloseUpKit/Updates/UpdateChannel.swift
  • Tests/CloseUpKitTests/OverlaySettingsTests.swift
  • Tests/CloseUpKitTests/UpdateChannelTests.swift
  • Tests/CloseUpKitTests/WindowCapabilitiesTests.swift
  • Tests/CloseUpKitTests/WindowInfoTests.swift
💤 Files with no reviewable changes (5)
  • Sources/CloseUpKit/MissionControl/EventTap.swift
  • Sources/CloseUp/Localization/AppKitStrings.swift
  • Tests/CloseUpKitTests/WindowCapabilitiesTests.swift
  • Sources/CloseUpKit/MissionControl/WindowCapabilities.swift
  • Tests/CloseUpKitTests/UpdateChannelTests.swift

Summary by CodeRabbit

  • Bug Fixes

    • Improved screenshot settings rendering so the correct language and content are shown more reliably.
    • Fixed internal session/overlay cleanup to make window overlays behave more consistently.
    • Updated saved data handling so older settings continue to load correctly.
  • Refactor

    • Simplified and standardized Settings footers across the app for a more consistent look.
    • Streamlined internal window and update channel handling.
  • Documentation

    • Updated command-line logging examples.
  • Tests

    • Adjusted coverage to match the latest settings and window behavior.

Walkthrough

Several public API members are removed: WindowInfo.title (property and initializer parameter), WindowCapabilities.hasAny, EventTap.isRunning, UpdateChannel's CaseIterable/Identifiable conformances, and the AppKitStrings variadic formatting overload. AppState.restartEngine() is narrowed to private. In MissionControlEngine, settle-state resets are extracted into resetSettleState() and overlay cleanup into clearOverlayContent(), replacing duplicated inline code across beginSession, resyncSession, endSession, repositionOverlay, and hideOverlay. In the design system, unused tokens (danger, xxl, Motion.toggle, Motion.resultDwell) are removed and a settingsFooter() View extension is added; all settings panes adopt it. Tests are updated to match removed fields and initializer signatures.

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title is related, but it does not match the required <type>(<scope>): <subject> format because it lacks the optional scope parentheses. Rewrite it as refactor(<scope>): remove dead code and reduce redundancy project-wide or another valid <type>(<scope>): <subject> title.
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly matches the refactor and dead-code cleanup work described in the changeset.
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.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch refactor/whole-project-cleanup

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

@BlackHole1 BlackHole1 merged commit e746d84 into main Jun 30, 2026
3 checks passed
@BlackHole1 BlackHole1 deleted the refactor/whole-project-cleanup branch June 30, 2026 03:10
BlackHole1 added a commit that referenced this pull request Jun 30, 2026
…IME) (#5)

## Problem

The Nightly (Beta) / Release publish job fails at **Build appcasts**
with exit 1, right after:

```
Wrote 1 new update, updated 0 existing updates, and removed 0 old updates in appcast-arm64.xml
```

`test -f "build/dist-$ARCH/appcast.xml"` then fails.

## Root cause

`generate_appcast` can't run the app, so it derives the output appcast
**filename from the app's `SUFeedURL` basename**. The per-arch split
(#3) set `Info.plist` `SUFeedURL` to `…/appcast-arm64.xml`, so the tool
writes `appcast-arm64.xml` in **every** `build/dist-$ARCH` dir — but the
CI seeds, tests, and publishes the **local** file
`build/dist-$ARCH/appcast.xml`. Mismatch → exit 1. (The log line `…in
appcast-arm64.xml` is the derived name, not the file actually written.)

## Fix — mirror LockIME (no `-o`)

- Revert `Sources/CloseUp/Info.plist` `SUFeedURL` → `…/appcast.xml`. It
is a **runtime no-op** (`UpdaterDelegate.feedURLString` pins an explicit
per-arch URL for both arches); its only jobs are the `generate_appcast`
naming basis and the 0.1.0 default. With basename `appcast.xml`, the
tool writes the local `appcast.xml` the CI already expects — **no `-o`
needed**.
- The local working file in each `build/dist-$ARCH` is always
`appcast.xml` (the arch is already in the directory name). The per-arch
feed name is applied **only at the gh-pages boundary**: seed
`appcast-$ARCH.xml` → local `appcast.xml`; publish local `appcast.xml` →
`appcast-$ARCH.xml`.
- **CloseUp keeps symmetric feeds** (`appcast-arm64.xml` /
`appcast-x86_64.xml`); `appcast.xml` stays a frozen 0.1.0 orphan the
pipeline never writes. Unlike LockIME (legacy arm64-only, so its arm64
feed *is* `appcast.xml`), CloseUp's universal 0.1.0 also runs on Intel —
arm64 entries in `appcast.xml` would push an arm64 build to an Intel
0.1.0.
- Also pass `inputs.tag`/`channel` + `github.repository` to the step via
`env` instead of interpolating `${{ }}` into the bash body
(shell-injection hardening, per CodeRabbit).

## Verification

- **Empirical** (Sparkle's prebuilt `generate_appcast`, basename
`appcast.xml`, no `-o`): writes local `appcast.xml`, adds the new entry,
preserves a seeded old entry's signature, creates no stray
`appcast-*.xml`.
- **Adversarial review** across 4 lenses (CI-correctness,
LockIME-parity, 0.1.0-orphan/cross-arch, completeness): 0 confirmed
defects.

Docs updated (`AGENTS.md`, `docs/RUNBOOK.md`); the `-o` approach is
removed. Rebased onto current `main` (includes #4).

Note: `ci.yml` (this PR's checks) builds/tests but does **not** call
`build-publish.yml`; only the scheduled nightly / manual release
dispatch exercise the publish path.
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