Skip to content

Comments

Add OnConnectionChangeFunc callback to BroflakeOptions#330

Merged
myleshorton merged 6 commits intomainfrom
adam/unbounded-widget-proxy
Feb 23, 2026
Merged

Add OnConnectionChangeFunc callback to BroflakeOptions#330
myleshorton merged 6 commits intomainfrom
adam/unbounded-widget-proxy

Conversation

@myleshorton
Copy link
Contributor

Summary

  • Adds ConnectionChangeFunc type and OnConnectionChangeFunc field to BroflakeOptions
  • UIImpl.OnConsumerConnectionChange calls the callback when set
  • NewBroflake wires the callback onto UIImpl before it gets copied to bus handlers

Allows callers (e.g. radiance) to receive consumer connection state change events without modifying the broflake internals.

🤖 Generated with Claude Code

Allows callers to receive consumer connection state change events
(connected/disconnected with worker index and IP) by passing a callback
via BroflakeOptions. The callback is set on UIImpl before it gets copied
to bus handlers in NewBroflake, ensuring the value receiver method works.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 adds a callback mechanism to allow external callers (such as "radiance") to receive consumer connection state change notifications without modifying broflake's internals. It introduces a new ConnectionChangeFunc type and adds an OnConnectionChangeFunc field to BroflakeOptions, which is wired through the UI implementation to be invoked when consumer connections change state.

Changes:

  • Added ConnectionChangeFunc type for connection state change callbacks
  • Extended BroflakeOptions with optional OnConnectionChangeFunc field
  • Updated non-WASM UIImpl to store and invoke the callback in OnConsumerConnectionChange

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
clientcore/settings.go Defines ConnectionChangeFunc type and adds OnConnectionChangeFunc field to BroflakeOptions struct
clientcore/ui_default_impl.go Adds OnConnectionChangeFunc field to non-WASM UIImpl struct and invokes callback in OnConsumerConnectionChange method
clientcore/broflake.go Wires the callback from BroflakeOptions to UIImpl before UI is copied to bus handlers

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

UI
BroflakeEngine *BroflakeEngine
BroflakeEngine *BroflakeEngine
OnConnectionChangeFunc ConnectionChangeFunc
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

The OnConnectionChangeFunc field is only added to the non-WASM UIImpl struct but not to the WASM version in ui_wasm_impl.go. Since both implementations share the same BroflakeOptions struct and NewBroflake function (which sets ui.OnConnectionChangeFunc at line 171 in broflake.go), this will cause a compilation error for WASM builds. The field needs to be added to the UIImpl struct in ui_wasm_impl.go as well, and the OnConsumerConnectionChange method in that file should also be updated to call the callback if set.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

myleshorton and others added 2 commits February 23, 2026 12:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Feb 23, 2026

@myleshorton I've opened a new pull request, #331, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits February 23, 2026 19:46
Co-authored-by: myleshorton <1143966+myleshorton@users.noreply.github.com>
Co-authored-by: myleshorton <1143966+myleshorton@users.noreply.github.com>
[WIP] Update implementation based on feedback for OnConnectionChangeFunc
@myleshorton
Copy link
Contributor Author

Gonna YOLO this -- pretty small change.

@myleshorton myleshorton merged commit 4065257 into main Feb 23, 2026
1 check failed
@myleshorton myleshorton deleted the adam/unbounded-widget-proxy branch February 23, 2026 19:50
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.

2 participants