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 Quick Fix UI and support for custom CommandNotFound OSC #16848

Merged
merged 26 commits into from
Jun 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
12100c5
Add support for custom CommandNotFound OSC
carlos-zamora Jan 22, 2024
c8d13d4
[Broken] Properly search through WinGet's catalog
carlos-zamora Jan 23, 2024
534c2d9
add debug code & dismiss button
carlos-zamora Mar 8, 2024
c1e1eab
remove info bar code; fix branch
carlos-zamora Mar 26, 2024
68ed03d
use suggestions UI instead
carlos-zamora Mar 26, 2024
c2417bb
add a lil polish
carlos-zamora Mar 26, 2024
6a361ef
address feedback; winget integration still in progress
carlos-zamora Mar 27, 2024
a2e57b4
Merge branch 'main' into dev/cazamor/cmdNotFound
carlos-zamora Apr 11, 2024
cfaa09d
moar progress! (useTransitions -> crash!)
carlos-zamora Apr 23, 2024
88b64cd
fix design
carlos-zamora Apr 25, 2024
48a36be
Merge branch 'main' into dev/cazamor/cmdNotFound
carlos-zamora Apr 25, 2024
d8c8807
feature flag; fix scroll bug; clear QF on enter
carlos-zamora Apr 26, 2024
8c0d7c6
clear quick fix on interaction
carlos-zamora Apr 29, 2024
ec1fbc2
Merge branch 'main' into dev/cazamor/cmdNotFound
carlos-zamora Jun 3, 2024
767692c
remove feature flag and WinMD refs; add QuickFixesAvailable API; addr…
carlos-zamora Jun 3, 2024
d4b6904
improve clearing functionality; fix build; x:Load; try to fix sizing
carlos-zamora Jun 5, 2024
4e5d07d
accessibility!
carlos-zamora Jun 5, 2024
27d464c
adjust button sizing for better visibility
carlos-zamora Jun 5, 2024
0f801a9
make the icon not dumb
carlos-zamora Jun 5, 2024
a545325
codeformat
carlos-zamora Jun 5, 2024
755f121
remove the winmd we're not using anymore
carlos-zamora Jun 5, 2024
a0aa2d0
re-add feature flag; address Leonard's comments
carlos-zamora Jun 12, 2024
1ffbae1
Merge branch 'main' into dev/cazamor/cmdNotFound
carlos-zamora Jun 12, 2024
0c5d880
Apply suggestions from code review
DHowett Jun 28, 2024
ef6af81
Merge remote-tracking branch 'origin/main' into dev/cazamor/cmdNotFound
DHowett Jun 28, 2024
db7f464
Adjust for renderer changes on main
DHowett Jun 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove feature flag and WinMD refs; add QuickFixesAvailable API; addr…
…ess some other feedback
carlos-zamora committed Jun 3, 2024
commit 767692c782107c5ac8b29bdd385740a1511cbb21
17 changes: 0 additions & 17 deletions src/cascadia/CascadiaPackage/CascadiaPackage.wapproj
Original file line number Diff line number Diff line change
@@ -174,23 +174,6 @@
</ItemGroup>
</Target>

<!-- We need to include some additional files in the package for things like WinGet's Command Not Found -->
<Target Name="IncludeAdditionalFilesInPackage">
<PropertyGroup>
<WinGetAdditionalPackageFileRoot>$(SolutionDir)\src\cascadia\TerminalControl</WinGetAdditionalPackageFileRoot>
</PropertyGroup>
<ItemGroup>
<WinGetAdditionalPackageFile Include="$(WinGetAdditionalPackageFileRoot)\Microsoft.Management.Deployment.winmd">
<PackagePath>Microsoft.Management.Deployment.winmd</PackagePath>
</WinGetAdditionalPackageFile>
</ItemGroup>
<ItemGroup>
<AppxPackagePayload Include="%(WinGetAdditionalPackageFile.Identity))">
<TargetPath>%(WinGetAdditionalPackageFile.PackagePath)</TargetPath>
</AppxPackagePayload>
</ItemGroup>
</Target>

<!-- This is required to get the package dependency in the AppXManifest. -->
<Import Project="$(OpenConsoleDir)src\common.nugetversions.targets" />

7 changes: 1 addition & 6 deletions src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
@@ -2934,11 +2934,6 @@ namespace winrt::TerminalApp::implementation
{
assert(!Dispatcher().HasThreadAccess());

if (!Feature_QuickFix::IsEnabled())
{
co_return;
}

std::vector<hstring> suggestions;
suggestions.reserve(1);
suggestions.emplace_back(fmt::format(L"winget install {}", args.MissingCommand()));
Copy link
Member

Choose a reason for hiding this comment

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

📝 this doesn't actually do the winget lookup for args.MissingCommand, but we are including the winget winmd?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. Yeah, we're blocked by winget. Internally tracking here.

Removed any references to the WinMD since we're not actually using it.

@@ -2951,7 +2946,7 @@ namespace winrt::TerminalApp::implementation
co_return;
}
term.UpdateWinGetSuggestions(single_threaded_vector<hstring>(std::move(suggestions)));
term.ShowQuickFixMenu();
term.RefreshQuickFixMenu();
}

