GitNexus/gitnexus-web/src
Ankit Verma a839d029ac
feat(api): report branch and index freshness on the serve repo routes (#3232)
* feat(api): report branch and index freshness on the serve repo routes

`GET /api/repos` and `GET /api/repo` now return the branch an index was
built from, its `lastCommit`, and — where it can be computed — how far
behind the working tree it is. All of it already existed: the fields are
on `RegistryEntry`, and `checkStalenessAsync` is the helper MCP
`list_repos` and `gitnexus status` already use. Only HTTP never asked.

#3199 made this pointed. A branch-pinned analyze registers its own entry,
so one repository yields two rows in /api/repos, and telling them apart
over HTTP meant pattern-matching the clone-directory suffix — a layout
detail that is trimmed for long refs and absent for path-registered repos.

Staleness is reported in the shape `list_repos` already returns: present
only when the index is behind, carrying commitsBehind and hint. It is
meaningful for path-registered repos; a url-registered repo is cloned
--depth 1, so its recorded commit is HEAD and a diverged history cannot be
walked by rev-list anyway. Documented in repo-projection.ts rather than
left to be discovered.

The projections live in their own module so the field list is assertable.
Route-inline, they were reachable only by booting a server, which is how
`branch` stayed unexposed while `gitnexus list` printed it.

/api/repos also gains the rate limiter it lacked: this change makes one
unauthenticated GET cost a `git rev-list` per registered repo, the shape
this codebase already limits elsewhere.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* fix(api): bound the staleness probe and keep liveness off the fan-out route

Addresses the tri-review on #3232.

P1. `checkStalenessAsync` caught every git ERROR but not a HANG — a working
tree on a disconnected mount or behind a stuck lock never settles, and
/api/repos fans that out once per registered repo. Worse, the web liveness
probe used /api/repos on a 2s budget and re-polls on failure, so each failed
probe stacked another N children on a server that was actually healthy.

Two independent fixes, because either alone still leaves a sharp edge:
- `execFileAsync` now carries a 5s timeout, so a hang is killed and routed
  into the same fail-closed "not stale" answer the existing catch already
  gives a bad SHA. This also protects MCP `list_repos`, which shares the
  helper.
- `probeBackendStatus` (and `isDatabaseReady` through it) asks /api/health
  instead. Liveness should not cost one subprocess per indexed repo. Health
  sits behind the same /api/* edge gate, so the 401 "gated vs absent"
  distinction is preserved.

P2. rate-limit.test.ts pins which routes carry a limiter so a dropped one
fails a test before CodeQL has to catch it; /api/repos was newly limited but
not pinned. Added, and verified it fails when the limiter is removed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
2026-09-09 17:28:45 +01:00
..
components feat(indexing): add Objective-C semantic indexing support (#3179) 2026-09-09 09:40:21 +00:00
config feat: notify users when a newer gitnexus version is available (#3175) 2026-09-04 18:50:03 +01:00
core fix(server,web): honor the grep tool contract — real regex, fileFilter, caseSensitive (#3109) 2026-08-31 20:43:28 +01:00
hooks fix(server,web): honor the grep tool contract — real regex, fileFilter, caseSensitive (#3109) 2026-08-31 20:43:28 +01:00
i18n feat(render): add one-click deploy to render support (#2804) 2026-08-06 00:19:44 +00:00
lib feat(indexing): add Objective-C semantic indexing support (#3179) 2026-09-09 09:40:21 +00:00
locales feat: notify users when a newer gitnexus version is available (#3175) 2026-09-04 18:50:03 +01:00
services feat(api): report branch and index freshness on the serve repo routes (#3232) 2026-09-09 17:28:45 +01:00
vendor/leiden feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
App.tsx feat: notify users when a newer gitnexus version is available (#3175) 2026-09-04 18:50:03 +01:00
index.css feat: configure prettier with pre-commit hook (#563) 2026-03-28 14:58:04 +00:00
main.tsx feat(i18n): make web and CLI language-aware (#1748) 2026-05-23 06:14:24 +01:00
vite-env.d.ts fix(web): chat-only mode for large projects to prevent WebUI hang (#2178) (#2185) 2026-06-13 11:07:58 +01:00