Skip to content

feat: add aggregate parameter input with presets #7146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

catalyst17
Copy link
Contributor

@catalyst17 catalyst17 commented May 23, 2025

PR-Codex overview

This PR introduces the AggregateParameterInput component to handle aggregate parameters in the BlueprintPlayground. It adds new presets for various data types and modifies the ParameterSection to utilize this new component, enhancing the functionality of the parameter input system.

Detailed summary

  • Added AggregateParameterInput component to handle aggregate parameters.
  • Introduced multiple preset options for aggregates, transactions, events, and blocks.
  • Updated ParameterSection to include a check for the aggregate parameter and render the new component.
  • Modified placeholder logic in ParameterSection to use param.description or param.name.
  • Passed endpointPath prop to AggregateParameterInput for context on preset selection.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features
    • Introduced a specialized input with preset selection for aggregate query parameters, enhancing usability when configuring aggregate values.
    • The playground UI now displays this new input component for aggregate parameters, providing relevant preset options based on the selected endpoint.
  • Improvements
    • Placeholders for parameter inputs now more accurately reflect the parameter’s description or name for better clarity.

Copy link

changeset-bot bot commented May 23, 2025

⚠️ No Changeset found

Latest commit: 72e77b2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

coderabbitai bot commented May 23, 2025

Warning

Rate limit exceeded

@catalyst17 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between 548f0c3 and 72e77b2.

📒 Files selected for processing (2)
  • apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx (1 hunks)
  • apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx (4 hunks)

Walkthrough

A new React component, AggregateParameterInput, is introduced to provide a specialized input field with preset dropdown options for aggregate query parameters, determined by the API endpoint path. The playground UI is updated to use this component for "aggregate" parameters, passing the relevant endpoint path and adjusting how placeholders are determined and passed.

Changes

Files/Paths Change Summary
apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx Added new AggregateParameterInput component with endpoint-specific preset selection, input, and integration with form control.
apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx Integrated AggregateParameterInput into the playground UI for "aggregate" parameters; updated prop passing and placeholder logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant BlueprintPlayground
    participant ParameterInput
    participant AggregateParameterInput

    User->>BlueprintPlayground: Opens playground UI
    BlueprintPlayground->>ParameterInput: Render input for parameter "aggregate"
    ParameterInput->>AggregateParameterInput: Render with endpointPath and form field
    AggregateParameterInput->>User: Shows input and preset dropdown
    User->>AggregateParameterInput: Selects preset or enters value
    AggregateParameterInput->>ParameterInput: Updates form value
    ParameterInput->>BlueprintPlayground: Form value updated
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the Playground Changes involving the Playground codebase. label May 23, 2025
Copy link

codecov bot commented May 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.62%. Comparing base (317211a) to head (72e77b2).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7146      +/-   ##
==========================================
- Coverage   55.63%   55.62%   -0.01%     
==========================================
  Files         902      902              
  Lines       58190    58190              
  Branches     4098     4098              
==========================================
- Hits        32373    32369       -4     
- Misses      25712    25716       +4     
  Partials      105      105              
Flag Coverage Δ
packages 55.62% <ø> (-0.01%) ⬇️

see 1 file with indirect coverage changes

🚀 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.

@catalyst17 catalyst17 requested a review from MananTank May 23, 2025 18:40
@catalyst17 catalyst17 marked this pull request as ready for review May 23, 2025 18:40
@catalyst17 catalyst17 requested review from a team as code owners May 23, 2025 18:40
Copy link
Contributor

github-actions bot commented May 23, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 56.62 KB (0%) 1.2 s (0%) 524 ms (+139% 🔺) 1.7 s
thirdweb (cjs) 309.13 KB (0%) 6.2 s (0%) 2.1 s (+2.93% 🔺) 8.2 s
thirdweb (minimal + tree-shaking) 5.69 KB (0%) 114 ms (0%) 161 ms (+428.94% 🔺) 275 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 80 ms (+1305.81% 🔺) 90 ms
thirdweb/react (minimal + tree-shaking) 19.5 KB (0%) 390 ms (0%) 132 ms (+163.51% 🔺) 522 ms

