jan icon indicating copy to clipboard operation
jan copied to clipboard

leave the app window active in the dock when closing on mac

Open Gri-ffin opened this issue 1 year ago • 6 comments

fixes #584

If its macOS, if the close button on the window is pressed we close all windows but we leave the app active in the dock otherwise we quit the app, this quit functionality using cmd + q shortcut on macOS still quits the app completely.

Should still be tested on other OSs.

quick demo:

https://github.com/janhq/jan/assets/82527700/8ac29ac3-e530-4460-883b-a33a95df3f2b

Gri-ffin avatar Jan 02 '24 19:01 Gri-ffin

Thank you for the quick update. I would like to provide some additional information so that you can proceed with the PR:

  1. The app needs to clean up resources when all windows are closed, such as killing Nitro subprocesses. This can be done by calling the stopModel() function. It would be better to decouple cleanUpAndQuit into cleanResources and app.quit() so we can call the corresponding action per platform.
  2. For other OS like Windows and Linux, we must clean up resources before quitting.

Please let me know if you need me to proceed with the changes. Thank you again for your contribution. We appreciate all the help from the community.

cc @Gri-ffin

louis-jan avatar Jan 03 '24 04:01 louis-jan

I've added some changes to cleanup the resources, @louis-jan does this do what is required?

Gri-ffin avatar Jan 03 '24 13:01 Gri-ffin

I've added some changes to cleanup the resources, @louis-jan does this do what is required?

Thanks for the update, it looks great.

Could you please also remove cleanUpAndQuit method, its now can be replaced by your new function:

cleanResources()
app.quit()

Idk why the test is failed on this PR, could you please investigate 🙏

louis-jan avatar Jan 03 '24 13:01 louis-jan

should work now

Gri-ffin avatar Jan 03 '24 16:01 Gri-ffin

Looks great @Gri-ffin. I will test it out a bit on other platforms and let you know.

louis-jan avatar Jan 04 '24 04:01 louis-jan

Hi @Gri-ffin, I conducted some testing and identified an issue with state synchronization. When the window is closed with the API Server enabled, reopening it does not sync with the server state immediately. As a result, the 'Enable API Server' toggle stops working.

louis-jan avatar Jan 04 '24 08:01 louis-jan

This PR is around for a month and there is no updates ever since. I'm closing this PR, please feel free to re-open it once you have been able to test. Thank you @Gri-ffin

hiro-v avatar Feb 05 '24 03:02 hiro-v