From 0bb06dca726da44d4816e8342fb14d16cc2e928c Mon Sep 17 00:00:00 2001 From: bincxz <16399091+binaricat@users.noreply.github.com> Date: Mon, 27 Jul 2026 19:31:20 +0800 Subject: [PATCH] fix(ci): prefer rebuilt final research fence --- scripts/cursor-automation.cjs | 2 +- scripts/cursor-automation.test.cjs | 46 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/scripts/cursor-automation.cjs b/scripts/cursor-automation.cjs index 94be2a88d..fc25324a8 100644 --- a/scripts/cursor-automation.cjs +++ b/scripts/cursor-automation.cjs @@ -306,8 +306,8 @@ function parseExternalResearchStream(value, input) { (message) => message.isFinalFlush, )?.text; const candidates = [ - finalAssistantText, ...fencedAssistantSuffixes, + finalAssistantText, terminalResult, partialAssistantText || assistantText, ].filter(Boolean); diff --git a/scripts/cursor-automation.test.cjs b/scripts/cursor-automation.test.cjs index 36274797d..28f372426 100644 --- a/scripts/cursor-automation.test.cjs +++ b/scripts/cursor-automation.test.cjs @@ -2184,6 +2184,52 @@ test('parseExternalResearchStream prefers a split final status over an earlier v ); }); +test('parseExternalResearchStream prefers a split final fence over cumulative flushes', () => { + const staleStatus = 'RESEARCH_NOT_NEEDED: initially appeared local-only'; + const finalStatus = 'RESEARCH_BLOCKED: WebSearch became unavailable'; + const cumulative = `${staleStatus}\n\`\`\`text\n${finalStatus}\n\`\`\``; + const events = [ + { + type: 'assistant', + timestamp_ms: 1, + message: { + content: [{ type: 'text', text: `${staleStatus}\n` }], + }, + }, + { + type: 'assistant', + timestamp_ms: 2, + message: { + content: [{ type: 'text', text: '```text\n' }], + }, + }, + { + type: 'assistant', + timestamp_ms: 3, + message: { + content: [{ type: 'text', text: `${finalStatus}\n\`\`\`` }], + }, + }, + { + type: 'assistant', + message: { + content: [{ type: 'text', text: cumulative }], + }, + }, + { + type: 'result', + subtype: 'success', + is_error: false, + result: cumulative, + }, + ].map(JSON.stringify).join('\n'); + + assert.throws( + () => auto.parseExternalResearchStream(events, {}), + /External research blocked: WebSearch became unavailable/, + ); +}); + test('parseExternalResearchStream keeps a valid terminal status over assistant fragments', () => { const terminalStatus = 'RESEARCH_BLOCKED: WebSearch became unavailable'; const staleAssistantEvents = [