Skip to content

FE-1895: Load Flow definitions from the graph in the frontend - #10073

Merged
CiaranMn merged 17 commits into
mainfrom
cm/fe-1895-load-flow-definitions-from-graph
Oct 19, 2026
Merged

CiaranMn merged 17 commits into
mainfrom
cm/fe-1895-load-flow-definitions-from-graph

Conversation

@CiaranMn

Copy link
Copy Markdown
Member

🌟 Purpose

We started storing Flow Definitions in the Graph in #10057, but the frontend is still reading the seeded system/example flows from code. This PR fixes that to make the FE load them from the Graph instead.

Flow Definitions can also change over time, and the latest definition may not be the one a run used. So we load definitions both in the FE and when fetching them in workflows as they were at the time that the workflow run started (i.e. the entity edition current at the time of workflow start).

Somewhat tangentially the PR also fixes:

  1. the fact we have a separator in stepIds, ~, but this was scattered across the codebase.
  2. handling of the status of forEach steps in flow runs

🔍 Changes

Key changes.

Where What it does
pages/shared/use-flow-definitions.ts Reads flow definitions from the graph: the current edition of each one the user can view, or one as it was at a given moment.
flow-definitions-context-provider.tsx Provides the definitions from the graph, with a loading flag, in place of the flows in code.
flow-visualizer.tsx Draws a selected run with the edition it executed, and otherwise the current edition.
get-flow-definition-activity.ts, process-flow-workflow.ts A run loads the edition of its definition current when it started, the same edition it's drawn with.
flow-runs-context.ts, swimlane.tsx, group-status.tsx, flows/step-run-id.ts Show the status of steps inside a for-each, whose runs are named per item, with shared helpers for those names.
libs/@local/hash-isomorphic-utils/src/flows/step-run-id.ts Utilities for the construction and parsing of stepIds

⚠️ Known issues

  • The small number of seeded system flows have uuids hardcoded in the repo, so that they can be discovered again where needed. This does mean that other HASH instances will have the same uuid for those flows (but a different entityId, as the system web id will be different).
  • FTSE investors is no longer listed on /flows, because it isn't seeded: it's a test fixture for forEach steps. The aviation flows are only listed in development, where the API seeds them.
  • A for-each step's own box in the swimlane shows no status. We will be replacing this UI anyway and will account for it then.

@CiaranMn
CiaranMn requested a balanced review from Copilot October 17, 2026 11:00
@CiaranMn
CiaranMn requested a review from a team as a code owner October 17, 2026 11:00
@vercel

vercel Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hash Ready Ready Preview Oct 19, 2026 5:49pm UTC
hashdotdesign-tokens Ready Ready Preview Oct 19, 2026 5:49pm UTC
petrinaut Ready Ready Preview Oct 19, 2026 5:49pm UTC
petrinaut-docs Ready Ready Preview Oct 19, 2026 5:49pm UTC

Request Review

@cursor

cursor Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes how flow definitions are resolved at run time and in the UI (graph + temporal queries), plus status aggregation for for-each steps; incorrect temporal or ID handling could show wrong DAGs or step state.

Overview
The frontend no longer hardcodes system flow definitions: use-flow-definitions loads current Flow Definition entities from the graph (with loading state), and useFlowDefinitionAtTime loads the edition that was current when a run started. The flow visualizer uses the historical definition for selected runs and the latest definition otherwise.

Workflow execution is aligned with that UI: getFlowDefinitionActivity takes an atTime timestamp (workflow start), and graph lookups use temporal axes so a run always executes the same edition it is drawn with.

Call sites that only needed stable IDs now import flowDefinitionIds and isGoalFlowDefinitionId from a shared module; full definitions live under flows/definitions/ for seeding and tests.

step-run-id centralizes ~-suffixed step run IDs for for-each branches. The engine and payload tests use generateStepRunId / parseStepRunId instead of ad hoc string splits.

Flow run UI status handling is updated so multiple runs per step inside a for-each roll up to the definition step and parent group (getStatusForSteps, getShownStepRun, parentStepId on nodes). Input requests on nodes match by parsed definition step id.

Reviewed by Cursor Bugbot for commit 4cabb0a. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team type/eng > backend Owned by the @backend team area/apps labels Oct 17, 2026
@CiaranMn
CiaranMn added this pull request to stack #10074 October 17, 2026 11:00
@CiaranMn CiaranMn changed the title FE-1895: Load Flow definitions from the graph in the fronten FE-1895: Load Flow definitions from the graph in the frontend Oct 17, 2026
@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 24.00000% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.13%. Comparing base (80975c5) to head (4cabb0a).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...flow-workflow/pass-outputs-to-unprocessed-steps.ts 0.00% 5 Missing ⚠️
...cal/hash-isomorphic-utils/src/flows/step-run-id.ts 37.50% 5 Missing ⚠️
...h-backend-utils/src/flows/process-flow-workflow.ts 0.00% 3 Missing ⚠️
...c/flows/shared/get-flow-definition-entity-by-id.ts 0.00% 2 Missing ⚠️
...flow-activities/generate-flow-run-name-activity.ts 0.00% 1 Missing ⚠️
.../common-activities/get-flow-definition-activity.ts 0.00% 1 Missing ⚠️
...ess-flow-workflow/get-step-definition-from-flow.ts 0.00% 1 Missing ⚠️
...-isomorphic-utils/src/flows/flow-definition-ids.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10073      +/-   ##
==========================================
- Coverage   68.13%   68.13%   -0.01%     
==========================================
  Files        1995     1997       +2     
  Lines      205555   205567      +12     
  Branches     8707     8711       +4     
