feat: add board preset templates for status list columns#161
feat: add board preset templates for status list columns#161ryota-murakami merged 1 commit intomainfrom
Conversation
Add 6 platform-based preset templates (Web App, Electron, CLI, Mobile, macOS, Software Release) selectable via radio card grid on /boards/new. Replaces hardcoded default columns with a shared preset system.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughIntroduces a board preset system allowing users to select from multiple pre-configured templates during board creation. Adds new UI components with Radix UI radio buttons, backend functions for preset-based status list creation, preset constants and validation, and E2E tests validating the selection workflow. Changes
Sequence DiagramsequenceDiagram
actor User
participant CreateBoardForm
participant PresetSelector
participant Board Action
participant Database
User->>CreateBoardForm: Load create board page
CreateBoardForm->>PresetSelector: Render with DEFAULT_PRESET_ID
PresetSelector-->>User: Display 6 preset options (Web App selected)
User->>PresetSelector: Click CLI Tool preset
PresetSelector->>CreateBoardForm: onChange(cli-tool)
CreateBoardForm->>CreateBoardForm: Update presetId state
PresetSelector-->>User: Highlight CLI Tool, show Command/Linter columns
User->>CreateBoardForm: Submit form with name & presetId
CreateBoardForm->>Board Action: createBoard(name, presetId: cli-tool)
Board Action->>Board Action: Validate presetId via presetIdSchema
Board Action->>Board Action: getPresetById(cli-tool)
Board Action->>Board Action: createStatusListsFromPreset(boardId, preset)
Board Action->>Database: Insert board & status lists (Command, Linter columns)
Database-->>Board Action: Success
Board Action-->>User: Board created with CLI Tool preset columns
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/lib/actions/board.ts (1)
517-533:⚠️ Potential issue | 🟠 MajorPrevent partial board creation when preset list insertion fails.
If board insert succeeds and
createStatusListsFromPresetfails, the action returns failure but leaves a created board behind. Add compensation (or transaction/RPC) to keep writes atomic.🛠️ Suggested rollback guard
if (error || !data) { throw new Error('Failed to create board') } - // Create status lists from selected preset - await createStatusListsFromPreset(data.id, presetValidation.data) + // Create status lists from selected preset + try { + await createStatusListsFromPreset(data.id, presetValidation.data) + } catch (statusListError) { + Sentry.captureException(statusListError, { + extra: { + context: 'Create board: rollback after preset status list failure', + boardId: data.id, + presetId: presetValidation.data, + }, + }) + + await supabase.from('board').delete().eq('id', data.id).eq('user_id', user.id) + throw new Error('Failed to initialize board') + } return { id: data.id, name: data.name }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/actions/board.ts` around lines 517 - 533, The board creation currently inserts into supabase then calls createStatusListsFromPreset(data.id) which, if it fails, leaves an orphaned board; modify createBoard flow to make the write atomic by either using a Supabase/RPC transaction to perform both the board insert and status-list inserts server-side, or add a rollback guard: after the .insert().select(...).single() success, call createStatusListsFromPreset(data.id, presetValidation.data) inside a try/catch and on any error call a compensating delete of the newly created board (e.g., delete from 'board' where id = data.id) before rethrowing the error; reference the existing insert block that creates the board and the createStatusListsFromPreset call to locate where to add the transaction or try/catch + delete.
🧹 Nitpick comments (1)
src/lib/constants/board-presets.ts (1)
28-31: TightenBoardPreset.idtoPresetIdfor compile-time consistency.Using
stringhere weakens the contract and allows silent drift betweenPRESET_IDSand preset objects. ReusePresetIdon the interface.♻️ Suggested refactor
export interface BoardPreset { /** Unique identifier (kebab-case) */ - id: string + id: PresetIdAs per coding guidelines, "Prefer reusing existing types over creating new ones".
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/constants/board-presets.ts` around lines 28 - 31, Update the BoardPreset interface so its id property uses the existing PresetId type instead of a plain string: change BoardPreset.id: string to BoardPreset.id: PresetId, and import or reference PresetId from its declaration to ensure compile-time consistency with PRESET_IDS and other preset objects; then run a quick compile to fix any callsites that rely on string (adjust types where needed) so all preset objects and PRESET_IDS remain type-aligned.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/lib/actions/board.ts`:
- Around line 517-533: The board creation currently inserts into supabase then
calls createStatusListsFromPreset(data.id) which, if it fails, leaves an
orphaned board; modify createBoard flow to make the write atomic by either using
a Supabase/RPC transaction to perform both the board insert and status-list
inserts server-side, or add a rollback guard: after the
.insert().select(...).single() success, call
createStatusListsFromPreset(data.id, presetValidation.data) inside a try/catch
and on any error call a compensating delete of the newly created board (e.g.,
delete from 'board' where id = data.id) before rethrowing the error; reference
the existing insert block that creates the board and the
createStatusListsFromPreset call to locate where to add the transaction or
try/catch + delete.
---
Nitpick comments:
In `@src/lib/constants/board-presets.ts`:
- Around line 28-31: Update the BoardPreset interface so its id property uses
the existing PresetId type instead of a plain string: change BoardPreset.id:
string to BoardPreset.id: PresetId, and import or reference PresetId from its
declaration to ensure compile-time consistency with PRESET_IDS and other preset
objects; then run a quick compile to fix any callsites that rely on string
(adjust types where needed) so all preset objects and PRESET_IDS remain
type-aligned.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (10)
e2e/logged-in/create-board.spec.tspackage.jsonsrc/app/boards/new/CreateBoardForm.stories.tsxsrc/app/boards/new/CreateBoardForm.tsxsrc/app/boards/new/PresetSelector.tsxsrc/app/boards/new/page.tsxsrc/components/ui/radio-group.tsxsrc/lib/actions/board.tssrc/lib/constants/board-presets.tssrc/lib/validations/board.ts
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #161 +/- ##
==========================================
+ Coverage 69.37% 69.45% +0.08%
==========================================
Files 155 157 +2
Lines 4696 4715 +19
Branches 1259 1262 +3
==========================================
+ Hits 3258 3275 +17
- Misses 1415 1417 +2
Partials 23 23 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
🧪 E2E Coverage Report (Sharded: 12 parallel jobs)
📊 Full report available in workflow artifacts |
Summary
/boards/newcreateFirstBoardIfNeededunaffected (still uses Software Release columns)Changes
New Files
src/lib/constants/board-presets.ts— Preset definitions (shared by client + server)src/components/ui/radio-group.tsx— shadcn/ui RadioGroup primitivesrc/app/boards/new/PresetSelector.tsx— Radio card grid componentModified Files
src/lib/validations/board.ts— AddedpresetIdSchemaZod enumsrc/lib/actions/board.ts— AddedcreateStatusListsFromPreset(), updatedcreateBoard(name, presetId?)signaturesrc/app/boards/new/CreateBoardForm.tsx— Preset state + PresetSelector integrationsrc/app/boards/new/page.tsx— Wider container, updated subtitlesrc/app/boards/new/CreateBoardForm.stories.tsx— Wider decoratore2e/logged-in/create-board.spec.ts— 3 new preset selection testsTest plan
/boards/newshows Web App preset pre-selectedSummary by CodeRabbit
Release Notes
New Features
Tests
Chores