Skip to content

refactor(web): move the funnel step builder into the page kit - #2171

Open
Makisuo wants to merge 5 commits into
mainfrom
refactor/funnel-step-builder-kit
Open

Makisuo wants to merge 5 commits into
mainfrom
refactor/funnel-step-builder-kit

Conversation

@Makisuo

@Makisuo Makisuo commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Moves the dashboard widget editor's funnel step builder into the page kit, so Product analytics (next in the stack) can mount the same editor.

  • apps/web/src/page/kit/funnel-steps.ts: the step schemas (StepDraft, StepKind, StepTextField), StepEdit with the pure edits it makes (applyStepEdit), the control ids and their parser, the combobox update, and stepBuilder, a view generic over the caller's message.
  • The widget editor keeps its attribute filter line and plugs it in through eventStepExtra. Its six step edits collapse into ProductEdit.Step({ scope, edit }).
  • Control ids are now step-<control>-<scope>-<index>. The combobox finds its input with the id in a CSS selector, so the ids can't contain :. A test pins that.

No behavior change for the dashboard editor.

Verification

  • bunx vitest run src/page/dashboards/widget src/page/kit/funnel-steps.test.ts: 43 tests pass, including the existing funnel and paths editor scene tests (session step demoted on reorder, paths anchor edits, step filter autocomplete).
  • tsrs --noEmit clean; oxlint -c .oxlintrc.effect.json, ui:index:check and ui:patterns:check pass.
  • Combobox suggestions and picks driven in a browser through the same kit builder in /lab/product-analytics (PR 2). The dashboard editor itself gets checked on the preview deploy.

Stack: this PR → #2172

Summary by CodeRabbit

  • New Features
    • Added a consistent step editor for funnel and paths panels. Funnel steps support event, page, and session types; paths panels retain a single event or page anchor.
    • Editors offer suggestions, page host fields, session-dimension controls, and options to add, remove, and reorder steps. Funnel additions respect the configured maximum.
  • Improvements
    • Moving a session step out of the first position changes it to an event step. Changing a step’s type resets its fields.

The dashboard widget editor's step builder (event, page or session steps,
their comboboxes and selects) becomes kit/funnel-steps: a view generic over
the caller's message, the step schemas, and StepEdit with the pure edits it
makes. The widget editor keeps its attribute filter line and plugs it in;
its six step edits collapse into ProductEdit.Step. No behavior change.

Product analytics (next) mounts the same builder.
@maple-review-bot

This comment has been minimized.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The pull request adds a shared funnel-step kit for step data, edit operations, and UI rendering. Dashboard funnel and paths editors now use the kit for step editing. Tests cover edit behavior and widget integration.

Changes: Funnel-step editing

Layer / File(s) Summary
Shared step model and edit operations
apps/web/src/page/kit/funnel-steps.ts, apps/web/src/page/dashboards/widget/product-edit.ts, apps/web/src/page/dashboards/widget/editor-state.ts, apps/web/src/page/dashboards/widget/lowering-product.ts, apps/web/src/page/kit/funnel-steps.test.ts
The kit defines step drafts, scoped edit operations, edit application, control-ID parsing, and combobox updates. Widget draft and edit types use the shared definitions. Tests cover edit application and control parsing.
Shared step builder UI
apps/web/src/page/kit/funnel-steps.ts, apps/web/src/page/dashboards/widget/view-steps.ts, apps/web/src/page/dashboards/widget/view-panels.ts, apps/web/src/page/dashboards/widget/view-product.ts, packages/views/src/ui/INDEX.md
The kit renders step inputs, suggestions, row actions, and add-step controls. The widget delegates step rendering to the kit and retains optional event-filter content. The UI index lists the kit.
Widget edit handling and validation
apps/web/src/page/dashboards/widget/product-apply.ts, apps/web/src/page/dashboards/widget/product-selects.ts, apps/web/src/page/dashboards/widget/product-step.ts, apps/web/src/page/dashboards/widget/where-fields.ts, apps/web/src/page/dashboards/widget/product.scene.test.ts, apps/web/src/page/dashboards/widget/where-fields.scene.test.ts
Widget select, combobox, and filter messages use shared step edits. The product update handler applies edits to funnel steps or the paths anchor. Tests exercise the shared edit shape.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Sequence Diagram(s)

