Skip to content

refactor: Move shared helpers & hooks from workflow-history to workflow-history-v2#1190

Merged
Assem-Uber merged 8 commits intocadence-workflow:masterfrom
adhityamamallan:fix-remaining-group-types
Feb 23, 2026
Merged

refactor: Move shared helpers & hooks from workflow-history to workflow-history-v2#1190
Assem-Uber merged 8 commits intocadence-workflow:masterfrom
adhityamamallan:fix-remaining-group-types

Conversation

@adhityamamallan
Copy link
Member

@adhityamamallan adhityamamallan commented Feb 23, 2026

Summary

This PR moves the filtering helpers and useInitialSelectedEvent from workflow-history to workflow-history-v2, to let them use the new types and prevent type errors when new event group types are introduced. The type WorkflowHistoryEventGroupFilteringType is also renamed to EventGroupCategory for clarity.

  • Rename WorkflowHistoryEventGroupFilteringType to EventGroupCategory for clarity
  • Rename configuration files to use "event-group-category" naming convention
  • Move and rename filter helper functions (filterGroupsByStatus, filterGroupsByCategory) from workflow-history to workflow-history-v2
  • Move useInitialSelectedEvent hook and its types to workflow-history-v2

Test plan

Builds passing + ran locally to sanity-check.

Before (testing with a mock group type)

npm run typecheck
> typecheck
> tsc --noemit

src/views/workflow-history-v2/config/workflow-history-filters.config.ts:38:5 - error TS2322: Type '(group: HistoryEventsGroup, value: WorkflowHistoryFiltersTypeValue) => boolean' is not assignable to type '(d: HistoryEventsGroup, value: WorkflowHistoryFiltersTypeValue) => boolean'.
  Types of parameters 'group' and 'd' are incompatible.
    Type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history-v2/workflow-history-v2.types").HistoryEventsGroup' is not assignable to type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history/workflow-history.types").HistoryEventsGroup'.
      Type 'NewHistoryGroup' is not assignable to type 'HistoryEventsGroup'.
        Type 'NewHistoryGroup' is not assignable to type 'SingleEventHistoryGroup'.
          Type 'NewHistoryGroup' is not assignable to type '{ groupType: "Event"; events: SingleHistoryEvent[]; }'.
            Types of property 'groupType' are incompatible.
              Type '"New"' is not assignable to type '"Event"'.

38     filterFunc: filterGroupsByGroupType,
       ~~~~~~~~~~

  src/views/workflow-history-v2/workflow-history-v2.types.ts:261:3
    261   filterFunc: (d: HistoryEventsGroup, value: V) => boolean;
          ~~~~~~~~~~
    The expected type comes from property 'filterFunc' which is declared here on type 'WorkflowHistoryFilterConfig<WorkflowHistoryFiltersTypeValue>'

src/views/workflow-history-v2/config/workflow-history-filters.config.ts:54:5 - error TS2322: Type '(group: HistoryEventsGroup, value: WorkflowHistoryFiltersStatusValue) => boolean' is not assignable to type '(d: HistoryEventsGroup, value: WorkflowHistoryFiltersStatusValue) => boolean'.
  Types of parameters 'group' and 'd' are incompatible.
    Type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history-v2/workflow-history-v2.types").HistoryEventsGroup' is not assignable to type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history/workflow-history.types").HistoryEventsGroup'.

54     filterFunc: filterGroupsByGroupStatus,
       ~~~~~~~~~~

  src/views/workflow-history-v2/workflow-history-v2.types.ts:261:3
    261   filterFunc: (d: HistoryEventsGroup, value: V) => boolean;
          ~~~~~~~~~~
    The expected type comes from property 'filterFunc' which is declared here on type 'WorkflowHistoryFilterConfig<WorkflowHistoryFiltersStatusValue>'

src/views/workflow-history-v2/workflow-history-event-group/helpers/get-event-group-filtering-type.ts:14:59 - error TS2345: Argument of type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history-v2/workflow-history-v2.types").HistoryEventsGroup' is not assignable to parameter of type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history/workflow-history.types").HistoryEventsGroup'.

14       (typeof filterConfig === 'function' && filterConfig(group)) ||
                                                             ~~~~~

