Skip to content

Add collapsible sections to Inputs block#105

Open
odgrim wants to merge 1 commit intomainfrom
feature/collapsible-input-sections
Open

Add collapsible sections to Inputs block#105
odgrim wants to merge 1 commit intomainfrom
feature/collapsible-input-sections

Conversation

@odgrim
Copy link
Copy Markdown
Collaborator

@odgrim odgrim commented Apr 3, 2026

Summary

  • Sections in the Inputs form can now be collapsed/expanded by clicking the section header chevron
  • New x-collapsed: true YAML property on variables controls whether a section starts collapsed
  • Backend parses x-collapsed and propagates it via the Section.Collapsed JSON field
  • Frontend replaces static <h3> section headers with clickable chevron toggles

Usage

variables:
  - name: FunctionName
    type: string
    x-section: Basic Configuration

  - name: MemorySize
    type: int
    x-section: Advanced Settings
    x-collapsed: true  # This section starts collapsed

Test plan

  • Go tests pass (TestExtractSectionGroupings with new x-collapsed cases)
  • TypeScript type-checks clean
  • Manual: verify sections toggle open/closed on click
  • Manual: verify x-collapsed: true sections render collapsed initially
  • Manual: verify sections without x-collapsed default to expanded

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Sections can now be configured to start in a collapsed or expanded state through YAML configuration settings.
    • Added interactive collapsible section headers with visual chevron icons that allow users to dynamically expand or collapse individual sections, improving usability and interface organization when working with complex boilerplate input configurations.

Sections in the Inputs form can now be collapsed/expanded by clicking
the section header. A new x-collapsed YAML property controls the
initial state (collapsed by default when set to true).

Backend: parse x-collapsed from boilerplate YAML, add Collapsed field
to Section struct, propagate to API response.

Frontend: replace static h3 headers with clickable chevron toggles
that show/hide section contents.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@odgrim odgrim requested a review from josh-padnick as a code owner April 3, 2026 07:43
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 3, 2026

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

Project Deployment Actions Updated (UTC)
runbooks Ready Ready Preview, Comment Apr 3, 2026 7:43am

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

Walkthrough

The changes implement a collapsible sections feature for boilerplate forms. The backend now parses an x-collapsed YAML extension field and propagates the collapsed state through the data model, while the frontend manages toggle state and conditionally renders section variables with clickable headers showing directional chevrons.

Changes

Cohort / File(s) Summary
Backend Data Model
api/types.go, web/src/types/boilerplateConfig.ts
Added Collapsed bool field to the Section struct/interface to track initial collapsed state.
Backend Section Processing
api/boilerplate_config.go
Extended rawXVariable struct with Collapsed *bool field and updated extractSectionGroupings to post-process grouped sections by extracting the first non-nil x-collapsed value and assigning it to matching Section.Collapsed.
Backend Tests
api/boilerplate_config_test.go
Added two new test cases verifying that x-collapsed: true and x-collapsed: false correctly populate the Collapsed field in grouped sections.
Frontend UI Component
web/src/components/mdx/_shared/components/BoilerplateInputsForm.tsx
Introduced collapsedSections state initialized from config, added toggleSection callback, imported chevron icons, and updated section rendering with clickable headers that conditionally show/hide variables based on collapsed state.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

Sections collapse with a chevron's dance,
Chevrons right and down, expanding wide,
Backend parses, frontend state advances,
Tidy forms that fold with pride! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main feature added: collapsible sections in the Inputs block, which aligns with the changeset's core functionality.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/collapsible-input-sections

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
Copy Markdown

@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: 2

🧹 Nitpick comments (1)
api/boilerplate_config_test.go (1)

660-685: Good coverage add — one extra edge case would make it bulletproof.

Consider adding a case where two variables in the same section set conflicting x-collapsed values, so the “first value wins” rule is locked in by tests (and future refactors don’t surprise us).

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

