HERMES-GIELIE/static
nesquena-hermes e68f74ac99 fix(approval): close SSE notify-ordering, head-fidelity, and trailing-approval gaps (Opus MUST-FIX A/C/D)
Pre-release Opus review caught three correctness bugs in the original
PR #1350 SSE wiring beyond the snapshot/subscribe race:

A) **Notify-ordering race (MUST-FIX A):** _approval_sse_notify took _lock
   only for the subscriber-list snapshot, then released it before
   put_nowait. With two parallel submit_pending calls, T2's notify
   could fire before T1's, leaving the UI showing pending_count=1 while
   the server actually had 2 queued.

C) **Trailing approval lost (MUST-FIX C):** _handle_approval_respond
   never called _approval_sse_notify after popping. With parallel
   tool-call approvals (#527), a second approval queued behind the one
   being responded to was invisible until the next event ever fired —
   in practice, the agent thread parked on it would appear hung.

D) **Payload showed tail not head (MUST-FIX D):** payload built from
   the just-appended entry instead of queue[0]. /api/approval/pending
   returns the head; SSE returned the tail. Diverging contracts.

Fix:
- Split into _approval_sse_notify_locked (caller holds _lock, no
  internal locking) and _approval_sse_notify (convenience wrapper).
- submit_pending: call _locked variant inside the queue-mutation lock,
  passing queue_list[0] as head.
- _handle_approval_respond: call _locked variant inside the pop lock,
  passing the new head (or None/0 if queue is empty).
- Restore fallback poll to 1500ms (was bumped to 3000ms; degraded-mode
  parity with v0.50.247 is more important than save 1.5s of polling).

New regression tests in tests/test_pr1350_sse_notify_correctness.py:
- test_second_submit_pending_sends_head_not_tail (D)
- test_respond_to_first_pushes_second_as_new_head (C)
- test_respond_to_only_pending_pushes_empty_state (C edge)
- test_pending_count_is_monotonic_under_contention (A)

Updated test_approval_sse.py to pin the new contract:
- _approval_sse_notify_locked(session_key, head, total)
- 1500ms fallback interval

Total: 3411 tests passing.

Co-authored-by: jasonjcwu <jasonjcwu@users.noreply.github.com>
2026-04-30 18:45:15 +00:00
..
vendor chore: vendor streaming-markdown@0.2.15, remove CDN dependency 2026-04-24 01:05:20 +00:00
boot.js fix(mobile): workspace panel sliver + composer footer collapse (#1300) 2026-04-30 15:24:36 +00:00
commands.js Add Portuguese (pt-BR) locale 2026-04-29 06:06:01 +00:00
favicon-32.png fix: add favicon (SVG + PNG + ICO), fix static MIME types (#613) 2026-04-16 20:11:02 -07:00
favicon.ico fix: add favicon (SVG + PNG + ICO), fix static MIME types (#613) 2026-04-16 20:11:02 -07:00
favicon.svg fix: add favicon (SVG + PNG + ICO), fix static MIME types (#613) 2026-04-16 20:11:02 -07:00
i18n.js feat(cron): auto-assign cron job sessions to dedicated 'Cron Jobs' project (#1079) 2026-04-30 17:13:59 +00:00
icons.js Add Portuguese (pt-BR) locale 2026-04-29 06:06:01 +00:00
index.html fix(ui+pwa): avoid stale Mermaid render errors and bust cached static asset URLs on every release 2026-04-30 16:18:01 +00:00
login.js v0.50.210: gpt-5.5, cron titles, agent cache, bfcache fix, onboarding fix, mermaid CSP, PWA auth (#1056) 2026-04-25 15:47:44 -07:00
manifest.json feat: add PWA support (manifest, service worker, install prompt) (#920) 2026-04-23 15:14:21 -07:00
messages.js fix(approval): close SSE notify-ordering, head-fidelity, and trailing-approval gaps (Opus MUST-FIX A/C/D) 2026-04-30 18:45:15 +00:00
onboarding.js v0.50.210: gpt-5.5, cron titles, agent cache, bfcache fix, onboarding fix, mermaid CSP, PWA auth (#1056) 2026-04-25 15:47:44 -07:00
panels.js fix(models): default model rehydration when providers share slash-qualified IDs (#1313) 2026-04-30 15:24:35 +00:00
sessions.js release: v0.50.244 (#1308) 2026-04-29 21:34:27 -07:00
style.css fix(mobile): workspace panel sliver + composer footer collapse (#1300) 2026-04-30 15:24:36 +00:00
sw.js fix(ui+pwa): avoid stale Mermaid render errors and bust cached static asset URLs on every release 2026-04-30 16:18:01 +00:00
terminal.js Restore terminal resize and collapse controls 2026-04-29 16:45:26 +08:00
ui.js fix(ui): show context indicator percentage without explicit context_length (#1349) 2026-04-30 18:31:30 +00:00
workspace.js release: v0.50.244 (#1308) 2026-04-29 21:34:27 -07:00