Skip to content

Implement version history and restore API endpoints #29

Description

@davstur

Overview

Build API endpoints to list version history for a topic and restore a previous version. The versions table and snapshot creation already exist (from #9, #21, #24). This adds the read + restore endpoints.

User Story

User Story: /docs/user-stories/active/version-history.md

As a user, I want to see a history of changes and restore any previous version, so I can undo AI changes I don't like.

Suggested Priority: high 🟠

Requirements

List Versions

  • GET /api/topics/{topic_id}/versions returns version history
  • Each version: id, action, created_at, target node label (from snapshot)
  • Sorted by created_at descending (newest first)

Get Version Snapshot

  • GET /api/topics/{topic_id}/versions/{version_id} returns full snapshot
  • Returns the nodes array from the JSONB snapshot field

Restore Version

  • POST /api/topics/{topic_id}/versions/{version_id}/restore
  • Creates a new version snapshot of current state (action="restore")
  • Deletes all current nodes for the topic
  • Inserts nodes from the snapshot
  • Returns the restored topic with nodes

Technical Approach

  • Versions table exists with topic_id, snapshot (JSONB), action, created_at
  • Restore flow: snapshot current → delete all nodes → insert from target snapshot → return
  • Use the same FK-aware delete order as _cleanup_partial_insert
  • The restored nodes need new UUIDs (can't reuse old IDs if they conflict)

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    high 🟠High priority - next milestone work✨ enhancementNew feature or capability

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions