Skip to content

fix(web): show hook and memory text as typed, not escaped twice - #35348

Merged
rnoack1 merged 1 commit into
mainfrom
fix/hooks-table-double-escape
Nov 11, 2026
Merged

rnoack1 merged 1 commit into
mainfrom
fix/hooks-table-double-escape

Conversation

@rnoack1

@rnoack1 rnoack1 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

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.txt shows as echo prompt >> /tmp/log.txt in 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

  • Changing esc() in website/src/api/helpers.ts. It stays correct for HTML strings, such as the md() builder.
  • Changing how hooks or memory entries are stored or sent by the backend.

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:

Page Fields now shown as typed
HooksPage.tsx name, command, matcher
overview/MemoryTab.tsx lesson rule, lesson source
overview/VectorMemoryCard.tsx semantic key and value, episodic text, audit key and value

None of these files imports esc any 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 &gt;, &lt; or &amp; in the row:

  • HooksPage.rawText.test.tsx: name, command, the command's title, 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 main and on this branch. Every table on main showed entities and none does on this branch (screenshots below).

Screenshots / video

Hooks table, before and after:

Hooks table on main

Hooks table on this branch

Lessons table, before and after:

Lessons table on main

Lessons table on this branch

Vector memory tables (Semantic, Episodic, Audit)

Semantic on main

Semantic on this branch

Episodic on main

Episodic on this branch

Audit on main

Audit on this branch

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() from api/helpers called inside a JSX expression container, where React already escapes the text

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

@rnoack1
rnoack1 requested review from a team and KiroCrewCaptain as code owners November 11, 2026 15:44
@rnoack1
rnoack1 requested a review from bolichen97 November 11, 2026 15:44
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 487450980bdfc2248165d5d3c4b5d04313cd4769 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing to check. The fix removes the double escape where it happens. Once it lands, no esc() from api/helpers is left inside JSX anywhere in website/src.

What this change ships

Inventory (5 items) — 5 justified

Intent: let people read hook and memory text in the dashboard exactly as it was stored. This is a FIX (#35264).

  1. The Hooks table shows a hook's name, command and matcher with >> and & as typed, not as &gt;&gt; or &amp; — justified
  2. The Lessons table shows a lesson's rule and any source without a label as stored — justified
  3. The Semantic, Episodic and Audit memory tables show keys, values and text as stored — justified
  4. A code comment about Semantic row render cost no longer lists esc() as one of the costs — justified
  5. Three new tests, one per page, check that >>, & and <…> show up exactly in each cell — justified

[FIRST-PRINCIPLES-REVIEWED] 4874509

Description read

[DESCRIPTION-READ] 8ac796b55cc8c0ebb0a152fb2f3ec06a3bd4a5a7d3c8fac832c407ac0475620c

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 487450980bdfc2248165d5d3c4b5d04313cd4769 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: React already escapes JSX text children, so dropping esc() at these call sites fixes the double-escaping at its source and opens no XSS path.

Notes

  • The "Pattern harvest" lint rule (no esc() from api/helpers inside a JSX expression) would stop this from coming back in other pages. It belongs in a separate PR.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 487450980bdfc2248165d5d3c4b5d04313cd4769 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 487450980bdfc2248165d5d3c4b5d04313cd4769 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 4874509

Verdict parsed from the review's SHA-scoped output markers for commit 487450980bdfc2248165d5d3c4b5d04313cd4769.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 487450980bdfc2248165d5d3c4b5d04313cd4769 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 487450980bdfc2248165d5d3c4b5d04313cd4769 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4874509

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 487450980bdfc2248165d5d3c4b5d04313cd4769 false-positive: <reason, 20 to 500 characters>

@KiroCrewCaptain

KiroCrewCaptain commented Nov 11, 2026 •

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

@rnoack1

rnoack1 commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in website/src/pages/ChatSidebar.tsx (same directory as website/src/pages/HooksPage.tsx) since this head went green (f859940 -> 23b63d2); CI re-running.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 11, 2026
@rnoack1
rnoack1 enabled auto-merge (squash) November 11, 2026 18:29

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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:

  • #35343 makes the same change for #35264. Once this one lands, it can close with a pointer here.
  • #18831 still renders {esc(l.rule)} on the lesson row. When it rebases, it should drop that call so the double escape does not come back.

@rnoack1
rnoack1 merged commit 89530fe into main Nov 11, 2026
135 of 139 checks passed
@rnoack1
rnoack1 deleted the fix/hooks-table-double-escape branch November 11, 2026 18:51
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 11, 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.

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

2 participants