Some checks failed
Release & Docker / release (push) Has been cancelled
* 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]>
161 lines
5.7 KiB
Python
161 lines
5.7 KiB
Python
import io
|
|
import json
|
|
import pathlib
|
|
import sys
|
|
from urllib.parse import urlparse
|
|
|
|
REPO_ROOT = pathlib.Path(__file__).parent.parent.resolve()
|
|
if str(REPO_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(REPO_ROOT))
|
|
|
|
import api.profiles as profiles
|
|
import api.routes as routes
|
|
|
|
|
|
class _FakeHandler:
|
|
def __init__(self):
|
|
self.status = None
|
|
self.headers = {}
|
|
self.wfile = io.BytesIO()
|
|
|
|
def send_response(self, status):
|
|
self.status = status
|
|
|
|
def send_header(self, key, value):
|
|
self.headers[key] = value
|
|
|
|
def end_headers(self):
|
|
pass
|
|
|
|
def json_body(self):
|
|
return json.loads(self.wfile.getvalue().decode("utf-8"))
|
|
|
|
|
|
def _clear_attention_state(*session_ids):
|
|
from api import clarify
|
|
|
|
with routes._lock:
|
|
for sid in session_ids:
|
|
routes._pending.pop(sid, None)
|
|
routes._gateway_queues.pop(sid, None)
|
|
for sid in session_ids:
|
|
clarify.clear_pending(sid)
|
|
|
|
|
|
def test_attention_summary_prefers_pending_approvals_over_clarify_questions():
|
|
sid = "attention-both-session"
|
|
_clear_attention_state(sid)
|
|
try:
|
|
routes.submit_pending(sid, {"command": "rm -rf /tmp/nope", "description": "Danger"})
|
|
routes.submit_pending(sid, {"command": "touch /tmp/nope", "description": "Also danger"})
|
|
routes.submit_clarify_pending(sid, {
|
|
"question": "Which option?",
|
|
"choices_offered": ["A", "B", "C"],
|
|
})
|
|
|
|
summary = routes._session_attention_summary(sid)
|
|
|
|
assert summary == {
|
|
"kind": "approval",
|
|
"count": 2,
|
|
"severity": "critical",
|
|
}
|
|
finally:
|
|
_clear_attention_state(sid)
|
|
|
|
|
|
def test_attention_summary_reports_clarify_when_no_approval_is_pending():
|
|
sid = "attention-clarify-session"
|
|
_clear_attention_state(sid)
|
|
try:
|
|
routes.submit_clarify_pending(sid, {
|
|
"question": "Pick deploy target",
|
|
"choices_offered": ["staging", "prod", "cancel"],
|
|
})
|
|
routes.submit_clarify_pending(sid, {
|
|
"question": "Pick rollout speed",
|
|
"choices_offered": ["slow", "fast"],
|
|
})
|
|
|
|
summary = routes._session_attention_summary(sid)
|
|
|
|
assert summary == {
|
|
"kind": "clarify",
|
|
"count": 2,
|
|
"severity": "question",
|
|
}
|
|
finally:
|
|
_clear_attention_state(sid)
|
|
|
|
|
|
def test_sessions_api_includes_attention_summary_for_sidebar_rows(monkeypatch):
|
|
sid = "attention-api-session"
|
|
_clear_attention_state(sid)
|
|
try:
|
|
routes.submit_pending(sid, {"command": "sudo service restart", "description": "Restart"})
|
|
|
|
monkeypatch.setattr(routes, "all_sessions", lambda diag=None: [{
|
|
"session_id": sid,
|
|
"title": "Needs approval",
|
|
"profile": "default",
|
|
"updated_at": 1,
|
|
"last_message_at": 1,
|
|
}])
|
|
monkeypatch.setattr(routes, "_reconcile_stale_stream_state_for_session_rows", lambda rows: False)
|
|
monkeypatch.setattr(routes, "load_settings", lambda: {"show_cli_sessions": False})
|
|
monkeypatch.setattr(profiles, "get_active_profile_name", lambda: "default")
|
|
|
|
handler = _FakeHandler()
|
|
routes.handle_get(handler, urlparse("http://example.com/api/sessions"))
|
|
|
|
assert handler.status == 200
|
|
sessions = handler.json_body()["sessions"]
|
|
assert sessions[0]["attention"] == {
|
|
"kind": "approval",
|
|
"count": 1,
|
|
"severity": "critical",
|
|
}
|
|
finally:
|
|
_clear_attention_state(sid)
|
|
|
|
|
|
def test_session_sidebar_renders_attention_badge_and_semantic_classes():
|
|
sessions_js = (REPO_ROOT / "static" / "sessions.js").read_text(encoding="utf-8")
|
|
style_css = (REPO_ROOT / "static" / "style.css").read_text(encoding="utf-8")
|
|
|
|
assert "function _sessionAttentionState" in sessions_js
|
|
assert "needs-attention" in sessions_js
|
|
assert "attention-approval" in sessions_js
|
|
assert "attention-clarify" in sessions_js
|
|
# Attention is conveyed by the colored status dot (is-attention-*), not a
|
|
# text badge — the badge was removed in favor of a color-coded dot + rail.
|
|
assert "is-attention-approval" in sessions_js
|
|
assert "is-attention-clarify" in sessions_js
|
|
assert "session-attention-badge" not in sessions_js
|
|
assert "session_attention_approval" in sessions_js
|
|
assert "session_attention_clarify" in sessions_js
|
|
assert "s.attention" in sessions_js
|
|
assert "_sessionAttentionState(s) ||" in sessions_js
|
|
|
|
i18n_js = (REPO_ROOT / "static" / "i18n.js").read_text(encoding="utf-8")
|
|
assert "session_attention_approval" in i18n_js
|
|
assert "session_attention_clarify" in i18n_js
|
|
assert "session_attention_approval_title" in i18n_js
|
|
assert "session_attention_clarify_title" in i18n_js
|
|
|
|
assert ".session-item.needs-attention" in style_css
|
|
assert ".session-item.attention-approval" in style_css
|
|
assert ".session-item.attention-clarify" in style_css
|
|
# The text-badge styles were removed; the dot now carries the color.
|
|
assert ".session-attention-badge" not in style_css
|
|
assert "is-attention-clarify" in sessions_js, (
|
|
"renderSessionList must tag the state indicator with is-attention-clarify."
|
|
)
|
|
assert ".session-state-indicator.is-attention-approval" in style_css
|
|
assert ".session-state-indicator.is-attention-clarify" in style_css
|
|
assert ".session-state-indicator.is-attention-generic{visibility:visible;}" in style_css
|
|
assert ".session-state-indicator.is-attention-approval{color:var(--error);}" in style_css
|
|
assert ".session-state-indicator.is-attention-clarify{color:var(--warning);}" in style_css
|
|
assert ".session-state-indicator.is-attention-generic{color:var(--warning);}" in style_css
|
|
assert "prefers-reduced-motion" in style_css
|