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

Separate between Close Tab Requested and Tab Closed flows #9574

Merged
8 commits merged into from
Mar 30, 2021

Conversation

Don-Vito
Copy link
Contributor

@Don-Vito Don-Vito commented Mar 21, 2021

Summary of the Pull Request

Currently, both when the tab is already closed, and when there is a
request to close a tab (might be rejected), we go through the same flow
in TerminalPage.

This might leave the system in inconsistent state, as the side-effects
of closing will persist even if the closing was aborted.

This PR separates between the two flows, by introducing a CloseRequested
event to the TabBase.

This event is used to inform the upper tier (the terminal page) about
the request and to trigger the same logic that happens when the tab is
closed directly from the terminal page (e.g., by clicking close on the
tab view).

The Closed event will be used only to handle the actual closing of the
tab. It will ensure that the tab gets removed from the terminal page if
required.

As a result, it a read-only pane will be closed non-interactively (aka
connection exits), the tab closed flow will be invoked, and no user
prompt will be shown.

References

PR Checklist

@DHowett
Copy link
Member

DHowett commented Mar 22, 2021

When I read #9572, I dearly hoped that you were going to do a Close/Requested split. This is amazing. I can't wait to read it on Monday.

@skyline75489
Copy link
Collaborator

Hey we have a conflict here😅

Wonder if msftbot can send notifications when someone’s PR has conflicts with target branch. I’ve seen other boys doing this.

@@ -120,8 +120,6 @@ class Pane : public std::enable_shared_from_this<Pane>

Borders _borders{ Borders::None };

std::atomic<bool> _isClosing{ false };
Copy link
Member

Choose a reason for hiding this comment

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

Is there another way that we're tracking a pane entering the closing state? Is it no longer necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I added it initially doesn't exist anymore, hence I removed it. We can also leave it, as it doesn't harm the correctness (closing is irreversible). I am fine with both 😊

src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
@@ -1794,7 +1813,7 @@ namespace winrt::TerminalApp::implementation
{
for (auto& tab : tabs)
{
co_await _RemoveTab(tab);
co_await _HandleCloseTabRequested(tab);
Copy link
Member

Choose a reason for hiding this comment

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

Is this one correct? This is an explicit action for removing all the tabs. What's it hooked up to, and is that thing expecting that it simply request closure?

Copy link
Member

Choose a reason for hiding this comment

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

What is the user experience here like? Do we get multiple dialogs? "Yes, close all tabs. YES, I understand this tab is read-only."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. This is the behavior we have today, that for each read-only tab asks if it should be closed or not.

src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
@@ -788,7 +788,7 @@ namespace winrt::TerminalApp::implementation
closeTabMenuItem.Click([weakThis](auto&&, auto&&) {
Copy link
Member

Choose a reason for hiding this comment

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

do we need to do the same for Settings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Settings inherit it from TabBase that already uses the correct event 😊

@ghost ghost added Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Mar 29, 2021
@Don-Vito Don-Vito requested a review from DHowett March 29, 2021 18:07
@DHowett
Copy link
Member

DHowett commented Mar 29, 2021

I suspect that Mike moving all of the tab management stuff into TabManagement.cpp just exploded most of your changes (thus the conflict). Argh! Sorry!

@zadjii-msft
Copy link
Member

(sorry)

@DHowett
Copy link
Member

DHowett commented Mar 30, 2021

I'll resolve the conflict while I'm here. Just to get this merged. 😄

@DHowett
Copy link
Member

DHowett commented Mar 30, 2021

Manually merged (UGH) by replicating the changes in the new files. Build is running

@DHowett
Copy link
Member

DHowett commented Mar 30, 2021

I've built and tested this, and it appears to act the same.

@DHowett DHowett added the AutoMerge Marked for automatic merge by the bot when requirements are met label Mar 30, 2021
@ghost
Copy link

ghost commented Mar 30, 2021

Hello @DHowett!

Because this pull request has the AutoMerge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit c585a93 into microsoft:main Mar 30, 2021
@ghost
Copy link

ghost commented Apr 14, 2021

🎉Windows Terminal Preview v1.8.1032.0 has been released which incorporates this pull request.:tada:

Handy links:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants