-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Refactor how connection restarting is handled #14548
Conversation
…arting-attempt-1-backport
…arting-attempt-1-backport
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, some big questions. I don't love how we're becoming more stringly-typed but perhaps it offers us some heretofore unobserved opportunities...
if (auto conpty{ existingConnection.try_as<ConptyConnection>() }) | ||
{ | ||
connectionInfo = TerminalConnection::ConnectionInformation(winrt::name_of<TerminalConnection::ConptyConnection>(), | ||
conpty.ToSettings()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like ConptyConnection (or, any connection) should be able to produce a fully-formed ConnectionInformation
itself, without the consumer needing to know about its classname
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That... might? be able to be done. Not sure it's immediately relevant here (in the defterm context). But I guess it could be ConptyConnection::CreateConnectionInfo(settings...) -> ConnectionInfo
, and have it fill in its own name.
@@ -2721,10 +2744,15 @@ namespace winrt::TerminalApp::implementation | |||
if (bothAltsPressed) | |||
{ | |||
std::tie(connection, debugConnection) = OpenDebugTapConnection(connection); | |||
// Debug Tap connections aren't really restartable. The |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so what happens if you do restart one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can restart the underlying connection, but not the debugtap-ness of it. The debug spew just stops, but the real pane gets restarted.
…arting-attempt-1-backport
…arting-attempt-1-backport
…arting-attempt-1-backport
…arting-attempt-1-backport
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
14/15
@@ -35,6 +35,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |||
winrt::fire_and_forget UpdateControlSettings(Control::IControlSettings settings, Control::IControlAppearance unfocusedAppearance); | |||
IControlSettings Settings() const; | |||
|
|||
TerminalConnection::ConnectionInformation ConnectionInfo(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't totally understand why TerminalPage can't just make a totally new connection out of nothing - I find it so weird that TermControl now has a Connection (which we gave it) and a ConnectionInfo (which we used to make the Connection, and then also gave it). How would a public user of TermControl's public API even know what to do with all of these members?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love the pattern of storing effectively random app data on random other classes, you know? We did the same for Profile (and pushed it all the way down to the Core)...
// connection's settings. This'll cause conpty to restart | ||
// the connection at the current place in the buffer. | ||
_ConnectionInfo.Settings().Insert(L"inheritCursor", Windows::Foundation::PropertyValue::CreateBoolean(true)); | ||
auto c = TerminalConnection::ConnectionInformation::CreateConnection(_ConnectionInfo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, I see, but I still don't love it. "Sometimes the connection comes from the app and sometimes TermControl spontaneously creates life and seeds it onto an empty planet makes its own connection".
if (ch == Enter) | ||
// If we have a connection info with which to try and re-create the | ||
// connection, then let's try doing that on Enter | ||
if (_ConnectionInfo != nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this puts us in a really weird position, where ConptyConnection
is responsible for printing out the "press ^D to restart" message, but TermControl is ultimately responsible for handling it.
But at the same time, this means that users of other connections (#4661) won't be told that ^D/Enter are options... but they MIGHT be? If they can be reconstructed via ConnectionInfo?
{ | ||
if (_connection) | ||
{ | ||
_connectionOutputEventRevoker.revoke(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overwriting _connectionStateChangedRevoker
later should revoke it automatically, without you needing to check this
// Starting Directory - alas, we don't know that for a defterm connection. | ||
// The Core might be able to fill it in, if the client app ever tells the | ||
// Terminal. | ||
Windows::Foundation::Collections::ValueSet ConptyConnection::GetDeftermSettings() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for my own understanding
We have to use this in the magical scenario where we got a connection created out of nowhere and we had no way to inform TerminalPage what settings it started with?
Closed in favor of #15240 |
A different take on #14548. > We didn't love that a connection could transition back in the state diagram, from Closed -> Start. That felt wrong. To remedy this, we're going to allow the ControlCore to... ASK the app to restart its connection. This is a much more sensible approach, than leaving the ConnectionInfo in the core and having the core do the restart itself. That's mental. Cleanup from #14060 Closes #14327 Obsoletes #14548
Admittedly, this is a lot of annoying plumbing.
We didn't love that a connection could transition back in the state diagram, from Closed -> Start. That felt wrong. To remedy this, we're going to allow the ControlCore to re-create connections, all on its own. This builds on a lot of work that was originally done for Process Model v2 (#5000), and was originally slated to be merged in #12938.
Basically, all the properties for a Connection are stashed already in a
ConnectionState
object. We're gonna take that, and stash the info in the ControlCore. When the control wants to restart the connection, it just uses that to rebuild a new one.Cleanup from #14060
Closes #14327