Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
37f8761
feat: Add model property to AppSettings and ensure settings are regis…
jisunchung Oct 3, 2025
e989f98
feat: Update settings model assignment based on connector type
jisunchung Oct 3, 2025
a3d93dc
feat: Enhance ChatHeader to display connector type and model settings
jisunchung Oct 3, 2025
fe4e327
feat: Add integration test to verify header displays connector type a…
jisunchung Oct 4, 2025
2e189bf
fix: Correct application title in ChatHeader and update corresponding…
jisunchung Oct 4, 2025
1792e2f
fix: Update ChatHeaderUITests to include connector type validation in…
jisunchung Oct 9, 2025
88a6718
Merge branch 'main' into feature/371-update-app-title-connector-model
jisunchung Oct 10, 2025
4e43a7c
refactor: Remove unused using directives in ChatHeaderUITests
jisunchung Oct 10, 2025
b4083fd
feat: Implement AppSettings extension methods for service configuration
jisunchung Oct 10, 2025
74ef31d
fix: Throw exception for unsupported ConnectorType in AppSettingsExte…
jisunchung Oct 10, 2025
8c6f632
test: Add unit tests for AppSettingsExtensions methods
jisunchung Oct 10, 2025
f2da8a2
refactor: Rearrange code in ConfigureModelName for clarity and mainta…
jisunchung Oct 10, 2025
36854bf
refactor: Simplify AppSettingsExtensionsTests by consolidating config…
jisunchung Oct 13, 2025
077f86c
fix: Update assertion in AddAppSettings test to use command line mode…
jisunchung Oct 13, 2025
1920ebb
fix: Add null checks for configuration and settings in AddAppSettings…
jisunchung Oct 14, 2025
74e9266
refactor: Separate test cases in AppSettingsExtensionsTests
jisunchung Oct 14, 2025
0ed06be
fix: Add null checks for services, configuration, and settings in Add…
jisunchung Oct 14, 2025
4bba586
fix: Update null argument exception assertions in AddAppSettings test…
jisunchung Oct 14, 2025
c3c834a
fix: Replace hardcoded model strings with constants in AddAppSettings…
jisunchung Oct 14, 2025
d00daeb
style: Add a blank line for improved readability in AppSettingsExtens…
jisunchung Oct 14, 2025
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
Expand Up @@ -7,6 +7,13 @@
New chat
</button>
</div>

<h1 class="page-width">OpenChat Playground</h1>
<h1 class="chat-header-app-title page-width">
<span class="app-title-text">OpenChat Playground</span>
<span class="app-title-settings">
<span>&ndash;</span>
<span class="app-connector">@Settings.ConnectorType</span>
<span>|</span>
<span class="app-model">@Settings.Model</span>
</span>
</h1>
</div>
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
using Microsoft.AspNetCore.Components;
using OpenChat.PlaygroundApp.Configurations;

namespace OpenChat.PlaygroundApp.Components.Pages.Chat;

public partial class ChatHeader : ComponentBase
{
[Parameter]
public EventCallback OnNewChat { get; set; }

[Inject]
public required AppSettings Settings { get; set; }
}
5 changes: 5 additions & 0 deletions src/OpenChat.PlaygroundApp/Configurations/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public partial class AppSettings
/// </summary>
public ConnectorType ConnectorType { get; set; }

/// <summary>
/// Gets or sets the model name to use.
/// </summary>
public string? Model { get; set; }

/// <summary>
/// Gets or sets the value indicating whether to display help information or not.
/// </summary>
Expand Down
58 changes: 58 additions & 0 deletions src/OpenChat.PlaygroundApp/Extensions/AppSettingsExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using OpenChat.PlaygroundApp.Configurations;
using OpenChat.PlaygroundApp.Connectors;

namespace OpenChat.PlaygroundApp.Extensions;

