Skip to content

Commit 71a1a84

Browse files
committed
Fixed for desktop module
1 parent b86237f commit 71a1a84

File tree

4 files changed

+32
-27
lines changed

4 files changed

+32
-27
lines changed

Bellatrix.LLM/Bellatrix.LLM.csproj

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>net8.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
88

9-
<ItemGroup>
10-
<ProjectReference Include="..\src\Bellatrix.Core\Bellatrix.Core.csproj" />
11-
<ProjectReference Include="..\src\Bellatrix.KeyVault\Bellatrix.KeyVault.csproj" />
12-
<ProjectReference Include="..\src\Bellatrix.Plugins.Screenshots\Bellatrix.Plugins.Screenshots.csproj" />
13-
</ItemGroup>
9+
<ItemGroup>
10+
<ProjectReference Include="..\src\Bellatrix.Core\Bellatrix.Core.csproj" />
11+
<ProjectReference Include="..\src\Bellatrix.KeyVault\Bellatrix.KeyVault.csproj" />
12+
<ProjectReference Include="..\src\Bellatrix.Plugins.Screenshots\Bellatrix.Plugins.Screenshots.csproj" />
13+
</ItemGroup>
1414

15-
<ItemGroup>
16-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.5" />
17-
<PackageReference Include="Microsoft.SemanticKernel" Version="1.50.0" />
18-
<PackageReference Include="Microsoft.KernelMemory" Version="0.98.250508.3" />
19-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
20-
<PackageReference Include="NUnit" Version="4.3.2" />
21-
</ItemGroup>
15+
<ItemGroup>
16+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.5" />
17+
<PackageReference Include="Microsoft.SemanticKernel" Version="1.50.0" />
18+
<!-- DO NOT update Microsoft.KernelMemory unless we move to .NET 9 -->
19+
<PackageReference Include="Microsoft.KernelMemory" Version="0.97.250211.1" />
20+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
21+
<PackageReference Include="NUnit" Version="4.3.2" />
22+
</ItemGroup>
2223

23-
</Project>
24+
</Project>

Bellatrix.LLM/plugins/SmartFailureAnalysisPlugin .cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
// The architecture and agent logic are original contributions by Anton Angelov, forming the foundation for a PhD dissertation.
1616
// Please cite or credit appropriately if reusing in academic or commercial work.</note>
1717

18+
using Bellatrix.LLM.Settings;
1819
using Bellatrix.Plugins.Screenshots.Contracts;
1920
using Bellatrix.Plugins;
2021
using Bellatrix.Plugins.Screenshots.Plugins;
@@ -26,12 +27,14 @@ public class SmartFailureAnalysisPlugin : Plugin, IScreenshotPlugin
2627
private readonly IScreenshotOutputProvider _screenshotOutputProvider;
2728
private readonly IViewSnapshotProvider _viewSnapshotProvider;
2829
private static ThreadLocal<string> _screenshotPath = new ThreadLocal<string>();
30+
private readonly bool _isEnabled;
2931

3032

3133
public SmartFailureAnalysisPlugin()
3234
{
3335
_screenshotOutputProvider = ServicesCollection.Current.Resolve<IScreenshotOutputProvider>();
3436
_viewSnapshotProvider = ServicesCollection.Main.Resolve<IViewSnapshotProvider>();
37+
_isEnabled = ConfigurationService.GetSection<LargeLanguageModelsSettings>().EnableSmartFailureAnalysis;
3538
}
3639

3740
public static void Add()
@@ -60,6 +63,7 @@ public void ScreenshotGenerated(object sender, ScreenshotPluginEventArgs args)
6063

