Skip to content

fix(hooks): render hook and memory cell text unescaped so React escapes it once - #35343

Closed
jeeshofone wants to merge 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/35264-hooks-double-escape
Closed

jeeshofone wants to merge 1 commit into
kirodotdev:mainfrom
jeeshofone:fix/35264-hooks-double-escape

Conversation

@jeeshofone

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: The Hooks table and the memory tables show hook and memory text exactly as written, with no stray > or &.

A hook whose command is echo prompt >> /tmp/log.txt shows as echo prompt >> /tmp/log.txt in the Hooks table, and & shows as &. The Name and Matcher columns do the same. The memory pages have the same bug: a lesson rule append with >> & wait shows as append with >> & wait, and so do semantic keys and values, episodic text, and audit keys and values.

Why it matters

Anyone whose hook commands or memory text contain <, > or & sees text that differs from what they saved, and the Command cell disagrees with its own tooltip. Shell commands with redirects and && are common in hooks, so most non-trivial hooks are affected.

Not a goal

  • Changing esc() itself or md(), which build HTML strings and still need escaping.
  • Any other table or page that does not render esc() output as JSX text.

What changed (motivation → approach → change)

Symptom: entities appear literally in table cells. Root cause: these cells passed the value through esc() from website/src/api/helpers.ts, which HTML-escapes it, and then rendered the result as a JSX text child. React escapes text children itself, so the text was escaped twice. Change: render the raw value as JSX text in HooksPage.tsx (name, command, matcher), MemoryTab.tsx (lesson rule, unlabelled lesson source) and VectorMemoryCard.tsx (semantic key and value, episodic text, audit key and value), and drop the now-unused esc imports. React's own text escaping keeps any markup in the value inert; none of these sites uses dangerouslySetInnerHTML or an HTML string builder.

Backwards compatibility

Compatible: only the displayed text changes; no API, type or stored data changes.

Removes nothing: the diff only drops a redundant escaping call on display.

Tests

  • website/src/test/HooksPage.cellText.test.tsx (new): the name, command and matcher cells show >, & and < as written, the command tooltip matches the cell, and a <b> in the command is not parsed into an element.
  • website/src/test/OverviewMemoryTabCov80.test.tsx: new case for a lesson rule and an unlabelled source carrying >, & and markup.
  • website/src/test/VectorMemoryCardCoverage.test.tsx: new case covering the semantic, episodic and audit cells with the same payloads.

All three fail with the page changes reverted and pass with them.

Proof: not provable -- frontend test

Manual verification

Built the SPA and rendered the Hooks page against stubbed API data with a hook named log & notify, command echo prompt >> /tmp/log.txt && notify and matcher <any>, before and after the change. Ran typecheck, eslint, i18n check, jscpd, the file line cap, phantom-classes, restyle ratchet, ui-index freshness, Semgrep and the Hooks and memory test files (252 tests).

Screenshots / video

Before (main): entities shown literally.

Hooks table before

After: text shown as written.

Hooks table after

Related Issues

Fixes #35264

Sibling sweep

Swept: git grep -n "esc(" -- website/src
Sibling: website/src/pages/overview/MemoryTab.tsx -- changed here
Sibling: website/src/pages/overview/VectorMemoryCard.tsx -- changed here
Sibling: website/src/api/helpers.ts -- not affected -- md() builds an HTML string that is sanitised before injection, so escaping is required there
Sibling: website/src/components/CommentOverlay.tsx -- not affected -- a local helper of the same name escapes prompt text, not HTML

Pattern harvest

Rule candidate: lint
Pattern: an HTML-escaping helper's result rendered as a JSX text child ({esc(x)}), which React escapes again

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

…es it once

The hooks table, the lessons table and the vector memory tables passed
values through esc() and then rendered the result as JSX text. React
escapes text children itself, so entities such as &gt; showed literally.
Render the raw values; React's own escaping keeps markup inert.
@jeeshofone
jeeshofone requested review from a team and KiroCrewCaptain as code owners November 11, 2026 15:22
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 1adf3f18a6aaf08850b90c58b7306e5ca63e7476 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 1adf3f1

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ⚠️ review incomplete

Reviewed 1adf3f18a6aaf08850b90c58b7306e5ca63e7476 via the fork AI-review pipeline; updated in place on each push.

No completed Opus verdict for this commit; see the Fork Opus 5.5 Review job logs.

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ⚠️ could not complete

The first-principles review did not produce a verdict for 1adf3f18a6aaf08850b90c58b7306e5ca63e7476 (the review step failed). See the Fork First Principles Review job logs. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ⚠️ could not complete

The design review did not produce a verdict for 1adf3f18a6aaf08850b90c58b7306e5ca63e7476 (the review step failed). See the Fork Design Review job logs. Does not block merge.

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: 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 a redundant esc() call in the JSX text cells of HooksPage, MemoryTab and VectorMemoryCard, so <, > and & no longer show as &lt;, &gt; and &amp;. React escapes text children itself, and none of these cells uses dangerouslySetInnerHTML or an HTML string builder, so dropping esc() is safe. A search of website/src found no JSX use of the HTML-escaping esc() left; the remaining callers (md(), CommentOverlay, commentsMessage.prompt) legitimately need their escaping. All the changed fields are typed as strings, and semanticValueText always returns a string, so no object can reach JSX and crash it. New tests on each page check that the raw characters render and that markup stays inert; they would fail on main.

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 1adf3f18a6 · 111 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 11, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

This PR and #35348 both close #35264 and make the same fix. Each removes esc() from the same cells in HooksPage.tsx, overview/MemoryTab.tsx and overview/VectorMemoryCard.tsx, so <, > and & show as typed.

Please keep one of #35343 and #35348 and close the other, carrying over anything only this one has.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 11, 2026
@jeeshofone

Copy link
Copy Markdown
Contributor Author

Superseded by #35348, which merged and fixes #35264 with the same change and tests for all three surfaces. Closing this one; nothing here needs carrying over.

@jeeshofone jeeshofone closed this Nov 11, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(hooks): Hooks table shows command, name and matcher double-escaped

2 participants