fix: prevent Inkeep citation href mutation loop
Created by: ihsraham
Summary
- Prevent the Inkeep citation cleanup observer from rewriting an anchor
hrefwhen the rewritten URL is identical to the current value. - Keeps citation deduplication behavior intact while avoiding unnecessary
hrefmutations during streamed Ask AI responses.
Root Cause
The Ask AI citation cleanup runs from a MutationObserver that watches href changes. Chrome can emit an attribute mutation even when code assigns the same anchor.href value back to the element, so the cleanup loop could retrigger itself while Inkeep was streaming citation links.
Validation
git diff --checknpm run check:metanpx tsc --noEmit --strict --skipLibCheck --target ESNext --lib DOM,DOM.Iterable,ESNext --moduleResolution bundler --module ESNext --jsx react-jsx src/lib/inkeep.tsLINK_CHECK_EXTERNAL=false npm run check:linksnpm run build
Manual QA
- Reproduced the production Ask AI hang before the patch when submitting a question.
- Local patched Ask AI could not complete answer-stream stress testing because Inkeep returned
403 Not authenticatedfor localhost chat completions. Staging should be used for the final manual stress pass after this reachesdevelop, since that origin is expected to be whitelisted.