* Harden interrupted recovery control filtering * Redesign live-to-final assistant replies * Fix live activity anchor test fixture * Fix CI lint issues for live reply tests * Strengthen live progress prompt contract * Recover PR #3401 refresh on origin/master * Repair live-to-final refresh regressions * Fix live worklog refresh regressions * Show live footer timer on initial stream start * Restore live stream shell after reload * Preserve per-frame live SSE replay cursors * Preserve reasoning as Worklog Thinking cards * Quiet Worklog Thinking card styling * Align Worklog Thinking card styling * Scope live Worklog Thinking cards by segment * Suppress exact duplicate settled Thinking * Close #3401 merge review test gaps * fix(#3401): resolve 4 deep-review regressions (inline-think, reconnect-dup, neon skin, busy-gate worklog) Deep review (Codex diff-vs-master + live-browser drive) of the live-to-final refactor surfaced 4 regressions vs master that the rewritten suite no longer guarded: 1. Inline <think>…</think>answer reasoning vanished — _assistantReasoningPayloadText used $-anchored regexes so a leading think block + visible answer extracted nothing and the Thinking card never rendered. Removed the 3 $ anchors to match the (non-anchored) display stripper. Live: inline-think thinking-only turn now renders. 2. (CORE) reconnect/reload duplicated the live reply — _rememberRunJournalCursor advanced a closure-local seq but never wrote INFLIGHT[activeSid].lastRunJournalSeq, so a reload replayed the journal from after_seq=0 over restored lastAssistantText. Now mirrors the cursor onto INFLIGHT + schedules a throttled persist. 3. Neon skin silently broke — PR deleted the :root[data-skin="neon"] CSS but left Neon in the picker. Restored the neon CSS block from master. 4. Settled tool-worklog rebuild gated purely on !S.busy — dropped every prior settled turn's worklog when renderMessages re-ran during an active stream (switch-back to an in-progress session). Restored master's !S.busy || (S.toolCalls && S.toolCalls.length). Live: busy re-render now preserves tool cards (4→4, was 4→0). Live-verified all 4 + confirmed #3709/#3592 invariants still hold (1 thinking card, none below footer; distinct siblings preserved). + tests/test_issue3401_deep_review_fixes.py (7). * test(#3401): realign 3 stale source-shape assertions to the deep-review fixes Fix commit changed two source literals that existing stage tests scanned for: - test_live_activity_timeline.py (x2): split anchor 'if(!S.busy){' → the restored 'if(!S.busy || (S.toolCalls&&S.toolCalls.length)){' guard (fix 4). - test_run_journal_frontend_static.py: 'after_seq=0' not in source — fix 2's comment contained that literal; rephrased the comment to 'the zero floor (after_seq of 0)'. Intent of all three assertions unchanged; only the matched string updated. No code behavior change. * docs(changelog): v0.51.294 — Release JJ (stage-3401, #3401 live-to-final redesign) --------- Co-authored-by: Frank Song <franksong2702@gmail.com> Co-authored-by: Nathan-Hermes <nesquena-hermes@users.noreply.github.com> Co-authored-by: nesquena-hermes <[email protected]>
90 lines
4.4 KiB
Python
90 lines
4.4 KiB
Python
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parent.parent
|
|
MESSAGES_JS = (ROOT / "static" / "messages.js").read_text(encoding="utf-8")
|
|
UI_JS = (ROOT / "static" / "ui.js").read_text(encoding="utf-8")
|
|
RUN_JOURNAL_PY = (ROOT / "api" / "run_journal.py").read_text(encoding="utf-8")
|
|
|
|
def test_stale_interrupted_event_marks_recovery_control():
|
|
assert "\"recovery_control\": True" in RUN_JOURNAL_PY
|
|
|
|
|
|
def test_done_and_restore_filters_recovery_messages_from_frontend_state():
|
|
assert "_filterRecoveryControlMessages(S.messages || [])" in MESSAGES_JS
|
|
assert "if(!m||m.role==='tool') return false;" in MESSAGES_JS
|
|
assert "if(m.recovery_control===true) return true;" in MESSAGES_JS
|
|
assert "previous response was cut off by a network error" in MESSAGES_JS
|
|
assert "continue exactly where you left off" in MESSAGES_JS
|
|
|
|
|
|
def test_apererror_recovers_on_recovery_control_event():
|
|
assert "isRecoveryControlMessage=isInterrupted && (d.recovery_control===true || _streamRecoveryControlMessageText(d.message));" in MESSAGES_JS
|
|
assert "Stream recovery signal received. Restoring transcript..." in MESSAGES_JS
|
|
assert "if(await _restoreSettledSession(source)) return;" in MESSAGES_JS
|
|
|
|
|
|
def test_ui_rejects_recovery_control_as_visible_assistant_content():
|
|
assert "function _isRecoveryControlMessageText" in UI_JS
|
|
assert "function _assistantMessageHasVisibleContent" in UI_JS
|
|
assert "if(_isRecoveryControlMessage(m)) return false;" in UI_JS
|
|
assert "if(_isRecoveryControlMessage(m)){ri++;continue;}" in UI_JS
|
|
assert "_assistantMessageHasVisibleContent(m)" in UI_JS
|
|
|
|
|
|
def test_recovery_control_detection_is_not_broad_phrase_matching():
|
|
assert "|| /continue exactly where you left off/i.test(normalized)" not in UI_JS
|
|
assert "|| /continue exactly where you left off/i.test(normalized)" not in MESSAGES_JS
|
|
assert "const systemRecovery=/^\\[System:/i.test(normalized)" in UI_JS
|
|
assert "const backendRecovery=/^the live worker stopped before this run finished\\.?$/i.test(normalized)" in UI_JS
|
|
def test_recovery_control_does_not_filter_genuine_interruption_card():
|
|
"""A real 'Response interrupted' card carries provider_details_label
|
|
'Interruption details' but is NOT a recovery-control row — it must stay
|
|
visible. Earlier drafts filtered on that label, which would drop a genuine
|
|
interruption the user should see (the inverse-#3300 data-loss class). Drive
|
|
the ACTUAL _isRecoveryControlMessage() from ui.js via node.
|
|
"""
|
|
import shutil, subprocess, json
|
|
node = shutil.which("node")
|
|
if node is None:
|
|
import pytest
|
|
pytest.skip("node not on PATH")
|
|
|
|
def _fn(src, name):
|
|
start = src.index(f"function {name}(")
|
|
brace = src.index("{", start)
|
|
depth = 0
|
|
for i in range(brace, len(src)):
|
|
if src[i] == "{":
|
|
depth += 1
|
|
elif src[i] == "}":
|
|
depth -= 1
|
|
if depth == 0:
|
|
return src[start:i + 1]
|
|
raise AssertionError(name)
|
|
|
|
fns = "\n".join(_fn(UI_JS, n) for n in ("_isRecoveryControlMessageText", "_isRecoveryControlMessage"))
|
|
driver = (
|
|
"function msgContent(m){return (m&&m.content)||'';}\n"
|
|
+ fns + "\n"
|
|
+ "const cases = JSON.parse(process.argv[1]);\n"
|
|
+ "process.stdout.write(JSON.stringify(cases.map(_isRecoveryControlMessage)));\n"
|
|
)
|
|
cases = [
|
|
# genuine interruption card the user MUST see — label set, no marker, normal text
|
|
{"role": "assistant", "content": "**Response interrupted:** the model stopped early",
|
|
"provider_details_label": "Interruption details"},
|
|
# a real user turn that merely mentions interruption — must stay
|
|
{"role": "user", "content": "my previous response was cut off, can you continue?"},
|
|
# explicit server marker — IS recovery control
|
|
{"role": "assistant", "content": "anything", "recovery_control": True},
|
|
# strict synthetic backend text — IS recovery control (backward-compat)
|
|
{"role": "assistant", "content": "The live worker stopped before this run finished."},
|
|
]
|
|
r = subprocess.run([node, "-e", driver, json.dumps(cases)], capture_output=True, text=True, timeout=15)
|
|
assert r.returncode == 0, r.stderr
|
|
out = json.loads(r.stdout)
|
|
assert out == [False, False, True, True], (
|
|
"genuine interruption card (label only) and a real user turn must NOT be "
|
|
f"filtered; only the explicit marker + strict synthetic text are. Got {out}"
|
|
)
|