Skip to content

Add batched commit summaries for history lists - #81

Merged
Mistium merged 5 commits into
mainfrom
commit-summaries
Nov 21, 2026
Merged

Mistium merged 5 commits into
mainfrom
commit-summaries

Conversation

@Mistium

@Mistium Mistium commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Follows #80 (merged).

Most MistWarp commits keep the default message "Updated project", so a project's history list is a wall of identical rows. This adds a batched endpoint that the history list can use to describe each commit instead.

What it adds

GET /v1/projects/:id/commit-summaries?shas=<sha>,<sha> returns one short summary per commit:

{"ok": true, "summaries": {"<sha>": {
  "ok": true, "sha": "<sha>", "initial": false, "legacy": false,
  "totals": {"scripts": {"added": 1, "removed": 0, "changed": 2, "moved": 0}, "items": 0, "state": 3,
             "assets": {"added": 0, "removed": 0, "modified": 1}, "files": 0, "stateOnly": false},
  "sprites": ["Main", "Window"], "spriteCount": 2, "authoredFiles": 0, "tooLarge": false
}}}
  • Totals: totals is exactly what /commits/:sha/changes reports (a Go test checks they match).
  • Sprites: sprites names up to five sprite folders that had script, item or asset changes. Saved state alone, fonts/ and root assets/ files are counted in the totals but name no sprite.
  • Request limits:
    • at most 50 lowercase hex SHAs per request;
    • malformed, repeated or unrecorded SHAs are ignored;
    • commits that can't be summarised (missing parent) are left out.
  • Access: the same rule as /commits/:sha/changes (canSeeInsideProject, projectRecordsCommit). Smoke steps check that a private project gives 404 signed out and as a stranger, and 200 as an editor.

Why it's computed when read, not at save time

The plan said to store summaries at save time. gitCommits is rebuilt in many save paths, and only its last 50 entries are kept. Computing on read covers every existing commit straight away, including history from before this change, and needs no migration.

Caching

A commit's summary depends only on its content, so it is cached by project and SHA rather than by workspace fingerprint. That means saving the project doesn't throw the summaries away.

  • Cache file: one JSON file per project under tmp/git-summaries/, kept out of the 256-file git-inspection/ directory so it can't push the workspace caches out. The cache name carries its own version (s1).
  • Locking: misses are computed without holding a lock. Only the merge and write take the per-project lock, and the merge re-reads the file first, so concurrent requests don't lose each other's entries.
  • Failures: cached for 10 minutes.
  • Size cap: the file holds up to 2,000 entries and starts again from the current request when new entries would push it past that.

Locally, all 100 most recent commits of a real public project (p1790295130360345000J3JZRS) summarise in about 5 seconds cold. After that they are served from the cache.

Other changes

  • changesBetween is split into computeChanges plus the existing encoder, so the summary and changes views share one code path. /changes output is unchanged (the totals parity test covers it).
  • src/git/commit-summary-cache.osl holds the pure helpers (SHA parsing, cache entry rules, merge cap), with OSL tests.

Checks

  • go test ./... and go vet in native/gitinspection, with new tests for:
    • fonts and root assets;
    • state-only commits;
    • a missing parent;
    • totals parity.
  • osl test: 63 passed.
  • osl compile main.osl with the CI pin.
  • python3 scripts/check_conventions.py.
  • python3 scripts/e2e_smoke.py: 340 steps, 0 unexpected server errors, with new steps for:
    • the endpoint with a mix of valid and invalid SHAs;
    • signed out;
    • from the cache;
    • with no SHAs;
    • three private-project access cases.
  • scripts/route_dump.py only gains GET /v1/projects/:id/commit-summaries.

Version: 1.2.0 (from #80) → 1.3.0, a new backwards-compatible endpoint.

No visible surface in this PR. The history list that uses it is MistWarp/scratch-gui (linked from there), and the docs are in MistWarp/docs.

@Mistium
Mistium changed the base branch from structured-compare to main November 21, 2026 01:58
@Mistium
Mistium merged commit ee93a15 into main Nov 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant