Skip to content

feat(wave-admin): bulk approve or reject repo applications - #2000

Open
jlin95 wants to merge 10 commits into
mainfrom
feat/admin-repo-decisions
Open

jlin95 wants to merge 10 commits into
mainfrom
feat/admin-repo-decisions

Conversation

@jlin95

@jlin95 jlin95 commented Nov 23, 2026 •

Copy link
Copy Markdown

Why

When a repo has to be approved (often a repo the automated review rejected, approved on request), the workaround is to copy the Wave access-token cookie from the browser and call POST /api/wave-programs/:id/repos/:orgRepoId/approve from the API docs. The per-program review page can't do it: it lists only pending applications (max 100), one at a time.

What

New admin section Repo decisions at /wave/admin/repo-decisions (card on the admin home). Access follows the API: program admins can act on their own programs, users with reviewWaveProgramRepos on all programs; picking a program you don't administer shows a clear message.

  1. Pick a wave program, paste GitHub URLs or owner/repo names (one per line; trailing slashes, /tree/..., .git, case and duplicates are handled).
  2. Look up (clears the previous list first, so a failed lookup can't leave it actionable) shows each repo's current status (pending / rejected incl. malware / approved / not in this program), rejection reason and date.
  3. Choose Approve or Reject (one optional shared reason, sent with the rejection notification).
  4. Confirm → each repo goes through the existing approve/reject endpoint, one call per repo, with a per-row result; one failure doesn't stop the rest. Each row then shows the status the API returned, so a repo approved a moment ago is skipped by a follow-up Reject. Results are cleared when the action changes or a new run starts, so the Result column always matches the current action.

Clicking on Refresh statuses reloads the list and program that were looked up.

So the page approves or rejects pending repos, and re-approves repos rejected for a normal reason.

Guards: two kinds of repo are never sent from this page:

  • Rejected for malware: re-approving one needs a real review, not a bulk click.
  • Already approved: rejecting a live repo unassigns contributors and removes its issues from the wave, and re-approving does not restore them.

The skip rules are in skip-reason.ts. This is a UI guard only: the backend /approve endpoint still accepts malware-rejected repos (the appeals flow uses it).

Failed rows show the API's message in plain text (e.g. "Repo is already approved"). An approval refused because the applicant is banned or restricted says so, instead of the shared API helper's misleading "Your account is currently restricted".

Depends on

drips-network/wave#891 (merge and deploy first). It adds GET /repos/applications?repoFullNames=, which the lookup uses: up to 20 names per request, requests run one after another (5 requests per 100 pasted repos).

Rollout

Merge drips-network/wave#891 first. Check it is live: GET /api/wave-programs/<id>/repos/applications?repoFullNames=<a rejected repo> returns that repo with status rejected. Then merge this PR. No Novu or config changes: the page uses the existing approve and reject endpoints and their existing notifications.

Testing

  • Unit tests (32): parse-repo-list (12, incl. a real pasted list of mixed-org URLs), describe-decision-error (5), skip-reason (7), look-up-applications (5: chunks of 20, one request at a time, input order, case-insensitive match, missing repos, stops on error), run-decisions (3: rows take the new status, a failed row stays as it was, one request at a time).
  • Clicked through locally end to end with seed data (pending, rejected, malware-rejected and approved repos; not-found repos), incl. a restricted applicant (row fails with the applicant message) and cross-program scoping (same repo with a different status in two programs).

New admin section at /wave/admin/repo-decisions (needs reviewWaveProgramRepos)
replacing the "copy the access-token cookie and call the approve endpoint from
the API docs" workaround for one-off approvals.

Pick a program, paste GitHub URLs or owner/repo names, look them up, then
approve or reject the batch. Rejected repos can be re-approved. Each repo is
sent through the existing approve/reject endpoints with a per-row result.
Malware-rejected repos (approve) and live approved repos (reject) are left
out unless explicitly included; reject takes one optional shared reason.

Depends on drips-network/wave#891 for the status/repoFullNames lookup params.
The page required the global reviewWaveProgramRepos permission, which is
stricter than the API: the list/approve/reject endpoints also allow admins
of the program. Program owners with other admin permissions couldn't use it.

Drop the frontend permission gate (card and loader) and let the API decide
per program. A 403 on lookup now shows "You're not an admin of <program>"
instead of the generic error modal.
authenticatedCall reshapes API errors, so result rows showed raw
"API call failed: 400 ... {json}" strings, a bare {"message":"Forbidden"},
and, worst, "Your account is currently restricted" when approval was
refused because the APPLICANT is banned or restricted.

Map row errors through extractApiErrorMessage, explain the restricted
applicant case on approve, and describe other 403s as missing
program-admin rights.
@ryph-dev

ryph-dev Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

✅ Reviewer finished — ryph run r-01m89n6r76ed58he1hvv4m8v5g is succeeded.

Proposed by Reviewer, a Ryph agent · Run · requested by @jlin95

Reviewer posted what it did in this thread.

No code changes were needed.

View the run

@ryph-dev ryph-dev Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Reviewer, a Ryph agent · Run · asked by @jlin95

Assessment: 🟡 Changes recommended

The malware/approved opt-in checkboxes stay ticked across lookups, so a new list can include dangerous repos without a fresh opt-in. The other remarks are smaller.
? The wave#891 backend contract (status and repoFullNames filters) is in another repo, so I couldn't check it.

const programId = waveProgramId;
const parsed = parseRepoList(input);
invalidEntries = parsed.invalid;
results = {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Reviewer, a Ryph agent · Run · asked by @jlin95

[should-fix] includeMalware and includeApproved are never reset. Tick the box, then look up a different list (or change program), and any malware or approved repos in the new list are pre-included with no fresh opt-in. The confirm modal does warn, but the guard is meant to be per-lookup. Reset both here and in the program onchange.

return null;
}

let eligible = $derived(rows ? rows.filter((r) => skipReason(r) === null) : []);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Reviewer, a Ryph agent · Run · asked by @jlin95

[should-fix] eligible is derived from the stale lookup status and ignores results. After a successful run the rows are still eligible, so the button still reads "Approve N repos" and a second click re-sends every one (they come back as "already approved" errors, or a repeated reject notification). Exclude rows whose result is done, or refresh the rows automatically after a run.

<span class="typo-text-small dim"
>{doneCount} done{failedCount ? `, ${failedCount} failed` : ''}</span
>
<Button size="small" variant="normal" disabled={running} onclick={lookUp}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Reviewer, a Ryph agent · Run · asked by @jlin95

[nit] "Refresh statuses" re-parses the current textarea (lookUp reads input), not the list that was looked up. If the user edited the text after the lookup, the table silently becomes a different list.

findWaveProgramRepoApplications(fetch, programId, status, names),
),
);
for (const response of responses) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Reviewer, a Ryph agent · Run · asked by @jlin95