src/views/workflow-history-v2/workflow-history-v2.tsx:254:5 - error TS2322: Type 'HistoryEventsGroupsMap' is not assignable to type 'Record<string, HistoryEventsGroup>'.
  'string' index signatures are incompatible.
    Type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history-v2/workflow-history-v2.types").HistoryEventsGroup' is not assignable to type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history/workflow-history.types").HistoryEventsGroup'.

254     eventGroups,
        ~~~~~~~~~~~

  src/views/workflow-history/hooks/use-initial-selected-event.types.ts:4:3
    4   eventGroups: Record<string, HistoryEventsGroup>;
        ~~~~~~~~~~~
    The expected type comes from property 'eventGroups' which is declared here on type 'UseInitialSelectedEventParams'

src/views/workflow-history-v2/workflow-history-v2.tsx:255:5 - error TS2322: Type '[string, import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history-v2/workflow-history-v2.types").HistoryEventsGroup][]' is not assignable to type '[string, import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history/workflow-history.types").HistoryEventsGroup][]'.
  Type '[string, import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history-v2/workflow-history-v2.types").HistoryEventsGroup]' is not assignable to type '[string, import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history/workflow-history.types").HistoryEventsGroup]'.
    Type at position 1 in source is not compatible with type at position 1 in target.
      Type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history-v2/workflow-history-v2.types").HistoryEventsGroup' is not assignable to type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history/workflow-history.types").HistoryEventsGroup'.

255     filteredEventGroupsEntries,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~

  src/views/workflow-history/hooks/use-initial-selected-event.types.ts:6:3
    6   filteredEventGroupsEntries: [string, HistoryEventsGroup][];
        ~~~~~~~~~~~~~~~~~~~~~~~~~~
    The expected type comes from property 'filteredEventGroupsEntries' which is declared here on type 'UseInitialSelectedEventParams'

src/views/workflow-history-v2/workflow-history-v2.tsx:322:35 - error TS2345: Argument of type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history-v2/workflow-history-v2.types").HistoryEventsGroup' is not assignable to parameter of type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history/workflow-history.types").HistoryEventsGroup'.

322         filterGroupsByGroupStatus(group, { historyEventStatuses: ['FAILED'] })
                                      ~~~~~

src/views/workflow-history-v2/workflow-history-v2.tsx:330:35 - error TS2345: Argument of type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history-v2/workflow-history-v2.types").HistoryEventsGroup' is not assignable to parameter of type 'import("/Users/adhitya.mamallan/cadence/web-fork/src/views/workflow-history/workflow-history.types").HistoryEventsGroup'.