@catalyst17 catalyst17 force-pushed the feat_add_aggregate_parameter_input_with_presets branch from a1e9e1a to 75d8e69 Compare May 23, 2025 18:41
Copy link

vercel bot commented May 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
thirdweb_playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 23, 2025 6:56pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) May 23, 2025 6:56pm
login ⬜️ Skipped (Inspect) May 23, 2025 6:56pm
thirdweb-www ⬜️ Skipped (Inspect) May 23, 2025 6:56pm
wallet-ui ⬜️ Skipped (Inspect) May 23, 2025 6:56pm

@vercel vercel bot temporarily deployed to Preview – docs-v2 May 23, 2025 18:44 Inactive
@vercel vercel bot temporarily deployed to Preview – login May 23, 2025 18:44 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb-www May 23, 2025 18:44 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 23, 2025 18:44 Inactive
@catalyst17 catalyst17 force-pushed the feat_add_aggregate_parameter_input_with_presets branch from 75d8e69 to 50f59b3 Compare May 23, 2025 18:44
@vercel vercel bot temporarily deployed to Preview – login May 23, 2025 18:44 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb-www May 23, 2025 18:44 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 23, 2025 18:44 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 23, 2025 18:44 Inactive
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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🧹 Nitpick comments (3)
apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx (1)

525-526: Consider the impact of placeholder logic change.

The placeholder logic has been simplified from a context-aware URL-based calculation to using param.description || param.name. While this works well for the aggregate parameter, it might reduce the user experience for path parameters where the original logic provided more meaningful placeholders like {param_name} or :param_name.

Consider preserving the original placeholder logic for non-aggregate parameters:

-                            placeholder={param.description || param.name}
+                            placeholder={param.name === "aggregate" ? (param.description || param.name) : (url.includes(`{${param.name}}`) ? `{${param.name}}` : url.includes(`:${param.name}`) ? `:${param.name}` : "Value")}

Or extract the placeholder logic into a helper function for better maintainability.

apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx (2)

138-148: Consider more flexible endpoint matching.

The current exact string matching for endpoint paths is brittle and won't handle dynamic path segments or variations in endpoint structure.

Consider implementing more flexible pattern matching:

-const ENDPOINT_SPECIFIC_PRESETS: Record<string, Preset[]> = {
-  "/v1/transactions": GENERAL_TRANSACTIONS_PRESETS,
-  "/v1/wallets/{wallet_address}/transactions": WALLET_TRANSACTIONS_PRESETS,
-  "/v1/events": EVENTS_PRESETS,
-  "/v1/blocks": BLOCKS_PRESETS,
-  // Add more endpoint paths and their specific presets here
-};
+const ENDPOINT_PATTERNS: Array<{pattern: RegExp, presets: Preset[]}> = [
+  { pattern: /\/v1\/transactions$/, presets: GENERAL_TRANSACTIONS_PRESETS },
+  { pattern: /\/v1\/wallets\/[^/]+\/transactions/, presets: WALLET_TRANSACTIONS_PRESETS },
+  { pattern: /\/v1\/events/, presets: EVENTS_PRESETS },
+  { pattern: /\/v1\/blocks/, presets: BLOCKS_PRESETS },
+];

 function getAggregatePresets(endpointPath: string): Preset[] {
-  return ENDPOINT_SPECIFIC_PRESETS[endpointPath] || DEFAULT_AGGREGATE_PRESETS;
+  const match = ENDPOINT_PATTERNS.find(({pattern}) => pattern.test(endpointPath));
+  return match?.presets || DEFAULT_AGGREGATE_PRESETS;
 }

180-186: Consider edge case handling for preset selection.

The current implementation only calls onChange when selectedValue is truthy, but consider what happens if a user wants to clear their selection.

Consider adding a "Clear" option or handling empty selection:

        onValueChange={(selectedValue) => {
-          if (selectedValue) {
-            onChange({ target: { value: selectedValue } });
-          }
+          onChange({ target: { value: selectedValue || "" } });
        }}

Or add a clear option to the select dropdown.

🛑 Comments failed to post (1)
apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx (1)

19-37: 🛠️ Refactor suggestion

Improve default preset usability.

