fix: prevent show_html cards from disappearing during streaming
This commit is contained in:
parent
9199f5ca7c
commit
e758df767f
@ -730,23 +730,6 @@ function renderShowImages(root: ParentNode | null = document) {
|
||||
});
|
||||
|
||||
let persistent = showHtmlPersistentRenderByPath.get(pathKey);
|
||||
if (!persistent && effectiveEncoded && inStreaming) {
|
||||
// 精确匹配
|
||||
let ep = showHtmlPersistentByEncoded.get(effectiveEncoded);
|
||||
// 前缀匹配:多条渲染源可能输出不同阶段的 encoded,用最长前缀匹配找到 COMPLETE 的 wrapper
|
||||
if (!ep) {
|
||||
let bestLen = 0;
|
||||
for (const [key, val] of showHtmlPersistentByEncoded) {
|
||||
if (key.startsWith(effectiveEncoded) && key.length > bestLen) {
|
||||
ep = val; bestLen = key.length;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ep) {
|
||||
persistent = { encoded: ep.encoded, ratioKey: ep.ratioKey, widthPx: ep.widthPx, heightPx: ep.heightPx, wrapper: ep.wrapper, host: ep.host, root: ep.root };
|
||||
showHtmlPersistentRenderByPath.set(pathKey, persistent);
|
||||
}
|
||||
}
|
||||
if (!persistent) {
|
||||
const wrapper = document.createElement('div');
|
||||
wrapper.className = 'chat-inline-card chat-inline-card--html chat-inline-html';
|
||||
@ -824,12 +807,6 @@ function renderShowImages(root: ParentNode | null = document) {
|
||||
persistent.widthPx = widthPx;
|
||||
persistent.heightPx = heightPx;
|
||||
persistent.ratioKey = ratioKey;
|
||||
if (effectiveEncoded && inStreaming) {
|
||||
showHtmlPersistentByEncoded.set(effectiveEncoded, {
|
||||
wrapper: persistent.wrapper, host: persistent.host, root: persistent.root,
|
||||
encoded: effectiveEncoded, ratioKey, widthPx, heightPx
|
||||
});
|
||||
}
|
||||
debugShowHtmlLog('render:node-persistent-update', {
|
||||
renderId,
|
||||
pathKey,
|
||||
@ -919,10 +896,6 @@ const showHtmlPersistentRenderByPath = new Map<
|
||||
root: HTMLElement
|
||||
}
|
||||
>();
|
||||
const showHtmlPersistentByEncoded = new Map<string, {
|
||||
wrapper: HTMLElement, host: HTMLElement, root: HTMLElement,
|
||||
encoded: string, ratioKey: string, widthPx: number, heightPx: number
|
||||
}>();
|
||||
const showHtmlJsPendingRenderByPath = new Map<
|
||||
string,
|
||||
{
|
||||
@ -1248,7 +1221,6 @@ export function teardownShowImageObserver() {
|
||||
showHtmlCompletedSnapshotByPath.clear();
|
||||
showHtmlStreamingSizeLockByPath.clear();
|
||||
showHtmlPersistentRenderByPath.clear();
|
||||
showHtmlPersistentByEncoded.clear();
|
||||
showHtmlJsPendingRenderByPath.clear();
|
||||
showHtmlJsIframeRenderByPath.clear();
|
||||
showTagObservedContainer = null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user