Skip to content

feat(cloud): author step undo (compensation) in the workflow editor - #401

Merged
mohabbis merged 1 commit into
masterfrom
feat/compensation-authoring-ui
Aug 4, 2026
Merged

feat(cloud): author step undo (compensation) in the workflow editor#401
mohabbis merged 1 commit into
masterfrom
feat/compensation-authoring-ui

Conversation

@mohabbis

@mohabbis mohabbis commented Aug 4, 2026

Copy link
Copy Markdown
Owner

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 and apps/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 passed compensateRun.test.ts (15 tests) 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 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, 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 field (shown to whoever approves the reversal).
  • An ordered list of undo actions (navigate/click/fill/select/waitFor), each with the same selector fields a forward step already uses.
  • An optional verify assertion that the reversal actually took effect.

Also 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 (different addressing — a step index vs. a step index and an action index). No behavior change to the two existing call sites; rendered aria-label strings 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:

  • Manually verified end-to-end in a live browser session: authored a click step's undo (description, one click action targeting a name selector, a textPresent verify assertion), saved the workflow, confirmed the persisted WorkflowVersion.steps JSON matches compensationSchema exactly via a direct psql query, then reopened the editor and confirmed every field (description, action selector, verify kind + expected text) reloads correctly.
  • pnpm typecheck clean.
  • pnpm lint clean (no new warnings).
  • Full pnpm test against a clean, isolated Postgres/Redis: 258/258 pass (unchanged — this PR adds no automated tests, by necessity above, but doesn't regress any).
  • pnpm build clean.

cloud/docs/CURSOR_HANDOFF.md updated to correct the stale entry and record what's actually closed vs. what was genuinely already done.

🤖 Generated with Claude Code

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>
@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ghost Ready Ready Preview Aug 4, 2026 2:32am

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@mohabbis
mohabbis merged commit c1696f2 into master Aug 4, 2026
8 checks passed
@mohabbis
mohabbis deleted the feat/compensation-authoring-ui branch August 4, 2026 02:38
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