Skip to content

feat: add task status transition utility#37

Open
helseaCat wants to merge 2 commits into
mainfrom
feat/task-status-transitions
Open

feat: add task status transition utility#37
helseaCat wants to merge 2 commits into
mainfrom
feat/task-status-transitions

Conversation

@helseaCat

@helseaCat helseaCat commented Jun 19, 2026

Copy link
Copy Markdown
Owner

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

  • Add src/utils/transitions.ts with getValidTransitions, isValidTransition, and STATUS_LABELS

Testing done

  • No new warnings
  • Self-reviewed

Checklist

  • No new warnings
  • Self-reviewed

Summary by CodeRabbit

  • New Features
    • Added consistent, validated task status transitions across the workflow (TODO → In Progress → In Review → Done).
    • Improved task status presentation with human-readable labels for each status.
  • Bug Fixes
    • Prevents invalid status changes to ensure task state progression follows the defined workflow.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bc3e34ce-b7ec-4bce-af8e-e698aa7c80df

📥 Commits

Reviewing files that changed from the base of the PR and between cbdba20 and 9c25db2.

📒 Files selected for processing (1)
  • nexus-frontend/src/utils/transitions.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • nexus-frontend/src/utils/transitions.ts

📝 Walkthrough

Walkthrough

A new utility file nexus-frontend/src/utils/transitions.ts is added. It defines an internal TRANSITION_MAP encoding a linear TODO → IN_PROGRESS → IN_REVIEW → DONE state machine, and exports getValidTransitions, isValidTransition, and STATUS_LABELS.

Changes

Task Status Transition Utility

Layer / File(s) Summary
State machine, transition helpers, and status labels
nexus-frontend/src/utils/transitions.ts
Adds TRANSITION_MAP encoding the linear task status flow with terminal empty arrays, exports getValidTransitions to look up allowed next statuses, isValidTransition to validate a specific status move, and STATUS_LABELS mapping each TaskStatus to a human-readable string.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐇 A map of tasks laid end to end,
From TODO on to DONE we wend,
Each hop and skip a lawful leap,
No status lost, no promise cheap.
The rabbit checks each label right —
Transitions tidy, clean, and bright! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: introducing a new task status transition utility. It is specific, clear, and directly reflects the primary objective of the pull request.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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 feat/task-status-transitions

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
nexus-frontend/src/utils/transitions.ts (1)

7-12: ⚡ Quick win

Avoid exposing mutable transition arrays from the internal state map.

getValidTransitions currently returns the same array instance stored in TRANSITION_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

📥 Commits

Reviewing files that changed from the base of the PR and between 0f0e196 and cbdba20.

📒 Files selected for processing (1)
  • nexus-frontend/src/utils/transitions.ts

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