feat(cloud): author step undo (compensation) in the workflow editor - #401
Merged
Conversation
Closes what turned out to be a stale Phase 1 item. The reversal engine was already complete and tested: packages/core/src/runtime/compensate.ts's planner and apps/worker/src/jobs/compensateRun.ts's job (journal verification, in-flight detection, COMPENSATION-phase approval gating, re-entrant execution, incident handling, audit trail) have existed and passed compensateRun.test.ts since PR #374. What was actually missing: a step is only reversible if its workflow definition carries a `compensate` block, and workflow-editor.tsx had no fields to author one at all — grepped the whole web app and found zero UI references to "compensate". So every workflow anyone actually created through the product had zero reversible steps, regardless of the engine underneath. Adds undo authoring to the step editor for click/fill/select — the only editable step types with a side effect to reverse, matching hasSideEffect in @ghost/core/compensate: - an optional "Add undo for this step" panel per step, absent by default (an unreversed step is still honestly reported as irreversible, never silently assumed complete) - a description (shown to whoever approves the reversal) - an ordered list of undo actions (navigate/click/fill/select/waitFor), each with the same selector fields as a forward step - an optional verify assertion that the reversal actually took effect Refactored SelectorFields to take a plain onChange callback instead of an (index, updateSelector) pair, so the same component serves both a step's own selector and a selector nested inside one of its undo actions — those two have different addressing (a step index vs. a step index *and* an action index) that the old signature couldn't express. No behavior change to the existing two call sites; the rendered aria-label strings are byte-identical. No component-testing infra exists in this codebase (no testing-library/jsdom in apps/web), so this can't get an automated test in the established style. Instead, manually verified end-to-end in a browser: authored a click step's undo (description, one click action, a textPresent verify assertion), saved, confirmed the persisted WorkflowVersion.steps JSON matches compensationSchema exactly via a direct DB query, then reloaded the editor and confirmed every field round-trips correctly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Summary
Closes what turned out to be a stale Phase 1 item ("Compensation / undo handlers"). The reversal engine was already complete and tested —
packages/core/src/runtime/compensate.ts's planner andapps/worker/src/jobs/compensateRun.ts's 589-line job (journal verification, in-flight detection,COMPENSATION-phase approval gating, re-entrant execution, incident handling, audit trail) have existed and passedcompensateRun.test.ts(15 tests) since PR #374.What was actually missing: a step is only reversible if its workflow definition carries a
compensateblock, andworkflow-editor.tsxhad zero fields to author one — I grepped the whole web app and found no UI references to "compensate" at all. So every workflow anyone actually created through the product ended up with zero reversible steps, regardless of the fully-built engine underneath.What's in this PR
Adds undo authoring to the step editor for
click/fill/select— the only editable step types with a side effect to reverse, matchinghasSideEffectin@ghost/core/compensate:Also refactored
SelectorFieldsto take a plainonChangecallback instead of an(index, updateSelector)pair, so the same component serves both a step's own selector and a selector nested inside one of its undo actions (different addressing — a step index vs. a step index and an action index). No behavior change to the two existing call sites; renderedaria-labelstrings are byte-identical.Test plan
No component-testing infra exists in this codebase (no testing-library/jsdom in
apps/web), so this can't get an automated test in the established style. Instead:textPresentverify assertion), saved the workflow, confirmed the persistedWorkflowVersion.stepsJSON matchescompensationSchemaexactly via a directpsqlquery, then reopened the editor and confirmed every field (description, action selector, verify kind + expected text) reloads correctly.pnpm typecheckclean.pnpm lintclean (no new warnings).pnpm testagainst a clean, isolated Postgres/Redis: 258/258 pass (unchanged — this PR adds no automated tests, by necessity above, but doesn't regress any).pnpm buildclean.cloud/docs/CURSOR_HANDOFF.mdupdated to correct the stale entry and record what's actually closed vs. what was genuinely already done.🤖 Generated with Claude Code