Repository navigation
fix(web): show hook and memory text as typed, not escaped twice - #35348
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. The fix removes the double escape where it happens. Once it lands, no What this change shipsInventory (5 items) — 5 justifiedIntent: let people read hook and memory text in the dashboard exactly as it was stored. This is a FIX (#35264).
[FIRST-PRINCIPLES-REVIEWED] 4874509 Description read[DESCRIPTION-READ] 8ac796b55cc8c0ebb0a152fb2f3ec06a3bd4a5a7d3c8fac832c407ac0475620c That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: React already escapes JSX text children, so dropping Notes
[DESIGN-REVIEWED] 4874509 Description read[DESCRIPTION-READ] e54fb0bab78c09819aac8a65559f7cd8bf652b4dddb03c98ae5a934e6a0ce88e That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. Every changed cell has a before and after screenshot (shots 01–10), and the blind reader read each "after" shot as the same item with the text now correct. [UX-REVIEWED] 4874509 Description read[DESCRIPTION-READ] 49bd2144e9300c0392012abd64f18a83ef2357aa10928c4c52e87d2f72c4292f That sha256 names everything this verdict read: the PR description, plus the 13 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: ApproveWhy: the decider estimates a 4% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes. Removes the HTML-escaping esc() from 11 spots where its output was rendered as JSX text, which React escaped a second time so entities showed on screen. React already escapes JSX text, so there is no XSS risk. esc() only accepted string/null/undefined/number, all of which React renders safely. No other place in website/src renders the HTML esc() output as React text, and esc() itself is unchanged for md(). Each page has a new test that would fail on main. Every check that had finished passed, including Frontend Lint & Type Check; CodeQL Analyze, Await Fast Gate and the Desktop builds were still pending. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
0e198f9 to
4874509
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Verified on this head: the change removes esc() from all ten places where its output was a JSX text child, in HooksPage.tsx, MemoryTab.tsx and VectorMemoryCard.tsx. It also drops the three imports that are no longer used. React already escapes text children, so this cannot under-escape anything. None of the three files uses dangerouslySetInnerHTML or innerHTML. Main still has every removed call. The three new raw-text tests have no sleeps, clocks or one-shot mocks, and each one fails against main's page files.
Done well: the fix goes after the cause at every call site and leaves esc()/md() alone where HTML escaping is still correct. The tests use &, < and > and check that no entity text appears anywhere in the row.
Optional:
Problem / Motivation
Goal: The Hooks and Memory tables show hook and memory text exactly as typed, with no
>or&in place of>and&.A hook whose command is
echo prompt >> /tmp/log.txtshows asecho prompt >> /tmp/log.txtin the Hooks table, and an&shows as&. The Memory page tables do the same to lesson rules, semantic keys and values, episodic text and audit rows.Why it matters
Anyone who reads a hook or a memory entry in the dashboard sees text that differs from what was stored. A shell command with
>>or&looks broken, and the cell disagrees with its own tooltip, so the user cannot trust what the page says the hook will run.Not a goal
esc()inwebsite/src/api/helpers.ts. It stays correct for HTML strings, such as themd()builder.What changed (motivation → approach → change)
The tables passed each value through
esc(), which returns an HTML-escaped string, then rendered that string as a JSX text child. React escapes text children itself, so the text was escaped twice and the entities showed up on screen.The cells now render the raw values and let React do the escaping:
HooksPage.tsxoverview/MemoryTab.tsxoverview/VectorMemoryCard.tsxNone of these files imports
escany more.Backwards compatibility
Compatible: only the on-screen text changes; the stored values and every API stay the same.
Removes nothing: the diff drops a display-time escape step and takes no record, key, path or capability away.
Tests
One test per page renders a value with
>>,&and<...>and checks the cell text equals it exactly, with no>,<or&in the row:HooksPage.rawText.test.tsx: name, command, the command'stitle, and matcher.MemoryTab.rawText.test.tsx: lesson rule and an unlabelled source.VectorMemoryCard.rawText.test.tsx: Semantic, Episodic and Audit tabs.Each test fails with the three page files restored from
main, and passes on this head. The three files passed 20 repeated runs, and the HooksPage, MemoryTab and VectorMemoryCard suites passed in shuffled order.Proof: not provable -- frontend test (prove.py runs Python only)
Manual verification
Rendered the real pages in Chromium with stubbed API data, on
mainand on this branch. Every table onmainshowed entities and none does on this branch (screenshots below).Screenshots / video
Hooks table, before and after:
Lessons table, before and after:
Vector memory tables (Semantic, Episodic, Audit)
Related Issues
Closes #35264
Sibling sweep
Swept: git grep -nE "import .*\besc\b" -- website/src
Sibling: website/src/pages/overview/MemoryTab.tsx -- changed here
Sibling: website/src/pages/overview/VectorMemoryCard.tsx -- changed here
Sibling: website/src/components/CommentOverlay.tsx -- not affected -- defines its own quote escaper for a prompt string, not the HTML esc()
Sibling: website/src/utils/commentsMessage.prompt.ts -- not affected -- defines its own quote escaper for a prompt string, not the HTML esc()
Pattern harvest
Rule candidate: lint
Pattern: the HTML-escaping
esc()fromapi/helperscalled inside a JSX expression container, where React already escapes the textChecklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)