330         filterGroupsByGroupStatus(group, {
                                      ~~~~~


Found 7 errors in 3 files.

Errors  Files
     2  src/views/workflow-history-v2/config/workflow-history-filters.config.ts:38
     1  src/views/workflow-history-v2/workflow-history-event-group/helpers/get-event-group-filtering-type.ts:14
     4  src/views/workflow-history-v2/workflow-history-v2.tsx:254

After (no type errors)

 npm run typecheck 
> typecheck
> tsc --noemit

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>
@adhityamamallan adhityamamallan changed the title fix: Move more shared types/helpers to workflow-history-v2 refactor: Move shared helpers & hooks from workflow-history to workflow-history-v2 Feb 23, 2026
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the workflow-history-v2 module to be more self-contained by moving shared types and helper functions from the workflow-history module into workflow-history-v2. The changes involve renaming types for clarity (e.g., WorkflowHistoryEventFilteringType to EventGroupCategory) and relocating filter helpers, hooks, and configuration files to avoid cross-module dependencies.

Changes:

  • Moved and renamed filter helper functions (filterGroupsByStatus, filterGroupsByCategory) from workflow-history to workflow-history-v2
  • Moved useInitialSelectedEvent hook and its types to workflow-history-v2
  • Created new type definitions (EventGroupCategory, EventGroupCategoryColors, etc.) in workflow-history-filters-menu.types.ts
  • Renamed configuration files to use "event-group-category" naming convention
  • Added comprehensive test coverage for the migrated helpers and hooks

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
workflow-history-v2.types.ts Removed unused WorkflowHistoryEventFilteringTypeColors type
workflow-history-v2.tsx Updated imports to use local filter helpers instead of importing from workflow-history module
workflow-history-ungrouped-event/workflow-history-ungrouped-event.tsx Updated import to use renamed color config file
workflow-history-ungrouped-event/workflow-history-ungrouped-event.styles.ts Updated import to use renamed color config file
workflow-history-timeline/workflow-history-timeline.tsx Updated import to use renamed color config file
workflow-history-navigation-bar-events-menu/workflow-history-navigation-bar-events-menu.tsx Updated import to use renamed color config file
workflow-history-filters-menu/workflow-history-filters-menu.types.ts Added new type definitions for event group categories and statuses
workflow-history-filters-menu/helpers/filter-groups-by-status.ts New file: migrated filter function with updated types
workflow-history-filters-menu/helpers/filter-groups-by-category.ts New file: migrated filter function with updated types
workflow-history-filters-menu/helpers/tests/filter-groups-by-status.test.ts New test file for status filter helper
workflow-history-filters-menu/helpers/tests/filter-groups-by-category.test.ts New test file for category filter helper
workflow-history-event-group/workflow-history-event-group.tsx Updated import to use renamed color config file
workflow-history-event-group/workflow-history-event-group.styles.ts Updated import to use renamed color config file
workflow-history-event-group/helpers/get-event-group-filtering-type.ts Updated to use local types and config instead of importing from workflow-history
workflow-history-event-group/helpers/tests/get-event-group-filtering-type.test.ts Updated mock path to use local config file
hooks/use-initial-selected-event.types.ts New file: type definitions for the migrated hook
hooks/use-initial-selected-event.ts New file: migrated hook from workflow-history
hooks/tests/use-initial-selected-event.test.ts New comprehensive test file for the migrated hook
config/workflow-history-filters.config.ts Updated to use local filter helpers and types
config/workflow-history-filters-type-options.config.ts Updated to use local types and renamed color config
config/workflow-history-event-group-category-filters.config.ts New file: renamed and migrated from workflow-history-filters-type.config
config/workflow-history-event-group-category-colors.config.ts Renamed file: updated to use local types
fixtures/workflow-history-event-groups.ts New file: mock event groups for testing

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/views/workflow-history-v2/workflow-history-event-group/helpers/tests/get-event-group-filtering-type.test.ts:33

  • This Jest mock doesn’t match the module’s default export shape. workflow-history-event-group-category-filters.config exports a default, but the mock returns the config object at the top level, which can make the default import undefined depending on Jest/TS interop. Update the mock to return { __esModule: true, default: { ... } } (like the other tests in this PR).
jest.mock(
  '@/views/workflow-history-v2/config/workflow-history-event-group-category-filters.config',
  () => ({
    ACTIVITY: 'Activity',
    CHILDWORKFLOW: 'ChildWorkflowExecution',
    DECISION: 'Decision',
    TIMER: 'Timer',
    SIGNAL: jest.fn(
      (g) =>
        g.groupType === 'SignalExternalWorkflowExecution' ||
        g.events[0].attributes === 'workflowExecutionSignaledEventAttributes'
    ),
    WORKFLOW: jest.fn(
      (g) =>
        g.groupType === 'RequestCancelExternalWorkflowExecution' ||
        (g.groupType === 'Event' &&
          g.events[0].attributes !== 'workflowExecutionSignaledEventAttributes')
    ),
  })
);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

const groupId = initialEventGroupEntry[0];
// If group index has not changed do not search again
if (
foundGroupIndexRef.current &&
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

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

foundGroupIndexRef.current is used as a truthy check here; if the found index is 0, this condition is skipped and the hook will re-scan filteredEventGroupsEntries on every render. Use an explicit foundGroupIndexRef.current !== undefined (or != null) check so index 0 is cached correctly.

Suggested change
foundGroupIndexRef.current &&
foundGroupIndexRef.current !== undefined &&

Copilot uses AI. Check for mistakes.
@Assem-Uber Assem-Uber merged commit ceafc80 into cadence-workflow:master Feb 23, 2026
9 of 10 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.

3 participants