Skip to content
Merged
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
52 changes: 52 additions & 0 deletions Assets/Tests/Editor/SetupWizardWindowTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,58 @@ public void GetSkillsButtonTextForSetupWizard_ReturnsExpectedLabel(
Assert.That(label, Is.EqualTo(expectedLabel));
}

[Test]
public void ShouldShowSkillsInstalledDialog_WhenTargetsAreMissing_ReturnsTrue()
{
// Verifies that Setup Wizard keeps the success dialog for first install.
List<SkillSetupTargetInfo> targets = new()
{
CreateSkillTarget(
hasSkillsDirectory: true,
SkillInstallState.Missing)
};

bool shouldShowDialog = SetupWizardWindow.ShouldShowSkillsInstalledDialog(targets);

Assert.That(shouldShowDialog, Is.True);
}

[Test]
public void ShouldShowSkillsInstalledDialog_WhenAnyTargetIsOutdated_ReturnsFalse()
{
// Verifies that Setup Wizard suppresses the success dialog for skill updates.
List<SkillSetupTargetInfo> targets = new()
{
CreateSkillTarget(
hasSkillsDirectory: true,
SkillInstallState.Missing),
CreateSkillTarget(
hasSkillsDirectory: true,
SkillInstallState.Outdated)
};

bool shouldShowDialog = SetupWizardWindow.ShouldShowSkillsInstalledDialog(targets);

Assert.That(shouldShowDialog, Is.False);
}

[Test]
public void ShouldShowSkillsInstalledDialog_WhenAnyTargetUsesDifferentLayout_ReturnsFalse()
{
// Verifies that Setup Wizard suppresses the success dialog for skill layout updates.
List<SkillSetupTargetInfo> targets = new()
{
CreateSkillTarget(
hasSkillsDirectory: true,
SkillInstallState.Missing,
hasDifferentLayoutSkills: true)
};

bool shouldShowDialog = SetupWizardWindow.ShouldShowSkillsInstalledDialog(targets);

Assert.That(shouldShowDialog, Is.False);
}

[TestCase(SkillInstallState.Installed, false, true, "setup-target-item__status--installed")]
[TestCase(SkillInstallState.Checking, false, true, "setup-target-item__status--checking")]
[TestCase(SkillInstallState.Outdated, false, true, "setup-target-item__status--outdated")]
Expand Down
31 changes: 31 additions & 0 deletions Assets/Tests/Editor/UnityCliLoopSettingsWindowCliActionTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NUnit.Framework;
using UnityEngine;

using io.github.hatayama.UnityCliLoop.Domain;
using io.github.hatayama.UnityCliLoop.Presentation;

namespace io.github.hatayama.UnityCliLoop.Tests.Editor
Expand Down Expand Up @@ -131,6 +132,36 @@ public void IsCliUpdateNeeded_UsesDispatcherMinimumVersion(
Assert.That(result, Is.EqualTo(expected));
}

[TestCase(SkillInstallState.Missing, false, true)]
[TestCase(SkillInstallState.Outdated, false, false)]
[TestCase(SkillInstallState.Missing, true, false)]
public void ShouldShowSkillsInstalledDialog_ReturnsExpectedValue(
SkillInstallState installState,
bool hasDifferentLayoutSkills,
bool expected)
{
// Verifies that Settings keeps the success dialog for first install only.
SkillSetupTargetInfo targetInfo = CreateSkillTarget(installState, hasDifferentLayoutSkills);

bool result = UnityCliLoopSettingsWindow.ShouldShowSkillsInstalledDialog(targetInfo);

Assert.That(result, Is.EqualTo(expected));
}

private static SkillSetupTargetInfo CreateSkillTarget(
SkillInstallState installState,
bool hasDifferentLayoutSkills)
{
return new SkillSetupTargetInfo(
"Claude Code",
".claude",
"--claude",
hasSkillsDirectory: true,
hasExistingSkills: true,
hasDifferentLayoutSkills,
installState);
}

private static UnityCliLoopSettingsWindow.CliPrimaryButtonAction ParseAction(string action)
{
return (UnityCliLoopSettingsWindow.CliPrimaryButtonAction)
Expand Down
15 changes: 14 additions & 1 deletion Packages/src/Editor/Presentation/Setup/SetupWizardWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,15 @@ internal static bool HasSkillUpdateForSetupWizard(
|| target.HasDifferentLayoutSkills));
}