// Method Description:
7 changes: 5 additions & 2 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
#include <unicode.hpp>
#include <utils.hpp>
#include <WinUser.h>
//#include <winrt/Microsoft.Management.Deployment.h>

#include "EventArgs.h"
#include "../../renderer/atlas/AtlasEngine.h"
@@ -23,7 +22,6 @@
#include "ControlCore.g.cpp"
#include "SelectionColor.g.cpp"

//using namespace winrt::Microsoft::Management::Deployment;
using namespace ::Microsoft::Console::Types;
using namespace ::Microsoft::Console::VirtualTerminal;
using namespace ::Microsoft::Terminal::Core;
@@ -2304,6 +2302,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return *context;
}

bool ControlCore::QuickFixesAvailable() const noexcept
{
return _cachedQuickFixes && _cachedQuickFixes.Size() > 0;
}

void ControlCore::UpdateQuickFixes(const Windows::Foundation::Collections::IVector<hstring>& quickFixes)
Copy link
Member

Choose a reason for hiding this comment

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

this is more of a Set than an Update. Update is like "do it on your own". Set is more like "i will give it to you"

{
_cachedQuickFixes = quickFixes;
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/ControlCore.h
Original file line number Diff line number Diff line change
@@ -242,6 +242,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation

hstring ReadEntireBuffer() const;
Control::CommandHistoryContext CommandHistory() const;
bool QuickFixesAvailable() const noexcept;
void UpdateQuickFixes(const Windows::Foundation::Collections::IVector<hstring>& quickFixes);

void AdjustOpacity(const float opacity, const bool relative);
1 change: 1 addition & 0 deletions src/cascadia/TerminalControl/ControlCore.idl
Original file line number Diff line number Diff line change
@@ -156,6 +156,7 @@ namespace Microsoft.Terminal.Control

String ReadEntireBuffer();
CommandHistoryContext CommandHistory();
Boolean QuickFixesAvailable { get; };

void AdjustOpacity(Single Opacity, Boolean relative);
void WindowVisibilityChanged(Boolean showOrHide);
4 changes: 2 additions & 2 deletions src/cascadia/TerminalControl/EventArgs.h
Original file line number Diff line number Diff line change
@@ -217,9 +217,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
{
public:
SearchMissingCommandEventArgs(const winrt::hstring& missingCommand) :
_MissingCommand(missingCommand) {}
MissingCommand(missingCommand) {}

WINRT_PROPERTY(winrt::hstring, MissingCommand);
til::property<winrt::hstring> MissingCommand;
};
}

39 changes: 12 additions & 27 deletions src/cascadia/TerminalControl/TermControl.cpp
Original file line number Diff line number Diff line change
@@ -338,24 +338,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
}
}
});

if (Feature_QuickFix::IsEnabled())
{
auto quickFixBtn{ QuickFixButton() };
quickFixBtn.PointerEntered({ get_weak(), &TermControl::QuickFixButton_PointerEntered });
quickFixBtn.PointerExited({ get_weak(), &TermControl::QuickFixButton_PointerExited });
}
}

void TermControl::QuickFixButton_PointerEntered(const IInspectable& /*sender*/, const PointerRoutedEventArgs& /*e*/)
void TermControl::_QuickFixButton_PointerEntered(const IInspectable& /*sender*/, const PointerRoutedEventArgs& /*e*/)
{
if (!_IsClosing() && _quickFixButtonCollapsible)
{
VisualStateManager::GoToState(*this, StateNormal, false);
}
}

void TermControl::QuickFixButton_PointerExited(const IInspectable& /*sender*/, const PointerRoutedEventArgs& /*e*/)
void TermControl::_QuickFixButton_PointerExited(const IInspectable& /*sender*/, const PointerRoutedEventArgs& /*e*/)
{
if (!_IsClosing() && _quickFixButtonCollapsible)
{
@@ -838,11 +831,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
// update. If we enabled scrollbar marks, then great, when we handle
// that message, we'll redraw them.

if (Feature_QuickFix::IsEnabled())
{
// update the position of the quick fix menu (in case we changed the padding)
ShowQuickFixMenu();
}
// update the position of the quick fix menu (in case we changed the padding)
RefreshQuickFixMenu();
}

// Method Description:
@@ -2349,7 +2339,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
_updateSelectionMarkers(nullptr, winrt::make<UpdateSelectionMarkersEventArgs>(false));
}

ShowQuickFixMenu();
RefreshQuickFixMenu();
}

hstring TermControl::Title()
@@ -3527,13 +3517,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
scaleMarker(SelectionStartMarker());
scaleMarker(SelectionEndMarker());

