Skip to content

feat(paywalls): round-trip state_declarations through AI paywall editing - #161

Merged
azvaliev merged 3 commits into
mainfrom
azatvaliev/pwai-422-cli-state-declarations
Sep 2, 2026
Merged

feat(paywalls): round-trip state_declarations through AI paywall editing#161
azvaliev merged 3 commits into
mainfrom
azatvaliev/pwai-422-cli-state-declarations

Conversation

@azvaliev

@azvaliev azvaliev commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

AI Paywall Editor will be able to start editing these, so we want to send and save


Note

Medium Risk
Changes paywall draft PATCH semantics (omit vs null vs {}) and AI session persistence; mistakes could clear declarations, though behavior is heavily covered by tests.

Overview
Adds state_declarations to the paywall components API and wires it through the CLI’s Paywalls AI edit/generate flows so the editor can read and update typed paywall state keys.

The OpenAPI spec and generated client types now expose state_declarations on component versions and on draft PATCH bodies, with discriminated StateDeclaration variants (boolean, integer, double, string). Hand-written API structs mirror that field for expanded GETs and PaywallDraftUpdate.

Paywalls AI sessions carry declarations in PaywallData, seed new drafts with {}, load them from the server when resuming or refreshing revision checks, and hydrate older session files from the current draft so dashboard-authored declarations are not replaced with empty objects. When persisting, presentJSON omits absent/null values from PATCH (server keeps stored declarations) while still sending {} to the editor when the API returns null (legacy drafts). Editor events that omit declarations no longer clear the session; echoed values update it. Tests cover JSON marshaling, edit round-trip, legacy sessions, and never PATCHing explicit null.

Reviewed by Cursor Bugbot for commit c640ac4. Bugbot is set up for automated code reviews on this repo. Configure here.

@azvaliev

This comment has been minimized.

@azvaliev

This comment has been minimized.

@azvaliev

This comment has been minimized.

cursor[bot]

This comment was marked as outdated.

chatgpt-codex-connector[bot]

This comment was marked as outdated.

claude[bot]

This comment was marked as outdated.

@azvaliev

This comment has been minimized.

@azvaliev

This comment has been minimized.

@azvaliev

This comment has been minimized.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: f40f822dd1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f40f822. Configure here.

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review found no issues

No high-confidence issues detected in this change.

@azvaliev
azvaliev marked this pull request as ready for review August 29, 2026 14:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-29T14:44:51.523408Z f40f822 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f40f822dd1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/cli/paywalls_ai.go
…ersion

The checked-in v2 snapshot predates khepri's schema change, so the
components-version response schema didn't admit the state_declarations
field the live endpoint already returns. Mirror the khepri definition
(required nullable map of discriminated StateDeclaration variants)
until the published spec catches up and spec-sync converges.

Copied from khepri @ cf3f5ea523aee8d5cffb27dd37437380e9a73889.
@azvaliev
azvaliev force-pushed the azatvaliev/pwai-422-cli-state-declarations branch from 4358ad2 to c640ac4 Compare August 29, 2026 15:03
@azvaliev
azvaliev requested a review from joshdholtz August 31, 2026 14:44

@joshdholtz joshdholtz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! :shipit:

@azvaliev
azvaliev merged commit 1a3d282 into main Sep 2, 2026
5 checks passed
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.

2 participants