Skip to content

Replace confirmCloseAllTabs with confirmOnClose#20055

Merged
carlos-zamora merged 3 commits into
mainfrom
dev/cazamor/confirmOnClose
May 4, 2026
Merged

Replace confirmCloseAllTabs with confirmOnClose#20055
carlos-zamora merged 3 commits into
mainfrom
dev/cazamor/confirmOnClose

Conversation

@carlos-zamora
Copy link
Copy Markdown
Member

@carlos-zamora carlos-zamora commented Apr 3, 2026

Summary of the Pull Request

Replaces the warning.confirmCloseAllTabs setting with a warning.confirmOnClose enum setting that accepts the following:

  • never: don't present a warning dialog when closing a session
  • automatic: present a warning dialog when closing multiple tabs/panes at once
  • always: present a warning dialog when closing any session

The confirmation dialog contains a "don't ask me again" checkbox. When checked, we update the setting to never.

This setting also affects the following actions:

  • "close other tabs"
  • "close tabs after"
  • "close other panes"
  • "quit"
    The appropriate confirmation dialog is shown in these scenarios. We also present an aggregate dialog instead of prompting the user once per tab/pane. If there are no other tabs/panes, we don't present a dialog and treat the key binding as unhandled (passing the key through).

References and Relevant Issues

Iteration of #19944

Validation Steps Performed

  • closing a tab:
    • ✅ 1 pane --> no dialog
    • ✅ 2 panes --> dialog
    • ✅ action and middle clicking tab trigger same flow
  • close all other tabs:
    • ✅ no other tabs --> no dialog
    • ✅ 1 other tab --> dialog
  • close all other panes:
    • ✅ 1 pane --> no dialog
    • ✅ 2 panes --> dialog
  • close all tabs after the current tab:
    • ✅ no tabs after --> no dialog (even if tabs before)
    • ✅ 1 tab after --> dialog
  • close window:
    • ✅ 2 tabs --> dialog
    • ✅ 2 panes --> dialog
    • ✅ 1 tab with one pane --> no dialog
  • Quit the Terminal:
    • ✅ 3 windows --> dialog
    • ✅1 window --> dialog
  • ✅ "don't ask me again" checkbox checked --> setting changed to "never"
  • ✅ "never" --> no dialog for scenarios above
  • ✅ "always" --> dialog always appears, even when closing a single pane

PR Checklist

Closes #5301
Closes #6641
"don't ask me again" checkbox is also mentioned in #10000

Co-authored by @zadjii-msft

@microsoft-github-policy-service microsoft-github-policy-service Bot added Issue-Task It's a feature request, but it doesn't really need a major design. Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Priority-2 A description (P2) Product-Terminal The new Windows Terminal. labels Apr 3, 2026
@carlos-zamora
Copy link
Copy Markdown
Member Author

carlos-zamora commented Apr 3, 2026

Demo

Settings UI:
settings UI exposure

Dialog UI:
dialog UI

Here's all the possible strings for the dialog:
image

@Hlsgs
Copy link
Copy Markdown

Hlsgs commented Apr 3, 2026

Apologies if this is not the proper place for this question: is it possible to implement a fourth setting that would mean "present a warning dialog when closing multiple tabs/panes at once AND at least one background tab is in Running State"?

@carlos-zamora
Copy link
Copy Markdown
Member Author

Feedback from bug bash (4/7):

I would like more explanatory messages inside the dialog content, like "Quitting Terminal will close all windows." (this one is probably fine) "Closing this window will close all tabs and panes inside it." "Closing this tab will close all panes inside it."

@carlos-zamora
Copy link
Copy Markdown
Member Author

carlos-zamora commented Apr 8, 2026

Note to self: also figure out #20083

(sorry for the back and forth Hlsg!)

Copy link
Copy Markdown
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

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

Found 1 2? bugs, otherwise LGTM.

Comment thread doc/cascadia/profiles.schema.json
_RemoveTabs(tabsToRemove);

actionArgs.Handled(true);
actionArgs.Handled(!tabsToRemove.empty());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this just a change on technical correctness or is there a common situation where tabsToRemove ends up being empty?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This makes it so that if there aren't any tabs to remove, we don't mark the event as handled. We disable the option in the context menu, but a user can still call the appropriate action via a key binding. Marking it as unhandled means that we'll let the key chord pass through.

