Skip to content

feat: replace hand-written bountyKeys with codegen-generated query keys#115

Merged
0xdevcollins merged 2 commits intoboundlessfi:mainfrom
ryzen-xp:feat/Use-Codegen-Generated-Query-Keys
Feb 25, 2026
Merged

feat: replace hand-written bountyKeys with codegen-generated query keys#115
0xdevcollins merged 2 commits intoboundlessfi:mainfrom
ryzen-xp:feat/Use-Codegen-Generated-Query-Keys

Conversation

@ryzen-xp
Copy link
Contributor

@ryzen-xp ryzen-xp commented Feb 24, 2026

Summary

Replaced hand-written bountyKeys with codegen-generated query keys using exposeQueryKeys: true, establishing a single source of truth for all bounty query keys.


Changes

  • Reviewed generated.ts key exports:

    • useBountiesQuery.getKey()
    • useBountyQuery.getKey()
    • useActiveBountiesQuery.getKey()
    • useOrganizationBountiesQuery.getKey()
    • useProjectBountiesQuery.getKey()
  • Updated lib/query/query-keys.ts to delegate to generated getKey methods.

  • Removed redundant hand-written key factories.

  • Existing hooks, handlers, and mutations now automatically use generated keys via bountyKeys.

  • Prefetch utilities already aligned — no changes needed.


Acceptance Criteria

  • ✅ Single source of truth for query keys (codegen)
  • ✅ All cache invalidation uses generated keys
  • ✅ No breaking changes
  • ✅ Successful compilation

Closes #107

Screenshot From 2026-02-24 13-16-19

Summary by CodeRabbit

  • Refactor
    • Reworked bounty query key generation to a codegen-driven, wrapped-key approach with stronger typing and clearer key semantics.
  • New Features
    • Added public support for querying active bounties, organization-specific bounties, and project-specific bounties.
  • Documentation
    • Added explicit docs describing the new key semantics and usage.

@vercel
Copy link

vercel bot commented Feb 24, 2026

@ryzen-xp is attempting to deploy a commit to the Threadflow Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Feb 24, 2026

📝 Walkthrough

Walkthrough

Replaces the hand-written bounty query key factory with codegen-generated React Query key helpers. Keys now delegate to generated hooks' getKey() methods, introduce typed variable wrappers, and add three new public key variants: active, organization, and project.

Changes

Cohort / File(s) Summary
Bounty Query Keys Refactor
lib/query/query-keys.ts
Replaced static tuple-based bountyKeys with calls to generated hook key helpers (e.g., useBountiesQuery.getKey, useBountyQuery.getKey). Introduced typed variable wrappers (BountiesQueryVariables, BountyQueryVariables, ActiveBountiesQueryVariables, OrganizationBountiesQueryVariables, ProjectBountiesQueryVariables). Added new public key entrypoints: active, organization, project. Expanded public imports/exports to include generated hooks and variable types.
Public API types/exports
(export list in same module) lib/query/query-keys.ts
Updated exported typings and re-exports to surface new variable types and generated hook references; adjusted module exports to match new key-generation signatures.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • 0xdevcollins

Poem

🐰 I nibble keys from codegen ground,
getKey calls now hop all around,
Typed wrappers snug in their burrowed den,
Active, org, project—three new friends! 🥕✨

🚥 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 accurately describes the main change: replacing hand-written bountyKeys with codegen-generated query keys.
Linked Issues check ✅ Passed The PR successfully delegates bountyKeys to codegen-generated getKey methods for all query operations, establishes codegen as single source of truth, and removes hand-written key factories.
Out of Scope Changes check ✅ Passed All changes are scoped to query-keys.ts and directly support the objective of replacing hand-written keys with codegen-generated ones; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

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

Copy link

