Skip to content

Fix plan version history recording on sync and create#170

Merged
Tyru5 merged 3 commits into
mainfrom
cursor/fix-plan-version-history-bf69
Jul 18, 2026
Merged

Fix plan version history recording on sync and create#170
Tyru5 merged 3 commits into
mainfrom
cursor/fix-plan-version-history-bf69

Conversation

@Tyru5

@Tyru5 Tyru5 commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Plan History (Pro) looked broken because the main ingest path never wrote planVersions rows.

What was wrong

  • cli.upsertPlan (daemon / POST /api/cli/sync) incremented plans.version but never inserted into planVersions
  • Creates (publishPlan / upsertPlan) set version: 1 with no v1 snapshot, so the original content was not restorable after the first edit
  • Web publishPlan updates always versioned (including no-ops) and labeled snapshots as cli_sync

What changed

  • Added shared helpers in planVersioning.ts (recordPlanVersion, ensureBaselinePlanVersion, planContentChanged)
  • Snapshot v1 on create (CLI sync + web publish)
  • Write a cli_sync snapshot on every content-changing CLI upsert
  • Editor / publish paths write editor snapshots; skip no-op republishes
  • On first update of a plan with empty history, backfill the pre-change state so existing cloud rows can recover a baseline
  • Restore uses the same helper

Test plan

  • bun test packages/ee/convex/planVersioning.test.ts
  • bunx tsc --noEmit -p packages/ee/convex/tsconfig.json
  • bun run lint / bun run fmt:check
  • Manual: sync a new plan via CLI → history shows v1; edit locally and sync again → v2 appears with CLI sync badge
  • Manual: create/edit in cloud editor → versions labeled Edited; restore creates a new Restored version
Open in Web Open in Cursor 

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>
@Tyru5
Tyru5 marked this pull request as ready for review July 18, 2026 04:31
@greptile-apps

greptile-apps Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe 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 planContentChanged, backfill a baseline for legacy rows, and write properly labeled snapshots. The diff algorithm refactor is pure logic extraction with no behavioral regressions. The only note is that the no-op early return in publishPlan skips patching non-content live fields, but this is a minor inconsistency with the CLI path rather than a data-loss path in normal usage.

packages/ee/convex/plans.ts — publishPlan's no-op branch returns without updating agent/format/filePath/workspace, unlike the CLI equivalent.

Reviews (3): Last reviewed commit: "feat: render git-style hunks in plan ver..." | Re-trigger Greptile

Comment thread packages/ee/convex/cli.ts
Comment thread packages/ee/convex/planVersioning.ts
cursoragent and others added 2 commits July 18, 2026 04:42
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>
@Tyru5
Tyru5 merged commit e09db6d into main Jul 18, 2026
4 checks passed
@Tyru5
Tyru5 deleted the cursor/fix-plan-version-history-bf69 branch July 18, 2026 07:08
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