Diff
src/notes/sync.ts+5 lines added−1 lines removed
for (const note of queue) {
Removed: await api.save(note)
Added: const saved = await api.save(note).catch(() => null)
Added: if (!saved) {
Added: offline.push(note)
Added: continue
Added: }
synced.add(note.id)
}
pnpm dlx shadcn@latest add @sortui/diffUsage
import {
Diff,
DiffHeader,
DiffTitle,
DiffStats,
DiffContent,
} from "@/components/ui/diff"Examples
Split
src/billing/invoice.ts+5 lines added−4 lines removed
export function invoiceTotal(items: LineItem[]) {
Removed: let total = 0
Removed: for (const item of items) total += item.price
Removed: return total
}
export function dueDate(issued: Date) {
@@ -21,3 +22,3 @@
export function invoiceTitle(invoice: Invoice) {
Removed: return "Invoice " + invoice.number
}
export function invoiceTotal(items: LineItem[]) {
Added: return items.reduce(
Added: (total, item) => total + item.price * item.quantity,
Added: 0
Added: )
}
export function dueDate(issued: Date) {
@@ -21,3 +22,3 @@
export function invoiceTitle(invoice: Invoice) {
Added: return `Invoice ${invoice.number} · ${invoice.customer}`
}
From two versions
package.json+6 lines added−5 lines removed
{
"name": "notes-app",
Removed: "version": "2.3.0",
Added: "version": "2.4.0",
"private": true,
"scripts": {
Removed: "dev": "next dev",
Removed: "build": "next build"
Added: "dev": "next dev --turbopack",
Added: "build": "next build",
Added: "test": "vitest"
},
"dependencies": {
Removed: "next": "15.4.0",
Removed: "react": "19.1.0"
Added: "next": "16.0.0",
Added: "react": "19.2.0"
}
}
Folded context
src/notes/notes.ts+3 lines added−1 lines removed
title: string
body: string
Added: pinned: boolean
updatedAt: Date
}
title,
body: "",
Added: pinned: false,
updatedAt: new Date(),
}
export function noteUrl(note: Note) {
Removed: return "/notes/" + note.id
Added: return `/notes/${slugify(note.title)}-${note.id}`
}
Review an agent's edit
src/notes/search.ts+10 lines added−3 lines removed
export function searchNotes(notes: Note[], query: string) {
Removed: const q = query.toLowerCase()
Removed: return notes.filter((note) => note.title.toLowerCase().includes(q))
Added: const q = query.trim().toLowerCase()
Added: if (!q) return notes
Added: return notes.filter(
Added: (note) =>
Added: note.title.toLowerCase().includes(q) ||
Added: note.body.toLowerCase().includes(q)
Added: )
}
export function sortNotes(notes: Note[]) {
Removed: return [...notes].sort((a, b) => b.updatedAt - a.updatedAt)
Added: return [...notes].sort(
Added: (a, b) => Number(b.pinned) - Number(a.pinned) || b.updatedAt - a.updatedAt
Added: )
}