internal static bool ShouldShowSkillsInstalledDialog(
IEnumerable<SkillSetupTargetInfo> targets)
{
Debug.Assert(targets != null, "targets must not be null");
return targets.All(target =>
target.InstallState != SkillInstallState.Outdated
&& !target.HasDifferentLayoutSkills);
}

internal static bool ShouldUseFirstInstallSkillsUi(string lastSeenSetupWizardVersion)
{
return string.IsNullOrEmpty(lastSeenSetupWizardVersion);
Expand Down Expand Up @@ -1316,6 +1325,7 @@ private async void HandleInstallSkills()
: FilterInstallableSkillTargets(targets);
if (installableTargets.Count == 0) return;

bool shouldShowSkillsInstalledDialog = ShouldShowSkillsInstalledDialog(installableTargets);
_isInstallingSkills = true;
UpdateSkillsStep(true, targets);

Expand All @@ -1325,7 +1335,10 @@ await _skillSetupUseCase.InstallSkillFilesAsync(
installableTargets,
!_installSkillsFlat,
CancellationToken.None);
EditorDialogHelper.ShowSkillsInstalledDialog();
if (shouldShowSkillsInstalledDialog)
{
EditorDialogHelper.ShowSkillsInstalledDialog();
}
}
finally
{
Expand Down
29 changes: 25 additions & 4 deletions Packages/src/Editor/Presentation/UnityCliLoopSettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,16 @@ private SkillInstallState GetSelectedTargetInstallState(bool includeFreshnessChe
private SkillInstallState GetSelectedTargetInstallState(
string projectRoot,
bool includeFreshnessCheck)
{
SkillSetupTargetInfo targetInfo = GetSelectedTargetInfo(projectRoot, includeFreshnessCheck);
return string.IsNullOrEmpty(targetInfo.DirName)
? SkillInstallState.Missing
: targetInfo.InstallState;
}

private SkillSetupTargetInfo GetSelectedTargetInfo(
string projectRoot,
bool includeFreshnessCheck)
{
SkillsTargetSelection selection = SkillsTargetSelectionResolver.Resolve(
_skillsTarget,
Expand All @@ -746,9 +756,7 @@ private SkillInstallState GetSelectedTargetInstallState(
SkillSetupTargetInfo targetInfo = targets
.FirstOrDefault(target => target.DirName == selection.DirectoryName);

return string.IsNullOrEmpty(targetInfo.DirName)
? SkillInstallState.Missing
: targetInfo.InstallState;
return targetInfo;
}

private void CancelSkillInstallStateRefresh()
Expand Down Expand Up @@ -967,6 +975,12 @@ internal static bool IsCliUpdateNeeded(string cliVersion, bool cliIsDispatcher)
return EvaluateCliSetupCompatibility(cliVersion, cliIsDispatcher).NeedsUpdate;
}

internal static bool ShouldShowSkillsInstalledDialog(SkillSetupTargetInfo targetInfo)
{
return targetInfo.InstallState != SkillInstallState.Outdated
&& !targetInfo.HasDifferentLayoutSkills;
}

private static CliSetupCompatibilityState EvaluateCliSetupCompatibility(
string cliVersion,
bool cliIsDispatcher)
Expand Down Expand Up @@ -1019,6 +1033,10 @@ private async void HandleInstallSkills()
return;
}

string projectRoot = UnityCliLoopPathResolver.GetProjectRoot();
SkillSetupTargetInfo selectedTargetInfo =
GetSelectedTargetInfo(projectRoot, includeFreshnessCheck: true);
bool shouldShowSkillsInstalledDialog = ShouldShowSkillsInstalledDialog(selectedTargetInfo);
CancelSkillInstallStateRefresh();
_isInstallingSkills = true;
RefreshCliSetupSection();
Expand All @@ -1040,7 +1058,10 @@ await _skillSetupUseCase.InstallSkillFilesAsync(
new List<SkillSetupTargetInfo> { target },
!_installSkillsFlat,
CancellationToken.None);
EditorDialogHelper.ShowSkillsInstalledDialog();
if (shouldShowSkillsInstalledDialog)
{
EditorDialogHelper.ShowSkillsInstalledDialog();
}
}
finally
{
Expand Down
Loading