fix: Show duration badges immediately for running workflows without breaking event polling#1203
fix: Show duration badges immediately for running workflows without breaking event polling#1203pandeyanshuman wants to merge 6 commits intocadence-workflow:masterfrom
Conversation
…ration badge delay When viewing an in-progress workflow's history, the Duration badge was hidden for ~50s because waitForNewEvent caused the server to long-poll on every request. Now waitForNewEvent is only enabled after we've already received an empty page, so the badge appears immediately when events finish loading. Signed-off-by: Anshuman Kishore Pandey <anshuman.pandey@uber.com>
Fix prettier formatting and import ordering issues. Signed-off-by: Anshuman Kishore Pandey <anshuman.pandey@uber.com>
…f suppressing waitForNewEvent Reverts the hasReceivedEmptyPage approach which broke polling (server doesn't return nextPageToken when waitForNewEvent is false). Instead, fixes the duration badge delay at the badge level: running workflows now show an ongoing duration while events are still loading, rather than hiding the badge entirely. Signed-off-by: Anshuman Kishore Pandey <anshuman.pandey@uber.com>
|
Thanks @Assem-Uber - I have updated the logic to fix the original issue and the issue you identified with my previous implementation. |
| expectedEndTime={new Date('2024-01-01T10:07:00Z').getTime()} | ||
| prefix="Remaining:" | ||
| workflowIsArchived={false} | ||
| workflowIsArchived={true} |
Screen.Recording.2026-03-24.at.12.52.13.mov |
| workflowCloseStatus !== 'WORKFLOW_EXECUTION_CLOSE_STATUS_INVALID'; | ||
|
|
||
| const shouldHide = loadingMoreEvents || workflowEnded; | ||
| const shouldHide = workflowEnded; |
There was a problem hiding this comment.
💡 Quality: Unused loadingMoreEvents prop in remaining-duration-badge
After the change on line 21 of workflow-history-remaining-duration-badge.tsx, shouldHide no longer references loadingMoreEvents. The prop is still declared in the Props type (line 9 of the types file) and destructured (line 15 of the component) but never used. This is dead code that will confuse future readers into thinking loading state still affects this badge.
Suggested fix:
Remove `loadingMoreEvents` from the `Props` type in the `.types.ts` file, remove it from the destructured props in the component, and remove it from all call sites passing it to this component.
Was this helpful? React with 👍 / 👎 | Reply gitar fix to apply this suggestion
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsFixes duration badge display for running workflows by enabling event polling after the first empty page instead of suppressing it entirely. Consider removing the unused 💡 Quality: Unused
|
| Auto-apply | Compact |
|
|
Was this helpful? React with 👍 / 👎 | Gitar


Problem
When viewing an in-progress workflow's history, the Duration badge (blue pill showing "Duration: Xm Xs") stays hidden for ~50 seconds. This happens because
waitForNewEvent: truecauses the server to long-poll on the first empty page, and the badge waits for that response before showing.A previous attempt to fix this (suppressing
waitForNewEventuntil the first empty page) broke event polling entirely: the Cadence server does not returnnextPageTokenwhenwaitForNewEventis false and there are no more events, so the fetcher's infinite query stops withhasNextPage: falseand never polls for new events on running workflows.Solution
Instead of modifying the fetcher's
waitForNewEventbehavior (which breaks server-side long polling), fix the problem at the badge level: duration badges for running workflows now display immediately as "ongoing" (ticking) while events are still loading, rather than hiding until all history pages are fetched.For completed workflows, badges still hide during loading since the final duration isn't known until the closing event is fetched.
Changes
workflow-history-fetcher.ts: RevertedhasReceivedEmptyPageflag and response interception.waitForNewEventis now passed through directly from params, restoring correct long-polling behavior.workflow-history-events-duration-badge.tsx: ChangednoDurationcondition fromloadingMoreEvents || ...to(loadingMoreEvents && workflowEnded) || ...so running workflows show an ongoing duration badge during loading.workflow-history-remaining-duration-badge.tsx: ChangedshouldHidefromloadingMoreEvents || workflowEndedtoworkflowEndedsince this badge is only for running workflows and doesn't need to wait for loading.Test plan
npx jest --testPathPattern="workflow-history-fetcher" --no-coverage)npx jest --testPathPattern="workflow-history-events-duration-badge" --no-coverage)npx jest --testPathPattern="workflow-history-remaining-duration-badge" --no-coverage)