Skip to content

[Repo Assist] improve: extract FormatAge into ModelFormatting, removing duplicate logic#154

Merged
shanselman merged 1 commit intomasterfrom
repo-assist/improve-extract-format-age-20260407-361cca80bdfd8dae
Apr 8, 2026
Merged

[Repo Assist] improve: extract FormatAge into ModelFormatting, removing duplicate logic#154
shanselman merged 1 commit intomasterfrom
repo-assist/improve-extract-format-age-20260407-361cca80bdfd8dae

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 7, 2026

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

GatewayNodeInfo and SessionInfo both implemented identical age-formatting logic independently:

if (delta.TotalSeconds < 60) return "just now";
if (delta.TotalMinutes < 60) return $"{(int)Math.Round(delta.TotalMinutes)}m ago";
if (delta.TotalHours < 48) return $"{(int)Math.Round(delta.TotalHours)}h ago";
return $"{(int)Math.Round(delta.TotalDays)}d ago";

This PR extracts that logic into a single ModelFormatting.FormatAge(DateTime) helper, consistent with the existing ModelFormatting.FormatLargeNumber pattern.

Changes

  • ModelFormatting — new FormatAge(DateTime timestampUtc) method
  • SessionInfo.AgeText — delegates to ModelFormatting.FormatAge(UpdatedAt ?? LastSeen)
  • GatewayNodeInfo.FormatAge — delegates to ModelFormatting.FormatAge(timestampUtc)

No behaviour change. Future age-formatting tweaks (e.g. adding weeks, locale) now only need one edit.

Test Status

  • ✅ Build succeeded (0 errors, 0 warnings)
  • ✅ Shared tests: 525 passed, 20 skipped, 0 failed
  • ✅ Tray tests: 99 passed, 0 failed
  • ℹ️ All existing SessionInfoAgeTextTests and GatewayNodeInfoTests.DetailText_LastSeen_* tests pass unchanged, confirming no behaviour regression.

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@cbb46ab386962aa371045839fc9998ee4e97ca64

…logic

GatewayNodeInfo and SessionInfo both implemented identical age-formatting
logic (just now / Xm ago / Xh ago / Xd ago). Consolidate into a single
ModelFormatting.FormatAge(DateTime) helper.

- Add ModelFormatting.FormatAge(DateTime timestampUtc)
- SessionInfo.AgeText now delegates to ModelFormatting.FormatAge
- GatewayNodeInfo.FormatAge now delegates to ModelFormatting.FormatAge
- No behaviour change; all existing tests pass (525 Shared, 99 Tray)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@shanselman shanselman marked this pull request as ready for review April 8, 2026 20:09
@shanselman shanselman merged commit 5c76d47 into master Apr 8, 2026
@shanselman shanselman deleted the repo-assist/improve-extract-format-age-20260407-361cca80bdfd8dae branch April 8, 2026 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant