Skip to content
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

Ctrl+C must work even if a dialog window is open #11876

Conversation

kiminuo
Copy link
Collaborator

@kiminuo kiminuo commented Nov 5, 2023

Fixes #11803
Alternative to #11857
Relevant read here

This PR is my take how I would approch the issue. I'm not sure if details on the UI side are OK or not. Review from somebody who understands that part of code would be very useful.

UI decoupling was not taken into account as well. If somebody wants to take over this PR, feel free to do so.

edit: It was found during review that this PR does not work when Run in background is turned on. Thanks for pointing it out.

@kiminuo
Copy link
Collaborator Author

kiminuo commented Nov 5, 2023

cc @AlexisKv @turbolay

Copy link
Collaborator

@MarnixCroes MarnixCroes left a comment

Choose a reason for hiding this comment

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

is this OS specific? because for me I can still never shutdown with Ctrl C #11544

@kiminuo
Copy link
Collaborator Author

kiminuo commented Nov 6, 2023

is this OS specific? because for me I can still never shutdown with Ctrl C #11544

It is not supposed to be OS-specific. I tested it on Windows and it seems to work for me. I can test on Linux, that is your OS, right?

@MarnixCroes
Copy link
Collaborator

is this OS specific? because for me I can still never shutdown with Ctrl C #11544

It is not supposed to be OS-specific. I tested it on Windows and it seems to work for me. I can test on Linux, that is your OS, right?

yes, debian

@kiminuo
Copy link
Collaborator Author

kiminuo commented Nov 6, 2023

@MarnixCroes Does it work if you wait until the wallet is fully loaded? I.e. outside the scope of #11544.

@MarnixCroes
Copy link
Collaborator

MarnixCroes commented Nov 6, 2023

@MarnixCroes Does it work if you wait until the wallet is fully loaded? I.e. outside the scope of #11544.

I can never shutdown fluent.desktop with ctrl c (master).
(So I can't test this PR)
So my comment #11876 (review) was somewhat unrelated to the PR, sorry for the confusion.

@AlexisKv
Copy link
Contributor

AlexisKv commented Nov 6, 2023

This solution doesn't close wasabi in the background. And I think it should close fully app from terminal.
You could change e.Cancel = false , but I have noticed that this solution could incorrect close process

private void Console_CancelKeyPress(object? sender, ConsoleCancelEventArgs e)
	{
		Logger.LogWarning($"Process termination was requested using '{e.SpecialKey}' keyboard shortcut.");

		// Do not kill the process ...
		e.Cancel = true;

		// ... instead signal back that the app should terminate.
		SignalTerminate(ctrlCPressed: true);
	}

@AlexisKv
Copy link
Contributor

AlexisKv commented Nov 6, 2023

As before, if you try to ctrl+c. than again open wallet, ctrl+c doesn't work anymore.

Copy link
Collaborator

@turbolay turbolay left a comment

Choose a reason for hiding this comment

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

This solution works perfectly on macOs.
All comments seem unrelated to the PR, and I believe should be tackled in subsequent ones:

  • As mentioned by @AlexisKv and discussed on Slack, this workflow should bypass the setting Run Wasabi in background after closing
  • It seems that there are some issues with Linux (in particular Debian?)

}

public void SignalTerminate()
public void SignalTerminate(bool ctrlCPressed)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe RPC stop command should also bypass the shutdown prevention. I would remove this parameter and always set result to true. We could also rename function SignalForceTerminate

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think you are right. I'll modify it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pushed 432eabc

@AlexisKv
Copy link
Contributor

AlexisKv commented Nov 6, 2023

@MarnixCroes Does it work if you wait until the wallet is fully loaded? I.e. outside the scope of #11544.

I can never shutdown fluent.desktop with ctrl c (master). (So I can't test this PR) So my comment #11876 (review) was somewhat unrelated to the PR, sorry for the confusion.

Does Run on background feature is turned off in settings? @MarnixCroes
Can you turn it off and try to ctrl+c?

@MarnixCroes
Copy link
Collaborator

@MarnixCroes Does it work if you wait until the wallet is fully loaded? I.e. outside the scope of #11544.

I can never shutdown fluent.desktop with ctrl c (master). (So I can't test this PR) So my comment #11876 (review) was somewhat unrelated to the PR, sorry for the confusion.

Does Run on background feature is turned off in settings? @MarnixCroes Can you turn it off and try to ctrl+c?

Run in background is turned on.
Turning it off makes Ctrl C work.
(running master)

@turbolay
Copy link
Collaborator

turbolay commented Nov 6, 2023

@kiminuo So problem was not about linux, but about the "run into background option". We should fix it in another PR, as this one is effectively fixing the issue mentioned. I asked review from @wieslawsoltes, if UI changes are OK please consider #11876 (comment) and proceed to merge.

Copy link
Contributor

@AlexisKv AlexisKv left a comment

Choose a reason for hiding this comment

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

It fixes issue. Looks good.

Copy link
Collaborator

@MarnixCroes MarnixCroes left a comment

Choose a reason for hiding this comment

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

tack 432eabc
also tested stop RPC #11876 (comment)

Copy link
Collaborator

@adamPetho adamPetho left a comment

Choose a reason for hiding this comment

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

tACK on Win11

@kiminuo kiminuo merged commit b14fecc into WalletWasabi:master Nov 7, 2023
7 checks passed
@kiminuo kiminuo deleted the feature/2023-11-05-CtrlC-when-dialog-is-open branch November 7, 2023 10:10
@kiminuo kiminuo mentioned this pull request Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dialog opened breaks ctrl+c
5 participants