Support nested if-branches and add comprehensive unit tests - #2
Conversation
…0.2.0
Upstream pppzet/KawaiiDecoNote's "ネストの機能更新" makes if-branches
nestable: a branch can now hold nested if-cards recursively, not just
plain steps. Port that into the React Native app.
- types: IfStep.branches now holds Step[] (recursive) instead of a
separate BranchStep[]; the BranchStep type is removed.
- model: normalizeStep / seedUid / dedupeIds recurse through nested
branches; add pure tree helpers updateStepInTree / removeStepFromTree
/ findStepInTree / appendToBranch. Old branch steps ({id,text,done})
migrate to type:"step" automatically on load.
- store: step text/toggle/delete operate on the whole tree by id;
addBranchStep plus new addBranchIfStep append into a branch; the old
branch-specific actions are dropped.
- IfCard: recursive IfCardNode renders nested branches with depth-based
colours, vertical branch stacking, and +工程 / +🔀if add buttons.
Testing:
- add vitest + @vitest/coverage-v8, vitest.config.ts, and test scripts.
- model.test.ts / format.test.ts: 59 tests at 100% coverage of the pure
logic (statements/branches/functions/lines), enforced via thresholds.
- wire `npm run test:coverage` into CI.
Version bumped to 0.2.0 (app.json versionCode 2).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SRfSVMnqmMKh8JSMEsKpM9
|
Warning Review limit reached
Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: QUIET Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR adds recursive ChangesRecursive branching and validation
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant IfCardNode
participant NotebooksState
participant ModelTreeHelpers
IfCardNode->>NotebooksState: edit or add nested branch step
NotebooksState->>ModelTreeHelpers: update or append by step id
ModelTreeHelpers-->>NotebooksState: updated recursive step tree
NotebooksState-->>IfCardNode: render updated nested card
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
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.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: QUIET
Plan: Pro Plus
Run ID: 195e502e-c892-43c2-8854-212a5a8717fa
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (12)
.github/workflows/ci.yml.gitignoreREADME.mdapp.jsonpackage.jsonsrc/components/flowchart/IfCard.tsxsrc/lib/format.test.tssrc/lib/model.test.tssrc/lib/model.tssrc/lib/types.tssrc/state/notebooks.tsvitest.config.ts
Address PR #2 review: BranchKey ("yes" | "no") was redefined in three files (model.ts, notebooks.ts, IfCard.tsx). Export it once from src/lib/types.ts and import it everywhere so the branch-key contract can't drift out of sync. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SRfSVMnqmMKh8JSMEsKpM9
Summary
This PR adds support for nested if-branches in flowchart steps, allowing if-cards to be placed inside other if-branches. It also introduces comprehensive unit tests for the model layer with 100% code coverage.
Key Changes
Nested If-Branches Support
BranchSteptype; branches now contain fullStepobjects (eitherNormalSteporIfStep), enabling arbitrary nestingupdateStepInTree(),removeStepFromTree(),findStepInTree(), andappendToBranch()functions to handle recursive operations on nested step structuresnormalizeStep()to recursively normalize steps within branches, supporting both old format (type-less branch steps) and new nested if-cardsIfCardcomponent to render nested if-cards within branches with proper depth-based styling; added "+🔀if" button to add nested if-branches alongside regular stepsState Management
useNotebooksstore to use tree traversal helpers for all step mutations (setStepText,toggleStep,deleteStep,setBranchLabel)addBranchIfStep()action to create nested if-branchessetBranchStepText,toggleBranchStep,deleteBranchStep) in favor of unified tree operationsTesting Infrastructure
vitest.config.tswith 100% coverage thresholds forsrc/lib/model.tsandsrc/lib/format.tssrc/lib/model.test.tswith 638 lines of comprehensive tests covering:newStep,newIfStep,newPage,newNotebook)src/lib/format.test.tswith tests for utility functionstestandtest:watchnpm scripts; integrated Vitest into CI pipelineVersion & Documentation
.gitignoreImplementation Details
seedUid()now recursively scans bothyesandnobranches to find the maximum ID numberhttps://claude.ai/code/session_01SRfSVMnqmMKh8JSMEsKpM9