Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions MiddleDrag/UI/MenuBarController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,30 @@ class MenuBarController: NSObject {

@objc func forceReleaseStuckDrag() {
multitouchManager?.forceReleaseStuckDrag()

// Provide visual feedback that the action was triggered
// Flash the status bar icon briefly
flashStatusBarIcon()
}

/// Flash the status bar icon to provide visual feedback for actions
private func flashStatusBarIcon() {
guard let button = statusItem?.button else { return }

// Store original image
let originalImage = button.image

// Flash to a highlighted state (use template rendering)
if let image = originalImage {
let highlightedImage = image.copy() as? NSImage
highlightedImage?.isTemplate = false // Make it appear "active"
button.image = highlightedImage
}

// Restore after a brief delay
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
button.image = originalImage
}
Comment on lines +620 to +634
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flash effect implementation has a fundamental issue: setting isTemplate = false on a copy of an already-template image doesn't produce a visible change. Template images are rendered using the system's accent color, and copying the image and changing this property doesn't make it appear different to the user.

For a visible flash effect, consider using an alpha animation (similar to the pattern in updateStatusIcon at lines 51-59) or changing the image to a different symbol temporarily.

Suggested change
// Store original image
let originalImage = button.image
// Flash to a highlighted state (use template rendering)
if let image = originalImage {
let highlightedImage = image.copy() as? NSImage
highlightedImage?.isTemplate = false // Make it appear "active"
button.image = highlightedImage
}
// Restore after a brief delay
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
button.image = originalImage
}
let originalAlpha = button.alphaValue
NSAnimationContext.runAnimationGroup({ context in
context.duration = 0.1
button.animator().alphaValue = 0.3
}, completionHandler: {
NSAnimationContext.runAnimationGroup({ context in
context.duration = 0.1
button.animator().alphaValue = originalAlpha
}, completionHandler: nil)
})

Copilot uses AI. Check for mistakes.
Comment on lines +621 to +634
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation has a potential race condition if the user clicks the menu item multiple times rapidly. Each invocation captures a different originalImage, and the last async block to execute might restore the wrong image. The image reference could also become nil if the button is deallocated.

Consider storing the original image as a property to avoid capturing stale references, or use a cancellable timer/task pattern to cancel pending restoration when a new flash is triggered.

Copilot uses AI. Check for mistakes.
Comment on lines +620 to +634
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flash implementation pattern differs from the existing visual feedback pattern in this class. The updateStatusIcon method (lines 43-60) uses NSAnimationContext with alpha animation for visual feedback, which is more consistent with macOS UI conventions and provides smoother animations.

Consider using a similar animation approach here for consistency, such as briefly animating the button's alpha or scale.

Suggested change
// Store original image
let originalImage = button.image
// Flash to a highlighted state (use template rendering)
if let image = originalImage {
let highlightedImage = image.copy() as? NSImage
highlightedImage?.isTemplate = false // Make it appear "active"
button.image = highlightedImage
}
// Restore after a brief delay
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
button.image = originalImage
}
// Use a brief alpha animation for visual feedback, consistent with updateStatusIcon
NSAnimationContext.runAnimationGroup { context in
context.duration = 0.15
button.animator().alphaValue = 0.3
} completionHandler: {
NSAnimationContext.runAnimationGroup { context in
context.duration = 0.15
button.animator().alphaValue = 1.0
}
}

Copilot uses AI. Check for mistakes.
Comment on lines +618 to +634
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new flashStatusBarIcon method lacks test coverage. The MenuBarControllerTests file contains tests for other UI methods like updateStatusIcon (lines 70-83), but there's no test for this new visual feedback functionality. Given that the repository has comprehensive test coverage for UI components, this method should have tests to verify it doesn't crash and handles edge cases like rapid clicks.

Copilot uses AI. Check for mistakes.
}

@objc func toggleLaunchAtLogin() {
Expand Down