AI-First Starting UX: Build from scratch#4918
Draft
lmac-1 wants to merge 3 commits into
Draft
Conversation
Base automatically changed from
4868-build-with-ai
to
4848-ai-first-starting-ux-parent
July 6, 2026 08:17
Adds the "Build from scratch" entry point on the new-workflow landing screen: Workflows.create_webhook_workflow/2 builds a workflow with a webhook trigger, one job, and an always-on edge; the build_from_scratch LiveView event authorizes via the role-scoped ProjectUsers :create_workflow check so viewers can't trigger it.
0110e36 to
290612b
Compare
…flow_name/2 Clicking "Build from scratch" twice in one project failed on the workflow name unique constraint, since create_webhook_workflow/2 hardcoded its name. Extract the collision-avoidance logic duplicated in workflow_channel.ex and new_workflow_component.ex into a public Workflows.unique_workflow_name/2 (names-only query, includes soft-deleted rows since the unique index is not partial) and use it in create_webhook_workflow/2, which now defaults to "Untitled workflow" with " 1", " 2"... suffixes on collision. The channel delegates to the shared function. The legacy component keeps its private copy because that path is being deleted in this epic.
Rapid double-clicks on the "Build from scratch" card sent multiple build_from_scratch events, each creating a workflow. Wrap the push in useActionLock so only one event goes out, disable the card while pending, and guard the LiveView handler with a creating_workflow? assign as a server-side backstop for events that arrive anyway. Also normalize the new-workflow placeholder to "Untitled workflow" to match the rest of the codebase, and add regression tests: repeated clicks create suffixed workflows, creation after deletion reuses the freed name, and a failed save shows an error flash.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the "Build from scratch" path from the new-workflow landing screen (part of the #4848 AI-first starting UX epic).
Clicking the "Build from scratch" card now:
Workflows.create_webhook_workflow/2: a webhook trigger, one "Transform Data" job on@openfn/language-common@latest, and an always-enabled edge — the same shape as the old "Event-based template".?trigger=<id>in the URL, so the trigger inspector ("What triggers this workflow?") is open on load.The
build_from_scratchLiveView event is authorized with the role-scopedProjectUsers:create_workflowpolicy, so viewers get a permission error flash instead of a new workflow.Workflows are named "Untitled workflow", "Untitled workflow 1", etc. via a new shared
Workflows.unique_workflow_name/2— extracted from the identical private copies inworkflow_channel.exandnew_workflow_component.ex, and now used by both this flow and the channel'svalidate_workflow_name. (The legacy component keeps its copy since that path is being deleted in this epic.) This also fixes a bug where clicking the card a second time in the same project failed on the name unique constraint.The card is also protected against double-clicks:
useActionLockensures onebuild_from_scratchevent per click-burst, the card is disabled while creation is pending, and the LiveView handler has acreating_workflow?guard as a server-side backstop.Closes #4895
Validation steps
<name>_del).Additional notes for the reviewer
create_webhook_workflow/2goes through the existingsave_workflow/2pipeline, so snapshots,lock_version, and audit behave like any other workflow save.AI Usage
Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):
You can read more details in our
Responsible AI Policy
Pre-submission checklist
/reviewwith Claude Code)
(e.g.,
:owner,:admin,:editor,:viewer)