==========================================
+ Hits       140065   140071       +6     
- Misses      63826    63833       +7     
+ Partials     1664     1663       -1     
Flag Coverage Δ
apps.hash-ai-worker-ts 7.27% <0.00%> (ø)
apps.hash-api 15.60% <ø> (+0.02%) ⬆️
local.hash-backend-utils 6.22% <0.00%> (-0.01%) ⬇️
local.hash-isomorphic-utils 31.98% <50.00%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Historical-edition consistency across workflow retries, resets, graph queries, and frontend rendering needs final human verification.

No open issues 🎉

What changed in this PR

Builds on #10057 by replacing frontend hardcoded flow definitions with graph-backed definitions and selecting historical editions for runs.

Changes:

  • Loads current definitions for browsing and historical definitions for execution and visualization.
  • Centralizes seeded flow IDs and per-item step-run ID helpers.
  • Aggregates for-each step statuses and adds focused tests.
File Description
libs/​@local/​hash-isomorphic-utils/​src/​flows/​validate-flow-definition.test.ts Updates definition imports.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​step-run-id.ts Adds shared step-run ID helpers.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​flow-definition-schema.ts Uses the shared ID separator.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​flow-definition-ids.ts Centralizes seeded flow IDs.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​definitions/​integration-flow-definitions.ts Uses centralized aviation flow IDs.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​definitions/​goal-flow-definitions.ts Uses the centralized goal ID.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​definitions/​ftse-investors-flow-definition.ts Uses the centralized fixture ID.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​definitions/​frontend-flow-definitions.ts Uses centralized dashboard flow IDs.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​definitions/​file-flow-definitions.ts Uses the centralized document flow ID.
libs/​@local/​hash-isomorphic-utils/​src/​flows/​definitions/​browser-plugin-flow-definitions.ts Uses centralized browser flow IDs.
libs/​@local/​hash-backend-utils/​src/​flows/​shared/​get-flow-definition-entity-by-id.ts Supports historical definition queries.
libs/​@local/​hash-backend-utils/​src/​flows/​process-flow-workflow/​pass-outputs-to-unprocessed-steps.ts Uses shared branch ID parsing.
libs/​@local/​hash-backend-utils/​src/​flows/​process-flow-workflow/​get-step-definition-from-flow.ts Uses shared step-run ID parsing.
libs/​@local/​hash-backend-utils/​src/​flows/​process-flow-workflow/​common-activities/​get-flow-definition-activity.ts Loads definitions at a supplied timestamp.
libs/​@local/​hash-backend-utils/​src/​flows/​process-flow-workflow.ts Supplies workflow start time and uses ID helpers.
libs/​@local/​hash-backend-utils/​src/​flows/​payload-storage.test.ts Constructs test IDs with shared helpers.
apps/​plugin-browser/​src/​scripts/​background/​infer-entities.ts Uses centralized inference flow IDs.
apps/​plugin-browser/​src/​pages/​popup/​popup-contents/​action-center/​shared/​use-flow-runs.ts Filters runs using centralized IDs.
apps/​plugin-browser/​src/​pages/​popup/​popup-contents/​action-center/​history/​shared/​table-label.tsx Builds links using centralized IDs.
apps/​plugin-browser/​src/​pages/​popup/​popup-contents/​action-center/​history/​manually-triggered.tsx Uses the centralized manual flow ID.
apps/​plugin-browser/​src/​pages/​popup/​popup-contents/​action-center/​history/​automatically-triggered.tsx Uses the centralized automatic flow ID.
apps/​hash-frontend/​src/​pages/​workers.page/​flow-run-table.tsx Updates the goal identification import.
apps/​hash-frontend/​src/​pages/​shared/​use-flow-definitions.ts Adds current and historical graph-loading hooks.
apps/​hash-frontend/​src/​pages/​shared/​flow-runs-context.ts Aggregates per-item step statuses.
apps/​hash-frontend/​src/​pages/​shared/​flow-runs-context.test.ts Tests aggregation and displayed-run selection.
apps/​hash-frontend/​src/​pages/​shared/​flow-definitions-context.ts Documents graph-backed context data.
apps/​hash-frontend/​src/​pages/​shared/​flow-definitions-context-provider.tsx Provides graph results and loading state.
apps/​hash-frontend/​src/​pages/​goals/​new.page.tsx Starts goals using the centralized ID.
apps/​hash-frontend/​src/​pages/​goals.page/​goals-list.tsx Updates the goal identification import.
apps/​hash-frontend/​src/​pages/​flows.page.tsx Updates the goal identification import.
apps/​hash-frontend/​src/​pages/​dashboard/​hooks/​use-dashboard-item-config.ts Starts dashboard flows using centralized IDs.
apps/​hash-frontend/​src/​pages/​@/​[shortname]/​shared/​flow-visualizer/​swimlane.tsx Supplies parent IDs for status aggregation.
apps/​hash-frontend/​src/​pages/​@/​[shortname]/​shared/​flow-visualizer/​outputs.tsx Updates the goal identification import.
apps/​hash-frontend/​src/​pages/​@/​[shortname]/​shared/​flow-visualizer/​flow-run-sidebar/​group-status.tsx Includes parent steps in group status inputs.
apps/​hash-frontend/​src/​pages/​@/​[shortname]/​shared/​flow-visualizer/​flow-run-sidebar.tsx Updates goal helper and type imports.
apps/​hash-frontend/​src/​pages/​@/​[shortname]/​shared/​flow-visualizer/​dag-slide.tsx Updates the goal identification import.
apps/​hash-frontend/​src/​pages/​@/​[shortname]/​shared/​flow-visualizer.tsx Draws runs using historical definitions.
apps/​hash-api/​src/​graphql/​resolvers/​knowledge/​file/​shared.ts Starts document flows using the centralized ID.
apps/​hash-api/​src/​graph/​ensure-system-graph-is-initialized/​migrate-ontology-types/​seeded-flows.ts Updates relocated seed definition imports.
apps/​hash-api/​src/​graph/​ensure-system-graph-is-initialized/​migrate-ontology-types/​seeded-flows.test.ts Updates relocated test imports.
apps/​hash-api/​src/​graph/​ensure-system-graph-is-initialized/​migrate-ontology-types/​dev-flows.ts Updates relocated development flow imports.
apps/​hash-api/​src/​ai/​infer-entities-websocket/​handle-infer-entities-request.ts Uses centralized inference flow IDs.
apps/​hash-ai-worker-ts/​src/​activities/​shared/​get-flow-context.ts Updates the goal input type import.
apps/​hash-ai-worker-ts/​src/​activities/​flow-activities/​generate-flow-run-name-activity.ts Uses centralized flow identification.

