Extend Bounty type optional fields; remove ad-hoc submissions casts - #221
Extend Bounty type optional fields; remove ad-hoc submissions casts#221oxravenz wants to merge 1 commit into
Conversation
|
@oxravenz is attempting to deploy a commit to the Threadflow Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThis PR adds type safety to the bounty application model by introducing a new ChangesBountyApplication Type and Hook Integration
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
There was a problem hiding this comment.
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 `@hooks/use-competition-join-state.ts`:
- Around line 41-43: The code accesses bounty.submissions but
BountyFieldsFragment lacks that field; update the data type or selection so
submissions is actually present: either change the query/component to use the
bounty detail GraphQL type/query that returns submissions (replace
BountyFieldsFragment usage with the detail fragment/query), or extend the
BountyFieldsFragment to include the submissions selection, and then remove the
unsafe cast; alternatively, if only the count is available, switch logic to use
bounty._count.submissions (or map from the real submissions field) where
bountySubmissions is computed in use-competition-join-state.ts so the variable
and types align with the generated BountyFieldsFragment.
🪄 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: b882dfad-1cbf-46df-8a8a-662a4f6d76a0
📒 Files selected for processing (2)
hooks/use-competition-join-state.tstypes/bounty.ts
| const bountySubmissions = ( | ||
| bounty as { submissions?: Array<{ submittedBy: string }> | null } | ||
| bounty | ||
| ).submissions; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Find the BountyFieldsFragment type definition to verify if it includes submissions
# Search for BountyFieldsFragment type/interface definition
rg -nP --type=ts -A20 '(type|interface|fragment)\s+BountyFieldsFragment'
# Also check GraphQL fragment definitions
fd -e graphql -e gql --exec rg -n 'fragment\s+BountyFields'Repository: boundlessfi/bounties
Length of output: 14864
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find BountyFieldsFragment definition and show the full block around it (bounded)
GEN="lib/graphql/generated.ts"
LINE=$(rg -n "export type BountyFieldsFragment" "$GEN" | head -n 1 | cut -d: -f1)
echo "BountyFieldsFragment starts at line: $LINE"
# show next ~200 lines but cap output
start=$((LINE-20))
end=$((LINE+220))
sed -n "${start},${end}p" "$GEN" | nl -ba | sed -n "1,240p"
# Check for submissions within that type
echo "---- submissions occurrences inside BountyFieldsFragment ----"
rg -n "submissions" "$GEN" | head -n 50
# Show context around each submissions occurrence near BountyFieldsFragment
echo "---- context for submissions occurrences near BountyFieldsFragment ----"
rg -n "submissions" "$GEN" -C 5 | head -n 120Repository: boundlessfi/bounties
Length of output: 168
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Find BountyFieldsFragment definition and show the surrounding block
GEN="lib/graphql/generated.ts"
LINE=$(rg -n "export type BountyFieldsFragment" "$GEN" | head -n 1 | cut -d: -f1)
echo "BountyFieldsFragment starts at line: $LINE"
start=$((LINE-20))
end=$((LINE+260))
sed -n "${start},${end}p" "$GEN" | nl -ba | sed -n "1,280p"
# Look for submissions usages/fields in generated.ts
echo "---- submissions occurrences in generated.ts ----"
rg -n "submissions" "$GEN" | head -n 80
echo "---- context for submissions occurrences ----"
rg -n "submissions" "$GEN" -C 6 | head -n 160Repository: boundlessfi/bounties
Length of output: 168
🏁 Script executed:
#!/bin/bash
set -euo pipefail
GEN="lib/graphql/generated.ts"
LINE=$(rg -n "export type BountyFieldsFragment" "$GEN" | head -n 1 | cut -d: -f1)
echo "BountyFieldsFragment starts at line: $LINE"
start=$((LINE-20))
end=$((LINE+260))
echo "---- BountyFieldsFragment block (approx) ----"
awk -v s="$start" -v e="$end" 'NR>=s && NR<=e { printf "%6d: %s\n", NR, $0 }' "$GEN" | head -n 340
echo "---- occurrences of 'submissions' in generated.ts ----"
rg -n "submissions" "$GEN" | head -n 80
echo "---- context for 'submissions' occurrences near BountyFieldsFragment ----"
rg -n "submissions" "$GEN" -C 6 | head -n 160
echo "---- check if BountyFieldsFragment type includes a submissions property ----"
# Extract just the type block and search within it (simple brace-depth heuristic)
python3 - <<'PY'
import re, sys, itertools
path="lib/graphql/generated.ts"
target="export type BountyFieldsFragment"
with open(path,'r',encoding='utf-8') as f:
lines=f.readlines()
start=None
for i,l in enumerate(lines):
if target in l:
start=i
break
assert start is not None
# find end of type by tracking braces for the initial '{'
brace=0
in_block=False
block=[]
for j in range(start, len(lines)):
l=lines[j]
if not in_block:
if "{" in l:
in_block=True
brace += l.count("{") - l.count("}")
else:
brace += l.count("{") - l.count("}")
block.append((j+1,l.rstrip("\n")))
if in_block and brace==0:
break
text="\n".join(l for _,l in block)
print("BountyFieldsFragment block lines:", block[0][0], "-", block[-1][0])
print("Contains 'submissions'? ->", "submissions" in text)
# print matching lines if present
if "submissions" in text:
for ln, l in block:
if "submissions" in l:
print("match:", ln, ":", l.strip())
PYRepository: boundlessfi/bounties
Length of output: 16313
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="hooks/use-competition-join-state.ts"
echo "---- file: $FILE (relevant lines around 41-60) ----"
sed -n '1,120p' "$FILE" | nl -ba 2>/dev/null || sed -n '1,120p' "$FILE" | head -n 120
echo "---- lines 30-70 ----"
sed -n '30,80p' "$FILE"
echo "---- find type annotations involving bounty and BountyFieldsFragment ----"
rg -n "BountyFieldsFragment|submissions|bounty" "$FILE"Repository: boundlessfi/bounties
Length of output: 4499
🏁 Script executed:
#!/bin/bash
set -euo pipefail
GEN="lib/graphql/generated.ts"
python3 - <<'PY'
import re
path="lib/graphql/generated.ts"
with open(path,'r',encoding='utf-8') as f: lines=f.readlines()
# locate the BountyFieldsFragment type block start/end
start=None
for i,l in enumerate(lines):
if "export type BountyFieldsFragment" in l:
start=i; break
assert start is not None
# find end by brace depth from first '{' on same line
brace=0
in_block=False
block=[]
for j in range(start, len(lines)):
l=lines[j]
if not in_block:
if "{" in l:
in_block=True
brace += l.count("{") - l.count("}")
else:
brace += l.count("{") - l.count("}")
block.append((j+1,l.rstrip("\n")))
if in_block and brace==0:
end=j+1
break
text="\n".join(l for _,l in block)
# detect top-level property declarations only (rough heuristic)
# We'll flag any line that looks like "submissions" property at the same indentation level as other fields.
top_level = [ (ln, s) for ln,s in block if re.search(r'^\s*submissions\s*\??\s*:', s) ]
count_submissions = [ (ln, s) for ln,s in block if ' _count' in s or '_count' in s]
# also check if any line includes "submissions" besides _count line
other_subs=[(ln,s) for ln,s in block if 'submissions' in s and ' _count' not in s and '_count' not in s]
print("BountyFieldsFragment lines:", block[0][0], "-", block[-1][0])
print("Top-level submissions property matches:", top_level)
print("Other 'submissions' occurrences excluding _count:", other_subs[:20])
PYRepository: boundlessfi/bounties
Length of output: 200
Fix type mismatch: BountyFieldsFragment doesn’t include submissions
hooks/use-competition-join-state.ts(lines 41-43) accessesbounty.submissions, butBountyFieldsFragment(lib/graphql/generated.ts, ~1919-1962) has nosubmissionsfield—only_count.submissions.- This contradicts the inline comment and should be addressed by using a type/query that includes
submissions(e.g., the detail query type) or extending the fragment to selectsubmissions(or reverting the unsafe cast).
🤖 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 `@hooks/use-competition-join-state.ts` around lines 41 - 43, The code accesses
bounty.submissions but BountyFieldsFragment lacks that field; update the data
type or selection so submissions is actually present: either change the
query/component to use the bounty detail GraphQL type/query that returns
submissions (replace BountyFieldsFragment usage with the detail fragment/query),
or extend the BountyFieldsFragment to include the submissions selection, and
then remove the unsafe cast; alternatively, if only the count is available,
switch logic to use bounty._count.submissions (or map from the real submissions
field) where bountySubmissions is computed in use-competition-join-state.ts so
the variable and types align with the generated BountyFieldsFragment.
Summary:
Validation:
No behavior change intended.
Summary by CodeRabbit
New Features
Refactor