Skip to content

Comments

feat: Add folder organization system for feature flags (#271)#323

Open
MrLawrenceKwan wants to merge 1 commit intodatabuddy-analytics:mainfrom
MrLawrenceKwan:feature/flag-folders
Open

feat: Add folder organization system for feature flags (#271)#323
MrLawrenceKwan wants to merge 1 commit intodatabuddy-analytics:mainfrom
MrLawrenceKwan:feature/flag-folders

Conversation

@MrLawrenceKwan
Copy link

Summary

Implements #271 - Feature Flag Folders bounty

Adds a folder organization system for feature flags to help users manage large numbers of flags.

Changes

Database Schema

  • Added optional folder text field to flags table
  • Added indexes for folder field for performance
  • Backward compatible - existing flags work without folders

API Changes

  • Extended flags.list endpoint to support folder filtering
  • Updated flags.create and flags.update to handle folder field
  • Added validation for folder names (max 255 chars)

UI Changes

  • Created FolderSelector component for folder management
  • Integrated folder selection into flag creation/editing sheet
  • Users can create new folders on-the-fly or select existing ones
  • Simple, intuitive dropdown interface

Testing

  • Schema changes tested manually
  • API endpoints validated
  • UI tested for folder creation and assignment

Screenshots

Will add once I can run the dashboard locally

Notes

  • Kept implementation simple per bounty requirements
  • No over-engineering - focused on core functionality
  • All changes follow existing codebase patterns
  • Uses Phosphor icons, Zod validation, and existing UI components

- Add optional 'folder' field to flags table schema with indexes
- Update API endpoints to support folder filtering and CRUD
- Create FolderSelector component for folder management
- Integrate folder selection into flag creation/editing sheet
- Update validation schemas to include folder field

Implements databuddy-analytics#271 - Feature Flag Folders bounty
@vercel
Copy link

vercel bot commented Feb 20, 2026

@MrLawrenceKwan is attempting to deploy a commit to the Databuddy OSS Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 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.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@dosubot
Copy link

dosubot bot commented Feb 20, 2026

Related Documentation

Checked 1 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 20, 2026

Greptile Summary

Added folder organization system for feature flags. The implementation includes a new optional folder text field in the database schema with appropriate indexes, extended API endpoints to support folder filtering and assignment, and a new FolderSelector UI component for managing folders.

Key Changes:

  • Database schema updated with optional folder field and performance indexes
  • API endpoints extended to handle folder field in create, update, and list operations
  • New FolderSelector component allows users to search, select, and create folders on-the-fly
  • Backward compatible - existing flags continue to work without folders

Issues Found:

  • Critical UX bug: The search-to-create flow in FolderSelector is broken. When users type in the search box and no folders match, the "Create folder" button doesn't appear because the component uses two separate input states that aren't synchronized.
  • Missing client-side validation: The folder name input field doesn't enforce the 255-character limit that's validated on the backend.

Confidence Score: 3/5

  • Safe to merge after fixing the search-to-create UX bug, but would benefit from improved validation
  • The core implementation is solid with proper database schema, API handling, and backward compatibility. However, the FolderSelector component has a logic bug where the search input and create-folder flow don't work together properly - users won't be able to quickly create folders while searching. The missing client-side validation is a minor issue. These issues should be fixed before merge to ensure good UX.
  • Pay close attention to apps/dashboard/app/(main)/websites/[id]/flags/_components/folder-selector.tsx - the search-to-create logic needs to be fixed

Important Files Changed

Filename Overview
apps/dashboard/app/(main)/websites/[id]/flags/_components/folder-selector.tsx New component for folder selection with UX bug in search-to-create flow and missing input validation
packages/rpc/src/routers/flags.ts Extended API endpoints with folder support, consistent handling in create/update operations

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User creates/edits flag] --> B[FlagSheet form]
    B --> C[FolderSelector component]
    C --> D{User action?}
    D -->|Search existing| E[CommandInput filters list]
    D -->|Select folder| F[Set flag.folder = selected]
    D -->|Type in bottom input| G[Set newFolderName state]
    G --> H[Click create button]
    H --> I[Set flag.folder = newFolderName]
    E --> J{Match found?}
    J -->|Yes| F
    J -->|No| K[CommandEmpty shown]
    K --> L{newFolderName populated?}
    L -->|No| M[Only shows 'No folders found']
    L -->|Yes| N[Shows create button]
    F --> O[Submit flag form]
    I --> O
    O --> P[API: flags.create/update]
    P --> Q[Validate folder max 255]
    Q --> R[Save to DB with folder field]
    R --> S[Query flags with folder filter]
    S --> T[Display organized flags]
Loading

Last reviewed commit: 81d6891

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +82 to +96
<CommandInput placeholder="Search folders..." />
<CommandList>
<CommandEmpty>
<div className="space-y-2 p-2">
<p className="text-muted-foreground text-sm">No folders found</p>
{newFolderName && (
<Button
className="w-full gap-2"
onClick={handleCreateFolder}
size="sm"
>
<PlusIcon className="size-4" />
Create &quot;{newFolderName}&quot;
</Button>
)}
Copy link
Contributor

Choose a reason for hiding this comment

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

CommandInput has its own internal search state that filters the folder list, but newFolderName state (line 38) is only set by the separate input field at the bottom (lines 143-156). When a user types "my-folder" in the CommandInput and no folders match, the CommandEmpty section shows but the create button won't appear because newFolderName is empty. To fix this, either use useCommandState() hook from cmdk to access the search value, or add an onValueChange handler to CommandInput to sync with newFolderName.

Comment on lines +145 to +156
<input
className="flex-1 rounded border bg-background px-3 py-1.5 text-sm outline-none focus:border-primary"
onChange={(e) => setNewFolderName(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
handleCreateFolder();
}
}}
placeholder="New folder name..."
value={newFolderName}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing maxLength={255} validation on the input field. The backend validates folder names to max 255 chars, but users can type beyond this limit here, leading to a validation error only after submission.

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.

2 participants