improve message autoscroll and metadata
This commit is contained in:
@@ -270,6 +270,8 @@ export default function MessageStream(props: MessageStreamProps) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const currentSession = createMemo(() => sessions().get(props.instanceId)?.get(props.sessionId))
|
||||||
|
|
||||||
const formattedSessionInfo = createMemo(() => {
|
const formattedSessionInfo = createMemo(() => {
|
||||||
const sessionInfo = getSessionInfo(props.instanceId, props.sessionId) || {
|
const sessionInfo = getSessionInfo(props.instanceId, props.sessionId) || {
|
||||||
tokens: 0,
|
tokens: 0,
|
||||||
@@ -287,6 +289,7 @@ export default function MessageStream(props: MessageStreamProps) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
function isNearBottom(element: HTMLDivElement, offset = SCROLL_OFFSET) {
|
function isNearBottom(element: HTMLDivElement, offset = SCROLL_OFFSET) {
|
||||||
const { scrollTop, scrollHeight, clientHeight } = element
|
const { scrollTop, scrollHeight, clientHeight } = element
|
||||||
const distance = scrollHeight - (scrollTop + clientHeight)
|
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}`)
|
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 baseDisplayParts = message.displayParts
|
||||||
|
|
||||||
const displayParts: MessageDisplayParts =
|
const displayParts: MessageDisplayParts =
|
||||||
baseDisplayParts && baseDisplayParts.showThinking === showThinking
|
baseDisplayParts && baseDisplayParts.showThinking === showThinking
|
||||||
? baseDisplayParts
|
? baseDisplayParts
|
||||||
|
|||||||
@@ -1409,19 +1409,20 @@ function handleMessageUpdate(instanceId: string, event: any): void {
|
|||||||
message.status = "complete" as const
|
message.status = "complete" as const
|
||||||
message.version += 1
|
message.version += 1
|
||||||
message.displayParts = computeDisplayParts(message, preferences().showThinkingBlocks)
|
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 {
|
function handleSessionUpdate(instanceId: string, event: any): void {
|
||||||
|
|
||||||
const info = event.properties?.info
|
const info = event.properties?.info
|
||||||
if (!info) return
|
if (!info) return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user