Fix plan version history recording on sync and create#170
Conversation
CLI sync was bumping plans.version without writing history rows, and creates never snapshotted v1, so Plan History stayed empty for the common path. Centralize snapshot writes and backfill a baseline when updating plans that have no history yet. Co-authored-by: Tyrus Malmström <tyrusM@hotmail.com>
Confidence Score: 5/5Safe to merge. The core versioning logic is correct across all write paths and the previous review gaps (no-op guard on CLI upsert, missing source label on backfill rows) are now addressed. All three mutation paths (CLI upsert, web publish, editor save) correctly guard with packages/ee/convex/plans.ts — Reviews (3): Last reviewed commit: "feat: render git-style hunks in plan ver..." | Re-trigger Greptile |
Skip planVersions bumps in upsertPlan when title/content are unchanged, still patching identity and path fields. Tag baseline history rows with source backfill so the drawer shows "Initial snapshot". Co-authored-by: Tyrus Malmström <tyrusM@hotmail.com>
Replace the flat Myers line list with numbered unified diffs, @@ hunk headers, expandable collapsed context, and a diff --git style header that includes title changes when present. Co-authored-by: Tyrus Malmström <tyrusM@hotmail.com>
Summary
Plan History (Pro) looked broken because the main ingest path never wrote
planVersionsrows.What was wrong
cli.upsertPlan(daemon /POST /api/cli/sync) incrementedplans.versionbut never inserted intoplanVersionspublishPlan/upsertPlan) setversion: 1with no v1 snapshot, so the original content was not restorable after the first editpublishPlanupdates always versioned (including no-ops) and labeled snapshots ascli_syncWhat changed
planVersioning.ts(recordPlanVersion,ensureBaselinePlanVersion,planContentChanged)cli_syncsnapshot on every content-changing CLI upserteditorsnapshots; skip no-op republishesTest plan
bun test packages/ee/convex/planVersioning.test.tsbunx tsc --noEmit -p packages/ee/convex/tsconfig.jsonbun run lint/bun run fmt:check