Skip to content

armgit / nota

Public Imported from GitHub
0

Nota — a free DAW for macOS, Windows and Linux. No subscription, no account — just open it and make music.

Add update checking

Egor Khindikaynen186422dc1ac9
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d3579dd1..0a9c1732 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,9 @@ Entry categories: `Added`, `Changed`, `Fixed`, `Removed`.
## [Unreleased]
### Added
+- **New-version notice on the welcome screen.** When a newer Nota release is on GitHub,
+ the launcher shows a banner with the version number and a **Download** button that opens
+ the release page. Without an internet connection nothing is shown.
- **Macros for the Drum Rack and Nota Rhythm, and every kit comes with its own.** The Drum
Rack has a new **Macro** tab and Rhythm a **MACRO** mode in its centre panel (click MACRO
next to VOICE). Each shows eight knobs over the whole kit, each with its name and where it
diff --git a/src/managed/Nota.App/MainWindow.Welcome.cs b/src/managed/Nota.App/MainWindow.Welcome.cs
index 09de0b7f..19559765 100644
--- a/src/managed/Nota.App/MainWindow.Welcome.cs
+++ b/src/managed/Nota.App/MainWindow.Welcome.cs
@@ -49,6 +49,14 @@ public partial class MainWindow
if (PendingRecovery is not null)
win.Closed += (_, _) => { try { _recovery.ClearRecovery(); } catch { } };
+ // Look for a newer release in the background; the banner appears if one turns up
+ // while the launcher is still open.
+ _ = UpdateChecker.CheckAsync().ContinueWith(t =>
+ {
+ if (t.Result is { } update)
+ Avalonia.Threading.Dispatcher.UIThread.Post(() => { if (win.IsVisible) win.ShowUpdateAvailable(update); });
+ }, TaskScheduler.Default);
+
await win.ShowDialog(this);
}
diff --git a/src/managed/Nota.App/UpdateChecker.cs b/src/managed/Nota.App/UpdateChecker.cs
new file mode 100644
index 00000000..49d73d8e
--- /dev/null
+++ b/src/managed/Nota.App/UpdateChecker.cs
@@ -0,0 +1,61 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright (c) 2026 Egor Khindikaynen (Nota). See LICENSES/ for license terms.
+//
+// New-version check for the welcome screen. Asks the GitHub API for the latest
+// published release (drafts and pre-releases are excluded by that endpoint) and
+// compares its tag against the running version. Best-effort: any network / parse
+// failure just means "no update known" — the launcher never waits on or errors
+// because of it.
+
+using System;
+using System.Net.Http;
+using System.Text.Json;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Nota.App;
+
+/// <summary>A release newer than the running app: its version and the page to download it from.</summary>
+public sealed record AvailableUpdate(string Version, string Url);
+
+public static class UpdateChecker
+{
+ public const string ReleasesPage = "https://github.com/nota-daw/nota/releases";
+ private const string LatestApi = "https://api.github.com/repos/nota-daw/nota/releases/latest";
+
+ /// <summary>The latest GitHub release if it's newer than <see cref="AppInfo.Version"/>, else null.</summary>
+ public static async Task<AvailableUpdate?> CheckAsync(CancellationToken ct = default)
+ {
+ try
+ {
+ using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(8) };
+ // GitHub's API rejects requests without a User-Agent.
+ http.DefaultRequestHeaders.UserAgent.ParseAdd($"Nota/{AppInfo.Version}");
+ http.DefaultRequestHeaders.Accept.ParseAdd("application/vnd.github+json");
+
+ using var resp = await http.GetAsync(LatestApi, ct).ConfigureAwait(false);
+ if (!resp.IsSuccessStatusCode) return null;
+ await using var s = await resp.Content.ReadAsStreamAsync(ct).ConfigureAwait(false);
+ using var doc = await JsonDocument.ParseAsync(s, cancellationToken: ct).ConfigureAwait(false);
+
+ var root = doc.RootElement;
+ var tag = root.TryGetProperty("tag_name", out var t) ? t.GetString() : null;
+ var url = root.TryGetProperty("html_url", out var u) ? u.GetString() : null;
+ return NewerThanRunning(tag, url);
+ }
+ catch
+ {
+ return null;
+ }
+ }
+
+ /// <summary>Compare a release tag ("v1.2.3" or "1.2.3") against the running version.</summary>
+ public static AvailableUpdate? NewerThanRunning(string? tag, string? url, string? running = null)
+ {
+ var latest = tag?.Trim().TrimStart('v', 'V');
+ if (!SemVer.TryParse(latest, out var lv)) return null;
+ if (!SemVer.TryParse(running ?? AppInfo.Version, out var cv)) return null;
+ if (lv.CompareTo(cv) <= 0) return null;
+ return new AvailableUpdate(latest!, string.IsNullOrWhiteSpace(url) ? ReleasesPage : url!);
+ }
+}
diff --git a/src/managed/Nota.App/WelcomeWindow.cs b/src/managed/Nota.App/WelcomeWindow.cs
index 86ecbe60..b6d52542 100644
--- a/src/managed/Nota.App/WelcomeWindow.cs
+++ b/src/managed/Nota.App/WelcomeWindow.cs
@@ -3,7 +3,8 @@
//
// Welcome screen — the launcher shown on startup (see MainWindow.ShowWelcomeAsync).
// Brand header, New / Open actions, a list of recent projects, and shortcuts to
-// Settings and What's New. New / Open / a recent project close the launcher and hand
+// Settings and What's New, plus banners for crash recovery and a newer release on
+// GitHub. New / Open / a recent project close the launcher and hand
// off to the main window; Settings and What's New open as child dialogs so the user
// stays on the launcher.
@@ -172,12 +173,18 @@ public sealed class WelcomeWindow : NotaWindow
Grid.SetRow(footer, 4);
root.Children.Add(footer);
- // Crash-recovery prompt rides on top as a dismissible banner (same wording as the
- // standalone recovery dialog). Absent when there's no surviving snapshot.
- Control body = root;
+ // Banners (crash recovery, available update) stack above the content. The update
+ // banner arrives asynchronously — see ShowUpdateAvailable.
+ _banners = new StackPanel();
+ var outer = new DockPanel();
+ DockPanel.SetDock(_banners, Dock.Top);
+ outer.Children.Add(_banners);
+ outer.Children.Add(root);
+
+ // Crash-recovery prompt (same wording as the standalone recovery dialog). Absent
+ // when there's no surviving snapshot.
if (recoveryMessage is not null && onRecover is not null)
{
- var outer = new DockPanel();
Border banner = null!;
banner = RecoveryBanner(
recoveryMessage,
@@ -185,25 +192,43 @@ public sealed class WelcomeWindow : NotaWindow
onDismiss: () =>
{
onDismissRecovery?.Invoke();
- (banner.Parent as Panel)?.Children.Remove(banner);
+ _banners.Children.Remove(banner);
});
- DockPanel.SetDock(banner, Dock.Top);
- outer.Children.Add(banner);
- outer.Children.Add(root);
- body = outer;
+ _banners.Children.Add(banner);
}
- SetBody(body);
+ SetBody(outer);
+ }
+
+ private readonly StackPanel _banners;
+
+ /// <summary>Show a "new version available" banner with a Download button that opens
+ /// the release page in the browser. Called once the background update check resolves.</summary>
+ public void ShowUpdateAvailable(AvailableUpdate update)
+ {
+ Border banner = null!;
+ banner = Banner(
+ "A new version of Nota is available",
+ $"Nota {update.Version} is out — you have {AppInfo.Version}.",
+ actionLabel: "Download",
+ onAction: () => _ = Launcher.LaunchUriAsync(new Uri(update.Url)),
+ onDismiss: () => _banners.Children.Remove(banner));
+ _banners.Children.Add(banner);
}
- // A dismissible alert card offering to restore a crashed session. Accent-tinted so it
- // reads as an action prompt, not an error.
+ // Offer to restore a crashed session.
private static Border RecoveryBanner(string message, Action onRecover, Action onDismiss)
+ => Banner("Unsaved work available", message, "Recover", onRecover, onDismiss);
+
+ // A dismissible alert card with one action. Accent-tinted so it reads as an action
+ // prompt, not an error.
+ private static Border Banner(string title, string message, string actionLabel,
+ Action onAction, Action onDismiss)
{
var text = new StackPanel { Spacing = 2, VerticalAlignment = VerticalAlignment.Center };
text.Children.Add(new TextBlock
{
- Text = "Unsaved work available",
+ Text = title,
FontSize = 13,
FontWeight = FontWeight.SemiBold,
Foreground = NotaPalette.TextPrimary,
@@ -219,11 +244,11 @@ public sealed class WelcomeWindow : NotaWindow
var recover = new Button
{
- Content = "Recover", // not solid brass: "New project" is this window's primary action
+ Content = actionLabel, // not solid brass: "New project" is this window's primary action
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(12, 0, 0, 0),
};
- recover.Click += (_, _) => onRecover();
+ recover.Click += (_, _) => onAction();
Grid.SetColumn(recover, 1);
var dismiss = new Button