Skip to content

feat: contract revision and change history UI (#240) - #272

Open
olatechy0 wants to merge 1 commit into
Lumina-eX:mainfrom
olatechy0:feat/contract-revision-history-240
Open

olatechy0 wants to merge 1 commit into
Lumina-eX:mainfrom
olatechy0:feat/contract-revision-history-240

Conversation

@olatechy0

Copy link
Copy Markdown

Summary

Adds a read-only contract revision history so clients and freelancers can see every change made to a contract, who made it, and when.

Closes #240

What's included

  • lib/db/migrations/012_contract_revisions.sql — append-only contract_revisions table storing a full contract + milestone snapshot per revision. A trigger rejects UPDATE/DELETE so history cannot be altered. Existing contracts are backfilled with a baseline snapshot.
  • lib/contracts/revisions.ts — snapshot loading, diffing (budget, deadline, scope, status, currency), baseline bootstrapping and revision recording.
  • app/api/contracts/[id]/revisions/route.ts — GET only. Returns 404 for unknown contract/user and 403 unless the caller is the contract's client or freelancer.
  • app/api/milestones/[id]/route.ts — records a baseline (pre-change) and an update revision (post-change) around milestone edits, which is where budget, deadline and scope change.
  • components/dashboard/contract-revision-history.tsx — revision timeline with author and timestamp, expandable highlighted diffs, side-by-side milestone comparison, responsive on mobile and desktop.
  • app/dashboard/contracts/[id]/page.tsx — mounts the history section below the activity timeline.

Acceptance criteria

Criterion Where
Revisions are read-only DB trigger + GET-only route
Unauthorized users blocked 403 for non-participants on the revisions route
Budget / deadline / milestone / scope changes highlighted diffSnapshots() + colour-coded change rows
Author and timestamp per revision author_id/author_wallet joined to users, rendered per row
Compare current vs previous milestones Milestone diff list + "Milestones at vN" snapshot
Desktop and mobile Responsive Tailwind classes

Tests

  • __tests__/lib/contract-revisions.test.ts — 7 diff cases
  • __tests__/api/contract-revisions.test.ts — 6 route cases (read-only exports, 404s, 403, happy path, failure)
  • __tests__/components/contract-revision-history.test.tsx — 3 component cases

All 16 pass. eslint is clean on the changed files. The 3 failing test files in the full suite (deliverables, reviews, recommendations) fail identically on main before this branch.

@drips-wave

drips-wave Bot commented Nov 19, 2026

Copy link
Copy Markdown

@olatechy0 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

[Feature]: Contract Revision & Change History UI

1 participant