Skip to content

perf(github): cache repository catalog - #207

Merged
ryota-murakami merged 4 commits into
mainfrom
codex/cache-github-repository-catalog
Jul 21, 2026
Merged

ryota-murakami merged 4 commits into
mainfrom
codex/cache-github-repository-catalog

Conversation

@ryota-murakami

@ryota-murakami ryota-murakami commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • consolidate the repository picker into one GitHub catalog Server Action
  • cache compact repository and organization pages for 24-hour user-isolated windows
  • retain organization-only repositories with ID deduplication and malformed-owner filtering
  • validate OAuth credentials live while preventing raw tokens from entering cache keys or error logs

Architecture

  • uses Next.js unstable_cache around each 100-item GitHub API page
  • partitions entries by SHA-256 token fingerprint, cache window, resource, source, and page
  • keeps each cache entry below the Next.js 2 MiB limit
  • reuses the catalog in the client after the first picker open

Verification

  • pnpm test run — 102 files, 1367 tests passed
  • pnpm lint
  • pnpm typecheck
  • pnpm build
  • pnpm e2e:parallel — 12/12 shards passed
  • security review — no findings

Summary by CodeRabbit

  • New Features
    • Added a unified GitHub repository picker catalog that loads on first open and reuses cached results for later openings.
  • Bug Fixes
    • Improved missing/expired GitHub access handling with safer, consistent messaging and better recovery on close/reopen.
    • Ensures the current user is excluded from organization-based filters.
  • UI/Style
    • Updated picker loading text and refined focus styling for the search input and visibility filter.

@vercel

vercel Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gitbox Ready Ready Preview, Comment Jul 21, 2026 1:52pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ffb29939-f5d4-4406-8b18-0caf8f7ccb92

📥 Commits

Reviewing files that changed from the base of the PR and between 2494546 and 581a333.

📒 Files selected for processing (1)
  • src/tests/unit/lib/actions/github-network-error.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/tests/unit/lib/actions/github-network-error.test.ts

📝 Walkthrough

Walkthrough

The pull request replaces separate GitHub user, organization, and repository loading with a cached repository catalog. It adds shared types and configuration, centralizes token handling, introduces catalog caching and pagination, updates the picker integration, and adds tests for loading, errors, caching, retries, and token safety.

Changes

Repository catalog flow

