~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/knotless

git that lives in your Atmosphere account

knotless.dev
1 collaborator

knotless 0.13.0 Latest 2 packages, 1 image

1
10

The History button counts the commits, and the Commits tab goes

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/knotless:web/history-count

What changes

The History button says how many commits there are. At a repository's root, the button at the end of the latest commit's row reads "🕘 7 commits", for whatever branch or tag is shown. In a folder it still says History. dev.knotless.getLastCommits gains an optional commitCount, answered at the root only. Serve counts by walking the ref's whole history, which reads the commit-graph mirrors now keep, and keeps each count in memory by its tip, up to 32,768 of them. A commit's history never changes, so a kept count never goes stale.

History links take Octicons' history icon (a clock turning back), rather than git-commit, which means one commit: on the code page, a file and its blame. In the latest commit's row it is a quiet button (.btn.quiet, new): filled softly, with its border only under the pointer, as GitHub's sits back from the row.

There is no Commits tab. The History button is the way to a repository's history, as on GitHub. The commits and commit pages sit under Code.

On a phone, the latest commit's row shows the way to the history by its icon alone, a tap's size, its words ("7 commits", or History) in its title and label, as GitHub's phone page has it; and it drops its time, as the file rows under it have none. Before, the row hid the button, and the Commits tab was the way to history.

The serve design note and the API reference say so.

Why

The tabs' counts are of what waits on someone: open issues, open pulls. A commit count only grows, so it belongs beside the code it counts, as a fact about the ref shown. On a tab it would always count the default branch, even on another branch's history. With the count on the button, the tab was a second way to the same page, in a tab row that already scrolls on a phone.

Counting the whole history on every view would be wasteful, which is why the commit-graph landed first. With one, a count of rust's 345,363 commits takes 170–200 ms and git's 82,634 takes 25–30 ms, once per tip. Prod's largest repository has 864 commits.

How it was checked

  • objects.rs's test counts main (a merge, five commits) and a side branch, twice to go through the cache, and a missing ref.
  • web.rs asserts the root answer has commitCount and a folder's does not.
  • Looked at with just look: the repository and a folder, desktop light and phone dark, and the count set to 345,363 for width. The commits page, with Code current. A fresh agent critiqued the pictures. Its finding of a subject squeezed to "Coun…" on a phone is fixed by dropping the time there, and since by the icon alone. Its other points were already the case (the tab row's fade on a phone, the time's colour by age) or are deliberate (a folder's button says History).
  • svelte-check and harness/lexicons.mjs pass here. The shots fixtures' two root answers gain their counts (7 for alice's tally, 8 for bob's fork), worked out from the world's script rather than recorded again.

Shots-moved: repository, directory, file, blame, markdown, markdown-plain, diagram, image, commits, commit, commit-merged, pulls, pulls-closed, pull, pull-open, pull-files, issues, issues-closed, issue, issue-closed, issue-fixed, fork, empty, missing, check, queue, checks, pull-queued, pull-ejected, settings, settings-branches, settings-labels, settings-access, settings-actions, releases, releases-image, releases-empty

Shortcomings

  • The count is kept in memory only, so after a restart the first view of each tip walks its history again. That walk is cheap with the graph.
  • A mirror that has not synced since the commit-graph landed walks the packs for its first count, and only once.

🤖 Generated with Claude Code

Approved

This pull adds an optional commitCount to getLastCommits, answered at the root only. The count walks the history once per tip and is kept in memory in a bounded cache. The History button shows the count, and the Commits tab is gone.

I found nothing that must change. The cache key is the tip's object id, which is safe because a commit's history never changes. The root-only gating is tested on both sides. The lexicon change is optional-only, so it passes the evolution rule. The serve design note and the API reference are both updated. The tab removal leaves no stale tab="commits" references. The {#await changes} button falls back to plain History while loading and in a folder.

Two things to know, neither blocking:

  • A failed count now turns the whole getLastCommits answer into a 404, because the count shares the map_err(not_found) path with the entry walk. That is fine while counting can only fail where the walk would.
  • The check workflow had passed when I looked. test, shots, web, lexicons, docs and e2e had not finished, and I did not check whether an e2e flow clicked the Commits tab. Please make sure e2e passes before you queue it.
Approved

Since my last round, the pull has one new commit. It swaps the git-commit icon for Octicons' history and turns the latest commit's History control into a quiet .history link instead of a bordered button. I read that diff and found nothing that must change.

  • The new .history class is used only in FileList.svelte. The phone rules in app.css (:not(.grow,.history) and .history .word) are updated to match, and no other .history selector is affected.
  • The file and blame pages keep .btn and only take the new icon.
  • history is added to the icon map and to its type union.
  • The check workflow passed on this head.
  • test was still running when I looked. Please wait for it, and for e2e, before the queue lands this.
  • My earlier note about getLastCommits returning a 404 when a count fails still stands. It isn't blocking.
Approved

Since my last round, the pull has one new commit. On a phone, the latest commit's History link now shows its icon alone, 32px square, with its words in title and aria-label. I found nothing that must change.

  • The words are wrapped in .words and the phone rule hides .history .words. .word still hides only the ref counts.
  • --control is defined in tokens.css.
  • The .history link was already excluded from the phone rule that hides the row's other links.
  • The title and aria-label are set in all three states: loading, folder and counted.
  • The check workflow passed on this head.
  • test was still running when I looked. Please wait for it, and for e2e, before the queue lands this.
  • My earlier note still stands, and it isn't blocking. A failed count turns the whole getLastCommits answer into a 404.
Merged as 6ae7e66