Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/AIUsageMonitor.Cli/Commands/WatchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ public static Command Create(DataService dataService, IUpdateChecker updateCheck
// visible while it runs rather than only after it exits.
var updateInfo = await updateChecker.CheckForUpdateAsync(ct);
var updateNotice = UpdateNotice.BuildRenderable(updateInfo);
var versionFooter = SpectreRenderer.BuildVersionFooter();

IRenderable BuildCurrent(IProgress<int>? progress = null)
{
Expand Down Expand Up @@ -151,8 +152,19 @@ IRenderable BuildLimits(IProgress<int>? progress)

ClearScreen();

IRenderable WithUpdateNotice(IRenderable content) =>
updateNotice is null ? content : new Rows(content, updateNotice);
IRenderable WithUpdateNotice(IRenderable content)
{
var rows = new List<IRenderable> { content };
if (updateNotice is not null)
{
rows.Add(updateNotice);
}
if (versionFooter is not null)
{
rows.Add(versionFooter);
}
return rows.Count == 1 ? content : new Rows(rows);
}

var current = view == "limits"
? WithUpdateNotice(SpectreRenderer.BuildUsageLimits(lastSessionWindow!, lastWeekWindow!, effectiveSessionTokenLimit, effectiveWeekTokenLimit, recalibrationEnabled, effectiveSessionResetAt is not null))
Expand Down
13 changes: 13 additions & 0 deletions src/AIUsageMonitor.Cli/Rendering/SpectreRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using AIUsageMonitor.Core.Models;
using AIUsageMonitor.UpdateCheck;
using Spectre.Console;
using Spectre.Console.Rendering;

Expand Down Expand Up @@ -364,6 +365,18 @@ public static IRenderable BuildUsageLimits(
/// <param name="stats">The session statistics data to render.</param>
public static void RenderSessionStats(SessionStats stats) => AnsiConsole.Write(BuildSessionStats(stats));

/// <summary>
/// Builds a footer line naming the application and its running version, for display under
/// the continuously refreshed <c>watch</c> view only - a one-shot command's output is short
/// enough that the version line would just be noise under it.
/// </summary>
/// <returns>A grey markup line, or <see langword="null"/> if the version could not be determined.</returns>
public static IRenderable? BuildVersionFooter()
{
var version = AppVersion.GetCurrent();
return version is null ? null : new Markup($"[grey]aimon v{version} · https://github.com/coldhighsun/AIUsageMonitor[/]");
}

/// <summary>
/// Builds a titled table with a single row of centered stat values, one column per stat.
/// </summary>
Expand Down
Loading