@coderabbitai coderabbitai bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@lib/query/query-keys.ts`:
- Around line 24-26: The infinite key currently reuses the exact same getKey as
list (see infinite and useBountiesQuery.getKey) which can cause cache collisions
between useQuery and useInfiniteQuery; modify the infinite key to append a
distinguishing suffix (for example include a literal like "infinite" or a second
tuple element) while preserving the original getKey base so the list key stays
unchanged—update the infinite function to return the base getKey result combined
with the suffix to ensure unique cache entries for useInfiniteBounties.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f1fcb62 and aedf803.

📒 Files selected for processing (1)
  • lib/query/query-keys.ts

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
lib/query/query-keys.ts (1)

25-30: Good fix for the list/infinite cache collision.

The "infinite" suffix differentiates infinite query keys from list query keys, preventing TanStack Query from treating useQuery and useInfiniteQuery results as the same cache entry. This properly addresses the previously flagged concern.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/query/query-keys.ts` around lines 25 - 30, The infinite query key now
appends the "infinite" suffix to avoid cache collision with the list query;
update the infinite function (in query-keys.ts) to build its key from
useBountiesQuery.getKey({ query: params } as BountiesQueryVariables) and append
"infinite" so that useInfiniteQuery and useQuery do not share the same cache
entry (ensure the signature uses params?: Omit<BountyQueryInput, "page"> and the
returned tuple is typed as const).
🧹 Nitpick comments (1)
lib/query/query-keys.ts (1)

52-56: BountyQueryKey is missing the new key variants.

The type union only covers list, infinite, and detail. The bountyKeys object also includes lists, active, organization, and project methods, which should be added to the type for completeness. While BountyQueryKey is currently not used elsewhere in the codebase, keeping the type union in sync with available keys prevents future type inconsistencies when this helper is adopted.

♻️ Proposed fix to include all key variants
 export type BountyQueryKey =
+  | ReturnType<typeof bountyKeys.lists>
   | ReturnType<typeof bountyKeys.list>
   | ReturnType<typeof bountyKeys.infinite>
-  | ReturnType<typeof bountyKeys.detail>;
+  | ReturnType<typeof bountyKeys.detail>
+  | ReturnType<typeof bountyKeys.active>
+  | ReturnType<typeof bountyKeys.organization>
+  | ReturnType<typeof bountyKeys.project>;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/query/query-keys.ts` around lines 52 - 56, Update the BountyQueryKey
union to include all variants exposed by bountyKeys: add ReturnType<typeof
bountyKeys.lists>, ReturnType<typeof bountyKeys.active>, ReturnType<typeof
bountyKeys.organization>, and ReturnType<typeof bountyKeys.project> in addition
to the existing list, infinite, and detail entries so the type stays in sync
with the bountyKeys object.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/query/query-keys.ts`:
- Around line 1-13: The BountyQueryKey union is missing variants and should
include all return types from bountyKeys; update the type to union
ReturnType<typeof bountyKeys.lists>, ReturnType<typeof bountyKeys.list>,
ReturnType<typeof bountyKeys.infinite>, ReturnType<typeof bountyKeys.detail>,
ReturnType<typeof bountyKeys.active>, ReturnType<typeof
bountyKeys.organization>, and ReturnType<typeof bountyKeys.project> so
BountyQueryKey covers lists, list, infinite, detail, active, organization, and
project (reference bountyKeys and the BountyQueryKey type).

---

Duplicate comments:
In `@lib/query/query-keys.ts`:
- Around line 25-30: The infinite query key now appends the "infinite" suffix to
avoid cache collision with the list query; update the infinite function (in
query-keys.ts) to build its key from useBountiesQuery.getKey({ query: params }
as BountiesQueryVariables) and append "infinite" so that useInfiniteQuery and
useQuery do not share the same cache entry (ensure the signature uses params?:
Omit<BountyQueryInput, "page"> and the returned tuple is typed as const).

---

Nitpick comments:
In `@lib/query/query-keys.ts`:
- Around line 52-56: Update the BountyQueryKey union to include all variants
exposed by bountyKeys: add ReturnType<typeof bountyKeys.lists>,
ReturnType<typeof bountyKeys.active>, ReturnType<typeof
bountyKeys.organization>, and ReturnType<typeof bountyKeys.project> in addition
to the existing list, infinite, and detail entries so the type stays in sync
with the bountyKeys object.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between aedf803 and 952aa22.

📒 Files selected for processing (1)
  • lib/query/query-keys.ts

@0xdevcollins 0xdevcollins merged commit 690866d into boundlessfi:main Feb 25, 2026
2 of 3 checks passed
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.

Update lib/query/query-keys.ts to use codegen-generated keys

2 participants