fix(#211): extend Bounty type with optional UI fields, remove ad-hoc …#263
Conversation
|
@1sraeliteX is attempting to deploy a commit to the Threadflow Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdds a new BountyApplication type and an optional ChangesBountyApplication Type Integration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 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 |
|
@Benjtalkshow check and merge PR, thanks! |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 `@components/bounty-detail/bounty-detail-client.tsx`:
- Around line 154-156: The fallback in isAssignedApplicant currently treats any
non-creator viewing an IN_PROGRESS bounty as an assigned applicant; tighten this
by replacing the third clause with a concrete check for an approved/assigned
submission or contributor membership instead of (!isCreator && bounty.status ===
"IN_PROGRESS"). Update the expression in isAssignedApplicant to include e.g.
bounty.assignedContributorId === session?.user?.id || bounty.submissions?.some(s
=> s.submittedBy === session?.user?.id && s.status === "APPROVED") or check a
contributors list (whichever matches your data model) so only truly
approved/assigned users can reach ApplicationSubmitWorkPanel.
In `@types/bounty.ts`:
- Around line 86-102: The BountyApplication.type currently declares
reputation.completionStats (string) which doesn't exist in the GraphQL schema;
update the BountyApplication interface and any uses in
ApplicationReviewDashboard and BountyFields to match ContributorStats fields
(use numeric fields completionRate: number and averageCompletionTime: number) or
replace completionStats with a derived display string constructed from those
numeric fields; adjust types and any code paths that read
reputation.completionStats to instead read reputation.completionRate and
reputation.averageCompletionTime (or compute a formatted string) so the TS types
align with the GraphQL schema.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5ef38978-3f62-4e03-bfa8-b12a8686af8b
📒 Files selected for processing (3)
components/bounty-detail/bounty-detail-client.tsxhooks/use-competition-join-state.tstypes/bounty.ts
| export interface BountyApplication { | ||
| id: string; | ||
| applicantAddress: string; | ||
| applicantName?: string; | ||
| proposal: { | ||
| approach: string; | ||
| estimatedTimeline: string; | ||
| relevantExperience: string; | ||
| portfolioUrl?: string; | ||
| }; | ||
| reputation: { | ||
| score: number; | ||
| tier: string; | ||
| completionStats: string; | ||
| }; | ||
| createdAt: string; | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check the GraphQL schema for BountyApplication type definition
# Search for the BountyApplication type or Application type in schema files
fd -e gql -e graphql | xargs rg -A 20 'type.*Application'
# Also search for reputation-related types
fd -e gql -e graphql | xargs rg -A 10 'type.*Reputation|reputation'Repository: boundlessfi/bounties
Length of output: 48
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Find all references to completionStats anywhere in the repo
rg -n "completionStats" . || true
# 2) Locate GraphQL schema files likely containing type definitions
# (expand beyond .gql/.graphql to catch .graphqls, .ts schema strings, etc.)
fd -e gql -e graphql -e graphqls -e schema -e schemas -e apollo -e apis -e api \
-e ts -e js -e json -e yml -e yaml \
--type f . | head -n 50 || true
# More targeted: list likely schema-containing files
fd -e graphql -e gql -e graphqls -e schema --type f . || true
# 3) Search those schema files for the BountyApplication/reputation types
# If no schema files exist, this will yield nothing, but rg for completionStats above should still show schema usage.
schema_files=$(fd -e graphql -e gql -e graphqls -e schema --type f . || true)
if [ -n "${schema_files}" ]; then
printf "%s\n" "${schema_files}" | xargs -I{} rg -n -C 2 --hidden -S "type\\s+.*Application|type\\s+.*Reputation|reputation|completionStats" {} || true
fiRepository: boundlessfi/bounties
Length of output: 2339
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Check the schema definition
rg -n "completionStats" lib/graphql/schema.graphql || true
# 2) Check any GraphQL fragments/operations that reference completionStats
rg -n "completionStats" lib/graphql/operations --glob='*.graphql' || true
# 3) Also search for the reputation field selection set to find the surrounding type context
rg -n "reputation\\s*\\{" lib/graphql/operations --glob='*.graphql' || true
# 4) Print the relevant portion of schema.graphql around the match
# (use sed to keep output small)
line=$(rg -n "completionStats" lib/graphql/schema.graphql | head -n1 | cut -d: -f1 || true)
if [ -n "${line}" ]; then
start=$((line-20))
end=$((line+20))
sed -n "${start},${end}p" lib/graphql/schema.graphql
fiRepository: boundlessfi/bounties
Length of output: 46
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Broad searches in the GraphQL schema and operations
echo "== schema.graphql matches for completionStats =="
rg -n "completionStats" lib/graphql/schema.graphql || echo "NO MATCH"
echo
echo "== lib/graphql matches for completionStats =="
rg -n "completionStats" lib/graphql || echo "NO MATCH IN lib/graphql"
echo
echo "== schema.graphql matches for completion =="
rg -n "completion" lib/graphql/schema.graphql | head -n 50 || echo "NO MATCH"
echo
echo "== schema.graphql matches for reputation type =="
rg -n "type\\s+.*Reputation|reputation\\b" lib/graphql/schema.graphql | head -n 80 || true
echo
echo "== schema.graphql matches for completionStats-like fields =="
rg -n "Stats|stats" lib/graphql/schema.graphql | head -n 80 || trueRepository: boundlessfi/bounties
Length of output: 441
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Where is reputation requested in GraphQL operations?
echo "== references to reputation in lib/graphql/operations =="
rg -n "reputation" lib/graphql/operations --glob='*.graphql' || true
# 2) Dump nearby text for the first few reputation matches (to see selected fields)
# (Limit output to keep it small)
echo
echo "== context around first reputation occurrence (operations) =="
first=$(rg -n "reputation" lib/graphql/operations --glob='*.graphql' | head -n1 || true)
if [ -n "$first" ]; then
file=$(echo "$first" | cut -d: -f1)
line=$(echo "$first" | cut -d: -f2)
start=$((line-30)); end=$((line+30))
sed -n "${start},${end}p" "$file"
fi
# 3) Search schema.graphql for "reputation" and "stats" types
echo
echo "== schema.graphql references to reputation =="
rg -n "reputation" lib/graphql/schema.graphql || echo "NO reputation match"
echo
echo "== schema.graphql references to \"tier\" and \"completion\" =="
rg -n "tier|completion|Completion|completionRate|ContributorStats" lib/graphql/schema.graphql | head -n 120 || true
# 4) Show the ContributorStats type definition area
echo
echo "== ContributorStats definition area =="
line=$(rg -n "type ContributorStats" lib/graphql/schema.graphql | head -n1 | cut -d: -f1 || true)
if [ -n "${line}" ]; then
start=$((line-10)); end=$((line+60))
sed -n "${start},${end}p" lib/graphql/schema.graphql
fiRepository: boundlessfi/bounties
Length of output: 1631
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find where completionStats is assigned/constructed (not only referenced)
rg -n "completionStats\\s*:" . || true
rg -n "completionStats" components app lib types hooks --glob='*.ts' --glob='*.tsx' || true
# Find where BountyApplication / reputation objects are built
rg -n "BountyApplication" . || true
rg -n "reputation:\\s*\\{" . || true
rg -n "reputation\\s*=\\s*" . || true
# Inspect the relevant type definition area in types/bounty.ts
sed -n '60,130p' types/bounty.ts
# Inspect the component usage area
sed -n '1,140p' components/bounty/application-review-dashboard.tsxRepository: boundlessfi/bounties
Length of output: 7436
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Search GraphQL ops for reputation-related selections (tier/stats/contributor stats)
rg -n "reputation|ContributorStats|completionRate|averageCompletionTime|currentStreak|tier\\b|completionStats" lib/graphql/operations --glob='*.graphql' || true
# 2) Inspect the main bounty queries/mutations that likely fetch applications
for f in lib/graphql/operations/bounty-queries.graphql lib/graphql/operations/bounty-mutations.graphql lib/graphql/operations/fragments.graphql lib/graphql/operations/submission-mutations.graphql; do
if [ -f "$f" ]; then
echo "===== $f ====="
# show only the most relevant parts (around common keywords)
rg -n "applications|application|BountyApplication|reputation|Contributor|tier|stats" "$f" || true
fi
done
# 3) Print fragments file sections around "stats" and "tier" if present
if [ -f lib/graphql/operations/fragments.graphql ]; then
rg -n "stats|tier|ContributorStats|LeaderboardContributor|reputation" lib/graphql/operations/fragments.graphql || true
fi
# 4) Search for mapping usage in TS/TSX: any transform of completionRate into completionStats
rg -n "completionRate|averageCompletionTime|currentStreak|longestStreak|completionStats" . --glob='*.ts' --glob='*.tsx' || trueRepository: boundlessfi/bounties
Length of output: 4852
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Look for any completionStats mention in generated GraphQL types
rg -n "completionStats" lib/graphql/generated.ts || true
# 2) Inspect bounty queries for application/reputation selections
for f in lib/graphql/operations/bounty-queries.graphql lib/graphql/operations/fragments.graphql lib/graphql/operations/bounty-mutations.graphql; do
if [ -f "$f" ]; then
echo "===== $f ====="
# show any "reputation" / "applications" sections
rg -n "applications|application|reputation|Contributor|completionRate|averageCompletionTime|stats|tier" "$f" || true
# show full file if it's small; otherwise show around matches
wc -l "$f"
if [ "$(wc -l < "$f")" -le 220 ]; then
sed -n '1,220p' "$f"
else
for pat in "applications" "reputation" "Contributor" "completionRate" "averageCompletionTime"; do
line=$(rg -n "$pat" "$f" | head -n1 | cut -d: -f1 || true)
if [ -n "$line" ]; then
start=$((line-60)); end=$((line+80))
sed -n "${start},${end}p" "$f"
fi
done
fi
echo
fi
done
# 3) Search TS code for constructing completionStats from numeric fields
rg -n "completionStats\\s*[:=]" . --glob='*.ts' --glob='*.tsx' || true
rg -n "completionRate|averageCompletionTime|currentStreak|longestStreak" lib/services --glob='*.ts' || true
# 4) Inspect reputation service and any bounty application service
sed -n '1,200p' lib/services/reputation.ts 2>/dev/null || true
# find possible bounty-application-related services
rg -n "get.*application|bounty.*application|selectApplicant|applications" lib/services --glob='*.ts' || trueRepository: boundlessfi/bounties
Length of output: 8237
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Trace the review dashboard data flow
rg -n "useSelectApplicant|use-bounty-application|selectApplicant" . --glob='*.ts' --glob='*.tsx' || true
# 2) Find where "applications" are loaded for bounty creators/admins
rg -n "applications\\b" app lib components hooks --glob='*.ts' --glob='*.tsx' || true
# 3) Find any API/route returning applications
rg -n "route\\.ts|applications" app/api --glob='*.ts' || true
# 4) Inspect GraphQL ops for "application"
rg -n "application|applications|BountyApplication" lib/graphql/operations --glob='*.graphql' || true
# 5) Find complete set of completionStats occurrences to see if it’s ever derived/assigned
rg -n "completionStats" . --glob='*.ts' --glob='*.tsx' || trueRepository: boundlessfi/bounties
Length of output: 2647
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Show the note about backend not providing applications
sed -n '1,140p' components/bounty-detail/bounty-detail-client.tsx
echo
echo "---- getApplications helper ----"
rg -n "function getApplications|getApplications\\b|applications\\s*\\?\\?\\s*\\[\\]" components/bounty-detail/bounty-detail-client.tsx
# print around the function use site
sed -n '40,120p' components/bounty-detail/bounty-detail-client.tsx
echo
echo "---- Inspect use-bounty-application hook ----"
sed -n '1,220p' hooks/use-bounty-application.ts
echo
echo "---- Inspect store applications type usage ----"
sed -n '1,200p' lib/store.ts
echo
echo "---- Inspect any mock/normalization for application reputation ----"
rg -n "completionStats" components hooks lib --glob='*.ts' --glob='*.tsx' || trueRepository: boundlessfi/bounties
Length of output: 21935
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find where Application[] is created/mocked
rg -n "mock.*application|applications\\s*:\\s*\\[|BountyApplication\\b|type\\s+Application\\b|const\\s+.*applications" . --glob='*.ts' --glob='*.tsx' || true
# Also inspect mock-bounty files
fd -e ts -e tsx -e js -e jsx mock . | head -n 50 || true
fd -e ts -e tsx -e js -e jsx mock-bounty . || true
# List and inspect mock-bounty/applications usage
rg -n "useLocalApplications\\(|useAddLocalApplication\\(|useUpdateLocalApplication\\(" . --glob='*.ts' --glob='*.tsx' || true
rg -n "applications\\s*\\]" lib components app hooks types --glob='*.ts' --glob='*.tsx' || trueRepository: boundlessfi/bounties
Length of output: 691
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect mock-bounty and related mock data for application/reputation completionStats
for f in lib/mock-bounty.ts lib/mock-data.ts lib/mock-project.ts lib/mock-model4.ts lib/mock-leaderboard.ts lib/mock-wallet.ts; do
if [ -f "$f" ]; then
echo "===== $f ====="
# show any Application or completionStats related lines
rg -n "completionStats|applications|reputation\\s*:\\s*\\{" "$f" || true
# show surrounding blocks around completionStats if present
if rg -n "completionStats" "$f" >/dev/null; then
line=$(rg -n "completionStats" "$f" | head -n1 | cut -d: -f1)
start=$((line-40)); end=$((line+40))
sed -n "${start},${end}p" "$f"
fi
echo
fi
done
# Also inspect any mock-bounty usage that might set completionStats in a constant
rg -n "completionStats" lib/mock-bounty.ts lib/mock-data.ts lib/mock-leaderboard.ts lib/mock-model4.ts lib/mock-project.ts lib/mock-wallet.ts types/bounty.ts components/bounty -S || trueRepository: boundlessfi/bounties
Length of output: 494
Update completionStats typing: it isn’t defined in the GraphQL schema
completionStats doesn’t exist in lib/graphql/schema.graphql, while the schema exposes ContributorStats numeric fields like completionRate: Float! and averageCompletionTime: Float!. Update types/bounty.ts / ApplicationReviewDashboard to align with the actual GraphQL fields (or derive a display string from ContributorStats), since BountyFields also doesn’t fetch applications from the backend yet.
🤖 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 `@types/bounty.ts` around lines 86 - 102, The BountyApplication.type currently
declares reputation.completionStats (string) which doesn't exist in the GraphQL
schema; update the BountyApplication interface and any uses in
ApplicationReviewDashboard and BountyFields to match ContributorStats fields
(use numeric fields completionRate: number and averageCompletionTime: number) or
replace completionStats with a derived display string constructed from those
numeric fields; adjust types and any code paths that read
reputation.completionStats to instead read reputation.completionRate and
reputation.averageCompletionTime (or compute a formatted string) so the TS types
align with the GraphQL schema.
|
@1sraeliteX But the branch is several merged PRs behind upstream main. The diff against upstream shows three regressions that would land if this is merged as-is:
Please rebase against upstream main. When the conflicts come up in |
…ove ad-hoc casts
- Add BountyApplication interface to types/bounty.ts
- Add applications?, claimCount?, maxParticipants?, assignedContributorId?
to the Bounty interface (submissions, milestones, contributorProgress,
maxSlots, totalSlotsOccupied were already present)
- Widen useCompetitionJoinState param to BountyFieldsFragment & Partial<Bounty>
so bounty.submissions is accessible without a cast
- Remove all (bounty as { ... }) casts from bounty-detail-client.tsx:
getApplications, isAssignedApplicant, competitionSubmissions
- Drop unused CompetitionSubmissionEntry import from bounty-detail-client.tsx
c0aa4b5 to
70fc977
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
types/bounty.ts (1)
86-102: ⚡ Quick winDeduplicate
components/bounty/application-review-dashboard.tsx’sApplicationtype withtypes/bounty.ts’sBountyApplication.
BountyApplicationintypes/bounty.tsis field-for-field identical to theApplicationinterface incomponents/bounty/application-review-dashboard.tsx(id/applicant*, proposal, reputation, createdAt). Keeping both definitions separate invites type drift—make one canonical and alias/re-export the other.♻️ Example: re-export the canonical type
// components/bounty/application-review-dashboard.tsx -export interface Application { - id: string; - applicantAddress: string; - applicantName?: string; - proposal: { ... }; - reputation: { ... }; - createdAt: string; -} +import type { BountyApplication as Application } from "`@/types/bounty`"; +export type { Application };🤖 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 `@types/bounty.ts` around lines 86 - 102, The local Application interface in components/bounty/application-review-dashboard.tsx is identical to BountyApplication in types/bounty.ts; remove the duplicated interface and instead import and re-export or alias the canonical BountyApplication type (e.g., import { BountyApplication } from 'types/bounty' and export type Application = BountyApplication or replace all local uses with BountyApplication) so the dashboard uses the shared type and avoids drift; update any references in application-review-dashboard.tsx from Application to the imported/aliased BountyApplication.
🤖 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.
Nitpick comments:
In `@types/bounty.ts`:
- Around line 86-102: The local Application interface in
components/bounty/application-review-dashboard.tsx is identical to
BountyApplication in types/bounty.ts; remove the duplicated interface and
instead import and re-export or alias the canonical BountyApplication type
(e.g., import { BountyApplication } from 'types/bounty' and export type
Application = BountyApplication or replace all local uses with
BountyApplication) so the dashboard uses the shared type and avoids drift;
update any references in application-review-dashboard.tsx from Application to
the imported/aliased BountyApplication.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5bc657b4-ba68-4f73-802a-602f467d22b4
📒 Files selected for processing (3)
components/bounty-detail/bounty-detail-client.tsxhooks/use-competition-join-state.tstypes/bounty.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- hooks/use-competition-join-state.ts
- components/bounty-detail/bounty-detail-client.tsx
|
@Benjtalkshow check and let me know if their are any further modifications |
Benjtalkshow
left a comment
There was a problem hiding this comment.
Rebase is clean. Branch is up to date with main, no rollback of the merged refactor PRs. Four ad-hoc casts gone, BountyApplication typed properly, useCompetitionJoinState parameter widened, no remaining (bounty as { ... }) casts in the bounty tree. Typecheck and lint clean.
Merging this in. Thanks.
Closes #211
Summary by CodeRabbit
New Features
Refactor