"You are about to close a read-only terminal" popup does not appear if I select "Close Tab" from the menu again #13036

Closed
opened 2026-01-31 03:31:59 +00:00 by claunia · 7 comments
Owner

Originally created by @KalleOlaviNiemitalo on GitHub (Mar 15, 2021).

Environment

Windows build number: 10.0.19042.867
Windows Terminal version (if applicable): Preview 1.7.572.0

Steps to reproduce

  1. Start a new session, e.g. Command Prompt.
  2. Press Ctrl+Shift+P to open the command palette, and choose "Toggle pane read-only mode". A lock icon appears in the tab header.
  3. Right-click the tab header. A menu opens.
  4. Select "Close Tab" from the menu. A warning pops up: "You are about to close a read-only terminal. Do you wish to continue?"
  5. Click "Cancel".
  6. Right-click the tab header again. A menu opens.
  7. Select "Close Tab" from the menu.

Expected behavior

The same warning should pop up again.

Actual behavior

The warning does not pop up and the tab does not close.

Notes

If you try to close the pane by pressing Ctrl+Shift+W or choosing "Close pane" from the command palette, then that pops up the warning each time.

Related to https://github.com/microsoft/terminal/issues/6981.

Originally created by @KalleOlaviNiemitalo on GitHub (Mar 15, 2021). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 10.0.19042.867 Windows Terminal version (if applicable): Preview 1.7.572.0 ``` # Steps to reproduce 1. Start a new session, e.g. Command Prompt. 2. Press Ctrl+Shift+P to open the command palette, and choose "Toggle pane read-only mode". A lock icon appears in the tab header. 3. Right-click the tab header. A menu opens. 4. Select "Close Tab" from the menu. A warning pops up: "You are about to close a read-only terminal. Do you wish to continue?" 5. Click "Cancel". 6. Right-click the tab header again. A menu opens. 7. Select "Close Tab" from the menu. # Expected behavior The same warning should pop up again. # Actual behavior The warning does not pop up and the tab does not close. # Notes If you try to close the pane by pressing Ctrl+Shift+W or choosing "Close pane" from the command palette, then that pops up the warning each time. Related to <https://github.com/microsoft/terminal/issues/6981>.
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Mar 15, 2021):

TerminalPage::_ShowCloseReadOnlyDialog is called from two functions:

TerminalPage::_RemoveTab is called from four functions:

TerminalPage::_RemoveTabViewItem, TerminalPage::_CloseFocusedTab, and TerminalPage::_CloseFocusedPane discard the IAsyncAction returned by TerminalPage::_RemoveTab, instead of awaiting it. Does that cause the coroutine to be aborted so that some cleanup is skipped?

@KalleOlaviNiemitalo commented on GitHub (Mar 15, 2021): TerminalPage::_ShowCloseReadOnlyDialog is called from two functions: - `winrt::Windows::Foundation::IAsyncAction TerminalPage::_RemoveTab(winrt::TerminalApp::TabBase tab)` <https://github.com/microsoft/terminal/blob/89c9e6db847ed7f262d1f5a7f972ef004320ff6e/src/cascadia/TerminalApp/TerminalPage.cpp#L1292> - `winrt::fire_and_forget TerminalPage::_CloseFocusedPane()` <https://github.com/microsoft/terminal/blob/89c9e6db847ed7f262d1f5a7f972ef004320ff6e/src/cascadia/TerminalApp/TerminalPage.cpp#L1689> TerminalPage::_RemoveTab is called from four functions: - `void TerminalPage::_RemoveTabViewItem(const MUX::Controls::TabViewItem& tabViewItem)` <https://github.com/microsoft/terminal/blob/89c9e6db847ed7f262d1f5a7f972ef004320ff6e/src/cascadia/TerminalApp/TerminalPage.cpp#L1280> - `void TerminalPage::_CloseFocusedTab()` <https://github.com/microsoft/terminal/blob/89c9e6db847ed7f262d1f5a7f972ef004320ff6e/src/cascadia/TerminalApp/TerminalPage.cpp#L1667> - `winrt::fire_and_forget TerminalPage::_CloseFocusedPane()` <https://github.com/microsoft/terminal/blob/89c9e6db847ed7f262d1f5a7f972ef004320ff6e/src/cascadia/TerminalApp/TerminalPage.cpp#L1713> - `winrt::fire_and_forget TerminalPage::_RemoveTabs(const std::vector<winrt::TerminalApp::TabBase> tabs)` <https://github.com/microsoft/terminal/blob/89c9e6db847ed7f262d1f5a7f972ef004320ff6e/src/cascadia/TerminalApp/TerminalPage.cpp#L1749> TerminalPage::_RemoveTabViewItem, TerminalPage::_CloseFocusedTab, and TerminalPage::_CloseFocusedPane discard the IAsyncAction returned by TerminalPage::_RemoveTab, instead of awaiting it. Does that cause the coroutine to be aborted so that some cleanup is skipped?
Author
Owner

@zadjii-msft commented on GitHub (Mar 15, 2021):

Huh. That's weird. Not totally sure why, but that's definitely happening. Thanks!

/cc @Don-Vito this seems like the kind of thing that interests you 😋

@zadjii-msft commented on GitHub (Mar 15, 2021): _Huh_. That's weird. Not totally sure _why_, but that's definitely happening. Thanks! /cc @Don-Vito this seems like the kind of thing that interests you 😋
Author
Owner

@KalleOlaviNiemitalo commented on GitHub (Mar 15, 2021):

If discarding the IAsyncAction really causes this, then can the compiler be made to warn about such usage, perhaps by making C++/WinRT emit [[nodiscard]] somewhere?

@KalleOlaviNiemitalo commented on GitHub (Mar 15, 2021): If discarding the IAsyncAction really causes this, then can the compiler be made to warn about such usage, perhaps by making C++/WinRT emit `[[nodiscard]]` somewhere?
Author
Owner

@Don-Vito commented on GitHub (Mar 21, 2021):

@zadjii-msft - please assign to me 😄
@KalleOlaviNiemitalo - thanks for the research (congrats for the profile picture!)

@Don-Vito commented on GitHub (Mar 21, 2021): @zadjii-msft - please assign to me :smile: @KalleOlaviNiemitalo - thanks for the research (congrats for the profile picture!)
Author
Owner

@Don-Vito commented on GitHub (Mar 21, 2021):

So the problem is that click on the "close tab" goes directly for the tab->rootPane->Close(), rather than asking the TerminalPage to remove the tab (which is not very successful design decision IMHO). Unfortunately, Pane::Close sets isClosing to true, even if the closing is dismissed, and as a result the next invocations of Pane::Close do nothing:

void Pane::Close()
{
    // We should not set the Pane to closing state if Closing is dismissed.
    if (!_isClosing.exchange(true))
    {        
        _ClosedHandlers(nullptr, nullptr);
    }
}
@Don-Vito commented on GitHub (Mar 21, 2021): So the problem is that click on the "close tab" goes directly for the tab->rootPane->Close(), rather than asking the TerminalPage to remove the tab (which is not very successful design decision IMHO). Unfortunately, Pane::Close sets isClosing to true, even if the closing is dismissed, and as a result the next invocations of Pane::Close do nothing: ``` void Pane::Close() { // We should not set the Pane to closing state if Closing is dismissed. if (!_isClosing.exchange(true)) { _ClosedHandlers(nullptr, nullptr); } } ```
Author
Owner

@ghost commented on GitHub (Apr 14, 2021):

:tada:This issue was addressed in #9571, which has now been successfully released as Windows Terminal v1.7.1033.0.🎉

Handy links:

@ghost commented on GitHub (Apr 14, 2021): :tada:This issue was addressed in #9571, which has now been successfully released as `Windows Terminal v1.7.1033.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.7.1033.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@ghost commented on GitHub (Apr 14, 2021):

:tada:This issue was addressed in #9571, which has now been successfully released as Windows Terminal Preview v1.8.1032.0.🎉

Handy links:

@ghost commented on GitHub (Apr 14, 2021): :tada:This issue was addressed in #9571, which has now been successfully released as `Windows Terminal Preview v1.8.1032.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.8.1032.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#13036