Skip to content

Keep evidence popovers whole on the what-changed diff - #143

Closed
gas2own wants to merge 4 commits into
mainfrom
evidence-diff-popovers
Closed

gas2own wants to merge 4 commits into
mainfrom
evidence-diff-popovers

Conversation

@gas2own

@gas2own gas2own commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Two defects reported against the survey's PR preview, both in how the
what-changed generator treats evidence popovers.

Hovers that show nothing. The popover is shown with pure CSS via
.ev:hover > .ev-pop — a child combinator. The word diff splits a changed
claim into <ins>/<del> runs, and when the popover fell inside one of those
runs it stopped being a direct child of .ev, so hovering did nothing. On the
survey preview 2 of 34 popovers were in that state — and they were the two
claims whose evidence the PR had just added, i.e. exactly the ones a reviewer
wants to hover.

Added evidence was invisible. When a claim's prose is unchanged and only its
evidence is new, the whole change lives inside a popover that is hidden until
hover. The diff rendered it as <ins> on text nobody can see, so the page
showed no change on that claim.

Fix: each <span class="ev-pop">…</span> subtree is swapped for one opaque
placeholder tag before the diff and restored after. Identical evidence aligns as
unchanged instead of being word-diffed; the placeholder is not an inline tag, so
emit_run emits it outside any wrapper and the restored popover is a direct
child of .ev again; and a placeholder that the diff inserted or deleted
restores with a visible evidence added / evidence removed chip on the claim.
The restored popover remains a direct child of .ev, preserving the extension.s child-combinator isolation.

Regenerated the survey preview's what-changed.html from the same two site
trees with this change: all 34 popovers are direct children of .ev (was 32),
and the three claims that PR gained evidence for each carry an evidence added
chip. Three tests cover added / unchanged / removed evidence; the module's
tests, ruff check and ruff format --check are clean.

Reviewer requested: jbragg

Suggested-by: @jbragg

🤖 Generated with Claude Code

Word-diffing an evidence popover broke two things on the survey preview: an
inserted popover landed inside the <ins> wrapper, so it stopped being the
direct child `.ev:hover > .ev-pop` needs and the hover showed nothing; and
evidence added to unchanged prose was marked only inside that hidden popover,
so a reviewer saw no change at all.

Each popover is now swapped for one opaque placeholder before the diff and
restored after, with an "evidence added"/"evidence removed" chip on the claim.
The popover CSS also uses a descendant combinator so any diff wrapper is
tolerated.

Suggested-by: @jbragg
@gas2own

gas2own commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Independent AI code review (Codex)

Automated review of the PR by a separately invoked Codex reviewer. Prioritised P0/P1/P2; treat as advisory input for the human reviewer, not a merge gate.

P0 (blocking)

None.

P1 (should fix)

  • plugins/asta-tools/skills/workspace/assets/what-changed.py:600: EV_POP_OPEN_RE only accepts double-quoted class attributes, so valid single-quoted HTML bypasses the new protection. Parse tags or support both quote styles; add a single-quoted regression test.
  • plugins/asta-tools/skills/workspace/assets/what-changed.py:601: \bev-pop\b also matches class names such as ev-pop-text, potentially extracting the wrong subtree. Match ev-pop as a whitespace-delimited class token.

P2 (nits)

None.

Recommendation: request-changes

@gas2own

gas2own commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Resolved both findings in 212b967:

  • Single-quoted class attributes are now recognized, with a regression test.
  • ev-pop is checked as an exact whitespace-delimited class token, so ev-pop-text is not extracted; a near-match regression test covers this.

Validation: tests/test_what_changed.py passes (25 tests); repository-wide Ruff lint and format checks pass; all 25 skill manifests validate. GitHub CI is running the full supported matrix.

@gas2own

gas2own commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Independent AI code review (Gemini)

Automated review of the PR by a separately invoked Gemini reviewer. Prioritised P0/P1/P2; treat as advisory input for the human reviewer, not a merge gate.

P0 (blocking)

None.

