* 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]>
73 lines
3.2 KiB
Python
73 lines
3.2 KiB
Python
"""#3592 / #3401 -- Thinking-only messages settle into folded Worklog detail.
|
|
|
|
Under the #3401 Worklog model, provider reasoning is not inline assistant prose
|
|
and not a Tool Card. It is preserved as an independent Thinking Card inside the
|
|
folded Worklog above the final answer.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
from pathlib import Path
|
|
|
|
UI_JS = (Path(__file__).resolve().parent.parent / "static" / "ui.js").read_text(encoding="utf-8")
|
|
|
|
|
|
def test_thinking_card_html_function_exists():
|
|
"""_thinkingCardHtml must be defined so Worklog Thinking Cards can render."""
|
|
assert "function _thinkingCardHtml(" in UI_JS, (
|
|
"_thinkingCardHtml function must exist in ui.js"
|
|
)
|
|
|
|
|
|
def test_settlement_loop_does_not_inline_thinking_only_messages():
|
|
"""Thinking-only messages should flow through the Worklog group path."""
|
|
assert "!cards.length&&assistantThinking.has(aIdx)" not in UI_JS, (
|
|
"Thinking-only messages must not use the old inline early-continue path"
|
|
)
|
|
assert "_thinkingActivityNode(thinkingText, false)" in UI_JS, (
|
|
"settled reasoning should render as a collapsed Worklog Thinking Card"
|
|
)
|
|
|
|
|
|
def test_worklog_thinking_card_is_not_a_tool_card():
|
|
"""Thinking Cards should be sibling Worklog items, not Tool Card rows."""
|
|
thinking_fn = UI_JS.split("function _thinkingActivityNode", 1)[1].split("function", 1)[0]
|
|
assert "data-worklog-thinking-card" in thinking_fn
|
|
assert "tool-card-row" not in thinking_fn
|
|
assert "buildToolCard" not in thinking_fn
|
|
|
|
|
|
def test_final_answer_reasoning_worklog_is_placed_before_anchor():
|
|
"""If the visible final answer carries reasoning metadata, its folded
|
|
Worklog must be inserted before that final-answer segment.
|
|
"""
|
|
assert "beforeAnchor:!!thinkingText&&!anchorIsWorklogSource" in UI_JS
|
|
ensure_fn = UI_JS.split("function ensureActivityGroup", 1)[1].split("function normalizeLiveActivityGroupPlacement", 1)[0]
|
|
assert "if(opts.beforeAnchor) inner.insertBefore(group, anchor);" in ensure_fn
|
|
assert "opts.syncAnchorReason!==false" in ensure_fn
|
|
|
|
|
|
def test_show_thinking_preference_respected():
|
|
"""The simplified render path must respect _showThinking for visible cards."""
|
|
render_match = re.search(r"if\(thinkingText&&window\._showThinking!==false\)\{(.*?)\n\s*\}", UI_JS, re.DOTALL)
|
|
assert render_match, "thinking render branch not found"
|
|
assert "assistantThinking.set(rawIdx, thinkingText)" in render_match.group(1)
|
|
|
|
|
|
def test_messages_with_tool_calls_still_use_worklog_group():
|
|
"""Messages that have tool calls must still flow through the Worklog group."""
|
|
assert "ensureActivityGroup(" in UI_JS, (
|
|
"ensureActivityGroup must still be called for messages with tool calls"
|
|
)
|
|
|
|
|
|
def test_thinking_only_turns_use_worklog_duration():
|
|
"""Thinking-only turns now create a folded Worklog group, so that group owns
|
|
the "Done in ..." duration instead of the final answer footer.
|
|
"""
|
|
m = re.search(r"const compactWorklogForMessage=isSimplifiedToolCalling\(\)&&([^;]+);", UI_JS)
|
|
assert m, "compactWorklogForMessage suppression condition not found"
|
|
cond = m.group(1)
|
|
assert "toolCallAssistantIdxs.has(mi)" in cond
|
|
assert "assistantThinking.has(mi)" in cond
|