diff --git a/AGENTS.md b/AGENTS.md index 8147740..2965975 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -105,6 +105,8 @@ agents edit the same files at once. ## Building and testing +Releasing: bump `` in `Directory.Build.props`, then publish; the tool stamps the plugin manifest. + Run every command from the repository root. | Command | What it does | @@ -124,7 +126,8 @@ a screenshot of each changed view: compiling is not working. - `tools/agent-review.sh`: posts an agent review and sets the `agent-review` status; see `docs/agents/review.md`. - `tools/publish.py`: publishes the app, `finaltoken-cli` and Stream Deck plugin with NativeAOT - into an empty output directory and creates a ZIP beside it. Run on the target OS. + into an empty output directory and creates a ZIP beside it. Run on the target OS. It stamps + the plugin manifest's `Version` from ``; its test is `python -B tools/test_publish.py`. ## Writing diff --git a/Directory.Build.props b/Directory.Build.props index bf5bb9a..aff0546 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,6 @@ + 1.0.1 net10.0 14 enable diff --git a/src/FinalToken.App/PanelWindow.cs b/src/FinalToken.App/PanelWindow.cs index 09cd0b0..7b8c87c 100644 --- a/src/FinalToken.App/PanelWindow.cs +++ b/src/FinalToken.App/PanelWindow.cs @@ -31,7 +31,7 @@ public sealed class PanelWindow : Window public PanelWindow(PanelViewModel model, Action refresh, Action settings, Action quit, Action reload) { this.model = model; - Title = "FinalToken"; Width = 1160; Height = 920; MinWidth = 720; MinHeight = 500; + Title = $"FinalToken {typeof(Program).Assembly.GetName().Version?.ToString(3)}"; Width = 1160; Height = 920; MinWidth = 720; MinHeight = 500; var header = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 12 }; header.Children.Add(Ui.Text("FinalToken", 28)); header.Children.Add(Ui.Button("Refresh now", refresh)); diff --git a/src/FinalToken.App/Popups.cs b/src/FinalToken.App/Popups.cs index fe336f5..f9f1970 100644 --- a/src/FinalToken.App/Popups.cs +++ b/src/FinalToken.App/Popups.cs @@ -41,7 +41,7 @@ public sealed class PopupWindow : Window (alert.Projection is { } projection ? $" At this rate: 100% at {Display.Projection(projection)}." : ""), open, accent: PaceBar.Colour(alert.State)); } -public sealed class PopupStack(Action open) : IDisposable +public sealed class PopupStack(Action open, TimeProvider? clock = null) : IDisposable { private readonly List windows = []; public void Pace(PopupEvent alert) => Show(PopupWindow.Pace(alert, open)); @@ -50,9 +50,10 @@ public sealed class PopupStack(Action open) : IDisposable windows.Add(window); window.Closed += (_, _) => { windows.Remove(window); Position(); }; window.Show(); Position(); - var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(8) }; - timer.Tick += (_, _) => { timer.Stop(); window.Close(); }; - window.Closed += (_, _) => timer.Stop(); timer.Start(); + // D8: timer callbacks are off the UI thread; closing always marshals back. + var timer = (clock ?? TimeProvider.System).CreateTimer(_ => Dispatcher.UIThread.Post(window.Close), + null, TimeSpan.FromSeconds(8), Timeout.InfiniteTimeSpan); + window.Closed += (_, _) => timer.Dispose(); } private void Position() { diff --git a/src/FinalToken.Core/AtomicFile.cs b/src/FinalToken.Core/AtomicFile.cs index 5f7958b..55bfecc 100644 --- a/src/FinalToken.Core/AtomicFile.cs +++ b/src/FinalToken.Core/AtomicFile.cs @@ -5,7 +5,9 @@ namespace FinalToken.Core; public static class AtomicFile { // D5: same-directory rename; a reader sees either complete version. - public static async Task WriteAsync(string path, string contents, CancellationToken cancellationToken = default) + public static Task WriteAsync(string path, string contents, CancellationToken cancellationToken = default) + => WriteAsync(path, contents, cancellationToken, TimeProvider.System); + public static async Task WriteAsync(string path, string contents, CancellationToken cancellationToken, TimeProvider timeProvider) { Directory.CreateDirectory(Path.GetDirectoryName(Path.GetFullPath(path))!); var temporary = path + "." + Guid.NewGuid().ToString("N") + ".tmp"; @@ -33,7 +35,7 @@ public static class AtomicFile { // Windows can report ACCESS_DENIED for an open destination as well as SHARING_VIOLATION. if (attempt == 10) throw new IOException("Atomic replacement remained blocked after 500 ms.", e); - await Task.Delay(TimeSpan.FromMilliseconds(50), cancellationToken).ConfigureAwait(false); + await Task.Delay(TimeSpan.FromMilliseconds(50), timeProvider, cancellationToken).ConfigureAwait(false); } } } diff --git a/src/FinalToken.StreamDeck/AGENTS.md b/src/FinalToken.StreamDeck/AGENTS.md index 999a640..cb58bb4 100644 --- a/src/FinalToken.StreamDeck/AGENTS.md +++ b/src/FinalToken.StreamDeck/AGENTS.md @@ -2,5 +2,7 @@ D10 native SDK-v2 plugin. Read snapshots using SnapshotFile (D9); use Core DTOs. Keep file IO off the socket owner loop. Never reconnect after the host closes the socket. Protocol DTOs use PluginJsonContext. Assets and the local inspector live in plugin/. +Directory.Build.props is the release version source. tools/publish.py stamps the published manifest; +the repository manifest is an asset template, not the shipped version. Core/StreamDeck owns D11 deployment with injectable host process control. Run `dotnet test --project tests/FinalToken.StreamDeck.Tests -c Release` from the root. diff --git a/tests/FinalToken.App.Tests/AGENTS.md b/tests/FinalToken.App.Tests/AGENTS.md index ce91ff9..e35e03f 100644 --- a/tests/FinalToken.App.Tests/AGENTS.md +++ b/tests/FinalToken.App.Tests/AGENTS.md @@ -4,3 +4,4 @@ Run `dotnet test --project tests/FinalToken.App.Tests -c Release` from the root. View-model tests use public Core queries. Headless tests run on a dedicated UI thread with Skia and HarfBuzz, exercise settings and popup actions, and save seven PNG screenshots outside the repo at ../runs/shots/w2. FINALTOKEN_SCREENSHOT_DIR overrides that path. +Popup expiry uses an injected TimeProvider; fire timers and pump the dispatcher instead of sleeping. diff --git a/tests/FinalToken.App.Tests/HeadlessTests.cs b/tests/FinalToken.App.Tests/HeadlessTests.cs index 2741d05..becd9d7 100644 --- a/tests/FinalToken.App.Tests/HeadlessTests.cs +++ b/tests/FinalToken.App.Tests/HeadlessTests.cs @@ -31,6 +31,7 @@ public sealed class HeadlessTests var model = FakeData.Model(); var panel = new PanelWindow(model, () => { }, () => { }, () => { }, () => { }) { Height = 2450 }; panel.RequestedThemeVariant = ThemeVariant.Light; panel.Show(); Save(panel, "panel-light.png"); + Assert.Equal($"FinalToken {typeof(Program).Assembly.GetName().Version!.ToString(3)}", panel.Title); Assert.Contains(panel.GetVisualDescendants().OfType(), t => t.Text == "Claude"); Assert.Contains(panel.GetVisualDescendants().OfType(), t => t.Text == "Tokens per day"); var filters = panel.GetVisualDescendants().OfType().ToArray(); @@ -74,7 +75,8 @@ public sealed class HeadlessTests var install = new PopupWindow("Stream Deck plugin", "Update ready", () => { }, "Update", () => installed++); install.Show(); install.GetVisualDescendants().OfType