/// <summary>
/// This represents the extension entity for handling AppSettings configuration.
/// </summary>
public static class AppSettingsExtensions
{
/// <summary>
/// Configures and adds AppSettings to the service collection with model name populated.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/> instance.</param>
/// <param name="configuration">The <see cref="IConfiguration"/> instance.</param>
/// <param name="settings">The <see cref="AppSettings"/> instance.</param>
/// <returns>Returns the modified <see cref="IServiceCollection"/> instance.</returns>
public static IServiceCollection AddAppSettings(this IServiceCollection services, IConfiguration configuration, AppSettings settings)
{
ArgumentNullException.ThrowIfNull(services);
ArgumentNullException.ThrowIfNull(configuration);
ArgumentNullException.ThrowIfNull(settings);

ConfigureModelName(configuration, settings);
services.AddSingleton(settings);

return services;
}

/// <summary>
/// Configures the model name in AppSettings based on the connector type.
/// </summary>
/// <param name="configuration">The <see cref="IConfiguration"/> instance.</param>
/// <param name="settings">The <see cref="AppSettings"/> instance.</param>
private static void ConfigureModelName(IConfiguration configuration, AppSettings settings)
{
string? modelFromSettings = settings.ConnectorType switch
{
ConnectorType.AzureAIFoundry => settings.AzureAIFoundry?.DeploymentName,
ConnectorType.FoundryLocal => settings.FoundryLocal?.Alias,
ConnectorType.GitHubModels => settings.GitHubModels?.Model,
ConnectorType.OpenAI => settings.OpenAI?.Model,
ConnectorType.HuggingFace => settings.HuggingFace?.Model,
ConnectorType.Anthropic => settings.Anthropic?.Model,
ConnectorType.LG => settings.LG?.Model,
_ => throw new ArgumentException($"Unsupported ConnectorType: {settings.ConnectorType}")
};

var section = configuration.GetSection(settings.ConnectorType.ToString());

settings.Model = modelFromSettings ?? settings.ConnectorType switch
{
ConnectorType.AzureAIFoundry => section.GetValue<string>("DeploymentName"),
ConnectorType.FoundryLocal => section.GetValue<string>("Alias"),
_ => section.GetValue<string>("Model")
};
}
}
3 changes: 3 additions & 0 deletions src/OpenChat.PlaygroundApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using OpenChat.PlaygroundApp.Abstractions;
using OpenChat.PlaygroundApp.Components;
using OpenChat.PlaygroundApp.Endpoints;
using OpenChat.PlaygroundApp.Extensions;
using OpenChat.PlaygroundApp.OpenApi;
using OpenChat.PlaygroundApp.Services;

Expand All @@ -16,6 +17,8 @@
return;
}

builder.Services.AddAppSettings(config, settings);

builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Microsoft.Playwright;
using Microsoft.Playwright.Xunit;

using OpenChat.PlaygroundApp.Connectors;

namespace OpenChat.PlaygroundApp.Tests.Components.Pages.Chat;

public class ChatHeaderUITests : PageTest
Expand All @@ -18,12 +20,26 @@ public override async Task InitializeAsync()
public async Task Given_Root_Page_When_Loaded_Then_Header_Should_Be_Visible(string expected)
{
// Act
var title = await Page.Locator("h1").InnerTextAsync();
var title = await Page.Locator("span.app-title-text").InnerTextAsync();

// Assert
title.ShouldBe(expected);
}

[Trait("Category", "IntegrationTest")]
[Fact]
public async Task Given_Root_Page_When_Loaded_Then_Header_Should_Display_ConnectorType_And_Model()
{
// Act
var connector = await Page.Locator("span.app-connector").InnerTextAsync();
var model = await Page.Locator("span.app-model").InnerTextAsync();

// Assert
connector.ShouldNotBeNullOrEmpty();
Enum.IsDefined(typeof(ConnectorType), connector).ShouldBeTrue();
model.ShouldNotBeNullOrEmpty();
}

[Trait("Category", "IntegrationTest")]
[Fact]
public async Task Given_Root_Page_When_Loaded_Then_NewChat_Button_Should_Be_Visible()
Expand Down
Loading
Loading