Allow Gantt tasks to use "duration, until <taskId | endDate>" and automatically calculate the start date#7409
Conversation
… calculate the start date
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🦋 Changeset detectedLatest commit: 323e2a7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@mermaid-js/examples
mermaid
@mermaid-js/layout-elk
@mermaid-js/layout-tidy-tree
@mermaid-js/mermaid-zenuml
@mermaid-js/parser
@mermaid-js/tiny
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #7409 +/- ##
==========================================
+ Coverage 3.52% 3.65% +0.12%
==========================================
Files 509 508 -1
Lines 49790 49845 +55
Branches 785 799 +14
==========================================
+ Hits 1754 1820 +66
+ Misses 48036 48025 -11
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
The latest updates on your projects. Learn more about Argos notifications ↗︎
|
|
@sidharthv96, this PR is ready to be merged. I’ve added |
knsv
left a comment
There was a problem hiding this comment.
[sisyphus-bot]
PR #7409 — Backward scheduling for Gantt tasks
Thanks for this contribution, @Shahir-47! Backward scheduling from deadlines is a really practical feature — the use cases in the issue (release planning, exam prep) are spot-on, and the implementation is clean. Let's get this across the finish line.
What's working well
🎉 [praise] The deriveStartFromEnd approach is well-designed. Introducing a new startTime type that gets resolved during compileTasks() fits naturally into the existing two-phase parse→compile architecture. The helper functions looksLikeDuration and looksLikeUntilReference are clearly documented and keep the parseData() switch cases readable.
🎉 [praise] Good test coverage — three ganttDb unit tests and three parser tests covering the key variants (duration + until task ID, duration + until fixed date, with and without explicit task ID). Codecov confirms all modified lines are covered.
Things to address
🔴 [blocking] — Missing changeset. The changeset-bot already flagged this. This is a user-facing feature, so it requires a changeset:
pnpm changeset
# Select `mermaid`, bump `minor`, message: "feat: add backward scheduling with `duration, until <taskId|endDate>` syntax for Gantt tasks"🟡 [important] — No E2E visual regression tests. Unit tests confirm the logic is correct, but there are no Cypress snapshot tests to verify the rendered Gantt chart looks right with backward-scheduled tasks. A visual regression test is the primary safety net for rendering features in this project. It would be great to add at least one imgSnapshotTest in cypress/integration/rendering/gantt.spec.js covering a diagram like:
gantt
dateFormat YYYY-MM-DD
section Backward Scheduling
Release :milestone, release, 2024-03-01, 0d
Development :dev, 14d, until release
Planning :plan, 7d, until dev
This confirms the backward-computed start dates render correctly and provides regression coverage.
💡 [suggestion] — Date vs task ID priority in until parsing (ganttDb.js:~375-380). The new getEndDate checks whether the until target is a valid date before looking up task IDs. This is sensible behavior, but it means a task ID that happens to match the dateFormat pattern would be silently interpreted as a date instead. This edge case is unlikely in practice and the current order is the right default — just worth a brief comment in the code noting the precedence so future maintainers understand the intent.
Summary
| Severity | Count |
|---|---|
| 🔴 blocking | 1 |
| 🟡 important | 1 |
| 💡 suggestion | 1 |
| 🎉 praise | 2 |
Verdict: REQUEST_CHANGES — the changeset is required before merge, and E2E visual tests would strengthen confidence. The core implementation is solid — these are mostly process items. Looking forward to the updated PR!
|
@knsv Thanks for the review. I addressed all requested items:
Everything is now ready for review. |
📑 Summary
This PR adds support for Gantt tasks written as
duration, until <taskId | endDate>so users do not need to provide a start date.For this syntax, both values are used:
until <taskId | endDate>sets the task end pointdurationsets the task lengthMermaid then calculates the start date automatically by subtracting the duration from the resolved end.
In this example,
kiwigets start date2017-08-22automatically.Resolves #7407
📏 Design Decisions
7d)until ...expressionsduration + until ...so the start date is derived from the end date.until ...(task reference(s) or end date indateFormat)duration, until <taskId>duration, until <endDate>until <taskId|endDate>behavior.📋 Tasks
Make sure you
MERMAID_RELEASE_VERSIONis used for all new features.pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.