Skip to content

fix(desktop): attach non-image web uploads by path instead of failing the read - #60

Merged
ashneil12 merged 1 commit into
mainfrom
fix/web-nonimage-attach-path-only
Jun 13, 2026
Merged

ashneil12 merged 1 commit into
mainfrom
fix/web-nonimage-attach-path-only

Conversation

@ashneil12

Copy link
Copy Markdown
Owner

Port of canary fix ashneil12/vanilla-hermes-agent-canary#103 (commit verified live on canary, confirmed by the reporter).

Problem

In the hosted web rich-chat (vweb client), dropping a non-image file (.md, .txt, .pdf, …) fails with a "Drop files / Could not read <name>" toast. Images work; other files don't. The upload itself succeeds — the file lands at ~/.hermes/uploads/<date>/<name> and the chip shows that server path — but the attach then errors.

Root cause

The hosted web SPA has no local filesystem. A dropped non-image file is uploaded to ~/.hermes/uploads via the web shim and attached as a kind:'file' ref pointing at that server path. At submit/eager-upload time, uploadComposerAttachment re-read the bytes client-side via window.hermesDesktop.readFileDataUrl(serverPath) — but the web shim's readFileDataUrl only serves an in-memory cache that's populated for images only. So non-image files return '' → null → throw new Error('Could not read ' + label), surfaced as the toast. Images escape only because their bytes are cached at drop time.

Fix

In the hosted web client, skip the client-side byte read for non-image files and attach by path only. The file already lives on the gateway, so file.attach resolves the path directly (_stage_session_file_attachment Case 2). No data_url round-trip, no 16 MB cap.

  • Native Electron remote mode is unchanged — its paths live on the client disk and still upload bytes.
  • Gated on window.__HERMES_WEB_CLIENT__.
  • Includes a regression test.

Verification

Built into vanilla-hermes-agent-canary:stable and rolled to a live canary instance; reporter confirmed .md (and other non-image) uploads now attach and are readable by the agent. This PR ships the identical one-commit fix to prod for the fleet rollout.

… the read (#103)

The hosted web SPA (vweb) has no local filesystem. When a .md/text/pdf is
dropped it is uploaded to ~/.hermes/uploads via the web shim and attached as
a kind:'file' ref pointing at that server path. At submit/eager-upload time
uploadComposerAttachment then re-read the file's bytes client-side via
window.hermesDesktop.readFileDataUrl(serverPath). The web shim only caches
data URLs for IMAGES (uploadBrowserFile gates the cache write on image/*
mime), so for any non-image file the read returned '' and the code threw
`Could not read <server-name>`, surfaced as the "Drop files / Could not read
…md" toast — even though the upload itself had already succeeded. Images
worked only because their bytes are cached.

Fix: in the hosted web client, skip the client-side byte read for non-image
files and attach by path only. The file already lives on the gateway
(~/.hermes/uploads, made agent-readable by the upload endpoint's chown), so
file.attach resolves the path directly (server.py _stage_session_file_attachment
Case 2 reads the bytes and returns an @file: ref). Native Electron remote mode
is unchanged — its paths live on the client disk and still upload bytes.

Adds a regression test asserting the web client attaches by path with no read
and no data_url.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🔎 Lint report: fix/web-nonimage-attach-path-only vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 10911 on HEAD, 10911 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5730 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@ashneil12
ashneil12 merged commit 8e60f74 into main Jun 13, 2026
25 checks passed
@ashneil12
ashneil12 deleted the fix/web-nonimage-attach-path-only branch June 13, 2026 11:36
ashneil12 added a commit that referenced this pull request Jul 15, 2026
… dropped __HERMES_WEB_CLIENT__ guard) (#91)

The hosted web SPA has no local filesystem — its picked files already live on
the gateway box (~/.hermes/uploads/...). When window.__HERMES_WEB_CLIENT__ is
set we must attach by PATH and let gateway file.attach read the bytes, never
client-read them. The web-shim's readFileDataUrl only caches image previews, so
for a .md/.txt it returns '' and the remote branch then threw "Could not read
<name>" even though the upload had already succeeded — breaking every non-image
attachment from the hosted web chat on webfree boxes.

This guard shipped as prod #60 (June 2026) but was dropped from
uploadComposerAttachment during a fork reconcile. Canary re-applied it in the
2026-07-15 upstream sync (PR NousResearch#166, commit 61addda147); this ports that exact
fix to the prod fork. Guarded by use-prompt-actions/index.test.tsx "hosted web
client attaches a non-image file by path only" — verified red→green (21→20
pre-existing failures, zero regressions).

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant