Skip to content

feat(Chat): support whitespace queries via allowSpaces on ChatComposerTrigger - #6128

Open
Geervan wants to merge 1 commit into
facebook:mainfrom
Geervan:feat/chat-trigger-allow-spaces
Open

feat(Chat): support whitespace queries via allowSpaces on ChatComposerTrigger#6128
Geervan wants to merge 1 commit into
facebook:mainfrom
Geervan:feat/chat-trigger-allow-spaces

Conversation

@Geervan

@Geervan Geervan commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #6110

Summary

Adds opt-in allowSpaces?: boolean to ChatComposerTrigger in @astryxdesign/core, enabling multi-word trigger queries (e.g. @Cindy Zhang) and trailing-space candidate browsing (@ ).

Scanner & Termination Rules

  • Punctuation boundaries: ., ,, !, ?, ;, : unconditionally terminate active queries.
  • Word cap: Maximum 5 words allowed in the active query (6th word closes the menu).
  • Apostrophe & Hyphen: Preserved (e.g. @O'Brien, @Jean-Luc's Task).
  • Cursor-relative binding: Scanning operates on textBeforeCursor up to the active selection offset.
  • Zero-length query: Immediate punctuation (@,, @.) returns null immediately.
  • Single-token triggers: Triggers with allowSpaces: false or unset (such as / slash commands) retain strict space-terminating single-token behavior.

New Test Suite (useTriggerMenu.test.tsx)

Added dedicated hook unit test file packages/core/src/Chat/useTriggerMenu.test.tsx covering all 12 scanner edge cases:

  1. Single-token / command behavior unchanged (closes on space).
  2. allowSpaces: true multi-word query matching (@Project Alpha).
  3. Trailing-space browse-all query (@ ).
  4. Punctuation termination, attached and spaced (., ,, !, ?, ;, :).
  5. Zero-length query + immediate punctuation returns null (@,, @.).
  6. Preserves apostrophes and hyphens (@O'Brien, @Jean-Luc's Task).
  7. 5-word cap enforcement (5 words active, 6 words closes).
  8. Double-space tolerance without closing or over-counting words.
  9. Stateless reactivation on backspacing past a terminator.
  10. Cursor repositioning / cursor-relative binding to earlier mentions.
  11. Word-boundary gate preservation (email@domain.com, foo/bar do not activate).
  12. Newline hard-termination.

Verification

  • packages/core/src/Chat/useTriggerMenu.test.tsx: 12/12 passed
  • packages/core/src/Chat/: 263/263 passed across 19 test files
  • ESLint: 0 errors
  • Changeset check: Passed

@vercel

vercel Bot commented Sep 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 7, 2026 5:50pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 7, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Sep 7, 2026
github-actions Bot added a commit that referenced this pull request Sep 7, 2026
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

Chat (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 5628 -
Complexity N/A Very High (464) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

Status: No visual change across 2 compared shot(s).


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] useTriggerMenu closes @ menus when the query contains whitespace

1 participant