Comment thread src/cascadia/TerminalApp/TerminalPage.cpp Outdated
Comment thread src/cascadia/TerminalApp/TerminalPage.cpp Outdated
Comment thread src/cascadia/TerminalApp/TerminalPage.cpp Outdated
Comment thread src/cascadia/TerminalApp/TabManagement.cpp Outdated
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 21, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Apr 29, 2026
@carlos-zamora carlos-zamora removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. labels Apr 29, 2026
@github-actions

This comment has been minimized.

@carlos-zamora carlos-zamora merged commit b753e3d into main May 4, 2026
20 checks passed
@carlos-zamora carlos-zamora deleted the dev/cazamor/confirmOnClose branch May 4, 2026 17:43

auto FromJson(const Json::Value& json)
{
return BaseEnumMapper::FromJson(json);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

curious - usually we don't need to override these...


// BODGY: After a ContentDialog is dismissed, FindName() can no longer
// resolve children inside it. Use Content() to get the checkbox directly.
const auto checkbox = dialog.Content().as<CheckBox>();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would rather you assign a name to the checkbox with x:Name and use it directly. That is less fragile than "treat the content as a checkbox" which will crash when we add more content.

}
dialog.Title(winrt::box_value(title));
dialog.PrimaryButtonText(primary);
dialog.CloseButtonText(RS_(L"ConfirmCloseDialog_Cancel"));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could be set in the resw, right


QuitRequested.raise(nullptr, nullptr);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

does this cause a behavioral change

Qmoony pushed a commit to Qmoony/terminal that referenced this pull request May 11, 2026
## Summary of the Pull Request
Replaces the `warning.confirmCloseAllTabs` setting with a
`warning.confirmOnClose` enum setting that accepts the following:
- `never`: don't present a warning dialog when closing a session
- `automatic`: present a warning dialog when closing multiple tabs/panes
at once
- `always`: present a warning dialog when closing any session

The confirmation dialog contains a "don't ask me again" checkbox. When
checked, we update the setting to `never`.

This setting also affects the following actions:
- "close other tabs"
- "close tabs after"
- "close other panes"
- "quit"
The appropriate confirmation dialog is shown in these scenarios. We also
present an aggregate dialog instead of prompting the user once per
tab/pane. If there are no other tabs/panes, we don't present a dialog
and treat the key binding as unhandled (passing the key through).

## References and Relevant Issues
Iteration of microsoft#19944 

## Validation Steps Performed
- closing a tab:
   - ✅ 1 pane --> no dialog
   - ✅ 2 panes --> dialog
   - ✅ action and middle clicking tab trigger same flow
- close all other tabs:
   - ✅ no other tabs --> no dialog
   - ✅ 1 other tab --> dialog
- close all other panes:
   - ✅ 1 pane --> no dialog
   - ✅ 2 panes --> dialog
- close all tabs after the current tab:
   - ✅ no tabs after --> no dialog (even if tabs before)
   - ✅ 1 tab after --> dialog
- close window:
   - ✅ 2 tabs --> dialog
   - ✅ 2 panes --> dialog
   - ✅ 1 tab with one pane --> no dialog
- Quit the Terminal:
   - ✅ 3 windows --> dialog
   - ✅1 window --> dialog
- ✅ "don't ask me again" checkbox checked --> setting changed to "never"
- ✅ "never" --> no dialog for scenarios above
- ✅ "always" --> dialog always appears, even when closing a single pane

## PR Checklist
Closes microsoft#5301 
Closes microsoft#6641
"don't ask me again" checkbox is also mentioned in microsoft#10000 

Co-authored by @zadjii-msft
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-UserInterface Issues pertaining to the user interface of the Console or Terminal Issue-Task It's a feature request, but it doesn't really need a major design. Priority-2 A description (P2) Product-Terminal The new Windows Terminal. zBugBash-Consider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a "remember my decision" checkbox to our confirmation dialogs closeTab should present a confirmation dialog

4 participants