fix(chat): keep find stable across footnotes and pending chats, and match mention chips next to punctuation

Merged
WA
1mo ago
+238-17

Summary

  • Chat find closed and cleared its query when a pending chat adopted its persisted id (undefined → id), although that's the same conversation. It now resets only when an existing scope changes
  • Footnotes made the find index and the rendered DOM disagree on match counts and order: the index kept footnote definitions, while the DOM showed the marker, the moved definitions, a visually hidden heading, and back-links. Footnote definitions are now left out of the index, and [data-footnote-ref] / [data-footnotes] are excluded from the DOM walk. The chat's link renderer now forwards data-footnote-ref so the marker can be excluded
  • Mention chips:
    • slash_command contexts render with the / prefix
    • the token match accepts trailing punctuation via a lookahead, so @Workflow, and back-to-back repeats (@A @A) now match, while @Workflow-2 still doesn't match @Workflow
    • overlapping matches resolve to the longest chip (@report vs @report.pdf, Workflow vs Workflow 2)
  • The @/blocks/integration-matcher test mock moves to one central @sim/testing mock used by all four suites
  • Responds to review threads on #8356

Type of Change

  • Bug fix

Testing

  • use-chat-find.test.tsx renders real ChatContent markup: find survives undefined → id but resets on a chat switch, and a footnoted message's match count equals its highlighted ranges. Each fails with its guard reverted
  • utils.test.ts: punctuation, repeats, slash commands, the prefix boundary, and longest-overlap cases. The behavior cases fail on staging
  • Cleanup passes (effects, state, memo, callback, React Query, EMCN, URL state, comments, test audit) found nothing
  • Home, chat, and composer suites (238 tests), type-check, lint, and check:audits pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)