Compare commits

..

No commits in common. "3789492de34995a4e7aeac8ccbe1304e9379c5ff" and "0dde7c40f322324ff77435036c5f263f1960ca2b" have entirely different histories.

7 changed files with 88 additions and 54 deletions

View File

@ -10,19 +10,27 @@ internal sealed record MenuItem(string Display, string Value);
public enum AppExitReason { Quit, SwitchProject }
public sealed record AppResult(AppExitReason Reason, string? NewProjectRoot = null);
public sealed class App(
public sealed class App
{
private DevToolConfig _config;
private string _projectRoot;
private readonly WorkspaceConfig? _workspace;
private readonly string? _workspaceRoot;
private IReadOnlyDictionary<string, BuildTarget> TargetMap =>
_config.Targets.ToDictionary(t => t.Id, StringComparer.OrdinalIgnoreCase);
public App(
DevToolConfig config,
string projectRoot,
WorkspaceConfig? workspace = null,
string? workspaceRoot = null)
{
private DevToolConfig _config = config;
private string _projectRoot = projectRoot;
private readonly WorkspaceConfig? _workspace = workspace;
private readonly string? _workspaceRoot = workspaceRoot;
private IReadOnlyDictionary<string, BuildTarget> TargetMap =>
_config.Targets.ToDictionary(t => t.Id, StringComparer.OrdinalIgnoreCase);
_config = config;
_projectRoot = projectRoot;
_workspace = workspace;
_workspaceRoot = workspaceRoot;
}
public async Task<AppResult> RunAsync()
{

View File

@ -5,10 +5,16 @@ using Spectre.Console;
namespace Sdt.Tui;
public sealed class ToolchainScreen(DevToolConfig config, string projectRoot)
public sealed class ToolchainScreen
{
private readonly DevToolConfig _config = config;
private readonly string _projectRoot = projectRoot;
private readonly DevToolConfig _config;
private readonly string _projectRoot;
public ToolchainScreen(DevToolConfig config, string projectRoot)
{
_config = config;
_projectRoot = projectRoot;
}
public async Task RunAsync()
{
@ -257,7 +263,7 @@ public sealed class ToolchainScreen(DevToolConfig config, string projectRoot)
// ── Helpers ───────────────────────────────────────────────────────────────
private static string ResolvePythonExe(PythonToolchain py)
private string ResolvePythonExe(PythonToolchain py)
{
if (OperatingSystem.IsWindows() && !string.IsNullOrWhiteSpace(py.WindowsExecutable))
return py.WindowsExecutable;

View File

@ -3,11 +3,18 @@ using Spectre.Console;
namespace Sdt.Tui;
public sealed class WorkspaceScreen(WorkspaceConfig workspace, string workspaceRoot, string currentProjectRoot)
public sealed class WorkspaceScreen
{
private readonly WorkspaceConfig _workspace = workspace;
private readonly string _workspaceRoot = workspaceRoot;
private readonly string _currentProjectRoot = currentProjectRoot;
private readonly WorkspaceConfig _workspace;
private readonly string _workspaceRoot;
private readonly string _currentProjectRoot;
public WorkspaceScreen(WorkspaceConfig workspace, string workspaceRoot, string currentProjectRoot)
{
_workspace = workspace;
_workspaceRoot = workspaceRoot;
_currentProjectRoot = currentProjectRoot;
}
/// <summary>
/// Shows the project switcher. Returns the absolute path to the selected project root,

View File

@ -67,11 +67,11 @@ app.MapPost("/api/command", async (CommandEnvelope? command, Entry entry) =>
app.MapGet("/api/sidecar/root", (SidecarRootState rootState) =>
{
var (root, isCustom) = rootState.Get();
var snapshot = rootState.Get();
return Results.Ok(new
{
root,
isCustom
root = snapshot.Root,
isCustom = snapshot.IsCustom
});
});
@ -84,12 +84,12 @@ app.MapPost("/api/sidecar/root", (SetSidecarRootRequest? request, SidecarRootSta
}
rootState.Set(path);
var (root, isCustom) = rootState.Get();
Environment.SetEnvironmentVariable("JOURNAL_PROJECT_ROOT", root);
var snapshot = rootState.Get();
Environment.SetEnvironmentVariable("JOURNAL_PROJECT_ROOT", snapshot.Root);
return Results.Ok(new
{
root,
isCustom
root = snapshot.Root,
isCustom = snapshot.IsCustom
});
});
@ -207,20 +207,32 @@ string ResolveWebDist(string repoRootPath)
string ErrorResponse(string message)
=> JsonSerializer.Serialize(new { ok = false, error = message }, gatewayJsonOptions);
sealed class WebUiState(string distPath)
sealed class WebUiState
{
public string DistPath { get; } = distPath;
public WebUiState(string distPath)
{
DistPath = distPath;
}
public string DistPath { get; }
public bool Exists => Directory.Exists(DistPath) && File.Exists(Path.Combine(DistPath, "index.html"));
}
sealed class SidecarRootState(string autoRoot)
sealed class SidecarRootState
{
private readonly object _sync = new();
private readonly string _autoRoot = autoRoot;
private string _currentRoot = autoRoot;
private readonly string _autoRoot;
private string _currentRoot;
private bool _isCustom;
public SidecarRootState(string autoRoot)
{
_autoRoot = autoRoot;
_currentRoot = autoRoot;
_isCustom = false;
}
public (string Root, bool IsCustom) Get()
{
lock (_sync)
@ -260,3 +272,5 @@ sealed class CommandEnvelope
public string? Tag { get; set; }
public JsonElement? Payload { get; set; }
}

View File

@ -3,5 +3,4 @@
<Project Path="Journal.Sidecar/Journal.Sidecar.csproj" />
<Project Path="Journal.SmokeTests/Journal.SmokeTests.csproj" />
<Project Path="Journal.DevTool/Journal.DevTool.csproj" />
<Project Path="Journal.WebGateway/Journal.WebGateway.csproj" />
</Solution>