feat(ui): add @mention and /command suggestions to ChatComposer
What
Two commits:
-
ChatComposerbase component (cherry-picked — it was pushed to the #6163 branch a few hours after that PR merged, so it never landed on main): Codex-style chat input with auto-growing textarea (IME-safe Enter-to-send viaisEnterSubmit), platform-aware⌘L/Ctrl Lfocus hint chip backed by a real global shortcut listener, atoolbarslot for app-owned controls, optional attach button, and a status-aware send button (disabled → primary arrow → stop square whilestatus="streaming"). Exported as@superset/ui/chat-composer. -
Suggestion layer: typing
@opens a mention popover (any position, token charset supports file paths); typing/opens a command popover (message start only). Consumers passmentions/commandsas{id, label, description?, icon?}arrays — filtering is case-insensitive contains, capped at 8.
Interaction details
- Popover anchors above the composer; ArrowUp/Down cycle (wrapping), Enter/Tab accept, Escape dismisses for the current token (reopens on a new token), mouse hover + click work with focus retained.
- While the popover is open, Enter accepts instead of submitting — verified that accepting never sends the message.
- Accepting replaces the active token with
@label//labeland restores the caret after the insertion. - Token tracking follows the caret (
selectionchangeviaonSelect), so clicking into the middle of@partialreopens the correct query; blur closes the popover.
Verification
Typecheck, Biome, and sherif pass. CDP-verified in Storybook: @Chat → 3 filtered file options with icons; ArrowDown+Enter inserted the second path without submitting; /re → /review with description; Enter completed the command, second Enter submitted and flipped the send button to stop.
https://claude.ai/code/session_0114z2gU9LFJjbwSiyfLTkzY
Summary by cubic
Replaces the old textarea composer with a production PromptInput in @superset/chat-ui, adding @mentions, /commands, rich attachments, dictation with Escape-to-cancel, a layout ComposerDropZone, and a ScrollToBottomButton. Menus are docked and ranked, and submit payloads now include structured mentions and attachments.
-
New Features
PromptInput: provider-based@mentions with sectioned, docked menus (top/bottom) and highlight callbacks; ranked/commands that execute actions and only trigger when the token is the full message; structured mentions in submit payloads.- Attachments and chips: drag/drop/paste; image/video thumbnails and MIME-aware icons; managed object URLs;
onAttachmentClickandonChipClick; single chip renderer with icon slot and blended colors. - Dictation: mic with live waveform/timer; send/plus disabled while recording; stop inserts transcript at end; Escape cancels or discards failed transcription with retry; start errors via
dictation.onError; editor starts two lines tall. - Layout and UX:
ComposerDropZoneroutes drops to the active composer;+opens the@menu in browse mode; menus are mutually exclusive;ScrollToBottomButton. Storybook scans@superset/chat-uifor Tailwind and importsshadcn/tailwind.css; demos include dictation error/retry and a circular scroll button.
-
Bug Fixes
- Docked full-width suggestion panels with inner scroll-fade to avoid clipped/offscreen popovers; consistent dismissal on Escape/outside press; fixed double-Escape by making modes exclusive.
- Attachments: deduped editor vs card drops; video thumbnails; image decode fallback to file card; improved remove badge contrast; chips always present an interactive hover.
- Mention chips: suppressed native text selection; click selects; Backspace/Delete remove; clicks bubble via
onChipClick. - Cleanup: removed the superseded textarea composer from
@superset/ui; co-locatedRemoveButton; removed unusedformatBytesutil and a straycnimport; sidebar story updated to use the circular scroll-to-bottom button.
Summary by CodeRabbit
-
New Features
- Added rich chat composers with text editing, mentions, slash commands, file attachments, drag-and-drop, paste support, attachment previews, and streaming controls.
- Added Lexical- and Tiptap-based composer options with configurable submission, stopping, placeholders, and auto-resizing behavior.
- Exposed composer components for reuse across the UI package.
-
Documentation
- Added interactive Storybook examples covering default, streaming, minimal, and editor-specific scenarios.