Adding a stale-snap warning on snapcraft.io

A small UI change I worked on for snapcraft.io. When the channel you're looking at hasn't seen a release in over two years, the page now tells you so before you click Install.

Most people land on a snapcraft.io snap-detail page from a search result and click Install without scrolling down far enough to read the “Last Updated” date. For an actively maintained snap that’s fine. For a snap whose channel hasn’t had a release in years, you’re installing a stale binary without realising it. canonical/snapcraft.io#5352 (merged today) adds a small warning on the snap-detail page that fires only when the channel is actually stale.

What the warning looks like

When the most recent release on the channel is older than a configurable threshold (default: two years), the snap-detail sidebar renders a p-notification--caution block with an orange left border, between the Last Updated row and Contact:

This snap hasn’t been updated in a while. It might be unmaintained and have stability or security issues.

How it’s wired up

Two helpers on the Python side:

  • is_snap_old(last_updated, threshold_years=2) returns a boolean. The Jinja template uses it to decide whether to render the block at all.
  • convert_date_month_year(date) formats the timestamp as "September 2022" instead of the full ISO date.

The template wires the two together. The React side is untouched. Tests cover the threshold logic (boundary cases, leap-year handling, missing dates) and the formatter. Closes #2988.