Add queued FFmpeg conversion and finish splitting the window from the host.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-25 01:49:50 +02:00
parent 48d03f794f
commit 6fc7506eb7
85 changed files with 3394 additions and 512 deletions

View File

@@ -1,7 +1,12 @@
using Explorer.Analysis;
using Explorer.Application;
using Explorer.Contracts;
using Explorer.Domain;
using Explorer.Domain.Abstractions;
using Explorer.Hosting;
using Explorer.Indexing;
using Explorer.Plugin.Abstractions;
using Explorer.Search;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -26,6 +31,10 @@ public class CoreRegistrationTests
Assert.NotNull(sp.GetService<ITransferHost>());
Assert.NotNull(sp.GetService<IIndexMutations>());
Assert.Null(sp.GetService<IOsClipboard>());
Assert.NotNull(sp.GetService<FilesystemScanner>());
Assert.NotEmpty(sp.GetServices<IStorageProvider>());
Assert.NotNull(sp.GetService<ICloudOverlay>());
Assert.IsType<StorageProviderRegistry>(sp.GetService<ICloudOverlay>());
}
finally
{
@@ -52,9 +61,22 @@ public class CoreRegistrationTests
Assert.Same(workbench.Sources, sp.GetService<ISourceHost>());
Assert.Same(workbench.Mutations, sp.GetService<IIndexMutations>());
Assert.False(sp.GetRequiredService<IIndexStore>().CanWrite);
Assert.NotNull(sp.GetService<BrowseService>());
Assert.NotNull(sp.GetService<SearchService>());
Assert.NotNull(sp.GetService<AnalysisService>());
Assert.NotNull(sp.GetService<Explorer.FileOperations.FileOperationService>());
Assert.NotNull(sp.GetService<Explorer.FileOperations.FolderSyncService>());
Assert.Same(NullCloudOverlay.Instance, sp.GetService<ICloudOverlay>());
Assert.Null(sp.GetService<FilesystemScanner>());
Assert.Null(sp.GetService<FolderReconciler>());
Assert.Null(sp.GetService<UsnChangeApplier>());
Assert.Null(sp.GetService<ArchiveContentsIndexer>());
Assert.Null(sp.GetService<IUsnJournal>());
Assert.Null(sp.GetService<IElevatedScanService>());
Assert.Empty(sp.GetServices<IStorageProvider>());
var hosted = sp.GetServices<IHostedService>().ToList();
Assert.Contains(hosted, s => s is IndexStoreLifetime);
Assert.DoesNotContain(hosted, s => s.GetType().Name is "IndexingCoordinator" or "TransferQueue" or "WatcherHostedService");
Assert.DoesNotContain(hosted, s => s.GetType().Name is "IndexingCoordinator" or "TransferQueue" or "WatcherHostedService" or "DuplicateHashWorker" or "HistoryRollupService");
}
finally
{

View File

@@ -17,6 +17,7 @@
<ProjectReference Include="..\..\src\Explorer.Application\Explorer.Application.csproj" />
<ProjectReference Include="..\..\src\Explorer.Contracts\Explorer.Contracts.csproj" />
<ProjectReference Include="..\..\src\Explorer.Domain\Explorer.Domain.csproj" />
<ProjectReference Include="..\..\src\Explorer.Hosting.Client\Explorer.Hosting.Client.csproj" />
<ProjectReference Include="..\..\src\Explorer.Hosting\Explorer.Hosting.csproj" />
</ItemGroup>
</Project>

View File

@@ -5,15 +5,12 @@ namespace Explorer.Hosting.Tests;
public class HostLogonAutostartTests
{
[Fact]
public void Create_args_are_per_user_logon_not_system_service()
public void Run_command_is_the_quoted_host_exe_for_the_current_user()
{
var args = HostLogonAutostart.CreateTaskArgs(@"C:\Tools\Explorer.Host.exe");
Assert.Contains("/SC", args);
Assert.Contains("ONLOGON", args);
Assert.Contains("/RL", args);
Assert.Contains("LIMITED", args);
Assert.Contains(HostLogonAutostart.TaskName, args);
Assert.DoesNotContain("ONSTART", args);
Assert.DoesNotContain("/RU", args);
var command = HostLogonAutostart.RunCommand(@"C:\Tools\Explorer.Host.exe");
Assert.Equal("\"C:\\Tools\\Explorer.Host.exe\"", command);
Assert.Equal("ExplorerWorkbenchHost", HostLogonAutostart.RunValueName);
Assert.DoesNotContain("/RU", command, StringComparison.OrdinalIgnoreCase);
Assert.DoesNotContain("ONSTART", command, StringComparison.OrdinalIgnoreCase);
}
}

View File

@@ -0,0 +1,67 @@
namespace Explorer.Hosting.Tests;
public class ProjectGraphTests
{
[Fact]
public void App_references_client_not_host_runtime_or_plugin_implementations()
{
var csproj = File.ReadAllText(Path.Combine(RepoRoot(), "src", "Explorer.App", "Explorer.App.csproj"));
Assert.Contains("Explorer.Hosting.Client", csproj);
Assert.Contains("Explorer.Presentation", csproj);
Assert.DoesNotContain("Explorer.Hosting\\Explorer.Hosting.csproj", csproj);
Assert.DoesNotContain("Explorer.Plugin.OneDrive", csproj);
Assert.DoesNotContain("Explorer.Plugin.GoogleDrive", csproj);
Assert.DoesNotContain("Explorer.Plugin.Nextcloud", csproj);
Assert.DoesNotContain("Explorer.Indexing", csproj);
}
[Fact]
public void Client_does_not_reference_plugin_implementations_or_scanners()
{
var csproj = File.ReadAllText(Path.Combine(RepoRoot(), "src", "Explorer.Hosting.Client", "Explorer.Hosting.Client.csproj"));
Assert.Contains("Explorer.Plugin.Abstractions", csproj);
Assert.Contains("Explorer.Storage.Sqlite", csproj);
Assert.DoesNotContain("Explorer.Plugin.OneDrive", csproj);
Assert.DoesNotContain("Explorer.Plugin.GoogleDrive", csproj);
Assert.DoesNotContain("Explorer.Plugin.Nextcloud", csproj);
Assert.DoesNotContain("Explorer.Indexing", csproj);
Assert.DoesNotContain("Explorer.Hosting\\Explorer.Hosting.csproj", csproj);
}
[Fact]
public void Host_runtime_owns_plugins_and_references_the_client()
{
var csproj = File.ReadAllText(Path.Combine(RepoRoot(), "src", "Explorer.Hosting", "Explorer.Hosting.csproj"));
Assert.Contains("Explorer.Hosting.Client", csproj);
Assert.Contains("Explorer.Plugin.OneDrive", csproj);
Assert.Contains("Explorer.Plugin.GoogleDrive", csproj);
Assert.Contains("Explorer.Plugin.Nextcloud", csproj);
Assert.Contains("Explorer.Indexing", csproj);
}
[Fact]
public void Presentation_may_reference_plugin_abstractions_not_implementations()
{
var csproj = File.ReadAllText(Path.Combine(RepoRoot(), "src", "Explorer.Presentation", "Explorer.Presentation.csproj"));
Assert.Contains("Explorer.Plugin.Abstractions", csproj);
Assert.DoesNotContain("Explorer.Plugin.OneDrive", csproj);
Assert.DoesNotContain("Explorer.Plugin.GoogleDrive", csproj);
Assert.DoesNotContain("Explorer.Plugin.Nextcloud", csproj);
}
private static string RepoRoot()
{
var dir = new DirectoryInfo(AppContext.BaseDirectory);
while (dir is not null)
{
if (File.Exists(Path.Combine(dir.FullName, "Explorer.slnx")))
{
return dir.FullName;
}
dir = dir.Parent;
}
throw new InvalidOperationException("Could not find Explorer.slnx above " + AppContext.BaseDirectory);
}
}

View File

@@ -1,7 +1,11 @@
using System.Diagnostics;
using System.Text.Json;
using Explorer.Application;
using Explorer.Contracts;
using Explorer.Domain;
using Explorer.Hosting.Ipc;
using Explorer.Plugin.Abstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging.Abstractions;
namespace Explorer.Hosting.Tests;
@@ -13,10 +17,7 @@ public class WorkbenchPipeTests
{
var indexing = new FakeIndexing();
var transfers = new FakeTransfers();
var server = new WorkbenchPipeServer(
new WorkbenchHost(indexing, transfers, new StubSources(), new StubMutations()),
new WorkbenchIpcOptions { PipeName = "ew-test" },
NullLogger<WorkbenchPipeServer>.Instance);
var server = CreateServer(indexing, transfers);
var ping = server.Handle(new IpcEnvelope { V = WorkbenchIpc.ProtocolVersion, Op = "Ping" });
Assert.True(ping.Ok);
@@ -46,15 +47,122 @@ public class WorkbenchPipeTests
[Fact]
public void Handle_rejects_other_protocol_versions()
{
var server = new WorkbenchPipeServer(
new WorkbenchHost(new FakeIndexing(), new FakeTransfers(), new StubSources(), new StubMutations()),
new WorkbenchIpcOptions(),
NullLogger<WorkbenchPipeServer>.Instance);
var server = CreateServer(new FakeIndexing(), new FakeTransfers());
var reply = server.Handle(new IpcEnvelope { V = 99, Op = "Ping" });
Assert.False(reply.Ok);
Assert.Contains("99", reply.Error);
}
[Fact]
public async Task Connect_to_a_missing_pipe_fails_quickly()
{
var options = new WorkbenchIpcOptions { PipeName = "ew-missing-" + Guid.NewGuid().ToString("N") };
var started = Stopwatch.GetTimestamp();
await Assert.ThrowsAsync<TimeoutException>(() =>
WorkbenchPipeClient.ConnectAsync(options, TimeSpan.FromMilliseconds(400)));
Assert.True(
Stopwatch.GetElapsedTime(started) < TimeSpan.FromSeconds(3),
"Named-pipe connect hung instead of timing out.");
}
[Fact]
public void Handle_cloud_places_does_not_need_a_workbench()
{
var services = new ServiceCollection();
services.AddSingleton<ICloudOverlay>(NullCloudOverlay.Instance);
using var sp = services.BuildServiceProvider();
var server = new WorkbenchPipeServer(
sp,
new WorkbenchIpcOptions(),
NullLogger<WorkbenchPipeServer>.Instance);
var reply = server.Handle(new IpcEnvelope { V = WorkbenchIpc.ProtocolVersion, Op = "Cloud.Places" });
Assert.True(reply.Ok);
var places = JsonSerializer.Deserialize<ProviderPlace[]>(reply.Payload ?? "null", WorkbenchIpc.Json);
Assert.NotNull(places);
Assert.Empty(places);
}
[Fact]
public async Task IsListening_does_not_consume_the_server_instance()
{
var options = new WorkbenchIpcOptions { PipeName = "ew-probe-" + Guid.NewGuid().ToString("N") };
using var sp = new ServiceCollection().BuildServiceProvider();
var server = new WorkbenchPipeServer(
sp,
options,
NullLogger<WorkbenchPipeServer>.Instance);
await server.StartAsync(CancellationToken.None);
try
{
await server.Listening.WaitAsync(TimeSpan.FromSeconds(3));
Assert.True(WorkbenchIpc.IsListening(options.PipeName, 200));
await using var client = await WorkbenchPipeClient.ConnectAsync(options, TimeSpan.FromSeconds(3));
}
finally
{
await server.StopAsync(CancellationToken.None);
}
}
[Fact]
public void Handle_host_shutdown_does_not_need_a_workbench()
{
using var sp = new ServiceCollection().BuildServiceProvider();
var server = new WorkbenchPipeServer(
sp,
new WorkbenchIpcOptions(),
NullLogger<WorkbenchPipeServer>.Instance);
var stopped = false;
server.ShutdownRequested = () => stopped = true;
var reply = server.Handle(new IpcEnvelope { V = WorkbenchIpc.ProtocolVersion, Op = "Host.Shutdown" });
Assert.True(reply.Ok);
Assert.True(stopped);
}
[Fact]
public void Ping_does_not_need_a_workbench()
{
using var sp = new ServiceCollection().BuildServiceProvider();
var server = new WorkbenchPipeServer(
sp,
new WorkbenchIpcOptions(),
NullLogger<WorkbenchPipeServer>.Instance);
var ping = server.Handle(new IpcEnvelope { V = WorkbenchIpc.ProtocolVersion, Op = "Ping" });
Assert.True(ping.Ok);
}
[Fact]
public async Task Ping_roundtrip_over_a_live_named_pipe()
{
var options = new WorkbenchIpcOptions { PipeName = "ew-live-" + Guid.NewGuid().ToString("N") };
using var sp = new ServiceCollection().BuildServiceProvider();
var server = new WorkbenchPipeServer(
sp,
options,
NullLogger<WorkbenchPipeServer>.Instance);
await server.StartAsync(CancellationToken.None);
try
{
await server.Listening.WaitAsync(TimeSpan.FromSeconds(3));
await using var client = await WorkbenchPipeClient.ConnectAsync(options, TimeSpan.FromSeconds(3));
}
finally
{
await server.StopAsync(CancellationToken.None);
}
}
private static WorkbenchPipeServer CreateServer(FakeIndexing indexing, FakeTransfers transfers)
{
var services = new ServiceCollection();
services.AddSingleton<IWorkbenchHost>(
new WorkbenchHost(indexing, transfers, new StubSources(), new StubMutations()));
return new WorkbenchPipeServer(
services.BuildServiceProvider(),
new WorkbenchIpcOptions { PipeName = "ew-test" },
NullLogger<WorkbenchPipeServer>.Instance);
}
private sealed class FakeIndexing : IIndexingHost
{
public long FullScanId { get; private set; }