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 support for restoring non-terminal panes, and opening them with splitPane, newTab #16914

Merged
merged 115 commits into from
Apr 5, 2024

Conversation

zadjii-msft
Copy link
Member

@zadjii-msft zadjii-msft commented Mar 21, 2024

This changes NewTabArgs, SplitPaneArgs, and NewWindowArgs to accept a INewContentArgs, rather than just a NewTerminalArgs. This allows a couple things:

  • Users can open arbitrary types of panes with the existing splitPane, newWindow actions, just by passing "type": "scartchpad" (for example). This is a lot more flexible than re-defining different "openScratchpad", "openTasksPane", etc, etc actions for every kind of pane.
  • This allows us to use the existing machinery of session restore to also restore non-terminal panes.

The type property was added to newTab, splitPane, newWindow. When omitted, we still just treat the json as a blob of NewTerminalArgs.

There's not actually any other kinds of INewContentArgs in this PR (other than the placeholder GenericContentArgs). In dev/migrie/fhl/md-pane, I have a type of pane that would LOVE to add some args here. So that's forward-thinking.

There's really just two stealth types of pane for now: settings, and scratchpad. Those I DON'T have as constants or anything in this PR. They probably should be? Though, I suspect around the time of the tasks & MD panes, I'll come up with whatever structure I actually want them to take.

future considerations here

  • In the future, this should allow extensions to say "I know how to host foo content", for 3p content.
  • The wt CLI args were not yet updated to also accept --type yet. There's no reason we couldn't easily do that.
  • I considered adding ICanHasCommandline to allow arbitrary content to generate a wt commandline-serializable string. Punted on that for now.

other PRs

Closes #17014

Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

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

LGTM, apart from the String Type which I have some concerns about.

src/cascadia/TerminalApp/AppActionHandlers.cpp Outdated Show resolved Hide resolved
Boolean Equals(INewContentArgs other);
UInt64 Hash();
INewContentArgs Copy();
String GenerateName();
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, I believe property-like functions are usually prefixed with Get.... Type should probably not be settable either.

Copy link
Member Author

Choose a reason for hiding this comment

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

Equals, Hash, Copy, and GenerateName were all just straight lifted out of NewTerminalArgs. I can rename them if you think it's important, but also, 🤷

Comment on lines 133 to 136
[default_interface] runtimeclass GenericContentArgs : INewContentArgs{
GenericContentArgs();
GenericContentArgs(String type);
};
Copy link
Member

Choose a reason for hiding this comment

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

I don't believe this would work well for an extension model as plugins may want arbitrary settings. It may be better to not have a string Type and instead have concrete runtimeclasses for each specific builtin Pane type. Extensions may define their own concrete types which we'll then somehow pass through to the plugin to get our IPaneContent or whatever. We can also skip that part of course and let such users create and pass IPaneContents directly to the term control constructor(s). In both cases however I would prefer concrete runtimeclasses.

Copy link
Member Author

Choose a reason for hiding this comment

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

Absolutely. As of this commit, the only real INewContentArgs is the NewTerminalArgs. The settings pane and scratch pane don't really have settings, so in the name of... laziness I guess... I used the smallest possible placeholder for their internal representation. GenericContentArgs was never supposed to be anything more than an internal helper.

In the "near" future where I plan to ship that markdown pane, that'll actually have it's own MarkdownPaneArgs with like, a filePath property or something.

Copy link
Member

Choose a reason for hiding this comment

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

If we don't want to have a INewContentArgs implementation for each content type, would it make sense to at least move the Type getter down into GenericContentArgs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh I mean, we absolutely could have SettingsContentArgs, ScratchContentArgs. They'd just basically each be exactly GenericContentArgs, just without the ctor that accepts the type.

Copy link
Member

Choose a reason for hiding this comment

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

FWIW...

never .. more than an internal helper

Internal helpers can use winrt::implements<> so they don't go in idl files/on the public API! If you need to try_as it, that means our IWhatever is an insufficient abstraction.

Copy link
Member Author

Choose a reason for hiding this comment

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

"internal" in the sense of "we can use this but I'm not really expecting others to use it"

Right now it's also used by TerminalApp to also return the type of content for a ScratchpadPane.

I could theoretically just rename it like, BaseContentArgs. Trying to make this entirely internal to TSM results in me basically just creating the same exact internal (non-projected) class up in TerminalApp

Base automatically changed from dev/migrie/f/sui-panes to main April 3, 2024 16:02
Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

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

LGTM, apart from a few nits.


Unrelated:

I continue to feel like the Type field in the INewContentArgs interface should be removed. While I think that giving contents descriptive names is a fantastic idea (makes understanding the content simpler), I feel like the mapping between names and types is an unrelated concern to the types themselves having names. Basically I can see why we want Name -> Type, but this adds Type -> Name, and... Do we really want that? 🤔 Additionally, checking for IIDs is well established for WinRT and COM which is IMO another +.

BTW this is also similar to how the interface has a Hash / Equals method. While we need those for our architecture of actions, there's no inherent reason IMO why an action needs an ID or must be comparable in the first place (a deduplication could hypothetically be done before we ever convert JSON to types, or could be done at some other point).
I'm not arguing that we should remove Hash / Equals, but I do think that the Type property may lead us down the wrong path for identifying contents and plugins.

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

@DHowett DHowett 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 done everything except the implementation in ActionArgs; I have some minor concerns so I'm blocking to drive them down - I am also bothered by it being stringly-typed but that's not the reason I'm blocking. I wouldn't mind that being improved (using IIDs/QI/whatever), but it's secondary to my other questions!

src/cascadia/TerminalSettingsModel/ActionArgs.idl Outdated Show resolved Hide resolved
src/cascadia/TerminalSettingsModel/ActionArgs.idl Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/TerminalPage.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/AppActionHandlers.cpp Outdated Show resolved Hide resolved
src/cascadia/TerminalApp/AppActionHandlers.cpp Outdated Show resolved Hide resolved
@microsoft-github-policy-service microsoft-github-policy-service bot 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 Apr 5, 2024
Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

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

I'll defer the decision regarding IID/Type to you and Dustin. Everything else LperfectTM. 😄

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

I'm okay with this for now, as it fills a need and doesn't get us too far away from the mark. As we grow I think we'll need to reconsider, but right now we don't have a plan and this is making session restore be busted.

Let's disagree and commit, then fix it later.

@DHowett DHowett added this pull request to the merge queue Apr 5, 2024
Merged via the queue into main with commit dc4026d Apr 5, 2024
20 checks passed
@DHowett DHowett deleted the dev/migrie/f/992-content-args branch April 5, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[1.21.921] Session persist doesn't trigger if the OS shuts down for an update
3 participants