The default presets contain placeholder text like your_field_here which requires user modification. This might confuse users who expect working presets.

Consider either:

  1. Removing the custom field presets from defaults and only including them in endpoint-specific collections where field names are known
  2. Adding clear documentation or help text indicating these are templates
 const DEFAULT_AGGREGATE_PRESETS: Preset[] = [
   { label: "Count All Items", value: "count() AS count_all" },
   { label: "Sum (gas_used)", value: "sum(gas_used) AS total_gas_used" },
   { label: "Average (gas_used)", value: "avg(gas_used) AS avg_gas_used" },
   { label: "Min (gas_used)", value: "min(gas_used) AS min_gas_used" },
   { label: "Max (gas_used)", value: "max(gas_used) AS max_gas_used" },
-  // Presets for a user-defined field
-  {
-    label: "Count (custom field)",
-    value: "count(your_field_here) AS count_custom",
-  },
-  { label: "Sum (custom field)", value: "sum(your_field_here) AS sum_custom" },
-  {
-    label: "Average (custom field)",
-    value: "avg(your_field_here) AS avg_custom",
-  },
-  { label: "Min (custom field)", value: "min(your_field_here) AS min_custom" },
-  { label: "Max (custom field)", value: "max(your_field_here) AS max_custom" },
 ];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

const DEFAULT_AGGREGATE_PRESETS: Preset[] = [
  { label: "Count All Items", value: "count() AS count_all" },
  { label: "Sum (gas_used)", value: "sum(gas_used) AS total_gas_used" },
  { label: "Average (gas_used)", value: "avg(gas_used) AS avg_gas_used" },
  { label: "Min (gas_used)", value: "min(gas_used) AS min_gas_used" },
  { label: "Max (gas_used)", value: "max(gas_used) AS max_gas_used" },
];
🤖 Prompt for AI Agents
In
apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx
around lines 19 to 37, the default aggregate presets include placeholders like
"your_field_here" which can confuse users expecting functional presets. To fix
this, remove these custom field presets from the default list and instead
include them only in endpoint-specific preset collections where actual field
names are known, or alternatively add clear inline comments or UI help text
indicating these presets are templates requiring user modification.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75d8e69 and 50f59b3.

📒 Files selected for processing (2)
  • apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx (1 hunks)
  • apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/playground-web/src/app/insight/[blueprint_slug]/aggregate-parameter-input.client.tsx
🧰 Additional context used
🪛 Biome (1.9.4)
apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx

[error] 454-454: This variable is unused.

Unused variables usually are result of incomplete refactoring, typos and other source of bugs.
Unsafe fix: If this is intentional, prepend placeholder with an underscore.

(lint/correctness/noUnusedVariables)

⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
apps/playground-web/src/app/insight/[blueprint_slug]/blueprint-playground.client.tsx (4)

38-38: LGTM!

The import statement is correctly added for the new AggregateParameterInput component.


525-526: LGTM!

The placeholder change improves user experience by showing descriptive text, and the endpointPath prop enables the new aggregate parameter functionality.


591-591: LGTM!

The endpointPath prop is correctly added to the interface to support the new aggregate parameter functionality.


628-638: LGTM!

The conditional rendering for aggregate parameters is correctly implemented. All required props are passed to the AggregateParameterInput component, enabling the specialized functionality for aggregate parameter handling.

@catalyst17 catalyst17 force-pushed the feat_add_aggregate_parameter_input_with_presets branch from 50f59b3 to 548f0c3 Compare May 23, 2025 18:49
@vercel vercel bot temporarily deployed to Preview – login May 23, 2025 18:49 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb-www May 23, 2025 18:49 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 23, 2025 18:49 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 23, 2025 18:49 Inactive
@catalyst17 catalyst17 force-pushed the feat_add_aggregate_parameter_input_with_presets branch from 548f0c3 to 72e77b2 Compare May 23, 2025 18:54
@vercel vercel bot temporarily deployed to Preview – login May 23, 2025 18:54 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 May 23, 2025 18:54 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui May 23, 2025 18:54 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb-www May 23, 2025 18:54 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Playground Changes involving the Playground codebase.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant