HERMES-GIELIE/api
nesquena-hermes d39d30a213
fix: correct message ordering after task cancellation — v0.50.163 (#883)
fix: correct message ordering after task cancellation — v0.50.163 (#883)

Fixes the message-ordering glitch from #882: clicking Cancel while the
agent is responding could cause a subsequent response to render above
the "*Task cancelled.*" marker.

Root cause: the cancel handler pushed the marker only to local S.messages
without persisting to the server. When the done event fired shortly after
and replaced S.messages from server state, the marker disappeared from
client state while the next response anchored to the server-authoritative
position.

Fix has three parts:
- Server (cancel_stream): append *Task cancelled.* to session.messages
  with _error:True + timestamp, then save. _error ensures
  _sanitize_messages_for_api() strips it from conversation_history on
  the next agent turn, so the LLM never sees it as a prior assistant
  turn. Precedent: same flag used for the apperror marker at line 1343.
- Client (SSE cancel handler): fetch /api/session instead of pushing
  locally (same pattern as the done handler). Falls back to local push
  if the fetch fails.
- Tests: fix test window width for cancel handler (1200→dynamic); add
  two regression tests pinning _error flag and _sanitize invariant.

1941 tests passing.

Co-authored-by: piliang <piliang1@jd.com>
2026-04-22 22:17:40 -07:00
..
__init__.py Hermes Web UI — Sprints 11-14: multi-provider models, settings, session QoL, alerts, polish 2026-03-31 07:02:47 +00:00
auth.py release: v0.50.102–v0.50.108 batch (code blocks, utf-8, image URLs, deletion warning, PermissionError, Docker docs, kimi-k2.5) (#755) 2026-04-20 00:26:55 -07:00
clarify.py feat: harden clarify dialog flow and refresh recovery 2026-04-15 13:10:50 +08:00
commands.py feat: slash command parity + skill autocomplete — v0.50.91 (PR #711) 2026-04-19 05:37:44 +00:00
config.py fix: Nous portal model IDs + portal provider routing guard — v0.50.157 (closes #854) 2026-04-22 23:05:27 +00:00
gateway_watcher.py fix(sessions): surface gateway SSE failures and add polling fallback (#828) 2026-04-21 21:18:55 -07:00
helpers.py fix: correct webui profile switching state — v0.50.150 (PR #849 by @migueltavares) 2026-04-22 16:27:01 +00:00
models.py fix: prune stale session index entries after session-id rotation — v0.50.148 (PR #847 by @franksong2702) 2026-04-22 16:26:38 +00:00
onboarding.py fix(onboarding): recognize credential_pool OAuth auth for openai-codex (#797) 2026-04-21 15:41:34 +00:00
profiles.py fix(profiles): complete profile isolation via cookie + thread-local (#805) 2026-04-21 17:04:11 +00:00
providers.py fix(ci): eliminate test_set_key flakiness — v0.50.161 2026-04-23 02:09:37 +00:00
routes.py feat(workspaces): autocomplete trusted workspace paths — v0.50.162 (PR #880 by @franksong2702, closes #616) 2026-04-23 02:35:58 +00:00
session_ops.py feat: slash command parity + skill autocomplete — v0.50.91 (PR #711) 2026-04-19 05:37:44 +00:00
startup.py fix(security): gate auto-install behind HERMES_WEBUI_AUTO_INSTALL=1 — v0.50.156 2026-04-22 20:49:28 +00:00
state_sync.py security: bandit fixes B310/B324/B110 + QuietHTTPServer (#354) 2026-04-13 11:11:56 -07:00
streaming.py fix: correct message ordering after task cancellation — v0.50.163 (#883) 2026-04-22 22:17:40 -07:00
updates.py fix: update banner — conflict recovery path + server self-restart after update (#816) 2026-04-21 17:10:41 -07:00
upload.py v0.50.25: mobile scroll, import timestamps, profile security, mic fallback (#404) 2026-04-13 22:11:45 -07:00
workspace.py feat(workspaces): autocomplete trusted workspace paths — v0.50.162 (PR #880 by @franksong2702, closes #616) 2026-04-23 02:35:58 +00:00