Overview
The version control UI lets users toggle versioning on a flow, switch between versions, create new versions, publish to production, and restore previous history snapshots. It is built with React Query for data fetching, Zustand for cross-component state, and URL parameters for version routing. Version control only appears when the flow hasversionControlEnabled: true. The toggle is available in the flow settings modal on /dashboard-beta routes.
Architecture
Version control spans four layers:- Service layer β
FlowVersionServicewraps all version API calls - React Query hooks β
useFlowVersionsprovides queries and mutations with cache invalidation - Zustand store β
storeVersionControlshares computed props between the editor and the top bar - UI components β
VersionControlDropdown,RestoreConfirmModal, andVersionNameModal
Data flow
CoreNodeDisplayfetches versions, deployed version, and history using React Query hooks- It computes
VersionControlProps(version items, handlers, UI state) in auseMemo - Props are stored in the Zustand store via
setVersionControlProps AgentTopBarreads from the store and rendersVersionControlDropdowninside a popover- User actions in the dropdown call handlers defined in
CoreNodeDisplay, which trigger mutations and page reloads
URL parameter
TheversionId query parameter controls which version is active:
- Present (
?versionId=abc-123) β The user is editing a specific version. All node and edge operations include this ID. - Absent β The user is viewing the deployed (production) version.
Components
VersionControlDropdown
The main UI for version management. Rendered inside a popover inAgentTopBar.
Props:
VersionNameModal to create a version.
History view β Shows the history snapshots for a selected version. The current snapshot is marked with a βCurrentβ badge. Past snapshots have a Restore button that opens RestoreConfirmModal.
VersionItem
The shared data shape used for both versions and history entries in the dropdown:RestoreConfirmModal
Confirmation dialog before restoring a version to a previous history snapshot. Props:VersionNameModal
Input modal for entering a version name when creating a new version. Props:onSubmit with the trimmed value. The input clears on submit and on close.
State management
Zustand store
storeVersionControl shares version control state between CoreNodeDisplay (which computes it) and AgentTopBar (which renders the dropdown).
versionControlPropsisnullwhen version control is disabled. The dropdown only renders when this value exists.isProductionViewtracks whether the user is viewing the deployed version.- Props are cleared on
CoreNodeDisplayunmount.
React Query hooks
All hooks are inuseFlowVersions.ts.
Queries:
| Hook | Query key | Description |
|---|---|---|
useDeployedVersion(flowId, enabled) | ['flow-version-deployed', flowId] | Fetches the deployed version with nodes and edges. Returns null on 404. |
useVersions(flowId, page, pageSize, enabled) | ['flow-versions', flowId, page, pageSize] | Paginated list of all versions. Default page size is 50. |
useVersionHistory(flowId, versionId, page, pageSize, enabled) | ['flow-version-history', flowId, versionId, page, pageSize] | Paginated history for a specific version. Only enabled when versionId is truthy. |
| Hook | Invalidates | Description |
|---|---|---|
useCreateVersion() | ['flow-versions'] | Creates a new version from a source version. |
usePushToProduction() | ['flow-version-deployed'], ['flow-versions'], ['flow-version-history'] | Publishes a version to production. |
useRollback() | ['flow-versions'], ['flow-version-history'] | Restores a version to a previous history snapshot. |
Service layer
FlowVersionService provides static methods that map to the version control API endpoints:
User workflows
Enabling version control
- User opens the flow settings modal (available on
/dashboard-betaroutes) - Toggles the Enable Version Control switch
- The frontend calls
FlowService.updateFlow(flowId, { versionControlEnabled: true }) - The API returns a
versionIdfor the new staging version - The page reloads with
?versionId={versionId}in the URL - The version control dropdown appears in the top bar
Switching versions
- User clicks a version in the dropdown
- The URL updates to
?versionId={selectedId} - The page reloads and all queries re-fetch with the new version context
Creating a new version
- User clicks Add New in the dropdown
VersionNameModalopens for name input- On submit,
createVersionMutationis called with the current version as the source - The page reloads to show the new version
Publishing to production
- User clicks Publish while viewing a non-deployed version
pushToProductionMutationis called with the selected version ID- React Query invalidation refreshes the deployed version, version list, and history
- The live version in the dropdown updates to reflect the new production state
Restoring a history snapshot
- User clicks the clock icon on a version to view its history
- The dropdown switches to history view with a list of snapshots
- User clicks Restore on a past snapshot
RestoreConfirmModalshows the transition from current to target- On confirmation,
rollbackMutationis called - The page reloads with the restored state
Disabling version control
- User toggles the switch off in flow settings
- The frontend calls
updateFlowwithversionControlEnabled: falseand the currentversionId - The
versionIdURL parameter is removed - The page reloads without version control UI
Next steps
- Version control concepts β How versioning, history snapshots, and semantic versioning work
- Version control API β Endpoint reference for all version operations