fix(ui): use part_text_accum_delta to prevent markdown cutoff during streaming (#26822)

This commit is contained in:
Brendan Allan
2026-05-11 15:15:03 +08:00
committed by GitHub
parent b1cb71856e
commit 5d6f2a1524
8 changed files with 37 additions and 2 deletions

View File

@@ -1461,7 +1461,7 @@ PART_MAPPING["text"] = function TextPartDisplay(props) {
const streaming = createMemo(
() => props.message.role === "assistant" && typeof (props.message as AssistantMessage).time.completed !== "number",
)
const text = () => (part().text ?? "").trim()
const text = () => (data.store.part_text_accum_delta?.[part().id] ?? part().text ?? "").trim()
const isLastTextPart = createMemo(() => {
const last = (data.store.part?.[props.message.id] ?? [])
.filter((item): item is TextPart => item?.type === "text" && !!item.text?.trim())
@@ -1521,11 +1521,12 @@ PART_MAPPING["text"] = function TextPartDisplay(props) {
}
PART_MAPPING["reasoning"] = function ReasoningPartDisplay(props) {
const data = useData()
const part = () => props.part as ReasoningPart
const streaming = createMemo(
() => props.message.role === "assistant" && typeof (props.message as AssistantMessage).time.completed !== "number",
)
const text = () => part().text.trim()
const text = () => (data.store.part_text_accum_delta?.[part().id] ?? part().text).trim()
return (
<Show when={text()}>

View File

@@ -24,6 +24,9 @@ type Data = {
part: {
[messageID: string]: Part[]
}
part_text_accum_delta?: {
[partID: string]: string
}
}
export type NavigateToSessionFn = (sessionID: string) => void