In `@api/boilerplate_config_test.go` around lines 660 - 685, Add a test case to
the existing table that exercises conflicting x-collapsed values in the same
section (e.g., two variables Var1 and Var2 both with x-section: "Same" but one
with x-collapsed: true and the other x-collapsed: false) to lock in the “first
value wins” behavior; add a case named like "x-collapsed conflict same section
first wins" and set expectedSections to a single Section{ Name: "Same",
Variables: []string{"Var1","Var2"}, Collapsed: true } (refer to the test table
entries, the Section type and its Collapsed field and expectedSections slice).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/components/mdx/_shared/components/BoilerplateInputsForm.tsx`:
- Around line 290-304: The toggle button rendering for the section (button using
onClick={() => toggleSection(section.name)} with labels based on isCollapsed)
lacks accessibility semantics; update the button element to include
aria-expanded set to the inverse of isCollapsed (or true/false based on current
expanded state) and add aria-controls pointing to the id of the collapsible
content container (generate a stable id from section.name or use section.id) so
screen readers can detect state and target the collapsible region; ensure the
collapsible container element (rendered when !isCollapsed) has the matching id.
- Around line 185-195: The collapsedSections state in BoilerplateInputsForm is
only initialized once from boilerplateConfig, so new configs keep old values;
update the component to reset/recompute collapsedSections whenever
boilerplateConfig changes by adding a useEffect that derives the same initial
Record<string, boolean> from boilerplateConfig and calls setCollapsedSections;
apply the same pattern to the other instance referenced around lines 197-203
(the related useState/set call) so both spots recompute on boilerplateConfig
changes, and reference the collapsedSections and setCollapsedSections symbols
when making the change.

---

Nitpick comments:
In `@api/boilerplate_config_test.go`:
- Around line 660-685: Add a test case to the existing table that exercises
conflicting x-collapsed values in the same section (e.g., two variables Var1 and
Var2 both with x-section: "Same" but one with x-collapsed: true and the other
x-collapsed: false) to lock in the “first value wins” behavior; add a case named
like "x-collapsed conflict same section first wins" and set expectedSections to
a single Section{ Name: "Same", Variables: []string{"Var1","Var2"}, Collapsed:
true } (refer to the test table entries, the Section type and its Collapsed
field and expectedSections slice).
🪄 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: 26f6b6d1-4d3b-4f3d-a6c4-13a315d8da40

📥 Commits

Reviewing files that changed from the base of the PR and between dae4200 and f201d20.

📒 Files selected for processing (5)
  • api/boilerplate_config.go
  • api/boilerplate_config_test.go
  • api/types.go
  • web/src/components/mdx/_shared/components/BoilerplateInputsForm.tsx
  • web/src/types/boilerplateConfig.ts

Comment on lines +185 to +195
// Track collapsed state per section, initialized from the API's collapsed flag
const [collapsedSections, setCollapsedSections] = useState<Record<string, boolean>>(() => {
if (!boilerplateConfig?.sections) return {}
const initial: Record<string, boolean> = {}
for (const section of boilerplateConfig.sections) {
if (section.name) {
initial[section.name] = section.collapsed ?? false
}
}
return initial
})
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Reset collapsedSections when boilerplateConfig changes.

Right now this state is a one-time snapshot. If the form loads a new config/template, old collapsed values can stick and ignore incoming section.collapsed.

Suggested fix
   const [collapsedSections, setCollapsedSections] = useState<Record<string, boolean>>(() => {
     if (!boilerplateConfig?.sections) return {}
     const initial: Record<string, boolean> = {}
     for (const section of boilerplateConfig.sections) {
       if (section.name) {
         initial[section.name] = section.collapsed ?? false
       }
     }
     return initial
   })
+
+  useEffect(() => {
+    const next: Record<string, boolean> = {}
+    for (const section of boilerplateConfig?.sections ?? []) {
+      if (section.name) {
+        next[section.name] = section.collapsed
+      }
+    }
+    setCollapsedSections(next)
+  }, [boilerplateConfig])

Also applies to: 197-203

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

In `@web/src/components/mdx/_shared/components/BoilerplateInputsForm.tsx` around
lines 185 - 195, The collapsedSections state in BoilerplateInputsForm is only
initialized once from boilerplateConfig, so new configs keep old values; update
the component to reset/recompute collapsedSections whenever boilerplateConfig
changes by adding a useEffect that derives the same initial Record<string,
boolean> from boilerplateConfig and calls setCollapsedSections; apply the same
pattern to the other instance referenced around lines 197-203 (the related
useState/set call) so both spots recompute on boilerplateConfig changes, and
reference the collapsedSections and setCollapsedSections symbols when making the
change.

Comment on lines +290 to +304
<button
type="button"
onClick={() => toggleSection(section.name)}
className="flex items-center gap-2 w-full pt-5 pb-1 border-b border-gray-400 cursor-pointer hover:border-gray-600 transition-colors"
>
{isCollapsed ? (
<ChevronRight className="size-4 text-gray-500 shrink-0" />
) : (
<ChevronDown className="size-4 text-gray-500 shrink-0" />
)}
<span className="text-lg font-semibold text-gray-800">
{section.name}
</span>
</button>
{!isCollapsed && (
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add expanded/collapsed semantics to the toggle button.

The toggle works, but screen readers won’t get section state without aria-expanded (and optionally aria-controls).

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

In `@web/src/components/mdx/_shared/components/BoilerplateInputsForm.tsx` around
lines 290 - 304, The toggle button rendering for the section (button using
onClick={() => toggleSection(section.name)} with labels based on isCollapsed)
lacks accessibility semantics; update the button element to include
aria-expanded set to the inverse of isCollapsed (or true/false based on current
expanded state) and add aria-controls pointing to the id of the collapsible
content container (generate a stable id from section.name or use section.id) so
screen readers can detect state and target the collapsible region; ensure the
collapsible container element (rendered when !isCollapsed) has the matching id.

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.

1 participant