Skip to content

Refactor notification registration for MCPMaxUINotification#66

Open
std-microblock wants to merge 1 commit intofosdickio:mainfrom
std-microblock:patch-1
Open

Refactor notification registration for MCPMaxUINotification#66
std-microblock wants to merge 1 commit intofosdickio:mainfrom
std-microblock:patch-1

Conversation

@std-microblock
Copy link

fix #34

Copilot AI review requested due to automatic review settings February 22, 2026 14:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors how the Binary Ninja UI notification handler (_MCPMaxUINotification) is registered, likely to improve Windows stability by keeping a persistent reference and adjusting the registration flow (fixes #34).

Changes:

  • Adds an __init__ to _MCPMaxUINotification that registers the instance with UIContext.
  • Stores the notification instance in a module-level variable instead of constructing it only as an argument to registerNotification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

def __init__(self):
super().__init__()
ui.UIContext.registerNotification(self)

Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

The blank line after ui.UIContext.registerNotification(self) contains trailing whitespace. Please remove the extra spaces to avoid whitespace-only diffs and potential lint/style issues.

Suggested change

Copilot uses AI. Check for mistakes.
Comment on lines +574 to +576
def __init__(self):
super().__init__()
ui.UIContext.registerNotification(self)
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

_MCPMaxUINotification.__init__ performs global registration as a side effect. Consider keeping registration in the outer block where the instance is created so the lifecycle is more explicit and it’s harder to accidentally register multiple instances in the future.

Copilot uses AI. Check for mistakes.
pass

ui.UIContext.registerNotification(_MCPMaxUINotification())
notification = _MCPMaxUINotification()
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

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

The new module-level notification variable is only used for its side effects / lifetime management, but the name is very generic and could be mistaken for dead code. Consider renaming it to something explicit like _ui_notification (and optionally add a short comment that it must be kept referenced to prevent GC).

Suggested change
notification = _MCPMaxUINotification()
# Keep a module-level reference so the UI notification is not garbage-collected
_ui_notification = _MCPMaxUINotification()

Copilot uses AI. Check for mistakes.
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.

Versions above 0.2.6 break Binary Ninja on Windows

2 participants