mirror of
https://github.com/nexu-io/open-design.git
synced 2026-06-01 03:14:35 +07:00
When the agent emits an HTML artifact with no `data-od-id` / `data-screen-label` annotations (a freeform PRD → HTML pass through a Claude-Code-compatible CLI without going through a skill, for example), the existing Inspect / Picker affordances no-oped silently: - The bridge's click handler walks up to <html>, finds nothing tagged, and bails before emitting `od:comment-target` — by design, since posting a synthetic id here would change save-to-source semantics for inspect overrides (the persisted CSS keys off the same elementId). - The host then sat at "Click any element with `data-od-id` to tune its style" — phrased as if the user just hadn't found the right element, when the page in fact had nothing matching at all. - Picker mode (Tweaks → Picker) had no hint at all. The bridge already broadcasts `od:comment-targets` with the full list on every mode toggle and DOM mutation, but the host's existing listener was gated on `boardMode` only — Inspect mode never learned the artifact's annotation count. Two surgical fixes: 1. `FileViewer.tsx`: a dedicated `od:comment-targets` listener that installs whenever Inspect OR Comments mode is active, mirroring the bridge's broadcast into `liveCommentTargets`. The comment-mode-only listener still owns its hover / click / pod events; this new listener only handles the targets list. 2. `FileViewer.tsx`: the inspect-empty-hint banner now dispatches on `liveCommentTargets.size === 0`. Empty: a clear "this artifact has no `data-od-id` annotations yet — ask the agent to add them" message that names the missing attribute. Populated: existing instructive copy. Mirrored across Inspect and Picker modes so the failure surface gives the same calibration signal in both. Tests: - `tests/runtime/srcdoc-bridge-empty-targets.test.ts` (3 cases): pin the bridge contract this fix depends on. Run the IIFE in jsdom and assert (a) `allTargets()` posts an empty list for unannotated DOM, (b) clicks on unannotated elements do NOT post `od:comment-target` (regression pin against future "synthetic id" fallbacks that would silently change save-to-source semantics), (c) clicks DO still resolve to an annotated ancestor when one exists. - `tests/components/FileViewer.inspect-empty-hint.test.tsx` (3 cases): pin the host dispatch — empty state in Inspect mode, the switch back to instructive copy when targets show up, and the mirrored affordance in Picker mode. Out of scope (flagged in the design comment so it isn't lost): - The follow-up scenario from #890 ("parent has data-od-id, target child does not → adjustments hit the parent") is a different bug that needs either synthetic-id fallback or a UI affordance to descend into the click target. Leaving that to a follow-up so this PR stays narrow. - i18n: the existing inspect-empty-hint copy is hardcoded English; rolling it into the 17-locale Dict is a separate cleanup. |
||
|---|---|---|
| .. | ||
| artifacts | ||
| components | ||
| edit-mode | ||
| i18n | ||
| providers | ||
| runtime | ||
| state | ||
| utils | ||
| App.test.ts | ||
| comments.test.ts | ||
| quickSwitcherRecents.test.ts | ||
| sidecar-proxy.test.ts | ||