Commit Graph
7860 Commits
Author SHA1 Message Date
e7ac9f09fd Release: mobile drawer + terminal-backend cache fixes (#6921 #6933 #6671 #6175) (#6990)
* fix: include terminal backend identity in agent cache signature (#5937) (#6175)

* fix(mobile): preserve extension panels in drawer sync

* fix: close mobile sidebar drawer when opening main-view create forms

The add-space/new-profile/new-skill/new-cron forms render in the main
view, which on phones is covered by the full-screen sidebar drawer
(z-index 200). Opening one from inside the drawer only focused the
input (keyboard popped up) while the form stayed hidden underneath.

- openWorkspaceCreate / openProfileCreate / openSkillCreate /
  openCronCreate now close the drawer after rendering the form,
  mirroring their *_Detail siblings.
- move the fromRailClick drawer re-open in switchPanel() into the
  synchronous section: it used to run after await loadXxxPanel(),
  racing (and re-opening over) a drawer close issued from inside the
  drawer during the panel load window.

Verified in Playwright (390x844): drawer closes and stays closed after
plus-click, form visible with focus on the path input; desktop (1280x800)
unchanged; 83 mobile + 26 workspace tests pass.

* fix: close mobile sidebar after project quick-create plus

The per-project '+' button (_attachProjectQuickCreateButton) created the
new project conversation but never closed the mobile sidebar drawer, so on
phones the tap looked like a no-op: the session was created, just hidden
underneath the full-screen drawer (z-index 200).

Close the drawer in the success path after the sidebar repaint, mirroring
$('btnNewChat').onclick in boot.js and the #5409 close in
_openSidebarSession. Failure path keeps the drawer open so the error toast
stays visible for retry.

Adds static regression tests pinning the guarded close call and its
position after the repaint.

* test: pin quick-create drawer close to the success path (try block)

Greptile review note: the string-presence and ordering assertions alone
would still pass if the guarded closeMobileSidebar call were moved into
the later catch branch, silently reintroducing the mobile drawer bug.

Add an explicit assertion that the close sits before the success-path
catch(err), so a regression that moves it into the failure branch is
caught.

* docs(changelog): stamp batch1-p1 (#6921 #6933 #6671 #6175)

---------

Co-authored-by: webtecnica <75556242+webtecnica@users.noreply.github.com>
Co-authored-by: Rodrigo Gomes da Silva <rodrigo.smscom@gmail.com>
Co-authored-by: silent-reader-cn <silent-reader-cn@users.noreply.github.com>
Co-authored-by: nesquena-hermes <nesquena-hermes@users.noreply.github.com>
2026-08-13 16:41:32 +00:00
nesquena-hermes 7d0bc4b6a5 Merge pull request #6981 from nesquena/release/stage-6979-1786619874
Release: per-message media preview snapshots (#6979)
2026-08-13 04:23:23 -07:00
nesquena-hermesandhappy5318 d0ba72035e docs(changelog): stamp #6979 per-message media preview snapshots
Co-authored-by: happy5318 <happy5318@users.noreply.github.com>
2026-08-13 11:17:54 +00:00
nesquena-hermes 0f1ae89082 Merge remote-tracking branch 'origin/master' into HEAD 2026-08-13 10:48:34 +00:00
happy5318 8841662768 fix: close snapshot capture/serve exfiltration holes + prefix-URL corruption (review round 2)
Addresses nesquena-hermes Round-2 review on #6979. All three MUST-FIX
items reproduced end-to-end are fixed; three SHOULD-FIX items folded in.

MUST-FIX 1 (data exfiltration) — capture/serve deny parity + source binding:
- The #3234 state/profile deny model is extracted into a single shared
  predicate (routes._media_deny_reason) used by BOTH /api/media serving and
  snapshot capture, so anything the serve path refuses is never captured in
  the first place (STATE_DIR subdirs, webui_state subdirs, named-profile
  roots, secret basenames, the snapshot store itself).
- Every captured digest now carries a server-owned canonical source-path
  association (<digest>.src.json sidecar, tmp+rename atomic). /api/media
  serves a digest only for the exact path it was captured from — replaying
  a valid digest through a different allowed path falls back to the live
  file instead of leaking stored bytes.
- Snapshot blobs are opened ANCHORED inside the store root (no-follow).
- Committed end-to-end regression: capture a denied state file and prove it
  cannot be served through any path.

MUST-FIX 2 (data exfiltration) — configured store root denied regardless of name:
- get_snapshot_dir() is resolved and any bare path= target at or below it is
  rejected BEFORE the allow/serve decision, so a custom
  HERMES_WEBUI_MEDIA_SNAPSHOT_DIR (e.g. /tmp/custom-store-name) can no
  longer be read via a plain path= request.

MUST-FIX 3 (silent corruption) — prefix-safe URL stamping:
- _stampMediaSnapshots now rewrites each COMPLETE path= query value
  atomically (boundary-aware regex, decode whole value, exact map lookup)
  instead of substring split/join. One path being a prefix of another
  (/tmp/a.png vs /tmp/a.png.backup) can no longer corrupt the longer URL or
  drop its digest. data-path placeholders use the same value-level rewrite
  with HTML-entity unescaping. Prefix-path regression test committed.

SHOULD-FIX folded in:
- A recorded digest is FINAL: quota eviction no longer causes a later settle
  to re-capture the current live bytes and rebind the historical message
  (immutability restored + no quota-thrash I/O).
- is_valid_digest uses whole-string fullmatch (\Z) — a trailing newline can
  no longer pass the gate.
- PDF/HTML fallback, download and open-full-page links now carry snap so
  they open/download the frozen bytes.

Deferred (noted in review thread): emission-time capture (streaming.py) and
worklog scene-prose stamping — scene rows do not carry parent-message
snapshot metadata; threading it through the scene reconciler is a separate
data-pipeline change. Main transcript + transparent ordered segments remain
the old/new comparison surface.

Tests: +11 backend/frontend regressions (36 total in
test_media_message_snapshots.py), incl. the exact Round-2 repros.
Reverse-verified: the new tests fail on the round-1 head (8 failed).
2026-08-13 18:02:03 +08:00
happy5318 1db353a1f0 fix: scope snapshot stamping to main+transparent paths (no scene render changes)
- Revert all worklog/scene render-path changes: the scene render chain is
  exercised by tests that extract function bodies and eval them in isolation
  (_renderAnchorSceneRowsIntoWorklog, _anchorSceneNodeForRow, etc.); adding
  helper references breaks those harnesses with ReferenceError.
- Snapshot stamping now covers the main transcript path and transparent
  ordered segments only — the comparison surface for old/new previews.
- Transparent segment stamping is inlined in the msg-body template guarded by
  typeof m, keeping the source-window string intact for test_issue3397 and
  keeping the eval'd ordered-block self-contained for test_status_command_card.
- PDF/HTML lazy loaders keep the exact publicMediaUrl source string the tests
  assert; snap is appended to mediaUrl only.
2026-08-13 16:40:24 +08:00
happy5318 e5ae65f510 fix: preserve transparent-part source window; clean lint in snapshot tests
- Keep `const partBodyHtml=_getCachedRender(partDisplayText,false);` line
  intact (test_issue3397 asserts the exact source string), apply snapshot
  stamping on the following line via partBodyHtmlStamped.
- Drop unused roots_before variable and unused import in
  test_media_message_snapshots.py (ruff F841/F401 on new lines).
- Update the source-invariant assertion to the two-line stamp shape.
2026-08-13 16:13:03 +08:00
happy5318 4eb98889ba fix: freeze per-message media previews with content-addressed snapshots
PR #6922 made /api/media revalidate on every use, so overwriting a file in
place (same filename) also rewrote every historical chat preview that
referenced it — the old/new comparison was lost.

At settle time, snapshot each local-file MEDIA: reference into a
content-addressed store (<STATE_DIR>/media_snapshots/<sha256>.snap) and stamp
the message with _media_snapshots {path: digest}. The frontend appends
&snap=<digest> to historical preview URLs; /api/media serves the frozen bytes
with immutable caching when the digest is valid, and falls back to the live
file otherwise (eviction/never-captured). The existing path allow/deny checks
still gate the request — snap only selects which bytes to serve, it never
widens access.

- api/media_snapshots.py: content-addressed store (sha256 key, dedup, 50MB
  per-file / 2GB total caps with FIFO eviction), MEDIA ref resolver, capture
  allow-list mirroring the /api/media roots + #3234 deny list
- streaming.py: annotate settled assistant messages (idempotent, best-effort)
- routes.py: snap= serving branch + download_name override + deny direct
  store-path access
- models.py: _media_snapshots registered in display-metadata merge keys
- ui.js: _stampMediaSnapshots post-cache stamping (main transcript,
  transparent ordered segments, worklog scene prose) + data-snap threading
  through the five lazy preview loaders

25 new tests incl. node-executed frontend behavior tests; reverse-verified.
2026-08-13 15:48:17 +08:00
nesquena-hermes 0fc0ebb2b7 Merge pull request #6977 from nesquena/release/stage-6968-1786605449
Release: multi-container Docker agent API reachability (#6968)
2026-08-13 00:23:39 -07:00
nesquena-hermesandbragov4ik fa54dbc9a2 docs(changelog): stamp #6968 multi-container Docker API_SERVER_HOST fix
Co-authored-by: bragov4ik <bragov4ik@users.noreply.github.com>
2026-08-13 07:17:29 +00:00
nesquena-hermes 0f6b9e674d Merge remote-tracking branch 'origin/master' into HEAD 2026-08-13 07:07:47 +00:00
nesquena-hermes 8540583d95 Merge pull request #6971 from nesquena/release/stage-6922-1786592110
Release: media ETag revalidation + post-commit error containment (#6922)
2026-08-12 20:40:31 -07:00
nesquena-hermesandhappy5318 b87d0179fc docs(changelog): stamp #6922 media ETag revalidation + post-commit error containment
Co-authored-by: happy5318 <happy5318@users.noreply.github.com>
2026-08-13 03:35:10 +00:00
nesquena-hermes e510219e16 Merge remote-tracking branch 'origin/master' into HEAD 2026-08-13 02:45:27 +00:00
happy5318 8228dbe4da fix: contain ALL post-commit body errors, not just disconnects
The post-commit body-transmission block only caught
_CLIENT_DISCONNECT_ERRORS. A non-disconnect error during body write —
a generic OSError/EIO from f.read(), or a PermissionError — escaped
_serve_file_bytes entirely, and Handler.do_GET (server.py:388-395)
caught it and emitted a second status line after the already-committed
200/206, corrupting the HTTP stream.

Broaden the post-commit except to swallow every Exception (keeping the
disconnect branch for its debug message). Regression tests drive both
the snapshot and streaming paths with generic OSError/EIO and
PermissionError mid-body, asserting the status sequence is exactly
[200] with no trailing 500.
2026-08-13 09:49:34 +08:00
nesquena-hermes f3e0e29815 Merge pull request #6969 from nesquena/release/stage-6966-1786581547
Release: de-dup session title on collision (#6964)
2026-08-12 17:44:22 -07:00
nesquena-hermesandwebtecnica fac3470668 docs(changelog): stamp #6964 title-dedup + add manual-rename-during-retry test
Codex SHOULD-FIX: add a committed test proving the de-dup retry variant never
clobbers a user-source manual rename (retry goes through the same provenance
rank guard). Additive test-only; no behavior change to the contributor's fix.

Co-authored-by: webtecnica <webtecnica@users.noreply.github.com>
2026-08-13 00:39:07 +00:00
nesquena-hermes 636a543853 Merge remote-tracking branch 'origin/master' into HEAD 2026-08-13 00:25:19 +00:00
Kirill Ivanov 821f45dbb6 Fix two containers 2026-08-12 23:23:18 +00:00
Kirill Ivanov 7b3f65bc42 Fix three containers 2026-08-13 02:18:31 +03:00
nesquena-hermes 3d1e2f1204 Merge pull request #6967 from nesquena/release/stage-6944-1786574898
Release: preserve custom-provider model identity (#6944)
2026-08-12 15:53:35 -07:00
nesquena-hermesandjosephcy95 38db12d72a docs(changelog): stamp #6944 + add ambiguous-suffix-match regression test
Codex round-2 SHOULD-FIX: add a committed test asserting the hinted bare-id
fallback returns null when two same-provider options normalize identically
(refuses to guess), plus single-match resolves and exact-match unaffected.
Additive test-only; no behavior change to the contributor's fix.

Co-authored-by: josephcy95 <josephcy95@users.noreply.github.com>
2026-08-12 22:48:19 +00:00
nesquena-hermes fc58592af7 Merge remote-tracking branch 'origin/master' into HEAD 2026-08-12 22:34:26 +00:00
webtecnica 91ceb60996 fix(sessions): dedup title on collision instead of leaving blank (#6964) 2026-08-12 18:35:09 -03:00
nesquena-hermes 5defcfedfe Merge pull request #6965 from nesquena/release/stage-6947-1786567873
Release: guard persist_user_timestamp kwarg for older-agent compat (#6935)
2026-08-12 14:02:26 -07:00
nesquena-hermesandharsh2hell 7f03b52a00 docs(changelog): stamp #6935 persist_user_timestamp kwarg-compat fix
Co-authored-by: harsh2hell <harsh2hell@users.noreply.github.com>
2026-08-12 20:51:13 +00:00
josephcy95 8673ca7338 fix(models): preserve hinted custom catalog fallback 2026-08-13 04:39:04 +08:00
nesquena-hermes b88452f68c Merge remote-tracking branch 'origin/master' into HEAD 2026-08-12 20:37:03 +00:00
nesquena-hermes 8fb95b43a7 Merge pull request #6960 from nesquena/release/stage-6892-1786560706
Release: sync session titles to state.db (#6892)
2026-08-12 11:57:04 -07:00
nesquena-hermesandliuguangyong93 d73cea803e docs(changelog): stamp #6892 + add direct sync_session_title coverage tests
Codex round-1 SHOULD-FIX: the PR's only test change mocked the new write to a
no-op. Add real-SessionDB tests proving generated-title persistence, manual-rename
no-overwrite, and cli/gateway source preservation on ensure_session. Additive
test-only; no behavior change to the contributor's fix.

Co-authored-by: liuguangyong93 <liuguangyong93@users.noreply.github.com>
2026-08-12 18:51:46 +00:00
nesquena-hermes 32b7f0a5e0 Merge remote-tracking branch 'origin/master' into HEAD 2026-08-12 18:36:54 +00:00
happy5318 1ff002d170 fix: never double-respond after end_headers() in file serving
Move ETag/snapshot computation into a pre-commit try/except OSError so
read errors still convert to a clean 500 before any status line is sent.
Remove the outer OSError catch around body transmission: once
end_headers() returns the response is committed, and a client disconnect
(BrokenPipeError et al.) during the snapshot write or fdopen stream would
previously have triggered bad() -> send_response(500) as a second status
line on a dead stream. Body paths now catch _CLIENT_DISCONNECT_ERRORS
(same tuple as _safe_write()), log at debug, and return True.

Add regression tests with a fake writer that raises BrokenPipeError
after end_headers() for both body paths, asserting exactly one
send_response call.
2026-08-13 00:30:10 +08:00
happy5318 fe34105b22 fix: preserve captured snapshot on short-read (round-6)
When a file is truncated between fstat and the snapshot read, we now return
(None, data, actual_size) instead of (None, None, actual_size). This preserves
the captured bytes so the body path serves the immutable snapshot instead of
re-reading the fd after headers are committed.

This closes the second-order TOCTOU window: if the file shrinks AGAIN between
the first read and body transmission, Content-Length (from actual_size) and
body length (from snapshot) can never diverge.

Changes:
- api/routes.py:18494: return None, data, actual_size (preserve snapshot)
- tests: remove unused original_read (ruff F841)
- test_shrink_again_during_body_transmission_200: 200 advertised 6 / wrote 6
- test_shrink_again_during_body_transmission_range_206: 206 advertised 4 / wrote 4
2026-08-12 21:21:31 +08:00
Harendra Pratap Singh 4e5703fc62 fix(streaming): inspect run_conversation signature before passing persist_user_timestamp (#6935) 2026-08-12 17:55:52 +05:30
happy5318 f5ff9b1465 fix: short-read safety + actual_size reconciliation for ETag snapshot
Round 5 fix: when a file is truncated between fstat and the snapshot read,
Content-Length/Range headers must match the actual bytes read, not the stale
fstat size.

Changes:
1. Replace os.pread with os.lseek + looped os.read (cross-platform + short-read safe)
2. _etag_and_snapshot now returns 3 values: (etag, snapshot, actual_size)
3. Caller uses actual_size for Content-Length/Range calculations
4. If actual_size != file_size (truncation), etag=None → streaming fallback

Regressions:
- test_short_read_truncation_uses_actual_size: Content-Length == body length
- test_short_read_no_etag_on_truncation: no ETag on truncated snapshot
- Updated test_etag_no_body_on_pread_failure for os.read (was os.pread)
2026-08-12 20:19:05 +08:00
happy5318 a959a4c754 fix: add Windows O_BINARY guard for binary file reads
Native Windows opens files in text mode by default, which corrupts
binary media files via CRLF translation. O_BINARY prevents this.

This completes the portability story — the PR was already correct on
all supported platforms (Linux/macOS/WSL2), but the round-3 change was
explicitly about portability, so we close the Windows path too.
2026-08-12 17:19:27 +08:00
josephcy95 1d8e7fe664 fix(models): preserve custom provider model identity 2026-08-12 15:44:05 +08:00
nesquena-hermes 483772b44b Merge pull request #6941 from nesquena/release/stage-6938-1786517565
Release: clear stale compression UI state on session switch (#6938)
2026-08-11 23:58:06 -07:00
nesquena-hermesandhappy5318 fb5a40f132 docs(changelog): stamp #6938 + add loadSession compression-cleanup regression test
Co-authored-by: happy5318 <happy5318@users.noreply.github.com>
2026-08-12 06:52:45 +00:00
liuguangyong93 912ba43d54 fix: use set_auto_title_if_empty and explicit default profile
Address gate-review blockers from nesquena-hermes:

1. Wrong title-authority API: replace `db.set_session_title()` with
   `db.set_auto_title_if_empty()` so auto-generated titles never
   overwrite a manual rename (set_session_title writes with 'user'
   authority; set_auto_title_if_empty only populates NULL titles).

2. Null profile fallback: pass `or 'default'` at both streaming.py
   call sites so background title workers (which lack request TLS)
   always resolve to the correct state.db instead of falling through
   to the process-global active profile.
2026-08-12 14:48:10 +08:00
liuguangyong93 54d60de1af test: mock sync_session_title in title generation test
Neutralize the new `sync_session_title` call in
`test_cleared_title_allows_initial_auto_generation` to prevent state.db
side effects from leaking into shared test state, matching the existing
pattern of mocking collaborators in this test.
2026-08-12 14:48:10 +08:00
liuguangyong93 ae8311915b fix: sync generated title to state.db so hermes sessions list shows WebUI titles
Background title generation (`_run_background_title_update` and
`_run_background_title_refresh`) writes the title to the WebUI sidecar
JSON but never syncs it back to hermes-agent's `state.db`. This causes
`hermes sessions list` to show blank titles for all WebUI-originated
sessions.

The existing `sync_session_usage` path is gated by the `sync_to_insights`
setting (default: off) and executes before the background title thread
completes, so it cannot cover this case.

Fix: add `sync_session_title()` to `state_sync.py` — an unconditional
(not gated by `sync_to_insights`) title-only sync — and call it from both
title generation paths immediately after persisting the title to the
sidecar.
2026-08-12 14:48:10 +08:00
happy5318 f7887bfc87 fix: clear stale compression state on session switch
When switching sessions in loadSession(), the window._compressionUi state
was not cleared, causing phantom 'Compressing context' barriers to appear
on fresh sessions that never triggered compression.

This complements PR #6572 which handles the case where compressed SSE
events are lost/delayed, but does not cover the session switch scenario.

Root cause: loadSession() tears down approval/clarify/composer state but
missed the compression UI state, which is per-session and must not leak.

Fix: Clear compression state immediately after hideClarifyCard() in the
loadSession() teardown sequence.
2026-08-12 12:56:12 +08:00
nesquena-hermes e9f1e2a459 Merge pull request #6934 from nesquena/release/stage-6932-1786470719
Release: search skills by keyword in slash-command autocomplete (#6932)
2026-08-11 10:57:28 -07:00
nesquena-hermes bf2f8f125f docs(changelog): stamp #6932 skill keyword autocomplete 2026-08-11 17:51:59 +00:00
MHJ e4c3c728d9 fix(commands): wait for bundle metadata before skill suggestions 2026-08-12 00:32:57 +09:00
MHJ eea4f03db8 fix(commands): search skills by keyword in slash autocomplete 2026-08-11 23:40:00 +09:00
nesquena-hermes 3c7fbe3809 Merge pull request #6926 from nesquena/release/stage-6924-1786445624
Release: extension turn-lifecycle events (#6924)
2026-08-11 04:03:34 -07:00
nesquena-hermes 1f046e11b0 docs(changelog): stamp #6924 extension turn-lifecycle events 2026-08-11 10:53:44 +00:00
happy5318 72cab65817 fix: pread snapshot + size cap + TOCTOU — address round-2 review (3 issues)
1. _ETAG_SIZE_CAP (10MB): files above skip ETag to avoid hashing large
   media / Range requests.

2. _etag_and_snapshot: single pread into immutable bytes; the ETag
   describes the exact snapshot that is sent, eliminating TOCTOU.

3. ETag computation moved inside fd-lifecycle try/finally; pread
   failures raise OSError caught by the outer except -> 500 + fd closed.

4. no-store content (HTML previews) skips ETag unconditionally.

5. Tests: large-file cap, pread-failure 500+fd-closed, TOCTOU snapshot
   correctness.

Related tests: 20/20 targeted + 33 neighboring passed.
2026-08-11 18:12:04 +08:00