fix(chat): stop loading bubble early, no tab switch on inject, convert md->html in richtext
This commit is contained in:
@@ -151,7 +151,9 @@ export function ContextualAIChat({
|
||||
|
||||
const { messages, sendMessage, status, stop } = useChat({ transport })
|
||||
|
||||
const isLoading = status === 'submitted' || status === 'streaming'
|
||||
const lastMsg = messages[messages.length - 1]
|
||||
const lastMsgHasContent = lastMsg?.role === 'assistant' && !!getMessageContent(lastMsg)
|
||||
const isLoading = (status === 'submitted' || status === 'streaming') && !lastMsgHasContent
|
||||
|
||||
useEffect(() => {
|
||||
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' })
|
||||
@@ -304,16 +306,15 @@ export function ContextualAIChat({
|
||||
/** Called from chat hover-actions: inject a chat message into the note */
|
||||
const handleInjectFromChat = async (msgText: string, mode: 'replace' | 'complete' | 'merge') => {
|
||||
if (mode === 'replace') {
|
||||
// Stay on chat tab — show preview inline via resourcePreview without switching tabs
|
||||
setResourceText(msgText)
|
||||
setResourceMode('replace')
|
||||
setResourcePreview({ text: msgText, source: 'chat' })
|
||||
setActiveTab('resource')
|
||||
return
|
||||
}
|
||||
setResourceText(msgText)
|
||||
setResourceMode(mode)
|
||||
setActiveTab('resource')
|
||||
// Auto-launch enrichment
|
||||
// Do NOT switch tabs — enrich and show preview in current tab
|
||||
setResourceEnriching(true)
|
||||
try {
|
||||
const res = await fetch('/api/ai/enrich-from-resource', {
|
||||
|
||||
Reference in New Issue
Block a user