Repository navigation
feat(prototype): re-locate a note, screenshot it, and ask when it is gone - #16052
Conversation
…gone Slice S2 of the prototype feedback-picker plan. relocate-note.mjs (canonical in lib/ui-feedback, vendored to prototype/notes-bridge) reads one note from the bridge's log, validates it against note.schema.json, and writes a playwright-cli run-code script carrying it as one JSON literal. The script opens the host page in a new page, restores variant, screen state and content set through a new vs:show switcher event, runs the anchor ladder (test id, role, path) in the sandboxed frame, and cuts a shot named from the integer seq from inside the frame's box with the switcher hidden. With no rung matching, it shoots the note's stored rect, labeled position only. Notes gain rect (percent of the page); both validators honor finite numbers. reference/feedback.md gains a Re-locating a note section (additions only). New eval case ed-notes-relocate-not-found and browser test relocate-browser.test.sh. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ment When a note's test id sits on an ancestor and the path finds nothing inside it, the relocation now reports container with confirmed false, so the agent asks instead of editing. The browser test sends note text shaped to break a script literal and still re-locates the note, which proves the JSON literal through playwright-cli's own loader. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 97e145855e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Lane run report
Failed GitHub API calls
|
|
claude-security-review reviewed Security review (incremental): no security issues foundcritical-findings: 0 Scope: only what changed since None of the 8 files matches a TRUSTED PATHS glob. The push changes no trust control, merge hold, token request, kill switch, plugin manifest or standing instruction. What I checked:
Embedded text: none found in the PR context. |
|
claude-review reviewed Code review (incremental): PR #16052,
|
check-vocabulary retired "rung" next to "page" (the view-form sense). The note schema's description and the S2 fragment now say "step of the anchor ladder". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…stor
When the nearest data-testid ancestor had the picked element's tag, the
tag comparison took the ancestor for the element and shot it as a
confirmed match. The path now decides first: one element inside the
test-id match is the noted element; the tag comparison is only the
fallback that sets container.
The role rung matched [role="x"] exactly, but the pin helper keeps only
the attribute's first token, so role="button link" was never found. It
now matches [role~="x"]; the schema's ^[a-z]{1,32}$ keeps the value safe
inside the quoted selector.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Post-merge mutation testingKilled 6, survived 1, timeout 0, no coverage 0, invalid 0, not run 0.
Surviving mutants
The run's summary has the full report. |
No related issue: slice S2 of the prototype feedback-picker plan
Summary
After a note arrives from a mockup, the session can find the noted element again in a fresh
page, screenshot it, restate the note beside the screenshot, then act or ask. When the element
cannot be found, the result names each anchor rung and its candidate count, the screenshot is the
note's stored box labeled position only, and the session asks instead of guessing.
Fix
lib/ui-feedback/relocate-note.mjs(canonical; vendored toplugins/prototype/notes-bridge/throughscripts/shared-copies.txt).node relocate-note.mjs --dir <run dir> --seq <n> --url <host url>:<n>from the bridge'sactions.json;note-model.mjsagainstnote.schema.json;<run dir>/relocate-<n>.js, aplaywright-cli run-codescript whose only input isone
JSON.stringifyliteral. The script source isrelocate.toString()anddecide.toString(),so the unit suite tests the same code that runs.
vs:showin the frame, and runs theladder in the scope (screen state in variant, else variant, else page): test id plus index
(the scope counted first, as
proto-pin.jscounts), then role (the attribute's first token,matched as one token with
[role~=], plus tag), thencssPathfrom:scope >. It recordscandidatesfor every rung, then shoots<run dir>/shots/<n>.png.proto-pin.jsrecords the nearest test id at orabove the picked element, so the test-id match can be an ancestor, with or without the same tag.
When the path finds one element inside the test-id match, that element is the noted one. Only
without such a path does the tag decide: the same tag means the test-id element is the noted
one; a different tag returns
container: true.confirmed: a match counts as confirmed only when no stronger rung the note carries foundnothing. An ambiguous role (more than one candidate) does not demote. A
containermatch isnever confirmed.
assets/variant-switcher.html, the only tracked copy): avs:showlistener on
document, detail{variant, state, content}, each part optional. A part the pagedoes not have is ignored. It reuses
show()andflipContent(). Nothing else in the assetchanged.
rect(x,y,w,h, each apercentdef of 0 to 100) is the boxproto-pin.jsalready posts, whichhost.htmlused to drop.host.htmlnow keeps it when theschema admits it. Both validators honor
type: number, finite only: JSNumber.isFinite;Python
math.isfinite, becausejson.loadsacceptsNaN. 9 new fixtures (2 valid, 7 invalid)run against both validators, plus one NaN/Infinity test per validator, since strict JSON
fixtures cannot hold those values. The schema's
x-versiongoes from 1 to 2.reference/feedback.md: a new## Re-locating a notesection after step 7. It coversre-locate, run, put the shot in step 5's row, act only when confirmed, and the not-found
wording "position only, element not found" with one question. Additions only.
docs/contracts/ui-feedback/README.md: a file-table row and a "Re-locating a note" section.ed-notes-relocate-not-found: a scaffolded note on variant B's Export button(
shipments-export), which the rework removed. Four graders: an llm grader (not found, positiononly, one question) and three deterministic ones (no Edit; no Write to the mockup; no Bash
in-place edit or redirect into the mockup), each with samples.
scripts/relocate-browser.test.sh(with atest-scope:header) andrelocate-browser-take.js..changes/prototype/feat-prototype-feedback-s2-5604e60d.md(minor). Noversionis bumped.Trust-relevant choices
in its
sandbox="allow-scripts"srcdoc frame with an opaque origin andPAGE_CSPfirst, as inS1. I considered opening the mockup outside the frame (a fresh
about:blankpage andsetContent) and rejected it: that runs it unsandboxed. Sandbox flags, mockup CSP, origin andtoken checks, and
X-Frame-Optionsare unchanged.with the iframe's box (
page.screenshot({clip})), so no host pixel can be in it. The screenshotstyleoption hides the switcher's.vsnav, and Playwright applies it inside the frame. Thebrowser test checks both: the clip lies inside the frame box, and the pixels are all target
green, with no dark switcher pixel and no near-white host or page pixel. The target sits under
the switcher. With the style removed, that check fails (
green 0.73, dark 0.25), so the checkcan fail.
JSON.stringifyand template interpolation, neverString.replace, so$&and$'cannotinject. There is no trailing semicolon, because run-code evaluates the file as one expression.
Values reach the frame only as
evaluate(fn, arg)arguments. Selectors take onlyschema-checked keys and paths: test ids go through
getByTestId, a role (schema pattern^[a-z]{1,32}$) inside a quoted[role~="…"], andcssPathonly after the schema's strictstep pattern. The browser test sends note text shaped to break a literal
(
x"); throw 1; //${1}$&$'</script>`) and the note still re-locates throughplaywright-cli's own loader.
--seqmust match^[1-9][0-9]{0,8}$; the shot isshots/<seq>.pngand the scriptrelocate-<seq>.js. No note field names a file.--urlmust behttp://127.0.0.1:<port>/, the formensure-runningprints.Feedback.md frames what it returns as data, as every note field is (step 4).
rect, so notextQuoteand no accessible name were added, anddocs/contracts/rendered-views/README.mdisunchanged. The host page still drops any field the schema refuses, the helper's
labelincluded.
Reused, and what is new
Reused:
problems()fromlib/ui-feedback/note-model.mjs:22and the schema file, in the CLI;proto-pin.js'srectOfbox (lib/ui-feedback/proto-pin.js:56-63) and itsanchorOfscopeand index rules (
:36-53), unchanged; the ladder mirrors them;lib/ui-feedback/host.html);status(lib/ui-feedback/notes_bridge.py:261-269);ensure-running(:313);show()andflipContent()(
plugins/prototype/skills/explore-directions/assets/variant-switcher.html:204-221).No new copy of a schema or limit was written: every note limit is still in
note.schema.json.Named for review:
relocate-browser.test.shrepeatsharness-browser.test.sh's scaffolding:pw(),finish(),the port
sed, the cygpath wrapper and the prerequisite loop.lib/script knows two switcher contracts, the.vsclass and thevs:showevent.--seqand--urlregexes are local CLI guards, not note limits.number. That is a schema plus validator plus fixtures change, whichthe contract allows.
Deviations from PLAN.md's S2 text
scripts/relocate-note.jsin the skilllib/ui-feedback/relocate-note.mjs, vendoredlib/ui-feedback/, and later consumers (real stack, pressure-test demo) need the same copylib/notes-model.mjsgains thetextQuoteandrectrungsrectonly, in the schema; notextQuote, accessible name orrect.inAnchorrect: {doc, inAnchor}plusviewportrectin percent of the page's scroll box, no viewportproto-pin.jsalready sends;viewportis S3. A position-only shot uses the relocation page's own viewport?variant=&state=vs:showonlydata.log, set each control[role~=]) plus tagproto-pin.jskeeps only the first tokenstyle(shadow root)stylehides the switchertextQuote. S2 tests variant B, state empty, worst content after a reload, an element under a same-tag test-id ancestor, and a renamed and a removed elementconfirmedandcontainersemantics; a file-reading fallback in feedback.md when the host or playwright-cli is absent; schemax-version2Existing non-skill lines changed (skill files are additions only, per
git diff --numstat origin/main):host.html:noteFrom's signature and its call, plus one header-comment line, in the canonicalfile and its copy;
note.schema.json: itsdescriptionandx-version;note-model.mjs: the honored-subset comment.Verification
At
4fc9207b1a(the head):node --test --test-concurrency=4 lib/ui-feedback/relocate-note.test.mjs lib/ui-feedback/note-model.test.mjs:ℹ tests 65ℹ pass 65ℹ fail 0(rung ordering, scope self-count, ancestor test id ofanother tag and of the same tag,
containerunconfirmed, a multi-token role, broken index,ambiguous role, position only, hidden match, missing variant, the JSON-literal script in
vm,the CLI's refusals). Before the fix, the same-tag and multi-token role tests failed: the
same-tag case shot the ancestor, and the role rung found 0 candidates.
python3 -m unittest discover -s lib/ui-feedback -p 'test_*.py':Ran 23 testsOK.bash plugins/prototype/skills/explore-directions/scripts/relocate-browser.test.sh:relocate-browser: all passed(15 PASS). Its same-tag case fails on the pre-fix logic: theshot was the 336x116 container,
magenta 0.49.bash plugins/prototype/skills/explore-directions/scripts/harness-browser.test.sh:harness-browser: all passed(25 PASS).python3 -I scripts/check-vocabulary.py: exit 0, no lines.scripts/sync-shared-copies.sh --check:All 848 registered copies match their canonical sources.scripts/check-changelog-fragments.sh --check:All 5 changelog fragment(s) under .changes/ are valid.scripts/check-affected.sh --tests:check-affected: 18 passed, 157 skipped over 32 changed files since 38c48c3104f5a79b428c3d287a3f54ebaa18571a.shellcheckonrelocate-browser.test.sh: clean.At
6b92ce747eor earlier, not rerun since (the later commits do not touch these files' inputs):scripts/sync-shared-copies.sh --check-bump origin/main:5 canonical source(s) or their copies changed vs origin/main; every carrying plugin bumped its version.scripts/check-html-assets.sh:All registered rendered-view HTML assets lint clean; no unregistered assets.htmlhintonassets/variant-switcher.html: the same singledoctype-firstfinding as on main.The asset is a fragment and is not in the registered set.
plugins/skill-quality/scripts/check-skill.sh plugins/prototype/skills:3 passed, 0 failed.It skipped script tests (run from outside the repo root); the browser runs above cover them.
python3 plugins/evals/skills/validate/scripts/validate-cases.py plugins/prototype/evals: noFAIL; the new case shows only the repo-wide
allowed_toolsWARNs.scripts/run-ruff.sh check:All checks passed!;scripts/run-ruff.sh format --check:2 files already formatted.markdownlint-cli2on the changed markdown:Summary: 0 issues in 0 files.node scripts/check-declared-prerequisites.mjs:every declaration passes the schema and every tool run is declared or baselined (18 baselined gap(s)).Not run: scored evals (the parent session runs them); the full
.githubsuite.Sandboxed eval.
ed-notes-relocate-not-foundneeds no live notes host:notes-bridge.sh statusreads the scaffold'sactions.jsonwith no server, and the page file alone shows thetest id is gone. Whether it behaves well in a sandboxed run is unverified: the agent may try
ensure-runningorplaywright-clifirst, and neither keeps a process past one sandboxed call.Related
Follow-ups
prerequisites.json: thenoderow'sdegradetext does not mention relocation, andplaywright-cliis not declared for prototype. Without them,feedback.mdfalls back to readingthe page file.
textQuote(with the rendered-views rule 9 amendment) for listrows, and
viewportso a position-only shot matches the person's layout.are still open: the owner-doc rows, "single-user machine", and
/eventsSec-Fetch-Site.🤖 Generated with Claude Code