Layer / File(s) Summary
GitHub contracts and token transport
src/lib/constants/github.ts, src/lib/types/github.ts, src/lib/axios-github.ts
Adds shared GitHub configuration and catalog types, centralizes token resolution, and supports explicit Axios tokens with optional unauthorized-cookie cleanup.
Cached catalog assembly
src/lib/github/repository-catalog.ts
Fetches and caches paginated user and organization data, filters malformed entries, merges repositories without duplicates, and redacts upstream errors across cache boundaries.
Catalog Server Action
src/lib/actions/github.ts, src/lib/utils/handle-github-token-missing.ts
Adds getAuthenticatedRepositoryCatalog with token checks, IP rate limiting, normalized errors, and revoked-token cookie cleanup.
Lazy picker integration
src/hooks/board/*, src/components/Board/AddRepositoryCombobox.tsx
Loads the catalog when the picker opens, supports refresh and retry behavior, filters the current user, and updates loading, error, and focus styling.
Catalog behavior validation
src/tests/unit/hooks/board/useRepositoryCatalog.test.tsx, src/tests/unit/lib/actions/*, src/tests/unit/lib/axios-github.test.ts, src/tests/unit/lib/github/repository-catalog.test.ts
Tests hook lifecycle, authentication failures, safe error handling, token resolution, cache reuse, pagination, cache rollover, retries, and token redaction.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant AddRepositoryCombobox
  participant useRepositoryCatalog
  participant getAuthenticatedRepositoryCatalog
  participant getCachedGitHubRepositoryCatalog
  participant GitHub
  User->>AddRepositoryCombobox: Open repository picker
  AddRepositoryCombobox->>useRepositoryCatalog: Load catalog
  useRepositoryCatalog->>getAuthenticatedRepositoryCatalog: Request catalog
  getAuthenticatedRepositoryCatalog->>getCachedGitHubRepositoryCatalog: Validate token and load pages
  getCachedGitHubRepositoryCatalog->>GitHub: Fetch /user and missing catalog pages
  GitHub-->>getCachedGitHubRepositoryCatalog: User, organization, and repository data
  getCachedGitHubRepositoryCatalog-->>getAuthenticatedRepositoryCatalog: Merged catalog
  getAuthenticatedRepositoryCatalog-->>useRepositoryCatalog: ActionResult
  useRepositoryCatalog-->>AddRepositoryCombobox: Filtered picker data
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: caching the GitHub repository catalog.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/cache-github-repository-catalog

Comment @coderabbitai help to get the list of available commands.

@codecov-commenter

codecov-commenter commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.19372% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.68%. Comparing base (bbe2e3d) to head (581a333).

Files with missing lines Patch % Lines
src/lib/github/repository-catalog.ts 93.91% 7 Missing ⚠️
src/hooks/board/useRepositoryCatalog.ts 85.71% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #207      +/-   ##
==========================================
+ Coverage   70.39%   70.68%   +0.29%     
==========================================
  Files         171      172       +1     
  Lines        4732     4824      +92     
  Branches     1265     1279      +14     
==========================================
+ Hits         3331     3410      +79     
- Misses       1382     1395      +13     
  Partials       19       19              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/lib/github/repository-catalog.ts (1)

409-419: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Known-status GitHub errors are silently dropped with zero telemetry. Both sites intentionally skip logging raw Axios/catalog errors to avoid leaking the Authorization header (per the comment "Axios config contains Authorization, so response-less errors must never be logged raw" at src/lib/actions/github.ts line 100), but end up adding no logging at all for very common failure classes (403/429/500/network) — only genuinely unrecognized errors are logged/reported to Sentry. A sanitized, status-only log line preserves the security goal while restoring observability.

  • src/lib/github/repository-catalog.ts#L409-L419: when an organization's repository fetch is rejected with a non-401 status, add a token-free log.warn({ status: getGitHubCatalogErrorStatus(organizationResult.reason) }, 'Skipping organization repositories') (or similar) before continue, instead of silently dropping it.
  • src/lib/actions/github.ts#L86-L121: in the isAxiosError and catalog-status branches of handleGitHubError, add a log.warn({ status: errorStatus, context }, ...) / lightweight Sentry.captureMessage call before returning the mapped message, without ever logging error.config or error.response?.data raw.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lib/github/repository-catalog.ts` around lines 409 - 419, Add sanitized
status-only warning telemetry for known GitHub failures without logging raw
Axios error objects or response data. In src/lib/github/repository-catalog.ts
lines 409-419, update the non-401 rejection path in the
organizationRepositoryResults loop to log the derived status before skipping; in
src/lib/actions/github.ts lines 86-121, update handleGitHubError’s Axios-error
and catalog-status branches to warn or capture a lightweight message with
errorStatus and context before returning the mapped message.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lib/github/repository-catalog.ts`:
- Around line 313-325: Update fetchOrganizationRepositoryCatalog to isolate
failures from fetchAllOrganizations: catch non-401 organization-list errors and
return an empty organization list with no repository results, allowing the
top-level catalog flow to preserve already-fetched user repositories. Preserve
existing 401 propagation and per-organization Promise.allSettled behavior.

---

Nitpick comments:
In `@src/lib/github/repository-catalog.ts`:
- Around line 409-419: Add sanitized status-only warning telemetry for known
GitHub failures without logging raw Axios error objects or response data. In
src/lib/github/repository-catalog.ts lines 409-419, update the non-401 rejection
path in the organizationRepositoryResults loop to log the derived status before
skipping; in src/lib/actions/github.ts lines 86-121, update handleGitHubError’s
Axios-error and catalog-status branches to warn or capture a lightweight message
with errorStatus and context before returning the mapped message.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 175e51ad-0296-4894-af1d-f23fe2dc8bc6

📥 Commits

Reviewing files that changed from the base of the PR and between bbe2e3d and 53b22c7.

📒 Files selected for processing (19)
  • src/components/Board/AddRepositoryCombobox.tsx
  • src/hooks/board/index.ts
  • src/hooks/board/useOrganizationData.ts
  • src/hooks/board/useRepositoryCatalog.ts
  • src/hooks/board/useRepositoryData.ts
  • src/lib/actions/github.ts
  • src/lib/axios-github.ts
  • src/lib/constants/github.ts
  • src/lib/github/repository-catalog.ts
  • src/lib/types/github.ts
  • src/lib/utils/handle-github-token-missing.ts
  • src/tests/unit/hooks/board/useOrganizationData.test.tsx
  • src/tests/unit/hooks/board/useRepositoryCatalog.test.tsx
  • src/tests/unit/hooks/board/useRepositoryData.test.tsx
  • src/tests/unit/lib/actions/github-error-code.test.ts
  • src/tests/unit/lib/actions/github-network-error.test.ts
  • src/tests/unit/lib/actions/github-pagination.test.ts
  • src/tests/unit/lib/axios-github.test.ts
  • src/tests/unit/lib/github/repository-catalog.test.ts
💤 Files with no reviewable changes (5)
  • src/tests/unit/hooks/board/useRepositoryData.test.tsx
  • src/tests/unit/lib/actions/github-pagination.test.ts
  • src/tests/unit/hooks/board/useOrganizationData.test.tsx
  • src/hooks/board/useOrganizationData.ts
  • src/hooks/board/useRepositoryData.ts

Comment thread src/lib/github/repository-catalog.ts
@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

🧪 E2E Coverage Report (Sharded: 12 parallel jobs)

Metric Coverage
Lines 93.19%
Functions 20.99%
Branches 17.48%
Statements 30.64%

📊 Full report available in workflow artifacts

- isolate non-auth organization list failures\n- add sanitized GitHub failure telemetry\n- cover partial failure and revoked-token behavior

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/tests/unit/lib/actions/github-network-error.test.ts`:
- Around line 92-94: Update the assertion in the github network error test to
inspect the relevant mock calls directly rather than
JSON.stringify(actionHarness). Serialize the .mock.calls arrays for logWarn and
captureException (and any other relevant mocks) so the rawToken leak check
includes function-invocation arguments.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c50ab3d-d46c-4730-a0fc-493a09bb3b90

📥 Commits

Reviewing files that changed from the base of the PR and between 8e92cfa and 2494546.

📒 Files selected for processing (4)
  • src/lib/actions/github.ts
  • src/lib/github/repository-catalog.ts
  • src/tests/unit/lib/actions/github-network-error.test.ts
  • src/tests/unit/lib/github/repository-catalog.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/lib/actions/github.ts
  • src/lib/github/repository-catalog.ts
  • src/tests/unit/lib/github/repository-catalog.test.ts

Comment thread src/tests/unit/lib/actions/github-network-error.test.ts Outdated
@ryota-murakami
ryota-murakami merged commit a9f0459 into main Jul 21, 2026
20 checks passed
@ryota-murakami
ryota-murakami deleted the codex/cache-github-repository-catalog branch July 21, 2026 14:02

This branch was successfully deployed

1 active deployment
Preview — 581a3333 Deployed Jul 21, 2026 by vercel[bot]
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.

2 participants