Skip to content

feat: show/hide cu profiling#925

Open
C0mberry wants to merge 6 commits intosolana-foundation:masterfrom
hoodieshq:feat-show/hide-cu-profiling
Open

feat: show/hide cu profiling#925
C0mberry wants to merge 6 commits intosolana-foundation:masterfrom
hoodieshq:feat-show/hide-cu-profiling

Conversation

@C0mberry
Copy link
Copy Markdown
Contributor

@C0mberry C0mberry commented Apr 7, 2026

Description

  • adding CollapsibleCard component
  • refactoring of existing Collapse/Expand btns
  • adding CollapsibleCard for CU profiling section

Type of change

  • New feature

Screenshots

Screenshot 2026-04-07 at 10 35 53 Screenshot 2026-04-07 at 10 38 44

Testing

Storybook
Transaction Page

Related Issues

HOO-404

Checklist

  • My code follows the project's style guidelines
  • All tests pass locally and in CI
  • I have run build:info script to update build information
  • CI/CD checks pass
  • I have included screenshots for protocol screens (if applicable)

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 7, 2026

@C0mberry is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@C0mberry C0mberry marked this pull request as draft April 7, 2026 07:43
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 7, 2026

Greptile Summary

This PR introduces a reusable CollapsibleCard component and migrates eight existing cards to use it, then wraps CUProfilingCard in it to deliver the show/hide feature. The refactor cleanly eliminates duplicated local expanded state across many components.

  • InspectorInstructionCard gains an unintended Collapse/Expand buttoncollapsible is not passed, so it defaults to true, adding a toggle that was never present on the inspector page. Add collapsible={false} to restore the original behavior.

Confidence Score: 4/5

Safe to merge after fixing the InspectorInstructionCard collapsible default — all other changes are clean refactors.

One P1 issue: InspectorInstructionCard omits collapsible={false}, causing an unintended Collapse/Expand button to appear on the inspector page. The remaining findings are P2 style/UX concerns. The core CollapsibleCard abstraction and the CU profiling show/hide feature are well-implemented.

app/components/common/InspectorInstructionCard.tsx requires a one-line fix before merge.

Important Files Changed

Filename Overview
app/components/shared/ui/collapsible-card.tsx New reusable CollapsibleCard component with forwardRef, aria-expanded, and cn('card', className) merging — well-structured abstraction.
app/components/common/InspectorInstructionCard.tsx Migrated to CollapsibleCard but omits collapsible={false}, adding an unintended Collapse/Expand button to inspector instruction cards that never had one.
app/components/common/BaseInstructionCard.tsx Cleanly refactored to CollapsibleCard; local expanded state removed. Raw button is now enabled while card is collapsed (minor UX regression).
app/features/cu-profiling/ui/CUProfilingCard.tsx Core feature: CU profiling card now wrapped in CollapsibleCard. className="e-card" results in "card e-card" due to cn() merge — may add unintended Bootstrap styles.
app/components/shared/ui/collapsible-card.stories.tsx Comprehensive Storybook stories covering default, collapsed, non-collapsible, header-buttons, and badge-title variants.
app/components/inspector/AccountsCard.tsx Clean migration to CollapsibleCard; original had a toggle button so the default collapsible=true is correct.
app/components/inspector/AddressTableLookupsCard.tsx Clean migration to CollapsibleCard; original had a toggle button so the default collapsible=true is correct.
app/components/inspector/UnknownDetailsCard.tsx Migrated to CollapsibleCard with defaultExpanded={false}, matching original collapsed-by-default behavior. React import correctly removed.
app/components/transaction/AccountsCard.tsx Clean refactor; Raw button moved to headerButtons prop, expanded state removed, behavior preserved.
app/components/transaction/TokenBalancesCard.tsx Straightforward migration to CollapsibleCard; original toggle button behavior preserved.
bench/BUILD.md Updated build-size metrics reflecting the new bundle output; no code logic involved.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class CollapsibleCard {
        +title: ReactNode
        +children: ReactNode
        +defaultExpanded: boolean
        +className?: string
        +headerButtons?: ReactNode
        +collapsible: boolean
        -expanded: boolean
        +setExpanded()
    }
    class BaseInstructionCard {
        +collapsible?: boolean
        +headerButtons?: ReactNode
        -showRaw: boolean
    }
    class InspectorInstructionCard {
        +defaultRaw?: boolean
        -showRaw: boolean
    }
    class CUProfilingCard {
        +instructions: InstructionCUData[]
        +unitsConsumed?: number
    }
    class AccountsCard_Transaction {
        -showRaw: boolean
    }
    class TokenBalancesCardInner {
        -tokenSymbols: Map
    }
    class AccountsCard_Inspector
    class AddressTableLookupsCard
    class UnknownDetailsCard {
        +defaultExpanded: false
    }
    CollapsibleCard <|-- BaseInstructionCard : uses
    CollapsibleCard <|-- InspectorInstructionCard : uses (collapsible=true by default)
    CollapsibleCard <|-- CUProfilingCard : uses (new feature)
    CollapsibleCard <|-- AccountsCard_Transaction : uses
    CollapsibleCard <|-- TokenBalancesCardInner : uses
    CollapsibleCard <|-- AccountsCard_Inspector : uses
    CollapsibleCard <|-- AddressTableLookupsCard : uses
    CollapsibleCard <|-- UnknownDetailsCard : uses
Loading

Reviews (2): Last reviewed commit: "resolve comments" | Re-trigger Greptile

Comment thread app/components/shared/ui/collapsible-card.tsx
Comment thread app/components/shared/ui/collapsible-card.tsx Outdated
@C0mberry C0mberry force-pushed the feat-show/hide-cu-profiling branch 2 times, most recently from c46b270 to 2498392 Compare April 13, 2026 09:14
@C0mberry C0mberry marked this pull request as ready for review April 13, 2026 09:18
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
explorer Ready Ready Preview, Comment Apr 23, 2026 9:30pm

Request Review

Comment thread bench/BUILD.md Outdated
@Woody4618
Copy link
Copy Markdown
Collaborator

Woody4618 commented Apr 20, 2026

Could we check maybe if a little animation would be possible.
And if we can replace the Expand and Collapse Button with an arrow icon button.

@C0mberry C0mberry force-pushed the feat-show/hide-cu-profiling branch from aeb03df to bb92eba Compare April 23, 2026 09:22
),
],
parameters: {
layout: 'centered',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please do not use centred. Padded is the right one. Let's use centred only if we really need this.
The idea is that the component could accidentally introduce extra margin or padding, and centered layout will make it invisible.
Padded makes that visible (pagging is gt that expected)

component: CollapsibleCard,
decorators: [
Story => (
<div style={{ width: '600px' }}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need width: 600 here? I'd prefer not having this. It is better to reuse Storybook's viewports rather than having a hardcoded wrapper. We do even have a decorator for this if I am not mistaken


export const CollapsibleCard = React.forwardRef<HTMLDivElement, CollapsibleCardProps>(
({ title, children, defaultExpanded = true, className, headerButtons, collapsible = true }, ref) => {
const [expanded, setExpanded] = React.useState(defaultExpanded);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's not use useState via namespace. Let's import it directly. I understand namespace for tests or the server code, but for the client, it is better not to use a namespace

Copy link
Copy Markdown
Contributor

@rogaldh rogaldh left a comment

Choose a reason for hiding this comment

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

LGTM

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.

3 participants