-
Notifications
You must be signed in to change notification settings - Fork 82
Lifecycle editor UI: state badge, Go live, Switch to draft#4873
Merged
Merged
Conversation
Surfaces the workflow lifecycle in the collaborative editor: - draft/live badge and a state-driven primary action (Go live when a draft, Switch to draft with a confirmation when live). - A Session transition (set_workflow_state) that flips state + trigger enablement and persists with the document in one save, reconciled into the Y.Doc; driven by go_live / switch_to_draft channel events. - The workflow's state is serialized to the editor and read via a new useSessionWorkflow hook; after a transition the session context is re-fetched so the badge and read-only lock update. Completes #4857
@github-project-automation
github-project-automation
Bot
moved this to New Issues
in Core
Jun 16, 2026
Security Review ✅
- S0 (project scoping): New
set_workflow_state/3reusesdo_save_workflow, which resolves the workflow againststate.workflow.project_id(set at session join from the project-scopedload_workflow/WorkflowResolver), never from client params. - S1 (authorization): Both new
handle_in("go_live", ...)andhandle_in("switch_to_draft", ...)dispatch throughtransition_lifecycle_state/2atlib/lightning_web/channels/workflow_channel.ex:1110, which gates onauthorize_edit_workflow/1(:edit_workflowpolicy, restricted to:owner/:admin/:editor). - S2 (audit trail): Lifecycle transitions flow through the shared
save_workflowmulti, whosemaybe_audit_workflow_state_changes/2recordsenabled/disabledaudit events whenupdate_triggers_enabled_state/2flips trigger state — matching the existingWorkflows.go_live/2andswitch_to_draft/2audit behavior.
Run (test) is only meaningful in editable states (draft, sandbox). It is now hidden when the editor is read-only, matching the concept where live and archived states have no Run action. Part of #4857
The Header now reads the session-context workflow via useSessionWorkflow; the keyboard test mocks useSessionContext, so it needs the new export or the Header throws on render. Part of #4857
Codecov Report
✅ All modified and coverable lines are covered by tests.
sandbox-devx@60709be). Learn more about missing BASE report.
Additional details and impacted files
@@ Coverage Diff @@ ## sandbox-devx #4873 +/- ## ============================================== Coverage ? 90.6% ============================================== Files ? 445 Lines ? 22736 Branches ? 0 ============================================== Hits ? 20593 Misses ? 2143 Partials ? 0
☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.
🚀 New features to boost your workflow:
- ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
- 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
Channel tests drive go_live and switch_to_draft (happy path + unauthorized rejection) through a joined socket, covering the handlers and transition_lifecycle_state. A session test covers the no-shared-doc error branch of the shared save pipeline. Part of #4857
Adds a test that triggers an interpolated changeset error (concurrency < 1) to cover the error-formatting path, and wraps the two genuinely-defensive save branches (:wrong_project, documented unreachable; :deserialization_failed, a catch-all rescue) in coveralls-ignore, matching the repo convention. Part of #4857
@github-project-automation
github-project-automation
Bot
moved this from New Issues
to Done
in Core
Jun 17, 2026
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.
Uh oh!
There was an error while loading. Please reload this page.
Description
Final slice for #4857: surfaces the workflow lifecycle in the collaborative editor and wires the transitions end to end.
draft/livebadge in the editor header.Session.set_workflow_state/3transition that flips the lifecycle state and trigger enablement and persists them with the document in a single save, reconciled back into the Y.Doc. It reuses the existing save pipeline (do_save_workflow), so going live and switching to draft are atomic and consistent with the collaborative session. Driven by newgo_live/switch_to_draftchannel events.stateis now serialized to the editor (Jason.Encoderderive +BaseWorkflowschema) and read via a newuseSessionWorkflowhook. After a transition the session context is re-fetched so the badge and the read-only lock update immediately.Closes #4857
Validation steps
Additional notes for the reviewer
The state lives on the DB row, not the Y.Doc (it gates editing globally, not per-edit). Transitions go through the Session GenServer (like
save_workflow) so the trigger and lock-version changes reconcile into the live document. Verified: backend session/channel/workflows tests pass; frontend type-checks (changed files), bundle builds, store/editor suites pass. Recommend a manual run-through of the three validation steps before merge.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)
(transitions reuse the role-based
:edit_workflowauthorization)