Skip to content
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
Expand Up @@ -4,18 +4,31 @@ namespace SalmonEgg.Presentation.Core.ViewModels.Chat.Overlay;

internal sealed class ChatConversationSurfaceProjectionCoordinator
{
private bool _hasLoadedActiveConversationRoot;
private bool _hasLoadedTranscriptSurface;

public ChatConversationSurfaceProjection Project(ChatConversationSurfaceStateInput input)
{
var state = ChatConversationSurfaceStatePresenter.Resolve(input);

if (state.ShouldShowActiveConversationRoot)
{
_hasLoadedActiveConversationRoot = true;
}

if (state.ShouldShowTranscriptSurface)
{
_hasLoadedTranscriptSurface = true;
}

return new ChatConversationSurfaceProjection(
state.IsActivationOverlayVisible,
state.IsOverlayVisible,
state.ShouldShowActiveConversationRoot,
state.ShouldShowActiveConversationRoot,
_hasLoadedActiveConversationRoot,
state.ShouldShowSessionHeader,
state.ShouldShowTranscriptSurface,
state.ShouldShowTranscriptSurface,
_hasLoadedTranscriptSurface,
state.ShouldShowConversationInputSurface,
state.ShouldShowBlockingLoadingMask,
state.ShouldShowLoadingOverlayStatusPill,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
namespace SalmonEgg.Presentation.Core.Tests.Chat;

[Collection("NonParallel")]
public partial class ChatViewModelTests
public partial class ChatViewModelTests
{
private static ViewModelFixture CreateViewModel(
SynchronizationContext? syncContext = null,
Expand Down Expand Up @@ -10155,10 +10155,10 @@ await fixture.UpdateStateAsync(state => state with
runtimeState.IsSessionActivationInProgress = true;

Assert.False(fixture.ViewModel.ShouldShowActiveConversationRoot);
Assert.False(fixture.ViewModel.ShouldLoadActiveConversationRoot);
Assert.True(fixture.ViewModel.ShouldLoadActiveConversationRoot);
Assert.False(fixture.ViewModel.ShouldShowSessionHeader);
Assert.False(fixture.ViewModel.ShouldShowTranscriptSurface);
Assert.False(fixture.ViewModel.ShouldLoadTranscriptSurface);
Assert.True(fixture.ViewModel.ShouldLoadTranscriptSurface);
Assert.False(fixture.ViewModel.ShouldShowConversationInputSurface);
Assert.Equal(SessionNamePolicy.CreateDefault("conv-1"), fixture.ViewModel.CurrentSessionDisplayName);
Assert.Equal(string.Empty, fixture.ViewModel.PresentedSessionHeaderDisplayName);
Expand Down Expand Up @@ -11215,10 +11215,10 @@ await fixture.DispatchConnectionAsync(new SetNewSessionDraftAction(new NewSessio
syncContext.RunAll();

Assert.False(fixture.ViewModel.ShouldShowActiveConversationRoot);
Assert.False(fixture.ViewModel.ShouldLoadActiveConversationRoot);
Assert.True(fixture.ViewModel.ShouldLoadActiveConversationRoot);
Assert.False(fixture.ViewModel.ShouldShowSessionHeader);
Assert.False(fixture.ViewModel.ShouldShowTranscriptSurface);
Assert.False(fixture.ViewModel.ShouldLoadTranscriptSurface);
Assert.True(fixture.ViewModel.ShouldLoadTranscriptSurface);
Assert.False(fixture.ViewModel.ShouldShowConversationInputSurface);

var switchTask = fixture.ViewModel.SwitchConversationAsync("conv-2");
Expand All @@ -11235,10 +11235,10 @@ await fixture.DispatchConnectionAsync(new SetNewSessionDraftAction(new NewSessio
syncContext.RunAll();

Assert.False(fixture.ViewModel.ShouldShowActiveConversationRoot);
Assert.False(fixture.ViewModel.ShouldLoadActiveConversationRoot);
Assert.True(fixture.ViewModel.ShouldLoadActiveConversationRoot);
Assert.False(fixture.ViewModel.ShouldShowSessionHeader);
Assert.False(fixture.ViewModel.ShouldShowTranscriptSurface);
Assert.False(fixture.ViewModel.ShouldLoadTranscriptSurface);
Assert.True(fixture.ViewModel.ShouldLoadTranscriptSurface);
Assert.False(fixture.ViewModel.ShouldShowConversationInputSurface);
Assert.Equal("conv-2", runtimeState.DesiredSessionId);
Assert.True(runtimeState.IsSessionActivationInProgress);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void Project_WhenActiveConversationRootWasShown_KeepsLoadStateWhenLaterHi
Assert.True(visible.ShouldShowActiveConversationRoot);
Assert.True(visible.ShouldLoadActiveConversationRoot);
Assert.False(hidden.ShouldShowActiveConversationRoot);
Assert.False(hidden.ShouldLoadActiveConversationRoot);
Assert.True(hidden.ShouldLoadActiveConversationRoot); // Changed to True
}

[Fact]
Expand Down Expand Up @@ -97,6 +97,6 @@ public void Project_WhenTranscriptSurfaceWasShown_KeepsLoadStateWhenLaterHidden(
Assert.True(visible.ShouldShowTranscriptSurface);
Assert.True(visible.ShouldLoadTranscriptSurface);
Assert.False(hidden.ShouldShowTranscriptSurface);
Assert.False(hidden.ShouldLoadTranscriptSurface);
Assert.True(hidden.ShouldLoadTranscriptSurface); // Changed to True
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public async Task RefreshSessionsAsync_ProjectsNeedsMappingAndUnclassifiedAffini
};
using var viewModel = CreateViewModel(
profilesViewModel,
connectionFacade,
connectionFacade,
new StubNavigationCoordinator());

await viewModel.RefreshSessionsCommand.ExecuteAsync(null);
Expand Down Expand Up @@ -119,7 +119,7 @@ public async Task RefreshSessionsAsync_WhenRemoteListIsEmpty_UsesEmptyPhaseInste
};
using var viewModel = CreateViewModel(
profilesViewModel,
connectionFacade,
connectionFacade,
new StubNavigationCoordinator());

await viewModel.RefreshSessionsCommand.ExecuteAsync(null);
Expand Down Expand Up @@ -209,7 +209,7 @@ public async Task RefreshSessionsAsync_WhenAgentDoesNotSupportSessionList_DoesNo
};
using var viewModel = CreateViewModel(
profilesViewModel,
connectionFacade,
connectionFacade,
new StubNavigationCoordinator());

await viewModel.RefreshSessionsCommand.ExecuteAsync(null);
Expand Down Expand Up @@ -713,7 +713,7 @@ public void SetLayoutMode_Narrow_UpdatesShowProperties()
var profilesViewModel = CreateProfilesViewModel(profile);
using var viewModel = CreateViewModel(
profilesViewModel,
new FakeDiscoverSessionsConnectionFacade(),
new FakeDiscoverSessionsConnectionFacade(),
new StubNavigationCoordinator());

viewModel.SetLayoutMode(DiscoverLayoutMode.Narrow);
Expand All @@ -732,7 +732,7 @@ public void OpenProfileDetails_InNarrowMode_MovesToDetailPane()
var profilesViewModel = CreateProfilesViewModel(profile);
using var viewModel = CreateViewModel(
profilesViewModel,
new FakeDiscoverSessionsConnectionFacade(),
new FakeDiscoverSessionsConnectionFacade(),
new StubNavigationCoordinator());

viewModel.SetLayoutMode(DiscoverLayoutMode.Narrow);
Expand All @@ -751,7 +751,7 @@ public void BackToProfiles_InNarrowMode_ReturnsToListPane()
var profilesViewModel = CreateProfilesViewModel(profile);
using var viewModel = CreateViewModel(
profilesViewModel,
new FakeDiscoverSessionsConnectionFacade(),
new FakeDiscoverSessionsConnectionFacade(),
new StubNavigationCoordinator());

viewModel.SetLayoutMode(DiscoverLayoutMode.Narrow);
Expand All @@ -770,7 +770,7 @@ public void SetLayoutMode_WhenModeIsUnchanged_DoesNotRaiseDerivedPaneNotificatio
var profilesViewModel = CreateProfilesViewModel(profile);
using var viewModel = CreateViewModel(
profilesViewModel,
new FakeDiscoverSessionsConnectionFacade(),
new FakeDiscoverSessionsConnectionFacade(),
new StubNavigationCoordinator());
var changedProperties = new List<string>();
viewModel.PropertyChanged += (_, e) => changedProperties.Add(e.PropertyName ?? string.Empty);
Expand All @@ -789,7 +789,7 @@ public void OpenProfileDetails_WhenAlreadyInDetailPane_DoesNotRaiseDerivedPaneNo
var profilesViewModel = CreateProfilesViewModel(profile);
using var viewModel = CreateViewModel(
profilesViewModel,
new FakeDiscoverSessionsConnectionFacade(),
new FakeDiscoverSessionsConnectionFacade(),
new StubNavigationCoordinator());
viewModel.SetLayoutMode(DiscoverLayoutMode.Narrow);
viewModel.OpenProfileDetailsCommand.Execute(null);
Expand All @@ -810,10 +810,10 @@ public void SelectingProfile_InNarrowMode_MovesToDetailPane()
var profile2 = new ServerConfiguration { Id = "profile-2", Name = "Profile 2" };
var profilesViewModel = CreateProfilesViewModel(profile1);
profilesViewModel.Profiles.Add(profile2);

using var viewModel = CreateViewModel(
profilesViewModel,
new FakeDiscoverSessionsConnectionFacade(),
new FakeDiscoverSessionsConnectionFacade(),
new StubNavigationCoordinator());

viewModel.SetLayoutMode(DiscoverLayoutMode.Narrow);
Expand All @@ -831,7 +831,7 @@ public void ClearingProfileSelection_CoercesPaneToListMode()
var profilesViewModel = CreateProfilesViewModel(profile);
using var viewModel = CreateViewModel(
profilesViewModel,
new FakeDiscoverSessionsConnectionFacade(),
new FakeDiscoverSessionsConnectionFacade(),
new StubNavigationCoordinator());

viewModel.SetLayoutMode(DiscoverLayoutMode.Narrow);
Expand All @@ -853,7 +853,7 @@ public void DiscoverSelection_IsLocallyOwned_AndNotOverwrittenBySharedProfileSel

using var viewModel = CreateViewModel(
profilesViewModel,
new FakeDiscoverSessionsConnectionFacade(),
new FakeDiscoverSessionsConnectionFacade(),
new StubNavigationCoordinator());

viewModel.SelectedProfile = profile2;
Expand All @@ -873,12 +873,12 @@ public void SwitchingToWideMode_ExposesBothPanes_PreservingSelection()
var profilesViewModel = CreateProfilesViewModel(profile);
using var viewModel = CreateViewModel(
profilesViewModel,
new FakeDiscoverSessionsConnectionFacade(),
new FakeDiscoverSessionsConnectionFacade(),
new StubNavigationCoordinator());

viewModel.SetLayoutMode(DiscoverLayoutMode.Narrow);
viewModel.OpenProfileDetailsCommand.Execute(null);

// Act: switch back to wide
viewModel.SetLayoutMode(DiscoverLayoutMode.Wide);

Expand Down Expand Up @@ -954,7 +954,7 @@ public async Task RefreshSessionsAsync_WhenProfileChangesDuringRefresh_DropsStal

using var vm = CreateViewModel(
profilesViewModel,
connectionFacade,
connectionFacade,
new StubNavigationCoordinator());
viewModel = vm;

Expand Down Expand Up @@ -1002,7 +1002,7 @@ public async Task OnConnectionFacadePropertyChanged_WhenProfileChanges_DropsStal
};
using var viewModel = CreateViewModel(
profilesViewModel,
connectionFacade,
connectionFacade,
new StubNavigationCoordinator());

// Start refresh for profile 1 with a valid chat service so the test isolates stale facade
Expand All @@ -1013,7 +1013,7 @@ public async Task OnConnectionFacadePropertyChanged_WhenProfileChanges_DropsStal

// Switch to profile 2
viewModel.SelectedProfile = profile2;

// At this point, the connection gating generation has been incremented.
// Simulate profile 1 connection error arriving late.
// Real property changes from the facade happen on a background thread.
Expand Down
Loading