Skip to content

fix: bugs, improvements, and SwiftUI modernization#115

Merged
pablopunk merged 2 commits intomainfrom
fix/code-review-improvements
Mar 29, 2026
Merged

fix: bugs, improvements, and SwiftUI modernization#115
pablopunk merged 2 commits intomainfrom
fix/code-review-improvements

Conversation

@pablopunk
Copy link
Copy Markdown
Owner

@pablopunk pablopunk commented Mar 29, 2026

Bugs fixed

  • CheckUpdatesButton: .disabled() was on Image instead of Button — button was never actually disabled
  • ShortcutsManager: mouse button subscriptions never fired for key+modifier shortcuts (activeShortcuts wasn't set to true)
  • ShortcutsManager: keyDown/keyUp monitor passed wrong userShortcut when stopping tracking for other shortcut types
  • drawCircleAt: now returns NSWindow so caller can keep a strong reference (was deallocated immediately)
  • AppDelegate: removed app activation/deactivation handlers that paused tracking — menu bar app is almost never "active", so these broke normal usage
  • MouseTracker: replaced force unwraps with guard let to prevent crashes on desynced state
  • UpdatesView: @ObservedObject@StateObject — view owns the instance, was being recreated every redraw

Improvements

  • Constants: varlet for IGNORE_APP_BUNDLE_ID and MAIN_WINDOW_WIDTH
  • Preferences: cached ignored apps Set to avoid recomputing on every call
  • PermissionsManager: removed large block of dead commented-out code
  • InfoView: removed unused hasPermissions parameter
  • ShortcutsManager.stopTracking: now cleans up mouse subscriptions to prevent stale CGEvent subscribers
  • Simplified redundant quadrant dx/dy calculation (iw.x terms canceled out)

SwiftUI modernization

  • foregroundColorforegroundStyle (deprecated since iOS 15+)
  • cornerRadiusclipShape(.rect(cornerRadius:)) (deprecated)
  • Force unwraps replaced with if let/guard let throughout views

Other

  • Added .agents/skills/swiftui-expert-skill for SwiftUI best practices reference

Summary by CodeRabbit

Release Notes

  • Documentation

    • Added comprehensive SwiftUI reference documentation covering accessibility, animations, charts, layouts, performance optimization, state management, macOS features, and more.
  • Bug Fixes

    • Improved null-safety throughout the app by eliminating unsafe force unwraps.
    • Removed problematic keyboard monitoring logic.
  • Refactor

    • Enhanced code quality and modernized deprecated styling patterns.
    • Improved ignored apps caching for better performance.

Bugs fixed:
- CheckUpdatesButton: .disabled() was on Image instead of Button
- ShortcutsManager: mouse button subscriptions never fired for key+modifier shortcuts
- ShortcutsManager: keyDown/keyUp monitor passed wrong userShortcut for other types
- drawCircleAt: now returns NSWindow to prevent immediate deallocation
- AppDelegate: removed app activation handlers that broke tracking in menu bar app
- MouseTracker: replaced force unwraps with guard-let to prevent crashes
- UpdatesView: @ObservedObject@StateObject (view owns the instance)

Improvements:
- Constants: var → let for IGNORE_APP_BUNDLE_ID and MAIN_WINDOW_WIDTH
- Preferences: cached ignored apps Set to avoid recomputing on every call
- PermissionsManager: removed dead commented-out code
- InfoView: removed unused hasPermissions parameter
- ShortcutsManager.stopTracking: cleans up mouse subscriptions
- Simplified redundant quadrant dx/dy calculation

SwiftUI modernization:
- foregroundColor → foregroundStyle
- cornerRadius → clipShape(.rect(cornerRadius:))
- Force unwraps → if-let/guard-let throughout views
@codesandbox
Copy link
Copy Markdown

codesandbox bot commented Mar 29, 2026

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0ecdc5e5-b3d6-4678-a533-566b072da516

📥 Commits

Reviewing files that changed from the base of the PR and between 1b177a7 and 3d2528d.

📒 Files selected for processing (35)
  • .agents/skills/swiftui-expert-skill/SKILL.md
  • .agents/skills/swiftui-expert-skill/references/accessibility-patterns.md
  • .agents/skills/swiftui-expert-skill/references/animation-advanced.md
  • .agents/skills/swiftui-expert-skill/references/animation-basics.md
  • .agents/skills/swiftui-expert-skill/references/animation-transitions.md
  • .agents/skills/swiftui-expert-skill/references/charts-accessibility.md
  • .agents/skills/swiftui-expert-skill/references/charts.md
  • .agents/skills/swiftui-expert-skill/references/image-optimization.md
  • .agents/skills/swiftui-expert-skill/references/latest-apis.md
  • .agents/skills/swiftui-expert-skill/references/layout-best-practices.md
  • .agents/skills/swiftui-expert-skill/references/liquid-glass.md
  • .agents/skills/swiftui-expert-skill/references/list-patterns.md
  • .agents/skills/swiftui-expert-skill/references/macos-scenes.md
  • .agents/skills/swiftui-expert-skill/references/macos-views.md
  • .agents/skills/swiftui-expert-skill/references/macos-window-styling.md
  • .agents/skills/swiftui-expert-skill/references/performance-patterns.md
  • .agents/skills/swiftui-expert-skill/references/scroll-patterns.md
  • .agents/skills/swiftui-expert-skill/references/sheet-navigation-patterns.md
  • .agents/skills/swiftui-expert-skill/references/state-management.md
  • .agents/skills/swiftui-expert-skill/references/view-structure.md
  • Swift Shift/src/AppDelegate.swift
  • Swift Shift/src/Constants.swift
  • Swift Shift/src/Manager/MouseTracker.swift
  • Swift Shift/src/Manager/PermissionsManager.swift
  • Swift Shift/src/Manager/Preferences.swift
  • Swift Shift/src/Manager/ShortcutsManager.swift
  • Swift Shift/src/View/AppView.swift
  • Swift Shift/src/View/IgnoredAppsTabView.swift
  • Swift Shift/src/View/InfoView.swift
  • Swift Shift/src/View/PermissionsRequestView.swift
  • Swift Shift/src/View/PreferencesView.swift
  • Swift Shift/src/View/ShortcutView.swift
  • Swift Shift/src/View/UpdatesView.swift
  • Swift Shift/src/lib/DrawCircle.swift
  • Swift Shift/src/lib/UIButton.swift

📝 Walkthrough

Walkthrough

This PR adds comprehensive SwiftUI reference documentation spanning state management, animations, accessibility, charts, and platform-specific APIs, while refactoring the Swift Shift app to improve code quality through const-correctness, safer optional handling, modern API usage, and internal logic optimization.

Changes

Cohort / File(s) Summary
SwiftUI Skill Documentation
.agents/skills/swiftui-expert-skill/SKILL.md, .agents/skills/swiftui-expert-skill/references/*
Added 19 markdown documentation files covering SwiftUI fundamentals (state management, animations, transitions, view structure, layout, scrolling), advanced topics (accessibility, charts, performance patterns, image optimization, Liquid Glass), platform-specific features (macOS scenes, views, window styling), and latest API replacements (iOS 15–26+).
AppDelegate Cleanup
Swift Shift/src/AppDelegate.swift, Swift Shift/src/Manager/PermissionsManager.swift
Removed app activation/deactivation observers, keyboard event monitor setup/teardown, and commented-out input monitoring permission probe; retained permission checking and settings routing.
Preferences & Constants
Swift Shift/src/Constants.swift, Swift Shift/src/Manager/Preferences.swift
Changed IGNORE_APP_BUNDLE_ID and MAIN_WINDOW_WIDTH from var to let; introduced in-memory cache for ignored apps list with invalidation mechanism in PreferencesManager.
Tracking & Shortcut Management
Swift Shift/src/Manager/MouseTracker.swift, Swift Shift/src/Manager/ShortcutsManager.swift
Refactored MouseTracker window tracking to safely unwrap properties via guard statements; adjusted resize-logic delta computation. Exposed activeShortcuts as read-only; improved shortcut tracking cleanup by calling cleanupMouseSubscriptions on stop.
SwiftUI Modernization – Style/Syntax
Swift Shift/src/View/AppView.swift, Swift Shift/src/View/IgnoredAppsTabView.swift, Swift Shift/src/View/PermissionsRequestView.swift, Swift Shift/src/View/ShortcutView.swift, Swift Shift/src/lib/UIButton.swift
Replaced .foregroundColor(...) with .foregroundStyle(...) for color application; updated onChange handlers to trailing-closure syntax; replaced .cornerRadius(40) with clipShape(.rect(cornerRadius: 40)).
SwiftUI Logic Improvements
Swift Shift/src/View/InfoView.swift, Swift Shift/src/View/PreferencesView.swift, Swift Shift/src/View/UpdatesView.swift
Removed optional parameter from InfoView.init(), replaced forced unwraps with safe optional bindings; updated CheckUpdatesButton to own its view model via @StateObject, changed disabled-state application from image to button container.
Utility Return Value
Swift Shift/src/lib/DrawCircle.swift
Changed drawCircleAt from void-returning to returning the created NSWindow, marked with @discardableResult.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 From skill docs blooming, a SwiftUI guide so bright,
State flows and animations dance through the night,
While Swift Shift finds safety in guards and in let,
Modern styles emerge—the cleanest refactor yet! ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/code-review-improvements

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.

@pablopunk pablopunk merged commit 9a6d193 into main Mar 29, 2026
3 of 4 checks passed
@pablopunk pablopunk deleted the fix/code-review-improvements branch March 29, 2026 12:34
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