Review effort: Balanced

@CiaranMn
CiaranMn requested a review from kostandinang October 17, 2026 11:06
kostandinang
kostandinang previously approved these changes Oct 19, 2026
Comment thread libs/@local/hash-backend-utils/src/flows/process-flow-workflow.ts
@vercel
vercel Bot temporarily deployed to Preview – petrinaut-docs October 19, 2026 13:30 Inactive
@vercel
vercel Bot temporarily deployed to Preview – petrinaut October 19, 2026 13:30 Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 22fcdc7. Configure here.

Comment thread libs/@local/hash-backend-utils/src/flows/process-flow-workflow.ts
Comment thread apps/hash-frontend/src/pages/shared/flow-runs-context.ts
…ow-definitions-from-graph

# Conflicts:
#	libs/@local/hash-backend-utils/src/flows/process-flow-workflow.ts
@vercel
vercel Bot temporarily deployed to Preview – petrinaut October 19, 2026 13:48 Inactive
@vercel
vercel Bot temporarily deployed to Preview – petrinaut-docs October 19, 2026 13:48 Inactive
Base automatically changed from cm/fe-1994-flow-run-entity-ids to main October 19, 2026 15:07
…graph

# Conflicts:
#	libs/@local/hash-isomorphic-utils/src/flows/flow-definition-schema.ts
@CiaranMn
CiaranMn requested a review from kostandinang October 19, 2026 15:51
@CiaranMn
CiaranMn added this pull request to the merge queue Oct 19, 2026
Merged via the queue into main with commit 0cdb349 Oct 19, 2026
74 checks passed
@CiaranMn
CiaranMn deleted the cm/fe-1895-load-flow-definitions-from-graph branch October 19, 2026 18:31

This branch was successfully deployed

4 active and 1 inactive (outdated) deployments
Preview – hash — 4cabb0a2 Deployed Oct 19, 2026 by vercel[bot]
Preview – petrinaut-docs — 4cabb0a2 Deployed Oct 19, 2026 by vercel[bot]
Preview – hashdotdesign-tokens — 4cabb0a2 Deployed Oct 19, 2026 by vercel[bot]
Preview – petrinaut — 4cabb0a2 Deployed Oct 19, 2026 by vercel[bot]
pull-request — fff44388 Deployed Oct 17, 2026 by CiaranMn via Sourcemaps (@apps/hash-integration-worker) #40165
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/apps > hash* Affects HASH (a `hash-*` app) area/apps > hash-api Affects the HASH API (app) area/apps area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

3 participants