Service: show the running version in the Service menu (so a self-update is visible)
Local checkpoint - NOT for public release. Answers "how will we know if the service
updated itself?"
- The service records its version + start time on every OnStart into ServiceStore
(ProgramData). A self-update restart therefore bumps the version and refreshes the
start time.
- The Service menu status line now shows it: "Service: installed, running — version 5.3,
running since 2 min ago". So you can see the running version at a glance, and a recent
start with a bumped version is the self-update landing.
- Also logged on start ("service: OnStart, version X") for the service log.
Status round-trip covered by the isolation self-test. Gate 27/27.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
56dbd0b80f
commit
d5767050f2
@@ -2205,6 +2205,12 @@ public sealed class MainForm : Form
|
||||
{
|
||||
var state = ServiceControl.Query();
|
||||
status.Text = "Service: " + DescribeServiceState(state);
|
||||
// Surface the running version + when it (re)started, so a self-update is visible at a glance.
|
||||
if (state is ServiceState.Running or ServiceState.Stopped && ServiceStore.LoadStatus() is { Version: { } ver } st)
|
||||
{
|
||||
status.Text += $" — version {ver}";
|
||||
if (state == ServiceState.Running && st.StartedUtc != default) status.Text += $", running since {DescribeAgo(st.StartedUtc)}";
|
||||
}
|
||||
var installed = state != ServiceState.NotInstalled;
|
||||
install.Enabled = !installed;
|
||||
uninstall.Enabled = installed;
|
||||
@@ -2214,6 +2220,16 @@ public sealed class MainForm : Form
|
||||
return serviceMenu;
|
||||
}
|
||||
|
||||
private static string DescribeAgo(DateTime utc)
|
||||
{
|
||||
var span = DateTime.UtcNow - utc;
|
||||
if (span < TimeSpan.Zero) span = TimeSpan.Zero;
|
||||
if (span.TotalMinutes < 1) return "just now";
|
||||
if (span.TotalHours < 1) return $"{(int)span.TotalMinutes} min ago";
|
||||
if (span.TotalDays < 1) return $"{(int)span.TotalHours} h ago";
|
||||
return $"{(int)span.TotalDays} d ago";
|
||||
}
|
||||
|
||||
private static string DescribeServiceState(ServiceState s) => s switch
|
||||
{
|
||||
ServiceState.NotInstalled => "not installed",
|
||||
|
||||
Reference in New Issue
Block a user