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 in Chat UI to Quickstart Playground #3913

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;

namespace DevHome.Common.Environments.Converters;

/// <summary>
/// Converter to convert the PromptStatus bool value to a style that will be used by the GenerateButton.
Copy link
Contributor

Choose a reason for hiding this comment

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

Converts a PromptStatus... Devs know this is a converter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same with the other converter.

/// </summary>
public class PromptStatusToGenerateButtonStyle : IValueConverter
Copy link
Contributor

Choose a reason for hiding this comment

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

This converter works on a bool and has domain knowledge and "PromptStyle" I suggest to rename the class to something generic BoolToAccentButtonStyle In case other parts of DevHome want to use the converter.

{
public object? Convert(object value, Type targetType, object parameter, string language)
{
bool validStatus = (bool)value;

switch (validStatus)
{
case true:
return Application.Current.Resources["AccentButtonStyle"] as Style;
case false:
return Application.Current.Resources["DefaultButtonStyle"] as Style;
}
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
32 changes: 32 additions & 0 deletions common/Environments/Converters/PromptStatusToSubmitButtonStyle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;

namespace DevHome.Common.Environments.Converters;

/// <summary>
/// Converter to convert the PromptStatus bool value to a style that will be used by the SubmitButton.
/// </summary>
public class PromptStatusToSubmitButtonStyle : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, string language)
{
bool validStatus = (bool)value;

switch (validStatus)
{
case true:
return Application.Current.Resources["DefaultButtonStyle"] as Style;
case false:
return Application.Current.Resources["AccentButtonStyle"] as Style;
}
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
2 changes: 1 addition & 1 deletion src/Models/ExtensionWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ExtensionWrapper : IExtensionWrapper
[typeof(ISettingsProvider)] = ProviderType.Settings,
[typeof(IFeaturedApplicationsProvider)] = ProviderType.FeaturedApplications,
[typeof(IComputeSystemProvider)] = ProviderType.ComputeSystem,
[typeof(IQuickStartProjectProvider)] = ProviderType.QuickStartProject,
[typeof(IQuickStartProjectProvider2)] = ProviderType.QuickStartProject,
[typeof(ILocalRepositoryProvider)] = ProviderType.LocalRepository,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace DevHome.SetupFlow.Models;

/// <summary>
/// Wrapper class for the IQuickStartProjectProvider interface that can be used throughout the application.
/// Wrapper class for the IQuickStartProjectProvider2 interface that can be used throughout the application.
/// Note: Additional methods added to this class should be wrapped in try/catch blocks to ensure that
/// exceptions don't bubble up to the caller as the methods are cross proc COM calls.
/// </summary>
Expand All @@ -21,7 +21,7 @@

private readonly string _errorString;

private readonly IQuickStartProjectProvider _quickStartProjectProvider;
private readonly IQuickStartProjectProvider2 _quickStartProjectProvider;

Check failure on line 24 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Release, x64, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartProjectProvider2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Release, arm64, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartProjectProvider2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Release, arm64, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartProjectProvider2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Debug, x86, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartProjectProvider2' could not be found (are you missing a using directive or an assembly reference?)

public string PackageFullName { get; }

Expand All @@ -34,7 +34,7 @@
public string[] SamplePrompts { get; }

public QuickStartProjectProvider(
IQuickStartProjectProvider quickStartProjectProvider,
IQuickStartProjectProvider2 quickStartProjectProvider,

Check failure on line 37 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Release, x64, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartProjectProvider2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 37 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Release, arm64, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartProjectProvider2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 37 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Release, arm64, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartProjectProvider2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 37 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Debug, x86, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartProjectProvider2' could not be found (are you missing a using directive or an assembly reference?)
ISetupFlowStringResource setupFlowStringResource,
string packageFullName)
{
Expand Down Expand Up @@ -77,6 +77,21 @@
}
}

public IQuickStartChatStyleGenerationOperation CreateChatStyleGenerationOperation(string prompt)

Check failure on line 80 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Release, x64, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartChatStyleGenerationOperation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 80 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Release, arm64, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartChatStyleGenerationOperation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 80 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Release, arm64, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartChatStyleGenerationOperation' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 80 in tools/SetupFlow/DevHome.SetupFlow/Models/QuickStartProjectProvider.cs

View workflow job for this annotation

GitHub Actions / build-and-test (Debug, x86, windows-latest, 8.0.x)

The type or namespace name 'IQuickStartChatStyleGenerationOperation' could not be found (are you missing a using directive or an assembly reference?)
{
try
{
TelemetryFactory.Get<ITelemetry>().LogCritical("QuickstartPlaygroundCreateChatStyleGenerationOperation");
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use .Log as this allows you to add extra information.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please follow the standard event naming convention. DevHome_[Area]_Event Maybe DevHome_GenerationOperation_Event

return _quickStartProjectProvider.CreateChatStyleGenerationOperation(prompt);
}
catch (Exception ex)
{
TelemetryFactory.Get<ITelemetry>().LogException("QuickstartPlaygroundCreateChatStyleGenerationOperation", ex);
_log.Error(ex, $"CreateProjectGenerationOperation for: {this} failed due to exception");
Copy link
Contributor

Choose a reason for hiding this comment

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

what will {this} print? The name of the class?

return null;
}
}

public override string ToString()
{
return $"QuickStartProject provider: {DisplayName}";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task<List<QuickStartProjectProvider>> GetQuickStartProjectProviders
{
try
{
var quickStartProjectProviders = (await extension.GetListOfProvidersAsync<IQuickStartProjectProvider>()).ToList();
var quickStartProjectProviders = (await extension.GetListOfProvidersAsync<IQuickStartProjectProvider2>()).ToList();
Copy link
Contributor

Choose a reason for hiding this comment

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

What if this releases but no extensions implement IQuickStartPRojectProvider2? GetListOfProvidersAsync will return 0 results. This is true even if some providers implement IQuickStartProjectProvider

foreach (var quickStartProjectProvider in quickStartProjectProviders)
Copy link
Contributor

@dhoehna dhoehna Oct 1, 2024

Choose a reason for hiding this comment

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

quickStartPRojectProviders.Where(x => x != null);

{
if (quickStartProjectProvider != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can GetListOfProvidersAsync return null values?`

Expand All @@ -44,7 +44,7 @@ public async Task<List<QuickStartProjectProvider>> GetQuickStartProjectProviders
}
catch (Exception ex)
{
_log.Error(ex, $"Failed to get {nameof(IQuickStartProjectProvider)} provider from '{extension.PackageFullName}'");
_log.Error(ex, $"Failed to get {nameof(IQuickStartProjectProvider2)} provider from '{extension.PackageFullName}'");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,14 @@
<value>Generate project</value>
<comment>Tooltip for the generate button on the QuickstartPlayground page</comment>
</data>
<data name="QuickstartPlaygroundSubmitButton.Content" xml:space="preserve">
<value>Submit</value>
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't use submit Change the name to the action that will happen when the button is clicked.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same for "Submit prompt"

<comment>Label for the submit button on the QuickstartPlayground page</comment>
</data>
<data name="QuickstartPlaygroundSubmitButtonTooltip.Content" xml:space="preserve">
<value>Submit prompt</value>
<comment>Tooltip for the submit button on the QuickstartPlayground page</comment>
</data>
<data name="QuickstartPlaygroundLaunchDropDownButton.Content" xml:space="preserve">
<value>Open in Editor</value>
<comment>Drop down button to launch QuickstartPlayground project</comment>
Expand Down
Loading
Loading