Injection warningPro
Marks content from a page, file, email or tool result that tried to instruct the agent, shows the injected text in place and what the agent ignored.
On this page
Installation
Usage
import { InjectionWarning } from "@/components/ui/chatcn/pro/injection-warning"
<InjectionWarning
source={{ kind: "page", title: "Plans and pricing" }}
excerpt={passage}
injection={injectedText}
hiddenAs="white text on a white background"
asked={["Open an upgrade link for 40 seats"]}
outcome="Kept comparing the three plans."
/>The passage shows as the agent read it with the injected text fenced in a hatched amber mark, revealed when it was hidden from people (hiddenAs). The instructions it gave are struck through, and outcome says what the agent did instead. Status scanning while a source is checked, blocked when the agent ignored it, paused when it stopped to ask (with Keep ignoring and Allow once), and allowed after a person let it through. Use variant="inline" inside a message: one quiet line that opens in place.
Examples
States
Props
| Prop | Type | Notes |
|---|---|---|
source | { kind, title, url? } | page, file, email or tool |
excerpt, injection | string | The passage, and the injected text inside it |
hiddenAs | string | How it was hidden from people |
asked | string[] | What it told the agent to do |
outcome | ReactNode | What the agent did instead |
status | "scanning" | "blocked" | "paused" | "allowed" | Default blocked |
variant | "card" | "inline" | Default card |
open, defaultOpen, onOpenChange | boolean | Cards open by default, inline closed |
onAllow, onIgnore | () => void | Paused only |
onViewSource, onReport | () => void | Footer actions, shown when set |
Keyboard
| Key | Action |
|---|---|
| Enter, Space | Open or close the details |
Accessibility
- A named region; the header is a button with
aria-expanded. - The injected text is a
markwith hidden start and end words, and each ignored instruction says it was not done.
Motion
When opened by pointer, the amber mark sweeps across the injected text once with clip-path (280 ms, mirrored in right to left), so the eye lands on it. No sweep when opened by keyboard or under reduced motion.