fix: briefing discuss button — full article content + scroll + optimistic UI
Three bugs in discussArticle(): - Scroll selector was '.briefing-chat' (doesn't exist) → '.briefing-center'; the panel never scrolled into view so the response was invisible until refresh - Only 300-char snippet was sent to the LLM; now passes the full stored content (up to 2000 chars) from the backend - User message wasn't shown until streaming ended; now added optimistically to messages[] immediately on click so it appears straight away Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ export interface NewsItem {
|
|||||||
title: string
|
title: string
|
||||||
url: string
|
url: string
|
||||||
snippet: string
|
snippet: string
|
||||||
|
content: string
|
||||||
published_at: string | null
|
published_at: string | null
|
||||||
topics: string[]
|
topics: string[]
|
||||||
source: string
|
source: string
|
||||||
|
|||||||
@@ -176,12 +176,25 @@ async function send(overrideText?: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function discussArticle(item: NewsItem) {
|
async function discussArticle(item: NewsItem) {
|
||||||
const snippet = item.snippet ? `\n\n"${item.snippet.slice(0, 400)}${item.snippet.length > 400 ? '…' : ''}"` : ''
|
const body = (item.content || item.snippet || '').trim()
|
||||||
const text = `Summarize the following article excerpt for me in a few sentences and share your thoughts. Do not use any research or search tools — just respond conversationally based on what I've shared below.\n\n**${item.title}**${snippet}\n\nSource: ${item.source}`
|
const bodyBlock = body ? `\n\n---\n${body}\n---` : ''
|
||||||
// Scroll the chat panel into view on narrow layouts, then send
|
const text = `Please summarize and share your thoughts on this article. Do not use any research or search tools — respond conversationally based only on the content below.\n\n**${item.title}**\nSource: ${item.source}${bodyBlock}`
|
||||||
|
|
||||||
|
// Add the user message optimistically so it appears immediately
|
||||||
|
const optimisticMsg: BriefingMessage = {
|
||||||
|
id: Date.now(),
|
||||||
|
role: 'user',
|
||||||
|
content: text,
|
||||||
|
created_at: new Date().toISOString(),
|
||||||
|
}
|
||||||
|
messages.value = [...messages.value, optimisticMsg]
|
||||||
|
|
||||||
|
// Scroll the chat panel into view
|
||||||
await nextTick(() => {
|
await nextTick(() => {
|
||||||
document.querySelector('.briefing-chat')?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
|
document.querySelector('.briefing-center')?.scrollIntoView({ behavior: 'smooth', block: 'nearest' })
|
||||||
|
scrollToBottom()
|
||||||
})
|
})
|
||||||
|
|
||||||
await send(text)
|
await send(text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -388,6 +388,7 @@ async def list_news():
|
|||||||
"title": r["title"],
|
"title": r["title"],
|
||||||
"url": r["url"],
|
"url": r["url"],
|
||||||
"snippet": (r["content"] or "")[:300],
|
"snippet": (r["content"] or "")[:300],
|
||||||
|
"content": r["content"] or "",
|
||||||
"published_at": r["published_at"].isoformat() if r["published_at"] else None,
|
"published_at": r["published_at"].isoformat() if r["published_at"] else None,
|
||||||
"topics": r["topics"] or [],
|
"topics": r["topics"] or [],
|
||||||
"source": r["feed_title"],
|
"source": r["feed_title"],
|
||||||
|
|||||||
Reference in New Issue
Block a user