live-wrap: multi-line JSX elements unfindable; fallback discard-restore can delete the original element

Author: german138Created Sep 28, 2026Updated Sep 28, 2026
Labelsneeds triage

Environment: impeccable 4.4.0 (engine 0.1.6), harness: omp 18.4.0, project: Vite + React 18 + TS + shadcn/ui (Tailwind), Chrome 152.

Bug A — live-wrap cannot locate multi-line JSX elements

The response element is a shadcn <Input> spanning multiple lines:

typescript
<Input
  id="email"
  type="email"
  placeholder="[email protected]"
  value={email}
  onChange={(e) => setEmail(e.target.value)}
  required
  autoComplete="email"
/>

Browser-side the element exists (picked via the live bar; anchor: "#email", anchorMatches: 1). Wrap fails both with runtime classes and without:

bash
$ impeccable live-wrap --id 7fb948f5 --count 1 --element-id "email" --tag "input" --text "" \
    --classes "flex,h-10,w-full,rounded-md,border,..." 
{"error":"Found file but could not locate element in src/pages/Login.tsx. Searched for: id=\"email\", class=\"flex h-10 ...\", className=\"flex h-10 ...\""}

$ impeccable live-wrap --id 7fb948f5 --count 1 --element-id "email" --tag "input" --text "" --file src/pages/Login.tsx
{"error":"Found file but could not locate element in src/pages/Login.tsx. Searched for: id=\"email\""}

The locator appears to match single-line patterns (id="email" on the same line as the open tag, or full className strings). Runtime classes are merged by cn() in the component, so they can never match source. Expected: AST/regex location of the JSX open tag by id (or name) attribute across multiple lines, returning the source-preview scaffold (sourceWritten: false).

Bug B — fallback discard-restore deletes the original element

Per the documented fallback flow, the wrapper was hand-written around the element in the source file and the event answered with --reply <id> done --file src/pages/Login.tsx. The browser mounted the variant via HMR (worked). When the user discarded via the bar, the poll output claimed success:

json
{"type":"discard","_acceptResult":{"handled":true,"file":"src/pages/Login.tsx","carbonize":false},"_completionAck":{"ok":true,"type":"discarded"}}

…but the restore removed the original element instead of the wrapper — the diff after "restore" deleted the entire <Input id="email" …/> block (10 lines) that the wrapper had enclosed, leaving <Label htmlFor="email"> followed directly by the password field.

Repro: source-preview fallback file containing <!-- impeccable-variants-start ID --> → <div data-impeccable-variants="ID"> → variant divs wrapping the original JSX element → generate → discard from the bar.

Workaround in use

Run live sessions only on a clean committed tree; after any discard, git diff the touched file and git checkout -- <file> when the restore mangled it. Live pick/generate/inject all work fine — this is specifically wrap-location and fallback restore.