Skip to content

chore: add connect/disconnect notifications on Coder Connect #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jul 1, 2025

Conversation

ibetitsmike
Copy link
Contributor

Fixes: #40

@ibetitsmike ibetitsmike requested a review from deansheather June 30, 2025 15:38
Comment on lines +342 to +343
var app = (App)Current;
if (app != null && app.TrayWindow != null)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this just be if (TrayWindow != null) TrayWindow.Tray_Open();?


private ConcurrentDictionary<string, INotificationHandler> Handlers { get; } = new();

public UserNotifier(ILogger<UserNotifier> logger, IDispatcherQueueManager dispatcherQueueManager,
INotificationHandler notificationHandler)
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should wrap it with a marker type like public interface IDefaultNotificationHandler : INotificationHandler so we don't inadvertently add another implementation that could get DI'd here, and only have the App implement IDefaultNotificationHandler

Comment on lines +157 to +166
// This method is called when the state changes, but we don't want to notify
// the user if the state hasn't changed.
var isRpcLifecycleChanged = rpcModel.RpcLifecycle == RpcLifecycle.Disconnected && curRpcLifecycle != rpcModel.RpcLifecycle;
var isVpnLifecycleChanged = (rpcModel.VpnLifecycle == VpnLifecycle.Started || rpcModel.VpnLifecycle == VpnLifecycle.Stopped) && curVpnLifecycle != rpcModel.VpnLifecycle;

if (!isRpcLifecycleChanged && !isVpnLifecycleChanged)
{
return;
}

Copy link
Member

Choose a reason for hiding this comment

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

I don't think you need any of these lines since they're essentially covered by what's below right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately no, I ignore the intermediate states of the Vpn lifecycle on purpose (and I don't update the prevRpcLifecycle for that reason).

@ibetitsmike ibetitsmike merged commit 7e3782f into main Jul 1, 2025
3 checks passed
@ibetitsmike ibetitsmike deleted the mike/40-connect-notification branch July 1, 2025 17:09
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.

VPN/RPC state changes should send the user a notification
2 participants