if (Feature_QuickFix::IsEnabled())
{
auto quickFixBtn = QuickFixButton();
quickFixBtn.Height(args.Height() / dpiScale);
QuickFixIcon().FontSize(std::min(static_cast<double>(args.Width() / dpiScale), GetPadding().Left));
ShowQuickFixMenu();
}
auto quickFixBtn = QuickFixButton();
quickFixBtn.Height(args.Height() / dpiScale);
QuickFixIcon().FontSize(std::min(static_cast<double>(args.Width() / dpiScale), GetPadding().Left));
RefreshQuickFixMenu();
}

void TermControl::_coreRaisedNotice(const IInspectable& /*sender*/,
@@ -3831,9 +3818,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
return GetPadding().Left / 3.0;
}

void TermControl::ShowQuickFixMenu()
void TermControl::RefreshQuickFixMenu()
{
if (!_quickFixesAvailable)
if (!_core.QuickFixesAvailable())
{
QuickFixButton().Visibility(Visibility::Collapsed);
return;
@@ -3867,14 +3854,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation

void TermControl::_bubbleSearchMissingCommand(const IInspectable& /*sender*/, const Control::SearchMissingCommandEventArgs& args)
{
_quickFixesAvailable = true;
SearchMissingCommand.raise(*this, args);
}

void TermControl::_clearQuickFix(const IInspectable& /*sender*/, const IInspectable& /*args*/)
{
_quickFixesAvailable = false;
ShowQuickFixMenu();
RefreshQuickFixMenu();
}

void TermControl::ClearQuickFix()
6 changes: 3 additions & 3 deletions src/cascadia/TerminalControl/TermControl.h
Original file line number Diff line number Diff line change
@@ -181,7 +181,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void RawWriteString(const winrt::hstring& text);

void ShowContextMenu();
void ShowQuickFixMenu();
void RefreshQuickFixMenu();
void ClearQuickFix();

void Detach();
@@ -340,8 +340,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
void _MouseWheelHandler(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Input::PointerRoutedEventArgs& e);
void _ScrollbarChangeHandler(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs& e);

void QuickFixButton_PointerEntered(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Input::PointerRoutedEventArgs& e);
void QuickFixButton_PointerExited(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Input::PointerRoutedEventArgs& e);
void _QuickFixButton_PointerEntered(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Input::PointerRoutedEventArgs& e);
void _QuickFixButton_PointerExited(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::Input::PointerRoutedEventArgs& e);

void _GotFocusHandler(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
void _LostFocusHandler(const Windows::Foundation::IInspectable& sender, const Windows::UI::Xaml::RoutedEventArgs& e);
2 changes: 1 addition & 1 deletion src/cascadia/TerminalControl/TermControl.idl
Original file line number Diff line number Diff line change
@@ -148,7 +148,7 @@ namespace Microsoft.Terminal.Control
Double CalculateQuickFixButtonCollapsedWidth { get; };

void ShowContextMenu();
void ShowQuickFixMenu();
void RefreshQuickFixMenu();
void ClearQuickFix();

void Detach();
4 changes: 3 additions & 1 deletion src/cascadia/TerminalControl/TermControl.xaml
Original file line number Diff line number Diff line change
@@ -1289,7 +1289,9 @@
AllowFocusOnInteraction="False"
CornerRadius="0,5,5,0"
Style="{StaticResource AccentButtonStyle}"
Visibility="Collapsed">
Visibility="Collapsed"
PointerEntered="_QuickFixButton_PointerEntered"
PointerExited="_QuickFixButton_PointerExited">
<Button.Content>
<FontIcon x:Name="QuickFixIcon"
HorizontalAlignment="Center"
7 changes: 0 additions & 7 deletions src/cascadia/TerminalControl/TerminalControlLib.vcxproj
Original file line number Diff line number Diff line change
@@ -171,13 +171,6 @@
<Private>false</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="$(OpenConsoleDir)src\cascadia\TerminalControl\Microsoft.Management.Deployment.winmd">
<IsWinMDFile>true</IsWinMDFile>
<Private>false</Private>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
</Reference>
</ItemGroup>
<!-- ====================== Compiler & Linker Flags ===================== -->
<ItemDefinitionGroup>
<ClCompile>
11 changes: 0 additions & 11 deletions src/features.xml
Original file line number Diff line number Diff line change
@@ -155,15 +155,4 @@
</alwaysEnabledBrandingTokens>
</feature>

<feature>
<name>Feature_QuickFix</name>
<description>Enables the Quick Fix menu</description>
<id>16599</id>
<stage>AlwaysDisabled</stage>
<alwaysEnabledBrandingTokens>
<brandingToken>Dev</brandingToken>
<brandingToken>Canary</brandingToken>
</alwaysEnabledBrandingTokens>
</feature>

</featureStaging>