Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(flows): adjust canvas view handling\n\nUpdate flow canvas components and view-fitting behavior to keep canvas interactions consistent.\n\nAuto-committed-on: macbook\n

Steven Enamakelfa50e02cdb00
diff --git a/app/src/components/flows/canvas/EditableFlowCanvas.tsx b/app/src/components/flows/canvas/EditableFlowCanvas.tsx
index 690bb1c93f..b1439e5b52 100644
--- a/app/src/components/flows/canvas/EditableFlowCanvas.tsx
+++ b/app/src/components/flows/canvas/EditableFlowCanvas.tsx
@@ -64,6 +64,7 @@ import { useT } from '../../../lib/i18n/I18nContext';
import { type FlowConnection, listFlowConnections } from '../../../services/api/flowsApi';
import { Button } from '../../ui';
import { type CanvasActions, CanvasActionsContext } from './canvasActions';
+import { FLOW_FIT_VIEW_OPTIONS } from './fitView';
import './flowCanvasStyles.css';
import FlowNodeComponent from './FlowNodeComponent';
import FlowValidationBanner from './FlowValidationBanner';
diff --git a/app/src/components/flows/canvas/FlowCanvas.tsx b/app/src/components/flows/canvas/FlowCanvas.tsx
index e7372a87eb..460dd414d9 100644
--- a/app/src/components/flows/canvas/FlowCanvas.tsx
+++ b/app/src/components/flows/canvas/FlowCanvas.tsx
@@ -44,6 +44,7 @@ import EditableFlowCanvas, {
type EditableFlowCanvasHandle,
type EditorSaveMeta,
} from './EditableFlowCanvas';
+import { FLOW_FIT_VIEW_OPTIONS } from './fitView';
import './flowCanvasStyles.css';
import FlowNodeComponent from './FlowNodeComponent';
import { StepNumberContext } from './stepNumbers';
@@ -98,21 +99,6 @@ interface FlowCanvasProps {
onViewportChange?: (viewport: Viewport) => void;
}
-/**
- * Shared `fitView` options for both canvases.
- *
- * React Flow's default is `{ padding: 0.1, maxZoom: 1 }`, so a small graph
- * opens at 100% and fills the viewport with three or four cards. `maxZoom`
- * 0.85 pulls back far enough to see the shape of a flow on open while the
- * 13px node titles stay readable, and the wider padding keeps the outermost
- * cards off the canvas edge.
- *
- * Exported because {@link EditableFlowCanvas} must fit identically — the
- * editable canvas persists its viewport, so a different initial zoom there
- * would be saved and then restored forever.
- */
-export const FLOW_FIT_VIEW_OPTIONS = { padding: 0.2, maxZoom: 0.85 } as const;
-
const NODE_TYPES = { [FLOW_NODE_TYPE]: FlowNodeComponent };
// Stable fallback so an omitted `meta` doesn't allocate a new object every
diff --git a/app/src/components/flows/canvas/fitView.ts b/app/src/components/flows/canvas/fitView.ts
new file mode 100644
index 0000000000..8ae02390d7
--- /dev/null
+++ b/app/src/components/flows/canvas/fitView.ts
@@ -0,0 +1,18 @@
+/**
+ * Shared `fitView` options for the two workflow canvases.
+ *
+ * React Flow's default is `{ padding: 0.1, maxZoom: 1 }`, so a small graph
+ * opens at 100% and three or four cards fill the viewport. `maxZoom` 0.85
+ * pulls back far enough to read the shape of a flow on open while the 13px
+ * node titles stay legible, and the wider padding keeps the outermost cards
+ * off the canvas edge.
+ *
+ * Its own module rather than an export from `FlowCanvas`: that file already
+ * imports `EditableFlowCanvas` (it delegates to it when `editable`), so the
+ * editable canvas importing back would close a cycle.
+ *
+ * Both canvases must fit identically. `EditableFlowCanvas` persists its
+ * viewport and restores it on the next mount, so a different initial zoom
+ * there would be captured once and then kept forever.
+ */
+export const FLOW_FIT_VIEW_OPTIONS = { padding: 0.2, maxZoom: 0.85 } as const;