agent: @U0AJM7X8FBR Admin + Docs + API - we want to update the /coding page in #22
Conversation
Updates the coding agent Slack tags page to surface which pull requests have been merged, using the new GET /api/admins/coding/pr endpoint. - types/coding-agent.ts — CodingPrStatus, CodingPrStatusResponse types - lib/recoup/fetchCodingPrStatus.ts — HTTP client for the new endpoint - hooks/useCodingPrStatus.ts — React Query hook, returns Set of merged URLs - lib/coding-agent/getTagsByDate.ts — adds merged_pr_count per date - components/Admin/AdminLineChart.tsx — adds thirdLine prop support - components/CodingAgentSlackTags/SlackTagsColumns.tsx — ship 🚢 emoji for merged PRs - components/CodingAgentSlackTags/SlackTagsTable.tsx — accepts mergedPrUrls prop - components/CodingAgentSlackTags/CodingAgentSlackTagsPage.tsx — wires it all together: merged PRs top stat, "PRs Merged" chart line, ship emoji in table Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe changes introduce merged PR tracking across the admin dashboard. A new Changes
Sequence DiagramsequenceDiagram
participant Page as CodingAgentSlackTagsPage
participant Hook as useCodingPrStatus
participant Privy as Privy
participant API as fetchCodingPrStatus
participant Server as Backend API
participant Chart as AdminLineChart
participant Table as SlackTagsTable
Page->>Hook: useCodingPrStatus(data?.tags)
Hook->>Privy: usePrivy() - get accessToken
Privy-->>Hook: accessToken
Note over Hook: Extract unique PR URLs<br/>from tags
Hook->>API: fetchCodingPrStatus(token, PRs)
API->>Server: GET /api/admins/coding/pr<br/>?pull_requests=...
Server-->>API: {pull_requests: [{url, status}]}
API-->>Hook: Set of merged PR URLs
Hook-->>Page: mergedPrUrls Set
Page->>Page: getTagsByDate(tags, mergedPrUrls)<br/>+ merged_pr_count per date
Page->>Chart: data, secondLine, thirdLine
Page->>Table: tags, mergedPrUrls
Chart-->>Page: Renders with 3 lines
Table->>Table: createSlackTagsColumns(mergedPrUrls)
Table-->>Page: Renders PR links with 🚢 prefix
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…boolean
Aligns with API change from { merged: boolean } to { status: "open" | "closed" | "merged" }.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| } | ||
|
|
||
| /** @deprecated Use createSlackTagsColumns() instead */ | ||
| export const slackTagsColumns = createSlackTagsColumns(); |
There was a problem hiding this comment.
remove the deprecated variable and refactor this file to be the same name as the function.
There was a problem hiding this comment.
Resolved — removed deprecated export, renamed file to createSlackTagsColumns.tsx.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
hooks/useCodingPrStatus.ts (1)
15-26: Unstable query key may cause unnecessary refetches.
allPrUrlsis recomputed on every render, creating a new array reference. React Query compares query keys by value for primitives but by reference for objects/arrays within the key. While the array contents may be the same, the changing reference could affect cache behavior.Consider memoizing or sorting the URLs for a stable key:
♻️ Proposed fix for stable query key
+import { useMemo } from "react"; + export function useCodingPrStatus(tags: SlackTag[] | undefined) { const { ready, authenticated, getAccessToken } = usePrivy(); - const allPrUrls = [...new Set(tags?.flatMap((tag) => tag.pull_requests ?? []) ?? [])]; + const allPrUrls = useMemo( + () => [...new Set(tags?.flatMap((tag) => tag.pull_requests ?? []) ?? [])].sort(), + [tags] + ); return useQuery({🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@hooks/useCodingPrStatus.ts` around lines 15 - 26, The query key is unstable because allPrUrls is recreated each render; memoize and normalize it before passing to useQuery: compute allPrUrls using React's useMemo (based on tags) and produce a stable representation (e.g., sort the URLs and/or join into a string) so the reference/value is stable, then use that memoized value in queryKey and in the fetch (keep getAccessToken and fetchCodingPrStatus usage the same).lib/recoup/fetchCodingPrStatus.ts (1)
20-25: Consider batching for URLs with 50+ PRs to avoid exceeding safe URL length limits.The query parameter approach works well for typical usage (< 20 PRs stay well under 2000 characters), but URLs with 50+ PRs risk exceeding safe cross-browser limits (~2000 chars). Since the API only supports GET (no POST variant found), implement batching to split large requests if this function will regularly handle many PRs.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/recoup/fetchCodingPrStatus.ts` around lines 20 - 25, fetchCodingPrStatus currently appends all pullRequests to a single GET URL which can exceed safe URL length for large arrays; change it to batch pullRequests into smaller chunks (e.g., 20–25 IDs per batch), for each chunk build a URL (using the existing URL and searchParams.append("pull_requests", pr) logic), issue parallel fetches (Promise.all) with the same headers/Authorization, and then merge/concatenate the responses before returning; ensure you keep the same error handling and response parsing used around the existing fetch call and reference the pullRequests variable, url construction code, and the fetch invocation when implementing the batching.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@hooks/useCodingPrStatus.ts`:
- Around line 15-26: The query key is unstable because allPrUrls is recreated
each render; memoize and normalize it before passing to useQuery: compute
allPrUrls using React's useMemo (based on tags) and produce a stable
representation (e.g., sort the URLs and/or join into a string) so the
reference/value is stable, then use that memoized value in queryKey and in the
fetch (keep getAccessToken and fetchCodingPrStatus usage the same).
In `@lib/recoup/fetchCodingPrStatus.ts`:
- Around line 20-25: fetchCodingPrStatus currently appends all pullRequests to a
single GET URL which can exceed safe URL length for large arrays; change it to
batch pullRequests into smaller chunks (e.g., 20–25 IDs per batch), for each
chunk build a URL (using the existing URL and
searchParams.append("pull_requests", pr) logic), issue parallel fetches
(Promise.all) with the same headers/Authorization, and then merge/concatenate
the responses before returning; ensure you keep the same error handling and
response parsing used around the existing fetch call and reference the
pullRequests variable, url construction code, and the fetch invocation when
implementing the batching.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e7cca115-b125-4350-977a-7db20d63cc83
📒 Files selected for processing (8)
components/Admin/AdminLineChart.tsxcomponents/CodingAgentSlackTags/CodingAgentSlackTagsPage.tsxcomponents/CodingAgentSlackTags/SlackTagsColumns.tsxcomponents/CodingAgentSlackTags/SlackTagsTable.tsxhooks/useCodingPrStatus.tslib/coding-agent/getTagsByDate.tslib/recoup/fetchCodingPrStatus.tstypes/coding-agent.ts
…eprecated export Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Shows percentage of Slack tags that resulted in a merged PR. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Automated PR from coding agent.
Prompt: @U0AJM7X8FBR Admin + Docs + API - we want to update the /coding page in the admin codebase to view analytics around pull requests MERGED by the coding-agent.
Summary by CodeRabbit