Skip to content

Conversation

@adhityamamallan
Copy link
Member

@adhityamamallan adhityamamallan commented Sep 22, 2025

Summary

  • Add badge to workflow history group to display time remaining, if waitTimerInfo is set for the event group
  • Fix the formatDuration util to accept a minimum unit

Test plan

Added/updated unit tests + ran locally.

Screenshot 2025-09-22 at 15 50 56 Screenshot 2025-09-22 at 15 51 23

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
import WorkflowHistoryRemainingDurationBadge from '../workflow-history-remaining-duration-badge';
import type { Props } from '../workflow-history-remaining-duration-badge.types';

jest.mock('../helpers/get-formatted-remaining-duration', () => jest.fn());
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: no need for the passing the second argument function, mock does this by default

const formatDuration = (
duration: Duration | null,
{ separator = ', ' }: { separator?: string } = {}
{ separator = ', ' }: { separator?: string } = {},
Copy link
Contributor

Choose a reason for hiding this comment

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

minUnit can go with separator, The second argument is meant for all optional configurations

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh, got it, that's good

const remainingNanosAsMillis = nanosAsMillis % 1;
const milliseconds = secondsAsMillis + intMillis;
const units = ['y', 'M', 'd', 'h', 'm', 's', 'ms'] as const;
const allUnits: Array<dayjs.ManipulateType> = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use the same type on props ?

Copy link
Member Author

Choose a reason for hiding this comment

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

['y', 'M', 'd', 'h', 'm', 's', 'ms'] is a subset of dayjs.ManipulateType, which also includes values like 'seconds', 'milliseconds' and such.

https://github.com/iamkun/dayjs/blob/80401e3ff91cc6c5310e6603a4d7a5fa92ca90ec/types/index.d.ts#L32

Copy link
Contributor

Choose a reason for hiding this comment

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

If we can add the type to the types and reuse it it would be the correct way.

expect(setIntervalSpy).not.toHaveBeenCalled();
});

it('clears existing interval when shouldHide becomes true', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: test case title is not clear as interval is used differently in above tests, can be changed to doesn't render duration when shouldHide becomes true

@Assem-Uber
Copy link
Contributor

Btw, the description says that group has field waitTimerInfo while code used expectedEndTimeInfo. The first name is much better is better and less confusing.

@adhityamamallan
Copy link
Member Author

Btw, the description says that group has field waitTimerInfo while code used expectedEndTimeInfo. The first name is much better is better and less confusing.

The new value doesn't have wait durations, it instead has the absolute expected end time. I am okay with either, but unfortunately the old PR had the same mistake. Do you want me to change it back?

@Assem-Uber
Copy link
Contributor

Yes, i noticed it in the prev PR. But reading it in usages made it more clear that it can be understood as expected event end time.
My suggestion would be:

 waitTimerInfo: {
        endTimeMs: 0,
        prefix: '',
      },

@adhityamamallan
Copy link
Member Author

Sounds good to me, would it be okay if I made this change in another PR?

@adhityamamallan adhityamamallan merged commit 3236871 into cadence-workflow:master Sep 29, 2025
4 checks passed
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.

2 participants