You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(images): deterministic host image paths to stop screenshot churn (#43)
Agent output references the same artifact through volatile `src` forms — a
relative `artifacts/…` path, a container absolute path
(`/opt/cursor/artifacts/…`), a repo/directory-named path
(`/home/user/<repo>/artifacts/…`), or a per-session download URL
(`…/v1/agents/<id>/artifacts/download?path=artifacts/…`). The host-injectable
image refactor dropped the normalization the old `artifact-images.ts` did, so
the host renderer now echoes `src` verbatim into `data-host-image-path`. Those
volatile segments (container dir, repo name, directory layout, session id) then
leak into the rendered DOM and churn the downstream e2e screenshots every time
the environment differs.
Restore determinism as a generic, app-agnostic primitive:
- Add `normalizeHostImagePath(src, { rootMarker })` — strips any leading
absolute/dir prefix down to the marker segment (default `artifacts`), prefers a
URL's `?path=` param, returns volatile query params separately, and rejects
path traversal. No host path is hardcoded, keeping the core decoupled.
- Route the host-image test policy through it and render only the stable path.
- Regression test proving five volatile forms of one artifact collapse to a
single identical placeholder and no session id leaks.
Hosts should call `normalizeHostImagePath(src).path` and keep volatile query
params out of any snapshot-visible attribute.
Claude-Session: https://claude.ai/code/session_01U5XyfYm8fojvk9USphcx4E
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments