HERMES-GIELIE/static
Arsh Kumar Singh d385db69d5
fix(clarify): require stable clarify_id and wait for backend ack so stale responses are rejected
The WebUI clarification popup had a response-delivery failure: users
submitted answers in the popup, but the agent still fell through to the
timeout fallback message.  Three bugs conspired:

1. No stable clarify_id — _ClarifyEntry had no unique identifier, so
   the frontend could not reference a specific pending prompt.  The
   backend used FIFO resolution which silently failed for stale/late
   responses.

2. Frontend hid the card before confirmation — respondClarify() called
   hideClarifyCard(true, 'sent') BEFORE the API call completed.  If the
   backend rejected the response, the card was already gone and the
   user's draft was discarded.

3. Backend lied about success — _resolve_clarify_legacy() returned
   bool(resolved) or not bool(clarify_id).  Since the frontend never
   sent clarify_id, the backend always reported ok:true even when
   nothing was resolved.

Changes:

api/clarify.py:
- _ClarifyEntry now auto-generates a stable clarify_id (uuid4.hex[:12])
- submit_pending() injects clarify_id into the data dict visible to the
  frontend via SSE and polling
- New resolve_clarify_by_id() for O(1) lookup by id instead of FIFO pop

api/routes.py:
- _resolve_clarify_legacy() uses resolve_clarify_by_id when clarify_id
  is provided; returns actual bool result (no more unconditional True)
- _handle_clarify_respond() returns HTTP 409 + {ok:false, stale:true}
  when resolution fails

static/messages.js:
- respondClarify() now sends clarify_id in the POST body
- Waits for a positive backend acknowledgement before hiding the card
- Saves a draft copy before POST and restores it on failure
- On 409/network error: re-enables controls, shows error toast
- Guards against parallel-SSE race where clearing the cache after a
  successful response could erase a newly queued next prompt (codex P1)

tests:
- Updated test_sprint30.py for new ack-before-hide behaviour
- Updated test_clarify_unblock.py for 409 on stale responses

Closes #2639.
2026-05-20 16:35:15 +00:00
..
vendor chore: vendor streaming-markdown@0.2.15, remove CDN dependency 2026-04-24 01:05:20 +00:00
apple-touch-icon.png feature: add manifest and icons to enable app install on android 2026-05-02 19:06:39 +02:00
boot.js feat: add Geist Contrast skin 2026-05-20 00:09:06 +00:00
commands.js fix: honour skin value in theme command 2026-05-20 00:09:06 +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-192.png feature: add manifest and icons to enable app install on android 2026-05-02 19:06:39 +02:00
favicon-512.png feature: add manifest and icons to enable app install on android 2026-05-02 19:06:39 +02:00
favicon-512.svg feature: add manifest and icons to enable app install on android 2026-05-02 19:06:39 +02: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: add Geist Contrast skin 2026-05-20 00:09:06 +00:00
icons.js Stage 382: PR #2500 (with whitespace polish on panels.js + ARCHITECTURE.md) 2026-05-18 03:45:02 +00:00
index.html Stage 388: PR #2533 2026-05-20 00:17:47 +00:00
login.js Fix login health probe credentials 2026-05-12 20:09:54 +08:00
manifest.json feat: add browser offline recovery and PWA cache hardening 2026-05-08 21:16:17 +00:00
messages.js fix(clarify): require stable clarify_id and wait for backend ack so stale responses are rejected 2026-05-20 16:35:15 +00:00
onboarding.js docs: clarify Anthropic auth choices in onboarding 2026-05-06 06:26:43 +00:00
panels.js fix: time out hung browser api requests 2026-05-20 02:41:00 +08:00
sessions.js fix(webui): prevent composer draft rollback on refresh 2026-05-19 13:31:12 -06:00
style.css feat: add Geist Contrast skin 2026-05-20 00:09:06 +00:00
sw.js fix: reduce browser storage pressure 2026-05-16 08:44:04 -07:00
terminal.js fix: anchor active sessions per browser tab 2026-05-01 19:52:05 +08:00
ui.js fix(system): allow browser-only dashboard links 2026-05-19 22:47:55 +00:00
workspace.js fix: time out hung browser api requests 2026-05-20 02:41:00 +08:00