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

Add restore recently closed panes #11471

Merged
4 commits merged into from
Jan 11, 2022

Conversation

Rosefield
Copy link
Contributor

@Rosefield Rosefield commented Oct 9, 2021

Summary of the Pull Request

Add an action to restore the last closed pane or tab. When all you have is restoring last sessions everything looks like a std::vector<ActionAndArgs>.

References

#9800

PR Checklist

  • Partially closes Feature Request - Restore closed tab #960
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Documentation updated. If checked, please file a pull request on our docs repo and link it here: #xxx
  • Schema updated.
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Detailed Description of the Pull Request / Additional comments

  • Keep a buffer of panes/tabs that were closed recently in the form of a list
    of actions to remake it.
  • To restore the pane or tab just run the list of actions.
  • This (deliberately) does not restore the exact visual state as focus could
    have changed / new panes might have been created in the mean time. Mostly
    this means that restoring a pane will just attach to the currently focused
    pane instead of whatever its old neighbor was.
  • Buffer is limited to 100 entries which might as well be "infinite" by most reasonable
    standards, but prevents complaints about there being memory leaks in long running
    instances.
  • The action name could be potentially changed, but it felt unwieldy as "restoreLastClosedPaneOrTab".
  • This does not handle restoring the actual running contents of a pane.

Validation Steps Performed

- Keep a buffer of panes/tabs that were closed recently in the form of a list
  of actions to remake it.
- To restore the pane or tab just run the list of actions.
- This (deliberately) does not restore the exact visual state as focus could
  have changed / new panes might have been created in the mean time. Mostly
  this means that restoring a pane will just attach to the currently focused
  pane instead of whatever its old neighbor was.
@ghost ghost added Area-Settings Issues related to settings and customizability, for console or terminal Area-User Interface Issues pertaining to the user interface of the Console or Terminal Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal. labels Oct 9, 2021
@Rosefield
Copy link
Contributor Author

2021-10-09.15-27-45.mp4

@Rosefield
Copy link
Contributor Author

Also I understand that the next release is probably 2021-10-15 and this probably won't get into 1.12

@@ -474,6 +474,23 @@ namespace winrt::TerminalApp::implementation
co_return;
}
}

if (const auto terminalTab = _GetTerminalTabImpl(tab))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we check the size of _previouslyClosedPanesAndTabs in this function? (like how we do in _CloseFocusedPane)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I probably just forgot. I added that as an afterthought right before pushing. It probably isn't even necessary overall since the vector in most reasonable cases won't be more than 10s to 100s of KB of data, but I'm curious what everyone's thoughts are on that.

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Honestly, this is just a nit and a question. I'm cool signing off on this, but I wanna make sure we've considered the parent pane situation first.

The code looks great, the implementation is simple and straightforward, thanks!


_AddPreviouslyClosedPaneOrTab(std::move(actions));
}
else if (tab.try_as<SettingsTab>())
Copy link
Member

Choose a reason for hiding this comment

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

this almost seems like TabBase should have a virtual method like BuildStartupActions that both TerminalTab and SettingsTab override with their specific implementations...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that seems reasonable.

src/cascadia/TerminalApp/TabManagement.cpp Show resolved Hide resolved
Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

yea I'm cool with this

@zadjii-msft zadjii-msft added the Needs-Second It's a PR that needs another sign-off label Dec 2, 2021
@Rosefield
Copy link
Contributor Author

Ping on this. Not sure if people are out for the holiday season yet.

@Rosefield
Copy link
Contributor Author

new year ping.

@zadjii-msft
Copy link
Member

@DHowett that means you. There was a reason you had me assign you last month, I'm sure of it (but I can't remember why)

@zadjii-msft zadjii-msft changed the title GH960 Add restore recently closed panes Add restore recently closed panes Jan 10, 2022
Comment on lines +404 to +411
if (const auto size = _previouslyClosedPanesAndTabs.size(); size > 150)
{
const auto it = _previouslyClosedPanesAndTabs.begin();
// delete 50 at a time so that we don't have to do an erase
// of the buffer every time when at capacity.
_previouslyClosedPanesAndTabs.erase(it, it + (size - 100));
}

Copy link
Member

Choose a reason for hiding this comment

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

Out of curiosity... when this has like 149 actions in it and you restore it... does the Terminal UI wildly flicker as it plays all the actions back until it settles? I'm concerned that either someone will interact with it in some way while it's playing back or that it will look horrendous on a slower system as it recreates a bunch of stuff.

Copy link
Contributor Author

@Rosefield Rosefield Jan 10, 2022

Choose a reason for hiding this comment

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

To disambiguate, _previouslyClosedPanesAndTabs itself contains vectors of actions, and when you restore the last closed thing it will pop one vector and run all of those. The size limit, whatever it ends up being, shouldn't meaningfully affect the performance of the UI. Technically this erase call will end up calling a memcpy and some destructors, but that should be fast.

To answer your intended question, in the video above I show what it looks like to restore a tab with 7 panes in it. It does take a second for it to resolve everything since it is spawning new processes/terminal controls for each one. Of course that is in a debug build so it might be faster in a release build.

I did another test just quickly (still a debug build, with debugger attached), restoring a tab that had 20 powershell panes in it took about ~6 seconds and the UI was unresponsive during that time. That corresponds to ~40 actions being executed: 20 split panes and some move focus to put the panes in the right spots.

Copy link
Member

Choose a reason for hiding this comment

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

Huh, down the line, we should display a message like "setting up your workspace..." or something like that rather than being unresponsive. That'd be some nice polish instead of sitting with an unresponsive UI haha.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah ok. I'm fine with taking it for the sake of getting the useful feature in, but Carlos is right that we should probably add some small polish to it in the future, if someone complains or we feel like it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the case of restoring a single pane, it won't be any slower than if the user did a split pane manually. It is only on the case where someone restores a tab with a bunch of panes on it that it takes some time. There is the benefit of the user (roughly) knowing what they are recreating, so they shouldn't be too surprised if it takes a second.

That being said, this is a fairly naive implementation so there is probably be room for improvement,

Copy link
Member

@miniksa miniksa left a comment

Choose a reason for hiding this comment

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

I've talked with @DHowett and he's fine with me being second on this. Let's do it and see how it rolls.

@zadjii-msft zadjii-msft added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 11, 2022
@ghost
Copy link

ghost commented Jan 11, 2022

Hello @zadjii-msft!

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 ec226ee into microsoft:main Jan 11, 2022
@Rosefield Rosefield deleted the feature/gh960-restore-last-pane-or-tab branch January 11, 2022 20:08
@Rosefield
Copy link
Contributor Author

I'm free~~~.

A number of the items on 9800 can probably be updated as well since they have been fixed / are stale.

@DHowett
Copy link
Member

DHowett commented Jan 11, 2022

Thanks so much for doing this 😄

@ghost
Copy link

ghost commented Feb 3, 2022

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

Handy links:

@ghost ghost mentioned this pull request Feb 3, 2022
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Area-User Interface Issues pertaining to the user interface of the Console or Terminal AutoMerge Marked for automatic merge by the bot when requirements are met Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Second It's a PR that needs another sign-off Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request - Restore closed tab
6 participants