Skip to content
caliper ui pro docs

Sweep apply

Reviews a set of suggested changes to one file, hunk by hunk. Accept or reject each change, or sweep through all of them as a highlight travels down each hunk while it merges.

Pro

Fix: hold to confirm never fires

Three edits from Kofi Mensah's review of pull request #482

hold-to-confirm.tsx3 of 3 changes pending
Line 3
function HoldToConfirm({
label = "Hold to confirm",
Removed: duration = 1500,
Added: duration = 1000,
onConfirm,
}: HoldToConfirmProps) {
Line 11
function finish() {
if (progress >= 1) {
Removed: console.log("done");
Added: onConfirm?.();
}
}
Line 21
​
return (
Removed: <button aria-label="Hold" onPointerDown={() => (start.current = Date.now())}>
Added: <button aria-label={label} onPointerDown={() => (start.current = Date.now())}>
{label}
</button>

Nothing applied yet. Saving keeps the file as it is.

When to use

  • Reviewing an assistant's edits to a file before they are written.
  • Applying a set of suggested fixes where each one needs a yes or no.

When not to use

  • Comparing two files with no decision to make; use the file diff.
  • Merge conflicts, which need a third side to choose from.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/sweep-apply

Adds its 7 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

API reference

SweepApply

8 props
PropTypeDefaultDescription
refRef<SweepApplyHandle>—
path *string—
before *string—
after *string—
languageCodeLanguage—
contextnumber2Unchanged lines kept around each change.
onChange((change: SweepApplyChange) => void)—
classNamestring—

countSweepChanges

0 props

No props of its own; it accepts the native props of its root element.

Keyboard

  • No custom key handling; Tab and the native activation keys do the work.

Accessibility

It exposes status and region semantics, with aria-hidden and aria-label kept in step with state. Changes that matter are announced through a live region.

Notes for AI

Give your coding assistant this page as Markdown instead of screenshots: the props, keyboard and examples in one file.

/docs/components/sweep-apply.md

The index of every part is at /llms.txt.

More in Developer tools