test(media): cover fade MEDIA streaming splits

This commit is contained in:
silent-reader-cn authored and nesquena-hermes committed 2026-07-13 07:41:13 +00:00
1 parent 3b19660235
commit e13a75b7b1
2 files changed
+4 -5

No files matched your search

+3 -4
View File
@@ -3720,7 +3720,7 @@ function attachLiveStream(activeSid, streamId, uploaded=[], options={}){
try{
let st=_anchorProseSmdCache.get(key);
// Self-heal desyncs (edit/sanitize made the text no longer a pure append):
// rebuild the parser+node from scratch, mirroring _smdWrite's guard.
// rebuild the parser+node from scratch, mirroring the _smdWrite guard.
if(st && st.writtenText && !value.startsWith(st.writtenText)) st=null;
if(st && st.fade!==fade) st=null;
if(!st){
@@ -3733,9 +3733,8 @@ function attachLiveStream(activeSid, streamId, uploaded=[], options={}){
node.appendChild(body);
const baseRenderer=fade?_streamFadeRenderer(body):_safeSmdRenderer(body);
const renderer=_smdRendererWithoutUnderscoreEmphasis(baseRenderer);
const parser=window.smd.parser(renderer);
_smdBindParserIdentity(renderer,parser,body);
st={node,parser,writtenText:'',fade};
st={node,parser:window.smd.parser(renderer),writtenText:'',fade};
_smdBindParserIdentity(renderer,st.parser,body);
_anchorProseSmdCache.set(key,st);
// Bound memory across turns: keys embed the stream id, so stale entries
// from finished streams age out here.
+1 -1
View File
@@ -435,7 +435,7 @@ class TestSmdMediaInStream(unittest.TestCase):
MESSAGES_JS.index("function _anchorProseIncrementalNode"):
MESSAGES_JS.index("function _clearAnchorProseIncrementalNode")
].replace(" ", "")
self.assertIn("_smdBindParserIdentity(renderer,parser,body)", anchor)
self.assertIn("_smdBindParserIdentity(renderer,st.parser,body)", anchor)
self.assertNotIn("(data && data.nodes && data.nodes[data.index]) || __SMD_PARSER_FALLBACK", MESSAGES_JS)
def test_smd_end_parser_clears_fallback_media_tail(self):