Skip to content

feat(ui): surface control version history and restore in edit modal#198

Open
lan17 wants to merge 5 commits intomainfrom
feature/control-version-history-ui
Open

feat(ui): surface control version history and restore in edit modal#198
lan17 wants to merge 5 commits intomainfrom
feature/control-version-history-ui

Conversation

@lan17
Copy link
Copy Markdown
Contributor

@lan17 lan17 commented Apr 25, 2026

Summary

This PR surfaces control version history directly inside the existing Edit Control modal and adds restore-to-version support for active controls.

Users can now open a control, switch to a History tab, inspect saved revisions, see what changed in each version, and restore an older version in place without leaving the modal.

User experience

Entry point

  • Version history is available from the existing Edit Control modal.
  • The modal now has two tabs: Editor and History.

History view

  • Versions are listed newest-first.
  • The current saved version is labeled Current.
  • Each version shows its event type and timestamp.
  • Selecting a version shows a diff against its immediate predecessor.
  • The diff view includes:
    • a change summary
    • changed field paths with before/after values
    • expandable raw JSON for deeper inspection

Restore flow

  • Users can restore a selected historical version from the History tab.
  • Restore overwrites the current saved control in place on the same control record.
  • A successful restore records a new latest version with event type restored.
  • After restore, the modal updates to the new saved state and the version list refreshes immediately.

Product behavior and business rules

Diff behavior

  • The selected historical version is diffed against its immediate predecessor.
  • Restore eligibility is determined by comparing the selected version against the current saved version.
  • The first recorded version has no predecessor diff and is shown as an initial version.

Restore eligibility

Restore is unavailable when:

  • the selected version is already the current saved version
  • the selected version is equivalent to the current saved control after canonicalization
  • the current saved version cannot be loaded
  • the selected historical version cannot be loaded

Unsaved edits

  • If the editor has unsaved local changes, restore shows a destructive confirmation first.
  • Confirming restore discards unsaved draft changes in the modal and applies the selected saved version.

Validation rules on restore

Restore uses current validation rules, not historical ones.

That means restore can fail if the historical snapshot:

  • is no longer parseable under current schemas
  • contains a control name that is no longer valid under current naming rules
  • conflicts with another active control name
  • fails current control-definition validation

No-op restore behavior

  • If a selected historical version already matches the current saved control, restore becomes unavailable in the UI.
  • On the backend, equivalent restore requests are treated as no-ops and do not create a new version.

Scope limits in v1

  • This is v1 for active controls.
  • Deleted control snapshots are not restorable in this PR.

Implementation notes

This PR also hardens the restore path so that:

  • preserved unknown snapshot fields round-trip correctly
  • restored payloads are re-persisted canonically instead of replaying legacy shapes verbatim
  • generated UI and SDK contracts expose the restore API cleanly
  • normal edits and restore flows keep UI caches in sync

Screenshots

Screenshots from a local end-to-end run are in this comment:

Validation

  • make check
  • pnpm run prettify:check in ui/
  • make ui-lint
  • make ui-typecheck
  • make sdk-ts-typecheck
  • make sdk-ts-test
  • fresh GPT-5.5 / xhigh review rounds, final round returned clean

@lan17 lan17 marked this pull request as ready for review April 25, 2026 05:23
@lan17 lan17 changed the title feat: surface control version history in edit UI feat(ui): surface control version history and restore in edit modal Apr 25, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

❌ Patch coverage is 90.81272% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...control_server/services/control_data_validation.py 92.17% 14 Missing ⚠️
...ver/src/agent_control_server/endpoints/controls.py 74.28% 9 Missing ⚠️
...erver/src/agent_control_server/endpoints/agents.py 78.57% 3 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor Author

lan17 commented Apr 25, 2026

UI demo screenshots from a local end-to-end run against this branch using a seeded version-history-demo agent.

Editor

History diff

Restore confirmation

Post-restore state

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