feat: add task status transition utility#37
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughA new utility file ChangesTask Status Transition Utility
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (1)
nexus-frontend/src/utils/transitions.ts (1)
7-12: ⚡ Quick winAvoid exposing mutable transition arrays from the internal state map.
getValidTransitionscurrently returns the same array instance stored inTRANSITION_MAP. A caller can mutate it (push,splice) and silently change global transition rules at runtime.Proposed hardening change
-const TRANSITION_MAP: Record<TaskStatus, TaskStatus[]> = { +const TRANSITION_MAP: Readonly<Record<TaskStatus, readonly TaskStatus[]>> = { TODO: ['IN_PROGRESS'], IN_PROGRESS: ['IN_REVIEW'], IN_REVIEW: ['DONE'], DONE: [], }; @@ export function getValidTransitions(currentStatus: TaskStatus): TaskStatus[] { - return TRANSITION_MAP[currentStatus] ?? []; + return [...(TRANSITION_MAP[currentStatus] ?? [])]; }Also applies to: 18-20
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@nexus-frontend/src/utils/transitions.ts` around lines 7 - 12, The getValidTransitions function returns direct array references from the TRANSITION_MAP constant, allowing callers to mutate these arrays and inadvertently modify global transition rules. Instead of returning the array reference directly from TRANSITION_MAP, create and return a shallow copy of the array (using spread operator or slice method) to prevent external mutations from affecting the internal state.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@nexus-frontend/src/utils/transitions.ts`:
- Around line 7-12: The getValidTransitions function returns direct array
references from the TRANSITION_MAP constant, allowing callers to mutate these
arrays and inadvertently modify global transition rules. Instead of returning
the array reference directly from TRANSITION_MAP, create and return a shallow
copy of the array (using spread operator or slice method) to prevent external
mutations from affecting the internal state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 91f00d55-5624-4a5b-a4ad-6b4318718039
📒 Files selected for processing (1)
nexus-frontend/src/utils/transitions.ts
Description
Add a task status transition utility that defines the valid state machine for task workflows (TODO → IN_PROGRESS → IN_REVIEW → DONE). This will be consumed by the TaskDetailPage to render valid transition buttons.
Changes
src/utils/transitions.tswithgetValidTransitions,isValidTransition, andSTATUS_LABELSTesting done
Checklist
Summary by CodeRabbit