6164
protected override void PreTestCleanup(object sender, PluginEventArgs e)
6265
{
66+
if (!_isEnabled) return;
6367
if (e.TestOutcome == TestOutcome.Passed)
6468
{
6569
var log = Logger.GetLogs();
@@ -87,7 +91,7 @@ private void RunFailureAnalysisAsync(PluginEventArgs e)
8791
snapshot,
8892
_screenshotPath.Value ?? string.Empty);
8993

90-
94+
9195
}
9296
catch (Exception ex)
9397
{
@@ -112,4 +116,4 @@ private void RunFailureAnalysisAsync(PluginEventArgs e)
112116
//{extended}
113117
//""");
114118
}
115-
}
119+
}

src/Bellatrix.Desktop/components/Core/Component.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ public AppiumElement WrappedElement
6767
{
6868
get
6969
{
70-
ReturningWrappedElement?.Invoke(this, new NativeElementActionEventArgs(GetAndWaitWebDriverElement()));
71-
var element = GetWebDriverElement();
70+
var element = GetAndWaitWebDriverElement();
71+
ReturningWrappedElement?.Invoke(this, new NativeElementActionEventArgs(element));
7272
return element;
7373
}
7474
internal set => _wrappedElement = value;
@@ -253,7 +253,7 @@ protected AppiumElement GetAndWaitWebDriverElement()
253253
if (_llmSettings.EnableSelfHealing)
254254
{
255255
var snapshot = _viewSnapshotProvider.GetCurrentViewSnapshot();
256-
LocatorSelfHealingService.SaveWorkingLocator(By.ToString(), snapshot, WrappedDriver.Title);
256+
LocatorSelfHealingService.SaveWorkingLocator(By.ToString(), snapshot, WrappedDriver.CurrentWindowHandle);
257257
}
258258

259259
_untils.Clear();
@@ -269,7 +269,7 @@ protected AppiumElement GetAndWaitWebDriverElement()
269269
Logger.LogWarning($"⚠️ Element not found with locator: {By}. Trying AI-based healing...");
270270

271271
var snapshot = _viewSnapshotProvider.GetCurrentViewSnapshot();
272-
var healedXpath = LocatorSelfHealingService.TryHeal(By.ToString(), snapshot, WrappedDriver.Title);
272+
var healedXpath = LocatorSelfHealingService.TryHeal(By.ToString(), snapshot, WrappedDriver.CurrentWindowHandle);
273273

274274
if (!string.IsNullOrEmpty(healedXpath))
275275
{

src/Bellatrix.Desktop/infrastructure/App.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static void StartAppiumServer()
105105
StartInfo = new ProcessStartInfo
106106
{
107107
FileName = "powershell.exe",
108-
Arguments = "-NoProfile -ExecutionPolicy RemoteSigned -Command \"appium driver list --installed --json\"",
108+
Arguments = $"-NoProfile -ExecutionPolicy RemoteSigned -File \"{appiumPs1Path}\" driver list --installed --json",
109109
RedirectStandardOutput = true,
110110
UseShellExecute = false,
111111
CreateNoWindow = true,
@@ -124,7 +124,7 @@ public static void StartAppiumServer()
124124
Console.WriteLine("NovaWindows driver not found. Installing...");
125125
Process.Start(
126126
"powershell.exe",
127-
$"-NoProfile -ExecutionPolicy RemoteSigned -Command \"appium driver install --source=npm appium-novawindows-driver@{latestVersion}\""
127+
$"-NoProfile -ExecutionPolicy RemoteSigned -File \"{appiumPs1Path}\" driver install --source=npm appium-novawindows-driver@{latestVersion}"
128128
)?.WaitForExit();
129129
}
130130
else
@@ -135,7 +135,7 @@ public static void StartAppiumServer()
135135
Console.WriteLine($"Updating NovaWindows driver to {latestVersion}...");
136136
Process.Start(
137137
"powershell.exe",
138-
"-NoProfile -ExecutionPolicy RemoteSigned -Command \"appium driver update novawindows\""
138+
$"-NoProfile -ExecutionPolicy RemoteSigned -File \"{appiumPs1Path}\" driver update novawindows"
139139
)?.WaitForExit();
140140
}
141141
else

0 commit comments

Comments
 (0)