Add actionId vocabulary to CanonicalDiff (back-compat with diffId)#21
Merged
Add actionId vocabulary to CanonicalDiff (back-compat with diffId)#21
Conversation
Data Machine unified its preview primitive on a generic "pending action" model (DM PR #1171, editor PR #5): any tool invocation can now stage → preview → resolve through a single /actions/resolve endpoint and a single action_id, not just the three content-diff tools (edit_post_blocks / replace_post_blocks / insert_content) that originally drove the v0.7 diff primitive here. The chat package was only reading `diffId` / `diff_id` from tool result payloads, so preview cards now render with an empty id and Accept/Reject callbacks deliver an empty string. This breaks every consumer that wires those callbacks to a resolve endpoint. Fix: - Add `actionId` as the canonical field on CanonicalDiffData. - Keep `diffId` as a deprecated alias, always populated with the same value as `actionId`, so consumers still reading `diff.diffId` keep working through one more major version. - parseCanonicalDiff now reads, in priority order: actionId → action_id → container.action_id → diffId → diff_id → container.diff_id. The result populates BOTH actionId and diffId with the same resolved string. - DiffCard's onAccept / onReject callbacks fire with `diff.actionId || diff.diffId` so the right id gets delivered regardless of which field the consumer wrote. Docblock example updated to show the new /actions/resolve + action_id shape. No breaking changes — strictly additive.
This was referenced Apr 24, 2026
Merged
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
Data Machine unified its preview primitive on a generic "pending action" model (DM #1171, editor #5). Any tool invocation can now stage → preview → resolve through a single
/actions/resolveendpoint and a singleaction_id— not just the three content-diff tools (edit_post_blocks/replace_post_blocks/insert_content) that originally drove the v0.7 diff primitive in this package.Server-side
CanonicalDiffPreview::build()now emitsactionIdon the diff payload. This package was only readingdiffId/diff_id, so:parseCanonicalDiffreturnsdiffId: ''on every fresh preview payload.DiffCard'sonAccept/onRejectcallbacks fire with an empty string.Fix
Add
actionIdas the canonical field onCanonicalDiffData.Keep
diffIdas a deprecated alias, always populated with the same value asactionId, so consumers still readingdiff.diffIdkeep working through one more major version.parseCanonicalDiffreads, in priority order:rawDiff.actionIdrawDiff.action_idcontainer.action_idrawDiff.diffIdrawDiff.diff_idcontainer.diff_idThe resolved string populates both
actionIdanddiffIdon the returnedCanonicalDiffData.DiffCard'sonAccept/onRejectnow fire withdiff.actionId || diff.diffIdso the right id gets delivered regardless of which field the consumer wrote.Docblock example updated to show the new
/actions/resolve+action_idshape.Compat
diff.diffIdkeep working.onAccept(id)/onReject(id)callback keep working — they now get the right id even when the backend sentactionId.diff.actionIdon their schedule. ThediffIdalias can be removed in a future major.Validation
npm run build(tsc) passes cleanly.diffId/action_id/diff_id.Downstream
data-machine-frontend-chathas a companion PR that updates its resolve call to/actions/resolvewithaction_idand bumps the chat dep — depends on this PR.ChatSidebar.jsxonly usescopyChatAsMarkdown/useChat, not the diff primitives, so no change needed there.AI assistance
CanonicalDiffPreview::build()to this package's parser, drafted the additive alias design, and verified no other internal call sites referencediffId. Chris flagged the audit target.