feat(chat): implicit prompt loading with badge dropdown#76
Conversation
Zhang-Henry
left a comment
There was a problem hiding this comment.
Code Review
Overall clean implementation — the badge + editable dropdown approach is well-designed. A few items to address:
Bug: attachedPrompt not cleared on slash command execution
useChatComposerState.ts — The slash command handler (line ~542) has its own cleanup and returns early, bypassing the main reset path where setAttachedPrompt(null) is called. If a user attaches a prompt then runs a /command, the badge will persist.
Fix: Add setAttachedPrompt(null) to the slash command cleanup block.
Performance: onUpdate fires on every keystroke
PromptBadgeDropdown.tsx — The editable textarea calls onUpdate → setAttachedPrompt on every onChange, causing the entire composer to re-render per keystroke. Consider updating on onBlur instead, or debouncing.
Minor
- Empty message bubble: When submitting with only an attached prompt (no user text),
message.contentis""— the bubble shows a badge with blank body. Consider hiding the content div or showing a prompt summary. - Circular
useEffect: TheeditTextsync effect re-fires on self-triggeredpromptTextchanges. Keying onprompt.scenarioIdinstead ofprompt.promptTextwould be cleaner (especially if switching to blur-based updates). - Accessibility:
PromptBadgeDropdownlacks Escape-to-close andaria-expanded/aria-controls.
Positive
- Clean
AttachedPrompttype andChatMessageextension - Full i18n coverage (en/zh-CN/ko)
- Good backward-compatible fallback via optional
setAttachedPromptprop - Correct thinking mode prefix fix (
currentInput→messageContent)
|
Thanks for the thorough review! All items addressed: Bug fix — Added setAttachedPrompt(null) to the slash command cleanup block so the badge is cleared on early return. Performance — Switched to blur-based updates. The text area now uses local state for keystroke responsiveness and only calls onUpdate on blur. Minor items:
|
When selecting a task card, the prompt is hidden behind a badge chip at the top of the input container. Users can click the dropdown arrow to expand and edit the prompt, while the textarea stays clean.
- Clear attachedPrompt on slash command execution to prevent stale badge - Update prompt text on blur instead of every keystroke to avoid re-renders - Hide empty content div when submitting with only an attached prompt - Sync editText on scenarioId change instead of promptText to avoid circular effect - Add aria-expanded, aria-controls, and Escape-to-close for accessibility
fb5796b to
9a86366
Compare
Summary
container, instead of filling the textarea with raw prompt text
Changes
AttachedPrompttype added toChatMessageto carry prompt metadata through the message flowuseChatComposerState— newattachedPromptstate;handleSubmitprepends prompt text and clears it after sendPromptBadgeDropdown— new component rendering the badge chip with collapsible editable promptGuidedPromptStarter/SkillShortcutsPanel— usesetAttachedPromptinstead ofsetInputto attach prompts implicitlyMessageComponent— renders attached prompt badge in user message bubblesTest plan