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

Process actions sync. on startup; don't dupe nonexistent profile #5090

Merged
merged 39 commits into from
Mar 26, 2020

Conversation

zadjii-msft
Copy link
Member

@zadjii-msft zadjii-msft commented Mar 23, 2020

This PR has evolved to encapsulate two related fixes that I can't really
untie anymore.

#2455 - Duplicating a tab that doesn't exist anymore

This was the bug I was originally fixing in #4429.

When the user tries to duplicateTab with a profile that doesn't exist
anymore (like might happen after a settings reload), don't crash.

As I was going about adding tests for this, got blocked by the fact that
the Terminal couldn't open any panes while the TerminalPage was size
0x0. This had two theoretical solutions:

  • Fake the TerminalPage into thinking it had a real size in the test -
    probably possible, though I'm unsure how it would work in practice.
  • Change Panes to not require an ActualWidth, ActualHeight on
    initialization.

Fortuately, the second option was something else that was already on my
backlog of bugs.

#4618 - wt command-line can't consistently parse more than one arg

Presently, the Terminal just arbitrarily dispatches a bunch of handlers
to try and handle all the commands provided on the commandline. That's
lead to a bunch of reports that not all the commands will always get
executed, nor will they all get executed in the same order.

This PR also changes the TerminalPage to be able to dispatch all the
commands sequentially, all at once in the startup. No longer will there
be a hot second where the commands seem to execute themselves in from of
the user - they'll all happen behind the scenes on startup.

This involved a couple other changes areound the TerminalPage

  • I had to make sure that panes could be opened at a 0x0 size. Now they
    use a star sizing based off the percentage of the parent they're
    supposed to consume, so that when the parent does get laid out,
    they'll take the appropriate size of that parent.
  • I had to do some math ahead of time to try and calculate what a
    SplitState::Automatic would be evaluated as, despite the fact that
    we don't actually know how big the pane will be.
  • I had to ensure that focus-tab commands appropriately mark a single
    tab as focused while we're in startup, without roundtripping to the
    Dispatcher thread and back

References

#4429 - the original PR for #2455
#5047 - a follow-up task from discussion in #4429
#4953 - a PR for making panes use star sizing, which was immensly
helpful for this PR.

Detailed Description of the Pull Request / Additional comments

CascadiaSettings::BuildSettings can throw if the GUID doesn't exist.
This wraps those calls up with a try/catch.

It also adds a couple tests - a few SettingsTests for try/catching
this state. It also adds a XAML-y test in TabTests that creates a
TerminalPage and then performs som UI-like actions on it. This test
required a minor change to how we generate the new tab dropdown - in the
tests, Application::Current() is not a TerminalApp::App, so it
doesn't have a Logic() to query. So wrap that in a try/catch as well.

While working on these tests, I found that we'd crash pretty agressively
for mysterious reasons if the TestHostApp became focused while the test
was running. This was due to a call in
TSFInputControl::NotifyFocusEnter that would callback to
TSFInputControl::_layoutRequested, which would crash on setting the
MaxSize of the canvas to a negative value. This PR includes a hotfix
for that bug as well.

Validation Steps Performed

  • Manual testing with a lot of commands in a commandline
  • run the tests
  • Team tested in selfhost

Closes #2455
Closes #4618

  You need to initialize a TerminalPage weirdly in the test, including _not_ checking App.Logic(), since the App doesn't have a Logic()
# Conflicts:
#	src/cascadia/LocalTests_TerminalApp/SettingsTests.cpp
#	src/cascadia/TerminalApp/TerminalPage.cpp
  Okay this is harder, but maybe not impossible, but probably impossible in v1.

  The Profile knows how to build the connection settings, and the
  ControlSettings, etc. However, when the settings reloads like in this bug,
  we'll remove all the old profiles, and build a new list.

  If we wanted the case 1 behavior, we could wait until the Profile is a winrt
  object, then have each Pane hold a strong ref to the Profile that it's
  hosting. Then it would be trivial to be able to duplicate the settings from
  it. I believe that work is tracked in #3998.

  How palatable is doing case 3 now (to fix the crash), then filing a follow up
  to do case 1 once #3998 is done?
@DHowett-MSFT
Copy link
Contributor

Does this fix the minor visual issue where you do wt ; ; ; ; ; and the tabs all pop into existence slowly?

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Mar 23, 2020
@zadjii-msft
Copy link
Member Author

Does this fix the minor visual issue where you do wt ; ; ; ; ; and the tabs all pop into existence slowly?

Yes, yes it does :)

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Most of the initialization stuff is pretty foreign for me. I still have to review the Tests but I'll do that later.

src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/Pane.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
@zadjii-msft
Copy link
Member Author

Sorry all for submitting the PR before pushing the last code cleanup commit 😅 Things should be much better now

Copy link
Contributor

@DHowett-MSFT DHowett-MSFT left a comment

Choose a reason for hiding this comment

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

Let's do it. I'll cut a SH build when this is in.

@DHowett-MSFT
Copy link
Contributor

I'm producing a selfhost test build with this pre-merged; it is likely ready, but I'll let you make that call.

@zadjii-msft
Copy link
Member Author

Note to the team: I'm giving this like 48 hours of selfhost before we ship it. Hence why I haven't AutoMerge'd this yet ☺️

@DHowett-MSFT
Copy link
Contributor

This feels so much better. We should just hashtag shipit

@DHowett-MSFT
Copy link
Contributor

@jsoref this may be what you were talking about on the other thread; I’m not getting a green check here despite merging in master?

@jsoref
Copy link
Contributor

jsoref commented Mar 25, 2020

@DHowett-MSFT : hmm, that isn't the right explanation for this. @german-one 's action is running in his fork (which is good) -- https://github.com/german-one/terminal/actions. The action should also be running on branches in this repo, but it doesn't appear to be: https://github.com/Microsoft/terminal/actions.

Fwiw, roughly the same configuration is in play here: https://github.com/check-spelling/examples-testing/actions and it's working:
check-spelling/examples-testing@0a7e8a2

Is it possible that these branches also have tags? If so, we might try removing:
https://github.com/microsoft/terminal/blob/master/.github/workflows/spelling.yml#L6-L7

I added that because for our repositories we were experiencing double builds in github.

@jsoref
Copy link
Contributor

jsoref commented Mar 25, 2020

@DHowett-MSFT : can you try making a branch of https://github.com/jsoref/terminal/pull/new/drop-tags-ignore in Microsoft/terminal? (no PR, just pull that branch into your repo and push it into github with a branch name)

@DHowett-MSFT
Copy link
Contributor

6f717ae

@DHowett-MSFT
Copy link
Contributor

See, this is why I wanted to run spell on this branch :D

@DHowett-MSFT DHowett-MSFT changed the title Process startup commands synchronously on startup, and don't crash when the user tries to duplicate a tab with a profile that no longer exists Process actions sync. on startup; don't dupe nonexistent profile Mar 26, 2020
@DHowett-MSFT DHowett-MSFT merged commit b3fa88e into master Mar 26, 2020
@DHowett-MSFT DHowett-MSFT deleted the dev/migrie/b/pane-initialization-order branch March 26, 2020 00:03
@ghost
Copy link

ghost commented Apr 22, 2020

🎉Windows Terminal Preview v0.11.1121.0 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-User Interface Issues pertaining to the user interface of the Console or Terminal Product-Terminal The new Windows Terminal.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wt command-line cannot consistently parse more than one argument Bug Report: Cannot find profile --> Crash
6 participants