P1 (should fix)

  • EV_POP_OPEN_RE uses \bclass, which incorrectly matches custom attributes like data-class="ev-pop". The \b after <span also erroneously matches custom elements like <span-foo>, causing them to be extracted.
    • plugins/asta-tools/skills/workspace/assets/what-changed.py:601: Change the regex to EV_POP_OPEN_RE = re.compile(r"""(?is)<span(?=\s|/|>)[^>]*?(?:\s)class\s*=\s*(?P<quote>["'])(?P<classes>.*?)(?P=quote)[^>]*>""")
  • _matching_close uses \b to check the tag boundary, meaning custom elements like <span-foo> inside a popover will be incorrectly parsed as <span>s, breaking block depth tracking.
    • plugins/asta-tools/skills/workspace/assets/what-changed.py:618: Change the pattern to pat = re.compile(rf"(?is)<(/?){re.escape(name)}(?=\s|/|>)[^>]*>")
  • The CSS change from child (>) to descendant ( ) combinator degrades component isolation and risks triggering multiple overlapping popovers if .ev claims are ever nested. The python comment and tests explicitly confirm the new placeholder approach "restores the direct-child relationship", making this CSS change both unnecessary and risky.
    • plugins/asta-tools/skills/workspace/assets/_extensions/evidence/evidence.head.html:57: Revert .ev:hover .ev-pop and similar selectors back to using the > combinator (e.g. .ev:hover > .ev-pop).

P2 (nits)

None.

Recommendation: request-changes

@gas2own

gas2own commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Resolved the three findings from the latest review in 7f341b3:

  • The opening-tag matcher now requires a real span tag and a whitespace-delimited class attribute, so span-foo and data-class no longer match.
  • The closing-tag scanner now uses the same exact tag boundary, so custom elements cannot alter popover depth.
  • The evidence CSS is restored to direct-child selectors; placeholder restoration preserves that relationship, so the broader descendant selectors were unnecessary.

Validation: tests/test_what_changed.py passes (27 tests), including new data-class and custom-element regressions; Ruff lint and format checks pass; all 25 skill manifests validate. Nothing remains open from this review.

@gas2own
gas2own requested a review from jbragg September 22, 2026 18:07
@gas2own
gas2own marked this pull request as ready for review September 22, 2026 18:07
@gas2own

gas2own commented Sep 22, 2026

Copy link
Copy Markdown
Contributor Author

Reproduced the reported "hover shows nothing" case against main and this branch, using the CycleResearcher claim from allenai/ai-for-science-survey#45 (prose unchanged, evidence newly attached, claim inside a table cell).

main:

... accepted <del>papers.</del><ins>papers<span class="ev-pop" role="note">…</span></ins></span><ins>.</ins>

The popover is emitted inside <ins>, so it is no longer the direct child .ev:hover > .ev-pop requires — hover is dead, and the only visible artifact is a sliver of <ins> highlight.

This branch (7f341b3):

... accepted <del>papers.</del><ins>papers</ins><span class="wc-ev-chip wc-ev-add">evidence added</span><span class="ev-pop" role="note">…</span></span><ins>.</ins>

Popover restored as a direct child of .ev, and the newly attached evidence is announced by a visible chip instead of an <ins> on hidden text.

The survey's preview pins uses: …/workspace-quarto-site.yml@main and the workflow fetches what-changed.py from job.workflow_sha, so this fix cannot reach any preview until it merges. allenai/ai-for-science-survey#45 carries a temporary pin to this branch so the behaviour can be seen live before then.

Suggested-by: @jbragg

@asta-mothership-agent asta-mothership-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the current head (7f341b3). I found no blocking issues. The opaque-placeholder approach keeps evidence popovers out of word-diff wrappers, restores the required direct-child relationship, and makes evidence-only changes visible with added/removed chips. The follow-up commits also tighten tag/class matching and cover the previously reported single-quote, near-class, data-class, and custom-element cases.

Validation: tests/test_what_changed.py passes locally (27 tests), repository-wide Ruff lint and format checks pass, and the GitHub CI matrix is green.

# Conflicts:
#	plugins/asta-tools/skills/workspace/assets/what-changed.py
@gas2own

gas2own commented Oct 12, 2026

Copy link
Copy Markdown
Contributor Author

Updated with current main (v0.109.0) in 8b40b32. The only conflict was the import list in what-changed.py, resolved by keeping both glob and hashlib. tests/test_what_changed.py and tests/test_workspace_what_changed.py pass locally (128 passed, 2 skipped). This PR now conflicts with #145 in what-changed.py, so whichever of the two merges second needs a rebase. #201 does not change or supersede it.

@gas2own

gas2own commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

The evidence-popover implementation and regression tests are folded into #290 so the consolidation has one implementation PR.

@gas2own gas2own closed this Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants