Skip to content

feat: undo/redo for plan and context edits via edit_history #21

Description

@jlunder00

What

The edit_history table exists in the schema but is never written to. Implement it so the UI (and potentially the bot) can undo/redo mutations.

Changes needed

DB (db/queries.py)

  • Write before/after snapshots to edit_history on every mutation:
    • upsert_tasks — record old task list as before_json, new as after_json
    • upsert_context_entry — record old body / new body
    • patch_anchor — record changed fields
  • Add get_edit_history(db_path, table_name?, limit?) query
  • Add rollback_edit(db_path, history_id) — re-applies before_json

API

  • GET /api/history?table=tasks&limit=20 — return recent edits
  • POST /api/history/{id}/undo — rollback that entry, broadcast WS update

Frontend

  • Undo/redo keyboard shortcuts (Ctrl+Z / Ctrl+Shift+Z) in PlanEditor and ContextEditor
  • Or a simple "Undo last edit" button per section

Notes

  • Scope to plan tasks and context entries for now (anchors less critical)
  • history entries should be scoped to today's session or last N edits — not unbounded
  • Bot mutations via apply_mutations should also write history so bot edits are undoable

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions