Skip to content

fix: repair file picker and html preview interactions#1803

Closed
franksong2702 wants to merge 1 commit into
nesquena:masterfrom
franksong2702:franksong2702/fix-1800-file-html-interactions
Closed

fix: repair file picker and html preview interactions#1803
franksong2702 wants to merge 1 commit into
nesquena:masterfrom
franksong2702:franksong2702/fix-1800-file-html-interactions

Conversation

@franksong2702
Copy link
Copy Markdown
Contributor

Summary

Fixes #1800.

This PR repairs the two Docker/browser interaction paths reported in the issue:

  • makes the composer Attach button more reliable by keeping the file input visually hidden rather than display:none, marking the button as type="button", and clearing/re-clicking the input from the user gesture;
  • makes .html attachments and HTML preview "Open full page" links open an inline browser view instead of behaving like inert badges or forced downloads.

Root Cause

There were two separate layers involved:

  • the attach button depended on a programmatic click against a display:none file input, which can be brittle in browser shells/container deployments;
  • HTML open/preview paths were split between forced-download safety defaults and inline preview expectations. The media endpoint did not allow sandboxed HTML inline responses, and global X-Frame-Options: DENY would block the workspace iframe path before the CSP sandbox could apply.

Changes

  • Add a visually-hidden file input class and make btnAttach explicitly non-submit.
  • Clear the file input value before calling .click() so re-selecting the same file still triggers change.
  • Render uploaded .html attachments as openable sandboxed inline links.
  • Change HTML MEDIA preview "Open full page" links to inline=1 new-tab links.
  • Allow /api/media?inline=1 for text/html only with Content-Security-Policy: sandbox allow-scripts.
  • Omit X-Frame-Options: DENY on sandboxed inline file responses so iframe previews can render; non-inline HTML still downloads with X-Frame-Options: DENY.

Validation

  • python -m pytest tests/test_issue1800_file_html_interactions.py tests/test_media_inline.py tests/test_779_html_preview.py tests/test_issue1095_pasted_images.py tests/test_pdf_html_preview.py tests/test_sprint20.py::test_attach_button_still_wired tests/test_sprint20.py::test_file_input_onchange_still_wired tests/test_sprint20.py::test_index_html_still_has_attach_button tests/test_issue1697_multi_image_paste.py tests/test_sprint29.py::TestContentDisposition -q
  • node -c static/boot.js && node -c static/ui.js
  • python -m py_compile api/routes.py

Conflict Check

Checked file-overlap PRs #1801, #1721, and #1588 with git merge-tree --write-tree; all merge cleanly with this branch.

@nesquena-hermes
Copy link
Copy Markdown
Collaborator

Shipped in v0.51.19https://github.com/nesquena/hermes-webui/releases/tag/v0.51.19

Thanks @franksong2702 for "repair file picker and html preview interactions". Closes #1800.

This PR didn't auto-close because the merge SHA was on the integration branch (stage-313) rather than directly on the contributor's fork — manually closing for hygiene. The change is on master at the v0.51.19 tag.

— hermes-agent (release sweep)

pull Bot pushed a commit to JamesWilliam1977/hermes-webui that referenced this pull request May 7, 2026
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.

Bug: Attach File button no response, and HTML file cannot open in browser

2 participants