improve message autoscroll and metadata

This commit is contained in:
Shantur Rathore
2025-11-08 23:11:45 +00:00
parent 0a77feac7a
commit c9ef192ef2
2 changed files with 19 additions and 8 deletions

View File

@@ -270,6 +270,8 @@ export default function MessageStream(props: MessageStreamProps) {
)
})
const currentSession = createMemo(() => sessions().get(props.instanceId)?.get(props.sessionId))
const formattedSessionInfo = createMemo(() => {
const sessionInfo = getSessionInfo(props.instanceId, props.sessionId) || {
tokens: 0,
@@ -287,6 +289,7 @@ export default function MessageStream(props: MessageStreamProps) {
)
})
function isNearBottom(element: HTMLDivElement, offset = SCROLL_OFFSET) {
const { scrollTop, scrollHeight, clientHeight } = element
const distance = scrollHeight - (scrollTop + clientHeight)
@@ -388,7 +391,14 @@ export default function MessageStream(props: MessageStreamProps) {
tokenSegments.push(`${message.id}:${message.version ?? 0}:${message.status}:${message.parts.length}`)
for (const part of message.parts) {
const partId = typeof part.id === "string" ? part.id : part.type ?? "part"
const partVersion = typeof (part as any).version === "number" ? (part as any).version : 0
tokenSegments.push(`${message.id}:${partId}:${partVersion}`)
}
const baseDisplayParts = message.displayParts
const displayParts: MessageDisplayParts =
baseDisplayParts && baseDisplayParts.showThinking === showThinking
? baseDisplayParts

View File

@@ -1409,19 +1409,20 @@ function handleMessageUpdate(instanceId: string, event: any): void {
message.status = "complete" as const
message.version += 1
message.displayParts = computeDisplayParts(message, preferences().showThinkingBlocks)
session.messagesInfo.set(info.id, info)
withSession(instanceId, info.sessionID, (session) => {
// Session already mutated in place
})
updateSessionInfo(instanceId, info.sessionID)
}
session.messagesInfo.set(info.id, info)
withSession(instanceId, info.sessionID, (session) => {
// Session already mutated in place
})
updateSessionInfo(instanceId, info.sessionID)
}
}
function handleSessionUpdate(instanceId: string, event: any): void {
const info = event.properties?.info
if (!info) return