Skip to content

AI-First Starting UX: Templates path#4912

Open
lmac-1 wants to merge 8 commits into
4868-build-with-aifrom
4870-ai-first-templates-path
Open

AI-First Starting UX: Templates path#4912
lmac-1 wants to merge 8 commits into
4868-build-with-aifrom
4870-ai-first-templates-path

Conversation

@lmac-1

@lmac-1 lmac-1 commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR wires up the "Browse templates" flow for the AI-first epic. When a user clicks "Browse templates" on the landing screen, a modal opens showing base templates and any saved user templates. Clicking a template card closes the modal, navigates to the canvas and creates a new workflow in the database - unlike the existing templates flow which only populates the editor client-side to preview.

The modal is built as two components by design: TemplateBrowserModal (pure presentational, plain props) and TemplateBrowserModalWrapper (Phoenix channel + store wiring). This keeps the UI easy to iterate on without needing the full Lightning infrastructure. Product has requested to make this part of the app as decoupled as possible so that they can easily iterate on templates and improve the UI very easily.

Key decisions

  • Base templates are always shown regardless of search query (same as existing behaviour)
  • Search behaviour follows the same pattern as the existing flow
  • No debounce - filtering is in-memory so live-on-keystroke is fine

Closes #4870

Validation steps

  1. Go to Create a new workflow
  2. Click Browse templates
  3. Opens modal with templates
  4. Search for a template and leave something written in search
  5. Check that you can close the modal with X and Esc
  6. Reopen modal and make sure nothing is in search bar
  7. Searching filters templates on title/description/tags
  8. Clicking on a template will close the modal, create a new workflow in the database automatically and show you the workflow on the canvas

Additional notes for the reviewer

  1. TemplateBrowserModal has no Lightning imports — it can be rendered in isolation (Storybook, tests) without a Phoenix channel or Y.Doc store. TemplateBrowserModalWrapper is the only place that touches hooks/store, following the AIAssistantPanel / AIAssistantPanelWrapper pattern already in the codebase.
  2. We will be cleaning up the dead code in AI-First Starting UX: Cleanup — remove old canvas entry points #4876. I've kept this PR tight to make it easier to review.
  3. Known issue: if saveWorkflow fails after importWorkflow has already run (e.g. a network error mid-select), the canvas is left with the template's nodes loaded but no database record behind them and creates a weird landing page state. This affects both the template browser and the existing YAML import flow. Will fix in a follow-up.

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review
    with Claude Code)
  • I have implemented and tested all related authorization policies.
    (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

lmac-1 added 4 commits June 30, 2026 13:16
Clicking "Browse templates" on the /new landing screen opens a modal
listing base templates (webhook + cron) plus any user-created templates.
Clicking a template creates the workflow immediately and dismisses the
landing screen — no separate confirm step.

- Add showTemplateBrowserModal state + open/close actions to UIStore
- Add WorkflowTemplateBrowserModal component (lazy fetch on open,
  one-click create, Escape to close, responsive grid + panel width)
- Connect LandingScreen.onBrowseTemplates to the new modal
… UI and Lightning wrapper

The original component mixed UI rendering with Phoenix channel fetching,
Y.Doc workflow imports, and global store hooks — making it impossible to
render or iterate on in isolation (Storybook, tests, or a plain React context)
without standing up the full collaborative editor infrastructure.

Split into two components:
- TemplateBrowserModal: pure presentational modal, takes only plain props,
  no Lightning dependencies. Product can open this file and iterate freely.
- TemplateBrowserModalWrapper: thin wiring layer that connects the modal to
  the Phoenix channel, Y.Doc workflow store, and global UI state.

Also fixes isSaving not being reset on successful template selection, and
clears the search query each time the modal opens.
@github-project-automation github-project-automation Bot moved this to New Issues in Core Jun 30, 2026
@lmac-1 lmac-1 changed the base branch from main to 4868-build-with-ai June 30, 2026 18:23
lmac-1 added 4 commits July 1, 2026 09:19
… set

When saveWorkflow({ silent: true }) was called from the template browser
or YAML import flows, handleSaveError would fire a toast before re-throwing,
causing a second toast alongside the caller's own error message.

Extends the silent flag to the error path so callers that pass silent: true
own their own error messaging.
… subscription, move query normalisation to call site
@lmac-1 lmac-1 marked this pull request as ready for review July 1, 2026 13:02
@lmac-1 lmac-1 requested a review from stuartc July 1, 2026 13:02
@lmac-1

lmac-1 commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator Author

@stuartc Hey Stu, this is ready for review, hopefully should be straightforward. I've done a couple of Claude reviews. Don't merge when/if you approve as there's an order to the PRs (this is a child of the Build with AI stuff). Thanks!

@nintyboy

nintyboy commented Jul 1, 2026

Copy link
Copy Markdown

Hey @lmac-1 I've popped together a loom for the design review: https://www.loom.com/share/60adb69177b344fbbb73b0c6e1dbc909

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Security Review ✅

  • S0 (project scoping): N/A — PR is pure frontend (React/TS in assets/js/collaborative-editor/); no new/modified Ecto queries or backend entrypoints touching project-scoped resources.
  • S1 (authorization): N/A — no new backend actions or handle_event clauses; template selection reuses the existing fetchTemplates channel call and saveWorkflow action already gated server-side.
  • S2 (audit trail): N/A — no config-resource writes changed; template import flows through the pre-existing saveWorkflow path whose audit behavior is unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: New Issues

Development

Successfully merging this pull request may close these issues.

2 participants