Stale Attachment Check

Flags an attachment that looks like an older copy, e.g. report_v2.pdf attached while report_v3_final.pdf was edited today.

StopsOld draft attached instead of final

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/stale-attachment-check.json

The files land in your project. They're yours to edit.

Usage

stale-attachment-check-usage.tsx
import { StaleAttachmentCheck, type StaleFile } from "@/components/ui/stale-attachment-check"

<StaleAttachmentCheck
  defaultValue={attached}
  nearby={folder}
  subject="Q3 report and minutes, 10 Oct"
  now={NOW}
  locale="en-IN"
  onSend={(files) => setSent(files.map((file) => file.name).join(", "))}
/>

What it catches

  • A newer file of the same document nearby
  • Names containing draft, old, copy or (1)
  • Office lock files (~$…)
  • Files last modified before a date named in the subject
  • One-tap swap to the newer file, with Undo

Props

StaleAttachmentCheck props
PropTypeDefault
value

Controlled attachments.

StaleFile[]—
defaultValue

Initial attachments when uncontrolled.

StaleFile[][]
onValueChange

Called with the new list after a swap or undo.

(files: StaleFile[]) => void—
nearby

Files beside the attachments: the same folder, drive or recent files.

StaleFile[][]
subject

The email subject, for "Minutes 14 Oct" style dates.

string""
now

"Now" in epoch ms, for deterministic rendering. Read from the clock after mount when omitted.

number—
graceDays

Days an edit may come before the subject's date without a warning ("deck for today's meeting").

number1
locale

Locale for dates.

string—
onSend

Called on Send. With warnings left, the first click jumps to them and the second sends. May return a Promise.

(files: StaleFile[]) => void | Promise<void>—
messages

Any visible string.

Partial<StaleAttachmentMessages>—

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Summary in a polite live region; status shown with icon and text
  • Focus moves to the next fix, Undo or Send as issues are resolved
  • Fix and Undo are labelled buttons

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • Only sees the nearby files you pass; it can't browse folders
  • Name matching ignores filler words, so different documents with similar names can be confused
  • Modified dates can be wrong after copying or syncing

What it stops

Old draft attached instead of final

Also known as

attachment · file version · final_final · email attach · upload · compose · proposal · invoice pdf

Field type

Dependencies

Pairs well with