Files
Chronos/src/Chronos.Core/Project/Auto.cs
T
Alby96andClaude Opus 5.5 9b24cf74fc
CI / Build and test (push) Successful in 9m43s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 27s
CI / PostgreSQL 16 integration (push) Failing after 8m41s
CI / PostgreSQL 17 integration (push) Successful in 12m37s
CI / Docker image (push) Successful in 56s
Release / Build, test and publish (push) Successful in 14m59s
Release / Server image (push) Successful in 1m51s
feat: owner review 2 phase 5a: workspace and projects with a local home (#14)
Edit opens a sequence as a project of a workspace folder outside the library. Projects have linear version histories kept as sidecars in .chronos/projects/, Main mirrors the sequence's settings, and sync merges setting by setting. Migration 0009, JobKind.WorkspaceCopy = 20, Settings › Workspace, and 241 new strings in 38 languages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-11-04 09:22:08 +01:00

46 lines
2.1 KiB
C#

using System.Text.Json;
using System.Text.Json.Serialization;
namespace Chronos.Core.Project;
/// <summary>
/// A parameter the advisor can decide (BRIEF §10.4). In Auto the advisor's <see cref="AutoValue"/> applies and
/// <see cref="ReasonKey"/>/<see cref="ReasonArgs"/> explain it; touching the control stores a manual
/// <see cref="Manual"/> value; reset returns to Auto.
/// </summary>
public sealed record Auto<T>
{
public bool IsAuto { get; init; } = true;
/// <summary>The advisor's value; meaningful only when <see cref="HasAdvice"/>.</summary>
public T? AutoValue { get; init; }
/// <summary>True once the advisor stored a value. Needed because a value type's <see cref="AutoValue"/> is never
/// null: without it "no advice" and an advised 0 or false look the same.</summary>
public bool HasAdvice { get; init; }
/// <summary>The user's value when <see cref="IsAuto"/> is false.</summary>
public T? Manual { get; init; }
/// <summary>Localization key of the reason shown in the Auto pill tooltip.</summary>
public string? ReasonKey { get; init; }
public IReadOnlyList<string>? ReasonArgs { get; init; }
/// <summary>
/// Members this Chronos does not know (written by a newer one, such as the advisor's confidence): kept as they are, so
/// they survive a round trip and every edit of the parameter (owner review 2, R8).
/// </summary>
[JsonExtensionData]
public Dictionary<string, JsonElement>? Extra { get; set; }
/// <summary>The value in force: manual when set by the user, otherwise the advisor's, otherwise <paramref name="fallback"/>.</summary>
public T Resolve(T fallback) => !IsAuto && Manual is not null ? Manual : HasAdvice && AutoValue is not null ? AutoValue : fallback;
public Auto<T> WithManual(T value) => this with { IsAuto = false, Manual = value };
public Auto<T> Reset() => this with { IsAuto = true, Manual = default };
public Auto<T> WithAdvice(T value, string? reasonKey, params string[] args) => this with { AutoValue = value, HasAdvice = true, ReasonKey = reasonKey, ReasonArgs = args };
}