sequenceDiagram
  actor User
  participant StepBuilder
  participant ProductSelectEdit
  participant ProductApply
  participant ApplyStepEdit
  User->>StepBuilder: Change a step control
  StepBuilder->>ProductSelectEdit: Send select message
  ProductSelectEdit->>ProductApply: Dispatch ProductEdit.Step
  ProductApply->>ApplyStepEdit: Apply edit to funnel steps
Loading
Merge Risk: Minimal · up to 4e9ab

This refactor moves the funnel step builder into a shared kit and reports no behavior change for the dashboard widget editor. No concrete defects were found in the supplied review context, and tests are reported passing. Merge risk is minimal; the dashboard editor still needs the planned manual check on the preview deploy.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "refactor(web): move the funnel step builder into the page kit" matches the main change. The PR moves the funnel step builder, its step schemas, StepEdit/applyStepEdit, control IDs, and comb…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "refactor(web): move the funnel step builder into the page kit" matches the main change. The PR moves the funnel step builder, its step schemas, StepEdit/applyStepEdit, control IDs, and combobox update logic from the dashboard widget into apps/web/src/page/kit/funnel-steps.ts. The widget files now delegate to this shared kit. The title is concise, specific, and describes a refactor. It does not mention the consolidation of ProductEdit step variants into ProductEdit.Step, but that is a secondary detail.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5b61525c-2903-4507-aca4-76fc68353cd4
Commits

Reviewing files that changed from the base of the PR and between 77be68f and 4e9ab8d.

Files selected for processing: 11

  • apps/web/src/page/dashboards/widget/editor-state.ts
  • apps/web/src/page/dashboards/widget/lowering-product.ts
  • apps/web/src/page/dashboards/widget/product-apply.ts
  • apps/web/src/page/dashboards/widget/product-edit.ts
  • apps/web/src/page/dashboards/widget/product-step.ts
  • apps/web/src/page/dashboards/widget/product.scene.test.ts
  • apps/web/src/page/dashboards/widget/view-steps.ts
  • apps/web/src/page/dashboards/widget/where-fields.ts
  • apps/web/src/page/kit/funnel-steps.test.ts
  • apps/web/src/page/kit/funnel-steps.ts
  • packages/views/src/ui/INDEX.md
Files skipped from review as they are similar to previous changes: 1

  • packages/views/src/ui/INDEX.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

The step edits arrive through the kit's control ids; this covers the
combobox and select paths end to end, not just the parsed ids.
@maple-review-bot

This comment has been minimized.

…builder-kit

# Conflicts:
#	apps/web/src/page/dashboards/widget/lowering-product.ts
#	apps/web/src/page/dashboards/widget/product-apply.ts
#	apps/web/src/page/dashboards/widget/product-selects.ts
#	apps/web/src/page/dashboards/widget/view-steps.ts
@maple-review-bot

This comment has been minimized.

@maple-review-bot

This comment has been minimized.

@maple-review-bot

maple-review-bot Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Maple review

🟢 Confidence 10/10 · safe to merge. Faithful move: each removed widget edit has an equivalent in the kit, and the pure edits and ids are pinned by tests.
no findings · tests covered · risk medium

Moves the funnel/paths step builder, its schemas and pure step edits into apps/web/src/page/kit/funnel-steps.ts, with the widget editor plugging its attribute filter line back in. The move is behavior-preserving and safe to merge.

  • applyStepEdit/applyAnchorEdit replace the widget's six step edits
  • Kit stepBuilder takes eventStepExtra for the widget's filter line
  • Control ids become step-<control>-<scope>-<index>, parsed by stepEditOf
  • ProductEdit.Step({ scope, edit }) carries every step edit

4e9ab8d · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant