Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(workflows): tile canvas feedback from the first internal pass (#120741)

Daniel Marchukd4e18069424b
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 103c01485a3a..0bd100f3078d 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -8243,9 +8243,9 @@ snapshots:
products-workflows-editor-graph--with-navigation--light:
hash: v1.k794b7964.56d8bf045970b426f994709ddc19478d18e1968fcf3a41f8e0d28485ff338fa1.QsH5OKiKp00RMcqNzSYgsacI4_1BZ7UtU31Qt2EYzuU
products-workflows-editor-tile-canvas--long-emails--dark:
- hash: v1.k794b7964.1c68fbef090e03ad78553e83f9600ca723e1410c5dea6cde7724640423dc63a3.IpQlXvn4eu0Kx0xAvtWrFY0HWEDmW2PJSaTJ-DdzfuQ
+ hash: v1.k794b7964.746428991aecc1377d0eee56fb4bfa599ea2655fd0e5ea52b422d2801a35b7d3.1ymLS7jybK2AYnJEU35IFIHsVPFfXodyVK7oL-aUNB8
products-workflows-editor-tile-canvas--long-emails--light:
- hash: v1.k794b7964.a44070a707b2bb3a40b702e9a651c7f65ace1aacbca38638558385d335b46931.-Ngt_-R_pmOJcOIUzg0hvf17t1OdkMaL3XHfBp8resg
+ hash: v1.k794b7964.eebfc3cc0b5c90e085ba25241bcc782ecea76b1d80eddecd7395694223163f78.6yn2sx_hr50S9YDOqkZOEFUj3ksKoyDB5SOGeOwjQ6k
products-workflows-editor-tile-canvas--paths-collapsed--dark:
hash: v1.k794b7964.a7d1365772454bc11513284e6b78429127fd18f9e88dc8596005089e1ec69719.W3pCWyBom6wjFqo5FoXZ1Ve1o6zhmWDzy3X0gRZHdN0
products-workflows-editor-tile-canvas--paths-collapsed--light:
@@ -8259,9 +8259,9 @@ snapshots:
products-workflows-editor-tile-canvas--time-window-and-webhook--light:
hash: v1.k794b7964.bb4d20744239d7853c41634985d6c021415cf69a6c7a7affd82cc1b66629c05c.V8xSVCs8-Ryzp0TxCYhQJGUE6lIVtIJhK3_z07BoEvc
products-workflows-editor-tile-canvas--with-step-counts--dark:
- hash: v1.k794b7964.2316bb905034aa99508f6137d9c223b2b4748f4095dcd1fedfe9f201505a5860.fonj_IIaN6K5A3Y_4FuSU0S8XBM-aMC8uhrRRFD4ac8
+ hash: v1.k794b7964.0ab0b8a7082c3361fbfe4411ced4404bb68a064b053b7f2ccf1a837eac899e16.J6jtQPYdW-CDpPpbapVHB1Ne2lsf5pfJIDUyPiAP5XM
products-workflows-editor-tile-canvas--with-step-counts--light:
- hash: v1.k794b7964.9250d4a392bfacf5d7777281f0e9759727d32119667b05630dd0131f89043d1e.e6tQol5A8SUhDy8Ubh964qHOS0Vp329Jjst4MIRsx-k
+ hash: v1.k794b7964.b152134d4ebad3b1aad8e7daa775d1c9a8eb751a4135054d79236ed3a667ab6d.SJNeHLOjBtEOEO14ecxMYO0Bc2DHtzrAF3ddp99XzsE
products-workflows-editor-tree--add-on-promotion-emails--dark:
hash: v1.k794b7964.b57f08708c8687742a71ed295c7e0d342e11cc63c709a9b9b703385fbf4d1b31.yosoQWPjKotHOoPqaIycyvai4desJVjTgoOqJHZu1fA
products-workflows-editor-tree--add-on-promotion-emails--light:
@@ -11253,7 +11253,7 @@ snapshots:
scenes-app-heatmap-new--authenticated-review--dark:
hash: v1.k794b7964.23ad5e208a3001a6415b90a9ba2402e483aab06938cc95fa7fe5d1ea5c496bcc.sZFsnhxz8q2n5R5WhX4eifoKj2C-UIdZM9Yv3Hp_G9U
scenes-app-heatmap-new--authenticated-review--light:
- hash: v1.k794b7964.61d6de77bd380e99500dae2f0a78057fec5603627b73f9eb7bd9054edac3266c.BU5AqsFGK7h4O8TAWLjEZXdNMSPz2sQpCmWjNvHGajk
+ hash: v1.k794b7964.1e5957da89de374b78732161eb00eea58830bd3dd0785bdc27cb31addfc970bd.7YJ59ISZkOm2Oe2GUoxbCJyhxqmfIFSTQimLYKZtwvM
scenes-app-heatmap-new--authenticated-with-recordings--dark:
hash: v1.k794b7964.442992a798205b41538d40ab3c5852395200d7d52fe23bd1059aed4c771b50ee.1nJ8Jqy6XLD1f94_Ynt--NV4WjG8B5DEVHmW88gBA5M
scenes-app-heatmap-new--authenticated-with-recordings--light:
diff --git a/frontend/src/layout/scenes/components/SceneDescription.tsx b/frontend/src/layout/scenes/components/SceneDescription.tsx
index 9518591a7e4b..6d12aff9e136 100644
--- a/frontend/src/layout/scenes/components/SceneDescription.tsx
+++ b/frontend/src/layout/scenes/components/SceneDescription.tsx
@@ -20,8 +20,6 @@ type SceneDescriptionProps = {
renameDebounceMs?: number
saveOnBlur?: boolean
maxLength?: number
- /** Shows at most two lines until the user clicks to edit. */
- clamp?: boolean
/** When true, description field is read-only (title AI control may be generating body copy too). */
isGeneratingMetadata?: boolean
}
@@ -36,7 +34,6 @@ export function SceneDescription({
renameDebounceMs = 100,
saveOnBlur = false,
maxLength,
- clamp = false,
isGeneratingMetadata = false,
}: SceneDescriptionProps): JSX.Element | null {
const [description, setDescription] = useState(initialDescription)
@@ -149,7 +146,7 @@ export function SceneDescription({
autoHeight
size="base"
>
- <LemonMarkdown lowKeyHeadings className={clamp ? 'line-clamp-2 min-w-0' : undefined}>
+ <LemonMarkdown lowKeyHeadings>
{description || (canEdit ? 'Enter description (optional)' : 'No description')}
</LemonMarkdown>
{canEdit && !forceEdit && <IconPencil />}
diff --git a/products/workflows/frontend/Workflows/Workflow.tsx b/products/workflows/frontend/Workflows/Workflow.tsx
index a9c5f145db56..ab0832f4a38e 100644
--- a/products/workflows/frontend/Workflows/Workflow.tsx
+++ b/products/workflows/frontend/Workflows/Workflow.tsx
@@ -7,7 +7,6 @@ import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { CanvasCommandGroup } from './hogflows/editor/tile-canvas/CanvasCommandGroup'
import { HogFlowEditor } from './hogflows/HogFlowEditor'
import { hogFlowEditorLogic } from './hogflows/hogFlowEditorLogic'
-import { WorkflowHeaderBar } from './WorkflowHeaderBar'
import { WorkflowLogicProps, workflowLogic } from './workflowLogic'
import { WorkflowStatusBar } from './WorkflowStatusBar'
@@ -16,24 +15,19 @@ export function Workflow(props: WorkflowLogicProps): JSX.Element {
workflowLogic(props)
)
const { loadWorkflow, keepMyWorkflowVersion } = useActions(workflowLogic(props))
- const { editorLayout, isTreeView, isTileCanvas, showsHeaderInWorkflowBar } = useValues(
- hogFlowEditorLogic(logicProps)
- )
+ const { editorLayout, isTreeView, isTileCanvas } = useValues(hogFlowEditorLogic(logicProps))
const { setEditorLayout } = useActions(hogFlowEditorLogic(logicProps))
const treeViewEnabled = useFeatureFlag('WORKFLOWS_LINEAR_VIEW')
return (
<div className="relative flex h-[calc(100vh-13rem)] max-h-full min-h-[25rem] grow flex-col overflow-hidden rounded-md border">
- {showsHeaderInWorkflowBar ? (
- <WorkflowHeaderBar {...props} commands={<CanvasCommandGroup {...logicProps} />} />
- ) : (
- <WorkflowStatusBar
- {...props}
- editorLayout={editorLayout}
- showEditorLayoutToggle={treeViewEnabled}
- onEditorLayoutChange={setEditorLayout}
- />
- )}
+ <WorkflowStatusBar
+ {...props}
+ editorLayout={editorLayout}
+ showEditorLayoutToggle={treeViewEnabled && !isTileCanvas}
+ onEditorLayoutChange={setEditorLayout}
+ commands={isTileCanvas ? <CanvasCommandGroup {...logicProps} /> : undefined}
+ />
{/* Brief working/disabled overlay while we reconcile to an edit made elsewhere (clean state). */}
{isSyncingExternalEdit && <SpinnerOverlay />}
{externallyEdited && (
diff --git a/products/workflows/frontend/Workflows/WorkflowHeaderBar.tsx b/products/workflows/frontend/Workflows/WorkflowHeaderBar.tsx
deleted file mode 100644
index 83e8e8d9f7b1..000000000000
--- a/products/workflows/frontend/Workflows/WorkflowHeaderBar.tsx
+++ /dev/null
@@ -1,144 +0,0 @@
-import { useActions, useValues } from 'kea'
-
-import { IconInfo } from '@posthog/icons'
-import { LemonDivider, LemonSwitch, LemonTag, Spinner, Tooltip } from '@posthog/lemon-ui'
-
-import { LastSavedIndicator } from 'lib/components/LastSavedIndicator'
-import { useDebouncedValue } from 'lib/hooks/useDebouncedValue'
-
-import { SceneBreadcrumbBackButton } from '~/layout/scenes/components/SceneBreadcrumbs'
-import { SceneDescription } from '~/layout/scenes/components/SceneDescription'
-import { SceneTitlePanelButton } from '~/layout/scenes/components/SceneTitlePanelButton'
-import { SceneName } from '~/layout/scenes/components/SceneTitleSection'
-
-import { WorkflowActions } from './WorkflowActions'
-import { workflowBackTo } from './workflowBackTo'
-import { WorkflowLogicProps, workflowLogic } from './workflowLogic'
-
-type WorkflowHeaderBarProps = WorkflowLogicProps & {
- commands?: JSX.Element
-}
-
-const BAR_CLASS_NAME =
- 'flex flex-wrap items-start justify-between gap-x-4 gap-y-2 rounded-t-md border-b bg-surface-secondary px-2 py-2'
-
-function WorkflowHeaderBarLoading(): JSX.Element {
- return (
- <div className={BAR_CLASS_NAME}>
- <div className="flex min-w-0 flex-1 basis-72 items-start gap-1">
- <SceneBreadcrumbBackButton className="mt-0.5 shrink-0" />
- <SceneName isLoading />
- </div>
- </div>
- )
-}
-
-export function WorkflowHeaderBar({ commands, ...props }: WorkflowHeaderBarProps): JSX.Element {
- const logic = workflowLogic(props)
- const {
- originalWorkflow,
- workflow,
- workflowLoading,
- hasUnsavedChanges,
- hasStagedDraft,
- isAutoSavePending,
- autoSaveEnabled,
- lastSavedAt,
- } = useValues(logic)
- const { setAutoSaveEnabled, setWorkflowValue } = useActions(logic)
- const showSaving = useDebouncedValue(isAutoSavePending || workflowLoading, 1000)
-
- if (!originalWorkflow) {
- return <WorkflowHeaderBarLoading />
- }
-
- const showWorkflowStatus = !props.editTemplateId
- const isSaved = !!props.id && props.id !== 'new'
- // Auto-save writes to a saved workflow, so a new one shows its Create button alone.
- const showAutoSave = showWorkflowStatus && isSaved
- const isActive = originalWorkflow.status === 'active'
- const isEditingDraftOfLive = isActive && (hasStagedDraft || hasUnsavedChanges)
-
- return (
- <div className={BAR_CLASS_NAME}>
- <div className="flex min-w-0 flex-1 basis-72 items-start gap-1">
- <SceneBreadcrumbBackButton
- className="mt-0.5 shrink-0"
- forceBackTo={workflowBackTo(workflow, props.id)}
- />
- <div className="flex min-w-0 flex-1 flex-col">
- <div className="flex min-w-0 items-center gap-2">
- <div className="min-w-0">
- <SceneName
- name={workflow?.name}
- onChange={(name) => setWorkflowValue('name', name)}
- canEdit
- renameDebounceMs={200}
- />
- </div>
- {showWorkflowStatus &&
- (isEditingDraftOfLive ? (
- <Tooltip title="The live version keeps running until you publish.">
- <LemonTag type="warning">Editing draft</LemonTag>
- </Tooltip>
- ) : isActive ? (
- <Tooltip title="Changes you make save as a draft.">
- <LemonTag type="success">Live</LemonTag>
- </Tooltip>
- ) : (
- <LemonTag>Draft</LemonTag>
- ))}
- </div>
- <SceneDescription
- description={workflow?.description}
- onChange={(description) => setWorkflowValue('description', description)}
- canEdit
- clamp
- renameDebounceMs={200}
- />
- </div>
- </div>
- <div className="flex flex-wrap items-center justify-end gap-x-3 gap-y-2">
- {commands}
- {commands && <LemonDivider vertical className="h-6" />}
- {showAutoSave && (
- // A fixed width keeps the buttons beside it still while the timestamp text changes.
- <div className="flex w-44 flex-col">
- <span className="flex items-center gap-1">
- <LemonSwitch
- checked={autoSaveEnabled}
- onChange={setAutoSaveEnabled}
- label="Auto-save"
- size="small"
- />
- <Tooltip
- title={
- isActive
- ? 'Auto-save stores your changes as a draft. Nothing goes live until you publish.'
- : 'Draft workflows auto-save as you edit.'
- }
- placement="bottom"
- >
- <IconInfo className="text-tertiary size-4" />
- </Tooltip>
- </span>
- <div className="truncate leading-tight">
- {autoSaveEnabled && showSaving ? (
- <span className="text-xs text-tertiary inline-flex items-center gap-1">
- <Spinner textColored /> Saving…
- </span>
- ) : lastSavedAt ? (
- <LastSavedIndicator timestamp={lastSavedAt} />
- ) : null}
- </div>
- </div>
- )}
- <div className="flex flex-wrap items-center gap-1.5">
- <WorkflowActions {...props} />
- </div>
- {/* A saved workflow shows the AI and side panel buttons beside its tabs, and a new one has no tabs yet. */}
- {!isSaved && <SceneTitlePanelButton />}
- </div>
- </div>
- )
-}
diff --git a/products/workflows/frontend/Workflows/WorkflowScene.tsx b/products/workflows/frontend/Workflows/WorkflowScene.tsx
index 176723f78f3d..870fd8da1729 100644
--- a/products/workflows/frontend/Workflows/WorkflowScene.tsx
+++ b/products/workflows/frontend/Workflows/WorkflowScene.tsx
@@ -19,7 +19,6 @@ import { SceneExport } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
-import { SceneTitlePanelButton } from '~/layout/scenes/components/SceneTitlePanelButton'
import { ProductKey } from '~/queries/schema/schema-general'
import { ActivityScope } from '~/types'
@@ -118,7 +117,6 @@ export function WorkflowScene(props: WorkflowSceneLogicProps): JSX.Element {
const { featureFlags } = useValues(featureFlagLogic)
const overviewTabEnabled = !!featureFlags[FEATURE_FLAGS.WORKFLOWS_OVERVIEW_TAB]
const { suggestionsAvailable } = useValues(workflowSuggestionsAvailabilityLogic)
- const tileCanvasEnabled = !!featureFlags[FEATURE_FLAGS.WORKFLOWS_TILE_CANVAS]
const isSavedWorkflow = !!props.id && props.id !== 'new'
const { sceneIntegrationEnabled } = useValues(sceneAgentPanelLogic)
const { aiComposerAvailable } = useValues(newWorkflowLogic)
@@ -245,37 +243,29 @@ export function WorkflowScene(props: WorkflowSceneLogicProps): JSX.Element {
// A deep link to a tab the flag hides would leave LemonTabs with no active tab and a blank page.
const activeTab = tabs.some((tab) => tab?.key === currentTab) ? currentTab : 'workflow'
- const renderScene = (editorShowsHeaderInBar: boolean): JSX.Element => {
- const headerInWorkflowBar = editorShowsHeaderInBar && (activeTab === 'workflow' || !isSavedWorkflow)
- return (
- <SceneContent className="h-full flex flex-col grow" data-attr="workflow-scene">
- <BindLogic logic={workflowLogic} props={workflowProps}>
- <WorkflowSceneHeader {...props} headerInWorkflowBar={headerInWorkflowBar} />
- <WorkflowEmailPauseBanner />
- {isSavedWorkflow && <WorkflowBroadcastMoveBanner id={props.id!} />}
- {!isSavedWorkflow && <WorkflowAiEmailDraftStatus {...workflowProps} />}
- {suggestionsAvailable && isSavedWorkflow && <WorkflowSuggestionsNotice id={props.id!} />}
- {/* Only show Logs and Metrics tabs if the workflow has already been created */}
- {!props.id || props.id === 'new' ? (
- <Workflow {...workflowProps} />
- ) : (
- <LemonTabs
- activeKey={activeTab}
- onChange={(tab) => router.actions.push(urls.workflow(props.id ?? 'new', tab))}
- tabs={tabs}
- sceneInset
- rightSlot={headerInWorkflowBar ? <SceneTitlePanelButton /> : undefined}
- className={clsx({
- 'flex flex-col grow [&>div]:flex [&>div]:flex-col [&>div]:grow':
- currentTab === 'workflow',
- })}
- />
- )}
- </BindLogic>
- </SceneContent>
- )
- }
-
- // The tile canvas carries the header in its own bar. Reading the flag here keeps the editor logic off the other tabs.
- return renderScene(tileCanvasEnabled)
+ return (
+ <SceneContent className="h-full flex flex-col grow" data-attr="workflow-scene">
+ <BindLogic logic={workflowLogic} props={workflowProps}>
+ <WorkflowSceneHeader {...props} />
+ <WorkflowEmailPauseBanner />
+ {isSavedWorkflow && <WorkflowBroadcastMoveBanner id={props.id!} />}
+ {!isSavedWorkflow && <WorkflowAiEmailDraftStatus {...workflowProps} />}
+ {suggestionsAvailable && isSavedWorkflow && <WorkflowSuggestionsNotice id={props.id!} />}
+ {/* Only show Logs and Metrics tabs if the workflow has already been created */}
+ {!props.id || props.id === 'new' ? (
+ <Workflow {...workflowProps} />
+ ) : (
+ <LemonTabs
+ activeKey={activeTab}
+ onChange={(tab) => router.actions.push(urls.workflow(props.id ?? 'new', tab))}
+ tabs={tabs}
+ sceneInset
+ className={clsx({
+ 'flex flex-col grow [&>div]:flex [&>div]:flex-col [&>div]:grow': currentTab === 'workflow',
+ })}
+ />
+ )}
+ </BindLogic>
+ </SceneContent>
+ )
}
diff --git a/products/workflows/frontend/Workflows/WorkflowSceneHeader.tsx b/products/workflows/frontend/Workflows/WorkflowSceneHeader.tsx
index ee2c20640f0e..8e897913c21f 100644
--- a/products/workflows/frontend/Workflows/WorkflowSceneHeader.tsx
+++ b/products/workflows/frontend/Workflows/WorkflowSceneHeader.tsx
@@ -28,14 +28,7 @@ import { workflowLogic } from './workflowLogic'
import { WorkflowSceneLogicProps } from './workflowSceneLogic'
import { WorkflowScenePanel } from './WorkflowScenePanel'
-type WorkflowSceneHeaderProps = WorkflowSceneLogicProps & {
- headerInWorkflowBar?: boolean
-}
-
-export const WorkflowSceneHeader = ({
- headerInWorkflowBar = false,
- ...props
-}: WorkflowSceneHeaderProps = {}): JSX.Element => {
+export const WorkflowSceneHeader = (props: WorkflowSceneLogicProps = {}): JSX.Element => {
const { workflow, hasUnsavedChanges, hasStagedDraft, workflowLoading, workflowUserAccessLevel } =
useValues(workflowLogic)
const { setWorkflowValue, duplicate, archiveWorkflow, publishDraft, discardDraft } = useActions(workflowLogic)
@@ -157,27 +150,23 @@ export const WorkflowSceneHeader = ({
</SceneMenuBarMenu>
</SceneMenuBar>
)}
- {headerInWorkflowBar ? (
- isSavedWorkflow && <WorkflowScenePanel {...props} />
- ) : (
- <SceneTitleSection
- name={workflow?.name}
- description={workflow?.description}
- resourceType={{ type: 'workflows' }}
- canEdit
- onNameChange={(name) => setWorkflowValue('name', name)}
- onDescriptionChange={(description) => setWorkflowValue('description', description)}
- isLoading={workflowLoading && !workflow}
- renameDebounceMs={200}
- forceBackTo={workflowBackTo(workflow, props.id)}
- actions={
- <>
- <WorkflowActions {...props} />
- {isSavedWorkflow && <WorkflowScenePanel {...props} />}
- </>
- }
- />
- )}
+ <SceneTitleSection
+ name={workflow?.name}
+ description={workflow?.description}
+ resourceType={{ type: 'workflows' }}
+ canEdit
+ onNameChange={(name) => setWorkflowValue('name', name)}
+ onDescriptionChange={(description) => setWorkflowValue('description', description)}
+ isLoading={workflowLoading && !workflow}
+ renameDebounceMs={200}
+ forceBackTo={workflowBackTo(workflow, props.id)}
+ actions={
+ <>
+ <WorkflowActions {...props} />
+ {isSavedWorkflow && <WorkflowScenePanel {...props} />}
+ </>
+ }
+ />
</>
)
}
diff --git a/products/workflows/frontend/Workflows/WorkflowStatusBar.tsx b/products/workflows/frontend/Workflows/WorkflowStatusBar.tsx
index b91fa57f8fbb..17cc44f8e5e8 100644
--- a/products/workflows/frontend/Workflows/WorkflowStatusBar.tsx
+++ b/products/workflows/frontend/Workflows/WorkflowStatusBar.tsx
@@ -14,12 +14,15 @@ type WorkflowStatusBarProps = WorkflowLogicProps & {
editorLayout: HogFlowEditorLayout
showEditorLayoutToggle: boolean
onEditorLayoutChange: (layout: HogFlowEditorLayout) => void
+ /** Editor commands that sit in the bar, such as the tile canvas panels. They bring their own History. */
+ commands?: JSX.Element
}
export function WorkflowStatusBar({
editorLayout,
showEditorLayoutToggle,
onEditorLayoutChange,
+ commands,
...props
}: WorkflowStatusBarProps): JSX.Element | null {
const logic = workflowLogic(props)
@@ -83,6 +86,7 @@ export function WorkflowStatusBar({
: 'Changes you make save as a draft.'}
</span>
)}
+ {commands}
</div>
{/* Interactive controls sit right-anchored with variable-width text leftmost, so the
toggle and History never shift as the narration or the timestamp changes. */}
@@ -113,15 +117,17 @@ export function WorkflowStatusBar({
<IconInfo className="text-tertiary size-4" />
</Tooltip>
</span>
- <LemonButton
- type="tertiary"
- size="small"
- icon={<IconClock />}
- to={urls.workflow(historyWorkflowId, 'history')}
- tooltip="See and restore previous versions"
- >
- History
- </LemonButton>
+ {!commands && (
+ <LemonButton
+ type="tertiary"
+ size="small"
+ icon={<IconClock />}
+ to={urls.workflow(historyWorkflowId, 'history')}
+ tooltip="See and restore previous versions"
+ >
+ History
+ </LemonButton>
+ )}
</div>
)}
</div>
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CanvasCommandButtons.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CanvasCommandButtons.tsx
index 820896dba251..ab648e22c2d6 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CanvasCommandButtons.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CanvasCommandButtons.tsx
@@ -9,8 +9,7 @@ import { useCanvasCommands } from './useCanvasCommands'
export function CanvasCommandButtons(): JSX.Element {
const { panelMode } = useValues(tileCanvasLogic)
const { togglePanel } = useActions(tileCanvasLogic)
- const { panel, morePanels, view } = useCanvasCommands()
- const moreIsActive = morePanels.some((command) => command.mode === panelMode)
+ const { panel, view } = useCanvasCommands()
return (
<div className="flex flex-wrap items-center gap-1" data-attr="workflow-tile-commands">
@@ -27,30 +26,16 @@ export function CanvasCommandButtons(): JSX.Element {
</LemonButton>
))}
<LemonMenu
- items={[
- {
- items: morePanels.map((command) => ({
- label: command.label,
- icon: command.icon,
- active: panelMode === command.mode,
- onClick: () => togglePanel(command.mode),
- 'data-attr': `workflow-tile-command-${command.id}`,
- })),
- },
- {
- items: view.map((command) => ({
- label: command.label,
- icon: command.icon,
- onClick: command.run,
- 'data-attr': `workflow-tile-command-${command.id}`,
- })),
- },
- ]}
+ items={view.map((command) => ({
+ label: command.label,
+ icon: command.icon,
+ onClick: command.run,
+ 'data-attr': `workflow-tile-command-${command.id}`,
+ }))}
>
<LemonButton
size="small"
icon={<IconEllipsis />}
- active={moreIsActive}
tooltip="More"
aria-label="More canvas commands"
data-attr="workflow-tile-command-more"
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CommandBar.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CommandBar.tsx
index 26325754981c..a5e903af3705 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CommandBar.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/CommandBar.tsx
@@ -11,8 +11,8 @@ export function CommandBar(): JSX.Element {
const triggerRef = useRef<HTMLButtonElement>(null)
const { commandPaletteQuery, paletteSections } = useValues(tileCanvasLogic)
const { openCommandPalette, closeCommandPalette, startPlacing } = useActions(tileCanvasLogic)
- const { panel, morePanels, view } = useCanvasCommands()
- const commands = useMemo((): CanvasCommand[] => [...panel, ...morePanels, ...view], [panel, morePanels, view])
+ const { panel, view } = useCanvasCommands()
+ const commands = useMemo((): CanvasCommand[] => [...panel, ...view], [panel, view])
return (
<div className="relative">
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/PathChip.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/PathChip.tsx
index 5a90f07c0fd3..0376b8517eba 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/PathChip.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/PathChip.tsx
@@ -1,8 +1,8 @@
import { NodeProps } from '@xyflow/react'
import { useActions } from 'kea'
-import { IconChevronDown } from '@posthog/icons'
-import { LemonButton } from '@posthog/lemon-ui'
+import { IconCollapse } from '@posthog/icons'
+import { Tooltip } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
@@ -17,25 +17,24 @@ export function PathChip({ data }: NodeProps<PathChipNodeType>): JSX.Element {
const motionStyle = motionProps(data.motion)
return (
<div className={cn('-translate-y-1/2', motionStyle.className)} style={motionStyle.style}>
- <div
- className="nodrag flex w-max items-center gap-1.5 whitespace-nowrap rounded-full border bg-surface-primary pr-2.5 shadow-sm"
- style={{ borderColor: color }}
- >
- <LemonButton
- size="xsmall"
- icon={<IconChevronDown />}
- tooltip="Collapse this path"
+ <Tooltip title="Collapse this path">
+ <button
+ type="button"
+ className="nodrag flex w-max cursor-pointer items-center gap-1.5 whitespace-nowrap rounded-full border bg-surface-primary py-1 pl-2 pr-2.5 shadow-sm hover:bg-surface-secondary"
+ style={{ borderColor: color }}
data-attr="workflow-tile-collapse-path"
onClick={(event) => {
event.stopPropagation()
collapsePath(data.group.id)
}}
- />
- <span className="size-2 shrink-0 rounded-full" style={{ backgroundColor: color }} />
- <span className="text-[13px] font-semibold" style={{ color }}>
- {data.group.label}
- </span>
- </div>
+ >
+ <IconCollapse className="size-3.5 shrink-0 text-secondary" />
+ <span className="size-2 shrink-0 rounded-full" style={{ backgroundColor: color }} />
+ <span className="text-[13px] font-semibold" style={{ color }}>
+ {data.group.label}
+ </span>
+ </button>
+ </Tooltip>
</div>
)
}
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileBadge.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileBadge.tsx
index 3baff71d8843..5a2bda85c25a 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileBadge.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileBadge.tsx
@@ -1,3 +1,5 @@
+import { IconPerson } from '@posthog/icons'
+
import { cn } from 'lib/utils/css-classes'
export function TileBadge({
@@ -27,7 +29,15 @@ export function TileBadge({
style={color ? { color } : undefined}
translate="no"
>
- {children}
+ {placement === 'count' ? (
+ // Beside a stack's step count, a bare number reads as steps rather than people.
+ <span className="inline-flex items-center gap-0.5">
+ <IconPerson className={size === 'mini' ? 'size-2.5' : 'size-3'} />
+ {children}
+ </span>
+ ) : (
+ children
+ )}
</span>
)
}
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileFace.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileFace.tsx
index dac65f1403cf..5e5581de8a01 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileFace.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileFace.tsx
@@ -1,10 +1,7 @@
import { Tooltip } from '@posthog/lemon-ui'
-import { EmailPreviewThumbnail } from 'lib/components/EmailPreviewThumbnail/EmailPreviewThumbnail'
import { humanFriendlyLargeNumber } from 'lib/utils/numbers'
-import type { HogFlowAction } from '../../types'
-import { emailContent } from './stepValues'
import { TileBadge } from './TileBadge'
import { TILE_SIZE } from './tileCanvasLayout'
import type { TileShape, TileStep } from './useTileStep'
@@ -20,48 +17,21 @@ function tileRadius(shape: TileShape): string {
: `${CORNER}px`
}
-export function TileFace({
- action,
- tile,
- count,
- showEmail,
- emailPlaceholder = false,
-}: {
- action: HogFlowAction
- tile: TileStep
- count: number | undefined
- showEmail: boolean
- /** Holds the thumbnail's size without loading the email, for copies that are only measured. */
- emailPlaceholder?: boolean
-}): JSX.Element {
- const html = showEmail ? emailContent(action)?.html : undefined
+export function TileFace({ tile, count }: { tile: TileStep; count: number | undefined }): JSX.Element {
return (
<div className="relative" data-tile-anchor>
- {html ? (
- <div
- className="overflow-hidden rounded-xl border-2 bg-surface-primary shadow-sm"
- style={{ borderColor: tile.color }}
- >
- {emailPlaceholder ? (
- <span className="block h-28 w-40" />
- ) : (
- <EmailPreviewThumbnail html={html} title={`${action.name} preview`} size="card" />
- )}
- </div>
- ) : (
- <div
- className="flex items-center justify-center border-2 bg-surface-primary text-[30px] shadow-sm"
- style={{
- width: TILE_SIZE,
- height: TILE_SIZE,
- borderRadius: tileRadius(tile.shape),
- borderColor: tile.color,
- color: tile.color,
- }}
- >
- {tile.icon}
- </div>
- )}
+ <div
+ className="flex items-center justify-center border-2 bg-surface-primary text-[30px] shadow-sm"
+ style={{
+ width: TILE_SIZE,
+ height: TILE_SIZE,
+ borderRadius: tileRadius(tile.shape),
+ borderColor: tile.color,
+ color: tile.color,
+ }}
+ >
+ {tile.icon}
+ </div>
{count !== undefined && <TileBadge placement="count">{humanFriendlyLargeNumber(count)}</TileBadge>}
{tile.badge && (
<TileBadge placement="setting" color={tile.color}>
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileHoverCard.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileHoverCard.tsx
index e7efb10650ba..76c090a55ea9 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileHoverCard.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileHoverCard.tsx
@@ -16,7 +16,6 @@ const PADDING = 14
const MIN_WIDTH = 440
const KIND_LABEL_ROOM = 72
const NAME_ROW_HEIGHT = 26
-const EMAIL_FACE = { width: 164, height: 116 }
export const HOVER_CARD_CLOSE_MS = 200
// The border snaps to whole device pixels but the card's edge can fall between them, so a clip on the
// edge itself can shave the bottom border off. Clipping just outside the card keeps the whole border.
@@ -40,21 +39,19 @@ export function TileHoverCard({
action,
tile,
count,
- showEmail,
}: {
open: boolean
action: HogFlowAction
tile: TileStep
count: number | undefined
- showEmail: boolean
}): JSX.Element {
- const face = showEmail ? EMAIL_FACE : { width: TILE_SIZE, height: TILE_SIZE }
+ const face = { width: TILE_SIZE, height: TILE_SIZE }
const width = Math.max(MIN_WIDTH, face.width + 12 + CAPTION_WIDTH + PADDING * 2 + KIND_LABEL_ROOM)
const nameRow = tile.customName ? NAME_ROW_HEIGHT : 0
const faceTop = PADDING + nameRow
const closedClip = `inset(${faceTop}px ${width - PADDING - face.width}px calc(100% - ${faceTop + face.height}px) ${PADDING}px round 12px)`
const kind = tile.presentation.kind
- const showPreview = kind !== 'fields' && !(showEmail && kind === 'email')
+ const showPreview = kind !== 'fields'
const ref = useRef<HTMLDivElement>(null)
const shift = useKeepInView(ref, open, FIT_MARGIN.bottom)
return (
@@ -78,7 +75,7 @@ export function TileHoverCard({
</div>
)}
<div className="relative flex items-start gap-3">
- <TileFace action={action} tile={tile} count={count} showEmail={showEmail} />
+ <TileFace tile={tile} count={count} />
<TileCaption facts={tile.facts} size="card" />
<div
className="absolute right-0 top-0 text-[10px] font-semibold uppercase tracking-wider"
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepNode.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepNode.tsx
index b6dfb55bc2f6..9acdea62cc6f 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepNode.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepNode.tsx
@@ -4,7 +4,6 @@ import { useRef } from 'react'
import { cn } from 'lib/utils/css-classes'
import type { HogFlow, HogFlowAction } from '../../types'
-import { emailContent } from './stepValues'
import { tileCanvasLogic } from './tileCanvasLogic'
import { hasStepMenu } from './tileCanvasModel'
import { TileCaption } from './TileCaption'
@@ -34,7 +33,6 @@ export function TileStepNode({
}): JSX.Element {
const ref = useRef<HTMLDivElement>(null)
const tile = useTileStep(action, workflow)
- const showEmail = !!emailContent(action)?.html
const hover = useHoverIntent(interactive && !selected && !menuOpen, HOVER_OPEN_DELAY_MS, HOVER_CARD_CLOSE_MS)
const { openStepMenu } = useActions(tileCanvasLogic)
useRaisedNode(ref, hover.mounted)
@@ -45,10 +43,8 @@ export function TileStepNode({
(selected || menuOpen) && 'ring-2 ring-[var(--color-accent)] ring-offset-4'
)}
>
- <TileFace action={action} tile={tile} count={count} showEmail={showEmail} emailPlaceholder={!interactive} />
- {hover.mounted && (
- <TileHoverCard open={hover.open} action={action} tile={tile} count={count} showEmail={showEmail} />
- )}
+ <TileFace tile={tile} count={count} />
+ {hover.mounted && <TileHoverCard open={hover.open} action={action} tile={tile} count={count} />}
</div>
)
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepPanelHead.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepPanelHead.tsx
index b5470e183436..b75b8cadd5fe 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepPanelHead.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/TileStepPanelHead.tsx
@@ -5,7 +5,6 @@ import { LemonButton } from '@posthog/lemon-ui'
import { HogFlowStepNameFields } from '../../panel/HogFlowStepNameFields'
import type { HogFlowAction } from '../../types'
-import { emailContent } from './stepValues'
import { tileCanvasLogic } from './tileCanvasLogic'
import { TileCaption } from './TileCaption'
import { TileFace } from './TileFace'
@@ -24,12 +23,7 @@ export function TileStepPanelHead({ action }: { action: HogFlowAction }): JSX.El
data-attr="workflow-tile-panel-head"
>
<div className="relative flex items-start gap-3">
- <TileFace
- action={action}
- tile={tile}
- count={countOf(action.id)}
- showEmail={!!emailContent(action)?.html}
- />
+ <TileFace tile={tile} count={countOf(action.id)} />
<TileCaption facts={tile.facts} />
<div
className="absolute right-0 top-0 text-[10px] font-semibold uppercase tracking-wider"
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.test.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.test.ts
index 94a5d58d8dfc..de1c91452421 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.test.ts
@@ -270,10 +270,23 @@ describe('stepFacts', () => {
expect(stepView(threePaths, split).badge).toBe('3 paths')
})
- it('falls back to the template name for a template it does not know', () => {
- const action = fn('hubspot', 'template-hubspot', { email: 'x' })
+ it.each<[string, Partial<HogFlowAction>, string, string | undefined]>([
+ ['shows the template name for a step that keeps it', {}, 'HubSpot', undefined],
+ [
+ 'keeps the name and description the author gave the step',
+ { name: 'Stamp the last email date', description: 'So the next run waits a week' },
+ 'Stamp the last email date',
+ 'So the next run waits a week',
+ ],
+ ['names the template under a renamed step', { name: 'Sync the contact' }, 'Sync the contact', 'HubSpot'],
+ ])('%s', (_, extra, headline, detail) => {
+ const action = fn('hubspot', 'template-hubspot', { email: 'x' }, extra)
- expect(stepFacts(workflow([action]), action, 'HubSpot').headline).toBe('HubSpot')
+ expect(stepFacts(workflow([action]), action, 'HubSpot')).toMatchObject({
+ headline,
+ detail,
+ fields: [['Runs', 'HubSpot']],
+ })
})
it.each<[string, HogFlowAction, string | undefined]>([
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.ts
index a1e5db25ff59..dbcb0a2f42ea 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.ts
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/stepFacts.ts
@@ -197,9 +197,14 @@ function windowFacts({ day, time, timezone }: TimeWindowPresentation): StepFacts
}
function otherStepFacts(action: HogFlowAction, templateName: string | undefined): StepFacts {
- return templateName
- ? { headline: templateName, fields: [['Runs', templateName]] }
- : { headline: action.name, detail: action.description || undefined, fields: [['Runs', action.name]] }
+ const runs = templateName ?? action.name
+ // A new step takes the template's name, so any other name is one the author chose.
+ const renamed = !!templateName && action.name.trim().toLowerCase() !== templateName.toLowerCase()
+ return {
+ headline: renamed ? action.name : runs,
+ detail: action.description || (renamed ? templateName : undefined),
+ fields: [['Runs', runs]],
+ }
}
function presentationFacts(
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.test.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.test.ts
index 8daa4a3fbd7c..d7d2bd71c180 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.test.ts
@@ -385,6 +385,14 @@ describe('tileCanvasModel', () => {
focus: { x: 0, y: 0, width: 64, height: 64 },
expected: { x: 24, y: 50, zoom: 0.5 },
},
+ {
+ name: 'lifts a selected step out from under the command bar',
+ startX: 100,
+ previousWidth: 1200,
+ nextWidth: 1200,
+ focus: { x: 0, y: 1400, width: 64, height: 64 },
+ expected: { x: 100, y: -28, zoom: 0.5 },
+ },
])('moves the viewport on a canvas resize: $name', ({ startX, previousWidth, nextWidth, focus, expected }) => {
const viewport = { x: startX, y: 50, zoom: 0.5 }
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.ts
index 26a42b2c8a8d..d92c946a81b8 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.ts
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/tileCanvasModel.ts
@@ -523,16 +523,24 @@ export interface Size {
height: number
}
+export const FIT_MARGIN = { side: 24, top: 32, bottom: 96 }
const VIEWPORT_MARGIN = 24
-function shiftIntoView(offset: number, start: number, length: number, zoom: number, extent: number): number {
+function shiftIntoView(
+ offset: number,
+ start: number,
+ length: number,
+ zoom: number,
+ extent: number,
+ farMargin = VIEWPORT_MARGIN
+): number {
const near = start * zoom + offset
const far = (start + length) * zoom + offset
if (near < VIEWPORT_MARGIN) {
return offset + VIEWPORT_MARGIN - near
}
- if (far > extent - VIEWPORT_MARGIN) {
- return offset - Math.min(far - (extent - VIEWPORT_MARGIN), near - VIEWPORT_MARGIN)
+ if (far > extent - farMargin) {
+ return offset - Math.min(far - (extent - farMargin), near - VIEWPORT_MARGIN)
}
return offset
}
@@ -545,13 +553,16 @@ export function viewportAfterResize(viewport: Viewport, previous: Size, next: Si
}
return {
x: shiftIntoView(x, focus.x, focus.width, viewport.zoom, next.width),
- y: shiftIntoView(y, focus.y, focus.height, viewport.zoom, next.height),
+ y: shiftIntoView(y, focus.y, focus.height, viewport.zoom, next.height, FIT_MARGIN.bottom),
zoom: viewport.zoom,
}
}
+export function viewportShowing(viewport: Viewport, canvas: Size, focus: Point & Size): Viewport {
+ return viewportAfterResize(viewport, canvas, canvas, focus)
+}
+
export const CANVAS_MIN_ZOOM = 0.15
-export const FIT_MARGIN = { side: 24, top: 32, bottom: 96 }
/** The command bar floats over the bottom of the canvas, so the room to show things in ends above it. */
function roomInView(canvas: Size): Size {
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasCommands.tsx b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasCommands.tsx
index cb13d6254652..4a7399a64aae 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasCommands.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasCommands.tsx
@@ -10,6 +10,7 @@ import {
IconGraph,
IconList,
IconPlay,
+ IconPlusSquare,
IconScreen,
} from '@posthog/icons'
@@ -27,13 +28,19 @@ export interface PanelCommand extends CanvasCommand {
export interface CanvasCommands {
panel: PanelCommand[]
- morePanels: PanelCommand[]
view: CanvasCommand[]
}
type PanelDefinition = Omit<PanelCommand, 'run'> & { needsSavedWorkflow?: boolean }
const PANELS: PanelDefinition[] = [
+ {
+ id: 'build',
+ mode: 'build',
+ label: 'Build',
+ hint: 'Browse every step you can add',
+ icon: <IconPlusSquare />,
+ },
{
id: 'test',
mode: 'test',
@@ -57,26 +64,24 @@ const PANELS: PanelDefinition[] = [
hint: 'Values the steps can read and write',
icon: <IconBrackets />,
},
+ {
+ id: 'metrics',
+ mode: 'metrics',
+ label: 'Metrics',
+ hint: 'How many people each step reached',
+ icon: <IconGraph />,
+ needsSavedWorkflow: true,
+ },
+ {
+ id: 'history',
+ mode: 'history',
+ label: 'History',
+ hint: 'See and restore previous versions',
+ icon: <IconClock />,
+ needsSavedWorkflow: true,
+ },
]
-const METRICS_PANEL: PanelDefinition = {
- id: 'metrics',
- mode: 'metrics',
- label: 'Metrics',
- hint: 'How many people each step reached',
- icon: <IconGraph />,
- needsSavedWorkflow: true,
-}
-
-const HISTORY_PANEL: PanelDefinition = {
- id: 'history',
- mode: 'history',
- label: 'History',
- hint: 'See and restore previous versions',
- icon: <IconClock />,
- needsSavedWorkflow: true,
-}
-
function tracked<Command extends CanvasCommand>(command: Command): Command {
return {
...command,
@@ -112,7 +117,6 @@ export function useCanvasCommands(): CanvasCommands {
}
return {
panel: available(PANELS),
- morePanels: available([METRICS_PANEL, HISTORY_PANEL]),
view: [...(hasPaths ? [pathsCommand] : []), fitCommand].map(tracked),
}
}, [openPanel, isSavedWorkflow, hasPaths, allPathsCollapsed, toggleAllPaths, requestFit])
diff --git a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasViewport.ts b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasViewport.ts
index 09add0d2541b..c855df5c0f8d 100644
--- a/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasViewport.ts
+++ b/products/workflows/frontend/Workflows/hogflows/editor/tile-canvas/useCanvasViewport.ts
@@ -10,6 +10,7 @@ import {
Size,
viewportAfterResize,
viewportAnchoredOn,
+ viewportShowing,
viewportToFit,
} from './tileCanvasModel'
@@ -54,6 +55,31 @@ function useViewportFollowsResize(wrapperRef: RefObject<HTMLDivElement>): void {
}, [reactFlow, wrapperRef, selectedStepBox])
}
+/** A step picked off screen, such as one just added, has no position until the next layout, so it is shown once that lands. */
+function useSelectedStepInView(wrapperRef: RefObject<HTMLDivElement>): void {
+ const reactFlow = useReactFlow()
+ const { selectedNodeId } = useValues(tileCanvasLogic)
+ const selectedStepBox = useSelectedStepBox()
+ const shownStepId = useRef<string | null>(null)
+ const box = selectedStepBox.current
+ useEffect(() => {
+ const wrapper = wrapperRef.current
+ if (!selectedNodeId) {
+ shownStepId.current = null
+ return
+ }
+ if (!wrapper || !box || shownStepId.current === selectedNodeId) {
+ return
+ }
+ shownStepId.current = selectedNodeId
+ const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches
+ void reactFlow.setViewport(viewportShowing(reactFlow.getViewport(), sizeOf(wrapper), box), {
+ duration: reduceMotion ? 0 : FOCUS_MS,
+ })
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, [selectedNodeId, box?.x, box?.y, box?.width, box?.height])
+}
+
/** Edits keep the viewport the person panned or zoomed to; only an explicit fit request moves it. */
function useFitOnRequest(wrapperRef: RefObject<HTMLDivElement>): void {
const reactFlow = useReactFlow()
@@ -95,6 +121,7 @@ function useFocusOnPath(wrapperRef: RefObject<HTMLDivElement>): void {
export function useCanvasViewport(wrapperRef: RefObject<HTMLDivElement>): void {
useViewportFollowsResize(wrapperRef)
+ useSelectedStepInView(wrapperRef)
useFitOnRequest(wrapperRef)
useFocusOnPath(wrapperRef)
}
diff --git a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.ts b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.ts
index fd4b89d69b42..ff35dd53ef47 100644
--- a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.test.ts
@@ -180,40 +180,6 @@ describe('hogFlowEditorLogic', () => {
logic.mount()
})
- it.each([
- { name: 'the tile canvas', flags: ['tile'], layout: 'advanced', id: 'flow-1', expected: true },
- {
- name: 'the list view of both flags',
- flags: ['tile', 'linear'],
- layout: 'simple',
- id: 'flow-1',
- expected: true,
- },
- {
- name: 'the graph view of both flags',
- flags: ['tile', 'linear'],
- layout: 'advanced',
- id: 'flow-1',
- expected: true,
- },
- { name: 'the graph editor', flags: [], layout: 'advanced', id: 'flow-1', expected: false },
- { name: 'the tile canvas of a new workflow', flags: ['tile'], layout: 'advanced', id: 'new', expected: true },
- ] as const)(
- 'moves the workflow header into the workflow bar only for $name: $expected',
- ({ flags, layout, id, expected }) => {
- const flagKeys = { tile: FEATURE_FLAGS.WORKFLOWS_TILE_CANVAS, linear: FEATURE_FLAGS.WORKFLOWS_LINEAR_VIEW }
- featureFlagLogic.actions.setFeatureFlags(
- flags.map((flag) => flagKeys[flag]),
- Object.fromEntries(flags.map((flag) => [flagKeys[flag], true]))
- )
- const editorLogic = hogFlowEditorLogic({ id })
- editorLogic.mount()
- editorLogic.actions.setEditorLayout(layout)
-
- expect(editorLogic.values.showsHeaderInWorkflowBar).toBe(expected)
- }
- )
-
it('resolves the selected action while React Flow nodes are still laying out', () => {
const action = logic.values.workflow.actions[0]
logic.actions.setNodesRaw([])
diff --git a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
index a5e17368ede8..a88d6e541977 100644
--- a/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/hogFlowEditorLogic.tsx
@@ -284,7 +284,6 @@ export interface hogFlowEditorLogicValues {
selectedNodeCanBeCopiedOrMoved: boolean
selectedNodeCanBeDeleted: boolean
selectedNodeId: string | null
- showsHeaderInWorkflowBar: boolean
treePathsCollapsedByDefault: boolean
}
@@ -2246,7 +2245,6 @@ export interface hogFlowEditorLogicMeta {
__keaTypeGenInternalSelectorTypes: {
isTileCanvas: (featureFlags: FeatureFlagsSet) => boolean
isTreeView: (featureFlags: FeatureFlagsSet, editorLayout: HogFlowEditorLayout, isTileCanvas: boolean) => boolean
- showsHeaderInWorkflowBar: (isTileCanvas: boolean) => boolean
nodesById: (nodes: HogFlowActionNode[]) => Record<string, HogFlowActionNode>
selectedNode: (
nodes: HogFlowActionNode[],
@@ -2483,8 +2481,6 @@ export const hogFlowEditorLogic = kea<hogFlowEditorLogicType>([
(featureFlags: FeatureFlagsSet, editorLayout: HogFlowEditorLayout, isTileCanvas: boolean): boolean =>
!isTileCanvas && !!featureFlags[FEATURE_FLAGS.WORKFLOWS_LINEAR_VIEW] && editorLayout === 'simple',
],
- /** The tile canvas carries the workflow header in its own bar, saved or not. */
- showsHeaderInWorkflowBar: [(s) => [s.isTileCanvas], (isTileCanvas: boolean): boolean => isTileCanvas],
nodesById: [
(s) => [s.nodes],
(nodes: HogFlowActionNode[]): Record<string, HogFlowActionNode> => {
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx
index dc80fa668c57..750051185fe1 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/panel/HogFlowEditorPanel.tsx
@@ -70,6 +70,9 @@ export function HogFlowEditorPanel({
),
key: mode,
}))
+ // A docked panel is too narrow for every tab, and Variables has its own button beside the canvas.
+ const shownTabs = layout === 'docked' ? tabs.filter((tab) => tab.key !== 'variables') : tabs
+ const title = view?.title ?? (shownTabs.some((tab) => tab.key === mode) ? null : capitalizeFirstLetter(mode))
return (
<div
@@ -121,15 +124,14 @@ export function HogFlowEditorPanel({
</div>
<div className="min-w-0 flex-1">
- {layout === 'docked' ? (
- <h3 className="m-0 truncate py-2 text-sm font-semibold">
- {view?.title ?? capitalizeFirstLetter(mode)}
- </h3>
+ {title ? (
+ <h3 className="m-0 truncate py-2 text-sm font-semibold">{title}</h3>
) : (
<LemonTabs
activeKey={mode}
onChange={(key) => setMode(key)}
- tabs={tabs}
+ tabs={shownTabs}
+ size={layout === 'docked' ? 'small' : undefined}
barClassName="-mb-px "
/>
)}