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

Prompt before closing the app when a process is running #684

Open
tleunen opened this issue Sep 2, 2016 · 20 comments · May be fixed by #7331
Open

Prompt before closing the app when a process is running #684

tleunen opened this issue Sep 2, 2016 · 20 comments · May be fixed by #7331
Labels
good first issue Issue is good for Hyper newcomers help wanted Contributions wanted towards the issue 🛠 Type: Feature Request Issue or PR is a feature request/proposal for Hyper

Comments

@tleunen
Copy link

tleunen commented Sep 2, 2016

Related to #623. Would it be possible to have a prompt before quitting the app when a process is running? It could help to prevent quitting the app with an ongoing process that we won't be able to kill without manually killing the PID.

@matheuss matheuss added help wanted Contributions wanted towards the issue 🛠 Type: Feature Request Issue or PR is a feature request/proposal for Hyper good first issue Issue is good for Hyper newcomers labels Sep 2, 2016
@vitorbal
Copy link

vitorbal commented Sep 4, 2016

Hi there! I would like to take a stab at this feature if possible.

I've already managed to hook up to the window close event and display a prompt to the user, but I'm having a bit of trouble figuring out how to determine if there is an ongoing process in a tab.
Could someone point me in the right direction?

Sorry if it's a silly question, this is my first time contributing to hyperterm. Thank you for the project, having a blast using it! :)

@NicholasWalton
Copy link

Perhaps take a look at how gnome-terminal does it?
https://github.com/linuxmint/gnome-terminal/blob/master/src/terminal-screen.c#L2083

@TylerRick
Copy link

I was just going to open an issue for this and ran across this one. 😄

Particularly since I'm not used to Ctrl-W closing the tab (except in web browser), I've already been bit by this a number of times and ⚡ lost all of the processes I had running in a window that I accidentally closed. Would love to see this one implemented. 👍

I was going to suggest the exact same thing as @NicholasWalton: Perhaps take a look at how gnome-terminal does it... Their prompt looks like this:

image

@kaushik-asp
Copy link

Still open?

@kevin-bebel
Copy link

Hi,

Is this Feature still available to work on?

@jpolack
Copy link

jpolack commented Apr 18, 2019

Would interest me aswell

@diogotorres97
Copy link

diogotorres97 commented Apr 24, 2019

@kevin-bebel and @jpolack, you could look to my PR and add some fixes!

#2477

@jackHedaya
Copy link

Looks like the PR is stale. I'm going to give this a shot myself.

@rohitkrishna094
Copy link

So any updates on this? I need this feature as a temporary solution for #623. Did the corresponding PR for this get merged? If yes, how to enable it in hyper? Thanks

@Nevnet99
Copy link

Nevnet99 commented Jul 7, 2020

Nowhere near finished still trying to fix a bug that has been nagging me for a few hours anybody knows of anywhere to look? https://github.com/Nevnet99/hyper/tree/bugfix/ISSUE-684 will be picking this up again a little later :) also still trying to look for the function that fires on close of the terminal.

TODO:

  • Find the solution to check if a process is running.
  • Make popup appear on the mass closure of the terminals.

@Nevnet99
Copy link

Nevnet99 commented Jul 7, 2020

Struggled with this the entire day didnt get any further ;(

@Project-Magenta
Copy link

I'm willing to do this for Hacktoberfest. Is this still available?

@jackHedaya
Copy link

@Project-Magenta Took a crack at it ages ago and didn't really get anywhere. Go ahead!

@Picoseconds
Copy link

Are we willing to introduce a new dependency of ps-node?

@Project-Magenta
Copy link

oh, btw Picoseconds is also me

@Picoseconds
Copy link

@lucleray can you add hacktoberfest tag so I can get a tshirt?

@theIDinside
Copy link

Is this feature still requested and not solved? I'm not particularly great at Typescript & Javascript, but I might have some ideas on how I could go about solving this on Linux at least, given a little time.

@theIDinside
Copy link

theIDinside commented Oct 13, 2021

Alright, so I got it working, I will push a commit to my fork, there's another issue though, I don't have enough insight into the code base, but I will require to know these things;

  • Based off of having a session object, how can I track what pane it is "bound to"? This is, so that when closing a window, we would probably want to focus on the actual shell/pane that has a child process running
  • I see that when one closes a tab, hyper does something like dispatch an event to rpc.on('termgroup close req') if i'm not mistaken, once again, I need to be able to get a hold of the session object(s) that exists on the particular pane handling that request in order to get a hold of the IPty/pseudo terminal, otherwise it will kill the child processes running in that tab without prompting, because as it stands right now, I've only hooked it up to when closing a hyper window. If any of the terminals in that window (tab or otherwise) has child processess running, it will prompt with the exact same message as the gtk message in this thread

I've tested this solution on Ubuntu, but it should work for most Linux dists, but I am not 100% certain of that right now.

I've pushed it to my fork to the branch on request_close_on_live_children. Should I ask for a pull request now and amend as we go, or what? If anyone can answer my questions, I'll add the features above as well if that's desired by maintainers.

I've also I believe figured out how to do this on Windows, but again, I need answers with respect to where events like "close tab/close pane" is handled. Is all that passed off to Electron?

@theIDinside
Copy link

theIDinside commented Oct 14, 2021

The action that gets dispatched to onCloseTab - how do I intervene before this/during this, so that I can run code on the "app" side so to speak? React is pretty convoluted and the functionality is spread across a vast array of files, so it's kind of hard for someone who has little knowledge of React/Redux to inject the behavior I want. For instance, in closeTab we can do rpc.emit('some-custom-function') but what I actually want, is to emit something to the app (or however it's supposed to be done) and wait for more user input (such as clicking Yes/No) before dispatching to userExitTermGroup - how do I do this?

The problem I'm facing is, I can react to session exits etc, but that won't prevent React from removing the tab and thus making it impossible to stop the tab from disappearing, if it has a child process running, i.e. the message box opens after the tab is already gone since I'm reacting to an "exit" event. I've read about the middleware, but that isn't exactly making me any smarter on what to do. I'll send a pull request for the feature only involving when closing the entire window, unless someone can chime in here.

@theIDinside
Copy link

I'm sending the pull request, later tonight, for the specific issue here - I won't add the functionality for when closing down tabs as there doesn't seem to be any reasonable way to implement this functionality that I am aware of. Could you be so kind to tag the pull request as hacktoberfest-accepted when I do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issue is good for Hyper newcomers help wanted Contributions wanted towards the issue 🛠 Type: Feature Request Issue or PR is a feature request/proposal for Hyper
Projects
None yet
Development

Successfully merging a pull request may close this issue.