feat(atlas): surface the user's own Gitea repos on stage 05 (#10)
CD / Deploy via GitOps (push) Successful in 0s
CD / Detect unsubstituted template (push) Successful in 1s
CD / Lint / Test / Vet (push) Successful in 6s
CD / var-go/oath (push) Skipped
CD / Build & Import (push) Successful in 5s

Adds the repos panel from #4's "Not yet shipped" list, following the shipped
issues slice (b2761a4) structurally rather than inventing a second approach:

- internal/atlas/repos.go — RepoNodes(), a pure parser over an already-decoded
  /user/repos response. Archived repos are dropped: the atlas shows where work
  happens, and an archived repo is by definition somewhere it does not.
- internal/gitea/client.go — MyRepos(), same PAT and same contract as MyIssues:
  errors when GITEA_TOKEN is unset so the caller skips the overlay rather than
  issuing an unauthenticated request. That unset path is the one running in
  prod today (#4), so it is tested, not assumed.
- internal/web/handler.go — wired into liveOverlay().

Stage 05 is the right home — repos are what the execution stage acts on — but
#11 had just claimed its `generate` key for stuck-badges, and a stage could
only name one source. So `generate` now accepts either spelling:

    "generate": "ci-jobs"
    "generate": ["stuck-badges", "gitea-repos"]

The bare string stays valid and marshals back as a bare string, so no authored
stage is rewritten and the frontend contract is unchanged. Stages 04 and 08
already share stuck-badges between them; this is the same growth one level in.

The overlay merge also moves out of the handler into atlas.PrependGenerated,
which is unit-testable where the inline loop was not — it sat behind a network
call. It covers the issues path too, and fixes a latent aliasing bug there: the
old `append(liveNodes, authored...)` wrote into the live slice's backing array,
so two stages sharing a key would corrupt each other. That shape is no longer
hypothetical now that stuck-badges spans three stages.

Verified end-to-end both ways: without GITEA_TOKEN the atlas returns 200 with
stage 05's authored nodes intact; with a real token stage 05 serves both
overlays at once — stuck badges, then eight live repos, then the authored
nodes — and a repo with no language emits one tag rather than an empty pill.

task check green (golangci-lint 0 issues, vet, -race).

Closes #10.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-28 22:01:48 +02:00
co-authored by Claude Opus 5
parent 62955c998d
commit 097d8747c6
14 changed files with 398 additions and 24 deletions
+10 -9
View File
@@ -58,19 +58,14 @@ func NewHandler() http.Handler {
if ld.run != nil {
nodes := atlas.RunNodes(*ld.run)
for i := range a.Stages {
if a.Stages[i].Generate == "ci-jobs" {
if a.Stages[i].Generate.Has("ci-jobs") {
a.Stages[i].Nodes = nodes
}
}
a.CIDurationS, a.CDDurationS = atlas.StageSeconds(*ld.run)
}
if ld.issues != nil {
for i := range a.Stages {
if a.Stages[i].Generate == "gitea-issues" {
a.Stages[i].Nodes = append(ld.issues, a.Stages[i].Nodes...)
}
}
}
atlas.PrependGenerated(&a, "gitea-issues", ld.issues)
atlas.PrependGenerated(&a, "gitea-repos", ld.repos)
// cad-atlas#11: overlay mathias/cad#14's cad-stuck findings as
// per-stage badges. Read-only — ApplyStuckOverlay only adds Nodes
// with a link out; it never writes anything back to Gitea.
@@ -84,7 +79,7 @@ func NewHandler() http.Handler {
live = append(live, atlas.FluxNode(*ld.flux))
}
for i := range a.Stages {
if a.Stages[i].Generate == "deploy-state" {
if a.Stages[i].Generate.Has("deploy-state") {
a.Stages[i].Nodes = append(live, a.Stages[i].Nodes...)
}
}
@@ -104,6 +99,7 @@ type liveOverlayData struct {
flux *atlas.Flux
timeline []atlas.RunDot
issues []atlas.Node
repos []atlas.Node
stuck []caddomain.StuckFinding
}
@@ -172,6 +168,11 @@ func liveOverlay() liveOverlayData {
d.issues = nodes
}
}
if raw, err := gitea.MyRepos(); err == nil {
if nodes, err := atlas.RepoNodes(raw); err == nil {
d.repos = nodes
}
}
if raw, err := cluster.Deployment(); err == nil {
if dep, err := atlas.DeployState(raw); err == nil {
d.deploy = &dep