Skip to content

Replace free-text plugin repo URL with a picker from the developer's own GitHub repos - #18

Merged
mrenvoize merged 9 commits into
openfifth:worktree-developer-oauth-loginfrom
mrenvoize:worktree-repo-picker
Aug 13, 2026
Merged

Replace free-text plugin repo URL with a picker from the developer's own GitHub repos#18
mrenvoize merged 9 commits into
openfifth:worktree-developer-oauth-loginfrom
mrenvoize:worktree-repo-picker

Conversation

@mrenvoize

Copy link
Copy Markdown
Member

Summary

  • Retains the developer's GitHub OAuth access token in session after login
  • Adds KohaPluginStore::GitHub::fetch_public_repos, called by fully-qualified name so tests can override it
  • Adds GET /api/v1/developer/repos, gated by the OpenAPI plugin's own security mechanism
  • Replaces the free-text repo URL field on the submission form with a <select> populated from the developer's public GitHub repos, with an honest empty state when they have none
  • Re-validates the submitted repo server-side in new_plugin against that same list, since the dropdown alone doesn't stop a hand-crafted request

Stacked on #15 (developer OAuth login) — diff here is just the 8 commits for this feature.

See docs/superpowers/specs/2026-08-07-repo-picker-design.md and docs/superpowers/plans/2026-08-07-repo-picker.md for the design/plan this followed.

Test plan

  • prove -l t/ — 35 tests, all passing
  • Manually exercised the empty-repos and populated-repos states of the new dropdown

@mrenvoize
mrenvoize force-pushed the worktree-repo-picker branch from d7a600b to cd0d6c1 Compare August 7, 2026 14:29
@mrenvoize
mrenvoize force-pushed the worktree-developer-oauth-login branch 2 times, most recently from f137c2d to eff9b07 Compare August 7, 2026 15:42
@mrenvoize
mrenvoize force-pushed the worktree-repo-picker branch from cd0d6c1 to 5fe7421 Compare August 7, 2026 15:43
Two related bugs found testing the repo picker fix against a real
GitHub account:

- Without read:org scope, GitHub silently omits organization-owned
  repos from affiliation=organization_member results -- no error,
  just missing data. This is why org repos never appeared even after
  fixing the pagination cap downstream.

- log_in_developer stored the developer's entire row (via unblessed)
  in the session, which lives entirely in a signed cookie capped at
  4KiB by Mojolicious. Once a developer's cached_repos grew past a
  few dozen entries, the session silently failed to persist at all
  (logged as "Cookie is bigger than 4KiB"), breaking every
  subsequent authenticated request with a 404. Nothing reads
  anything but the id back out of session (logged_in_user always
  re-fetches fresh from the DB), so only the id needs to be stored.
fetch_public_repos fetched a single per_page=100 page sorted by
recency, so org/collaborator repos past that cutoff (this account's
openfifth membership, where most real plugins live) never showed up
in the picker. Replaces it with fetch_all_repos, which paginates
through everything.

Rather than re-running that full fetch on every /new-plugin view,
the result is cached on the developer's row (cached_repos,
cached_repos_fetched_at) and only refreshed on first visit or an
explicit "Refresh my GitHub repos" button. The picker itself
(Tom Select) filters that cached list entirely client-side, so
searching a long repo list needs no server round-trip and no GitHub
Search API integration.

Submission-time ownership validation (new_plugin) keeps calling
fetch_all_repos live rather than reading the cache, so a stale
cached list can't be used to submit a repo the developer no longer
actually has access to.
@mrenvoize
mrenvoize force-pushed the worktree-repo-picker branch from 980275f to 8b6f514 Compare August 10, 2026 12:58
Re-authorizing without first revoking the app doesn't re-show
GitHub's per-organization grant screen -- confirmed against GitHub's
own docs, since a developer might otherwise reasonably expect
logging out and back in to let them add an org they skipped the
first time. Points at the one documented way to get that screen
back: revoke access at github.com/settings/applications, then log
in again.
@mrenvoize
mrenvoize merged commit 1fc95cb into openfifth:worktree-developer-oauth-login Aug 13, 2026
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