Terminal: Prompt before closing pane with multiple client apps

Created on 17 Jun 2020  路  6Comments  路  Source: microsoft/terminal

Description of the new feature/enhancement

Some console apps, like vim, neovim, far, etc, are ignored when you accidentally hit Ctrl+W and your unsaved work is gone forever.

Proposed technical implementation details (optional)

I'm not sure how to do that, but it would be nice to offer an API or something to block closing if some return code is not met.

Area-Settings Issue-Feature Product-Terminal

Most helpful comment

You know, I was going to just close this as a combo of #5301, #2976 and #5065. However, none of those cover this specific case, where we prevent closing a terminal tab/pane when there's more than one client in the process tree.

We really don't have a comprehensive discussion of all these requirements anywhere, do we?

Scenarios

  1. I want to never be prompted for confirmation
  2. I want to be prompted for confirmation when I close the window with multiple tabs
  3. I want to be prompted for confirmation when I close a tab with multiple panes
  4. I want to be prompted for confirmation when I close a pane with multiple clients
  5. I want to be prompted for confirmation when I close a pane always
  6. possibly more scenarios?
  7. I want to be prompted for confirmation when I close a pane with multiple clients, but I don't care about closing multiple tabs/panes with a single client in each.

Furthermore, we've only got one setting so far - confirmCloseAllTabs. This basically enables 1 and 2. #5874 enables 3 for _everyone_, without a way to opt-out.

All 6 comments

You know, I was going to just close this as a combo of #5301, #2976 and #5065. However, none of those cover this specific case, where we prevent closing a terminal tab/pane when there's more than one client in the process tree.

We really don't have a comprehensive discussion of all these requirements anywhere, do we?

Scenarios

  1. I want to never be prompted for confirmation
  2. I want to be prompted for confirmation when I close the window with multiple tabs
  3. I want to be prompted for confirmation when I close a tab with multiple panes
  4. I want to be prompted for confirmation when I close a pane with multiple clients
  5. I want to be prompted for confirmation when I close a pane always
  6. possibly more scenarios?
  7. I want to be prompted for confirmation when I close a pane with multiple clients, but I don't care about closing multiple tabs/panes with a single client in each.

Furthermore, we've only got one setting so far - confirmCloseAllTabs. This basically enables 1 and 2. #5874 enables 3 for _everyone_, without a way to opt-out.

Uhg, so the way I see it is something like this
image

which is, unwieldy to fill out, and I'm not super passionate about filling in right now. If someone has a better idea, please feel free to chime in.

You know, I was going to just close this as a combo of #5301, #2976 and #5065. However, none of those cover this specific case, where we prevent closing a terminal tab/pane when there's more than one client in the process tree.

We really don't have a comprehensive discussion of all these requirements anywhere, do we?

Scenarios

  1. I want to never be prompted for confirmation

  2. I want to be prompted for confirmation when I close the window with multiple tabs

  3. I want to be prompted for confirmation when I close a tab with multiple panes

  4. I want to be prompted for confirmation when I close a pane with multiple clients

  5. I want to be prompted for confirmation when I close a pane always

  6. possibly more scenarios?

  7. I want to be prompted for confirmation when I close a pane with multiple clients, but I don't care about closing multiple tabs/panes with a single client in each.

Furthermore, we've only got one setting so far - confirmCloseAllTabs. This basically enables 1 and 2. #5874 enables 3 for _everyone_, without a way to opt-out.

@zadjii-MSFT I think your comment is covered with #2976

Okay yea, i should have been more specific. We want to enable settings to enable/disable the prompts for each of these scenarios. Just prompting before the user quits, regardless of the content, isn't something that I think most people want.

Maybe it's gotta be a flag enum?

enum ConfirmOnClose
{
  Never = 0x0,
  MultipleProcesses = 0x1,
  MultiplePanes = 0x2,
  MultipleTabs = 0x4,
  Always = 0x8,
}

I'm adding the Always as another flag, for "I want to be prompted always, even if there's only one process in one pane in one tab"

Alright, I think I filled out actually just half this table, but here's an update
image

I'm not sure the "multipleTabs" columns of this table will be informative, but I might do them monday.

Now I need to make sure that the above scenarios are all reflected as actual cells in this grid.

Alright, I think I've done this as comprehensively as possible:
image

We've also got a bunch of scenarios listed above, so to re-iterate:

Scenarios

  1. I want to never be prompted for confirmation
  2. I want to be prompted for confirmation when I close the window with multiple tabs
  3. I want to be prompted for confirmation when I close a tab with multiple panes
  4. I want to be prompted for confirmation when I close a pane with multiple clients
  5. I want to be prompted for confirmation when I close a pane always
  6. possibly more scenarios?
  7. I want to be prompted for confirmation when I close a pane with multiple clients, but I don't care about closing multiple tabs/panes with a single client in each.
  8. I want to be prompted always, even if there's only one process in one pane in one tab

The above chart was made with one key assumption. There are basically three actions - closePane, closeTab, and closeWindow. Each one of these actions fundamentally also performs each of the preceding actions on all of the panes/tabs within the tab/window. If any of the preceding actions wants to warn the user, then the executed action should wait for the warning.

So if the user wants to be warned when they close multiple panes in a single tab, and they try to closeWindow a window which has a single tab with multiple panes, that should wait for a warning to be shown.

In my understanding, scenario 5 is no different than scenario 8.

I also considered another setting structure that was more like:

closePaneWarning: ["never", "multipleProcesses", "always"]
closeTabWarning: ["never", "multiplePanes", "always"]
closeWindowWarning: ["never", "multipleTabs", "always"]

This would be a more expressive set of settings with 27 possible combinations (as opposed to the 9 unique cases above). However, if we stick with the same assumption as above, I'm not sure there are actually 27 unique cases. If any child warning "infects" a parent command, then I hypothesize these 27 cases would simplify down to the same 9 cases.

This raises the question if our original assumption is useful or not. Do users really want to be able to be warned when they closeTab with multiple panes, but not when they closeWindow with a tab with multiple panes (simultaneously)? That doesn't really make sense to me. I'm sure there's some user out there who _might_ want that behavior, but I'd argue that it's confusing enough that most users wouldn't want it and it would lead to more confusion than not.


So, in my opinion, using the ConfirmOnClose: [Never, MultipleProcesses, MultiplePanes, MultipleTabs, Always] values make sense to me, and seem to get us the full level of fidelity that would be expected.

Now it's another matter of

  • how exactly do we express this setting
  • technically, how do we get a pane close warning to prevent the window from closing?

    • This includes questions like: "if the user tries to close the window and one tab doesn't want to close, then do we wait until all that tab's warning is accepted before closing _any_ tabs? What if two tabs want to warn on an exit?"

Was this page helpful?
0 / 5 - 0 ratings