[should-fix] If this runs against a backend without wave#891, the unknown status and repoFullNames params are ignored. All three calls then return the first 100 pending applications. The code never checks that app.status matches the status requested, and unmatched names render as "Not found", which would be misleading. Add a guard that app.status === status, and fail loudly on a mismatch.

…point

Use the new GET /repos/applications lookup (any status, max 20 names per
request) instead of three status-filtered calls to /repos/pending. Chunks
run one at a time.

Also reset the malware and approved opt-in checkboxes on each lookup, so a
new list needs a fresh opt-in.
Remove the two opt-in checkboxes. The page now only approves or rejects
pending repos and re-approves repos rejected for a normal reason.

- Malware-rejected repos are always skipped: re-approving one needs a
  real review, not a bulk click.
- Approved repos are always skipped: rejecting a live repo unassigns
  contributors and removes its issues from the wave, and re-approving
  doesn't restore them.

The skip rules move to skip-reason.ts with unit tests.
Move the lookup (chunks of 20, one request at a time, case-insensitive
match, missing repos marked) out of the page into look-up-applications.ts
and test it.
After a run the rows kept their old status, so repos approved a moment
ago still read as pending. Switching to Reject then offered to reject
them, which gets around the "never reject approved repos" rule.

Store each approve/reject response in its row, so the table and the
skip rules see the new status. The run loop moves to run-decisions.ts
with unit tests.
If a lookup failed (other than a 403), the previous list stayed on
screen with an active Approve/Reject button, so one click could act on
repos the user meant to replace. Clear the rows when a lookup starts.
…tarts

The Result column shows a row's last result before "Will …" or
"Skipped", so after switching from Approve to Reject a row could still
show the old approve error while being counted for the reject. The
done/failed counter also added up across runs. Clear the results when
the action changes and when a run starts.
@ryph-dev

ryph-dev Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ Reviewer finished — ryph run r-01m93pa6gzfah8bmyz9fteyefw is succeeded.

Proposed by Reviewer, a Ryph agent · Run · requested by @jlin95

Reviewer posted what it did in this thread.

No code changes were needed.

View the run

@ryph-dev ryph-dev Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Reviewer, a Ryph agent · Run · asked by @jlin95

Assessment: 🟡 Changes recommended

No blocking defects in the current head. The earlier "stale eligible rows" finding is fixed, because runDecisions replaces row.application and eligible re-derives. Mergeable once drips-network/wave#891 is deployed, with the two small items below addressed or accepted.
? The wave#891 contract (repoFullNames filter, 20-name cap, malware reason string) and the CI test jobs still running can't be checked from this repo.

<span class="typo-text-small dim"
>{doneCount} done{failedCount ? `, ${failedCount} failed` : ''}</span
>
<Button size="small" variant="normal" disabled={running} onclick={lookUp}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Reviewer, a Ryph agent · Run · asked by @jlin95

[should-fix] "Refresh statuses" calls lookUp, which re-parses the current textarea and the currently selected waveProgramId, not the list and program that were looked up. If the user edits the text or changes program after a lookup, the table is silently replaced (and results cleared). Refresh from the previous rows' names and lookedUpProgramId instead.

z.object({ data: z.array(waveProgramRepoWithDetailsDtoSchema) }),
await authenticatedCall(f, `/api/wave-programs/${waveProgramId}/repos/applications?${params}`),
);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Reviewer, a Ryph agent · Run · asked by @jlin95

[nit] If this runs before wave#891 is live, the unknown repoFullNames param is ignored. The endpoint then returns pending applications, so rejected or approved repos show as "Not found" with no error. Consider checking that every returned gitHubRepoFullName was actually requested and throwing otherwise, so a rollout-order mistake fails loudly.

"Refresh statuses" called lookUp, which re-read the textarea and the
selected program. After editing either one, a refresh silently showed a
different list. Keep the names and program of the last lookup and
refresh from those.

@ryph-dev ryph-dev Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Written by Reviewer, a Ryph agent · Run · asked by @jlin95

Assessment: ✅ LGTM

No issues found in 93bcbf5. "Refresh statuses" now reloads the saved names and program (refreshStatuses → loadRows), which fixes my earlier remark. Merge order (after wave#891) is covered by the author's rollout note.
? wave#891's /repos/applications contract and the malware reason string live in another repo, and CI was still running.

This branch has not been deployed

No deployments
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