hermes - ✅(Solved) Fix [Bug]: Fix TUI image attachment for paths containing spaces [1 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#17522Fetched 2026-04-30 06:47:05
View on GitHub
Comments
1
Participants
1
Timeline
5
Reactions
0
Participants
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

Error Message

Additional Logs / Traceback (optional)

Root Cause

When attaching images to a message in the Hermes TUI, file paths containing spaces (e.g., "Screenshot 2026-04-29.png") are truncated at the first space. This causes the image attachment to fail because the backend receives an incomplete path and the remainder of the user's message becomes stray text instead of being preserved as the prompt.

Fix Action

Fixed

PR fix notes

PR #17523: fix(tui): always call input.detect_drop for reliable image attachment

Description (problem / solution / changelog)

What does this PR do?

Fixes TUI image attachment for file paths containing spaces, quotes, or other special characters. The frontend submission logic previously used a restrictive regex pre-check that truncated paths at the first whitespace, causing the backend input.detect_drop to never run. This PR removes that gate so all submissions are validated by the backend's robust _detect_file_drop logic (shared with the CLI), which correctly handles edge cases.

Why this approach:

  • Backend _detect_file_drop already handles spaces, quotes, dots, tildes, and Windows drive letters correctly
  • Eliminates duplicated path-matching logic across frontend/backend
  • Single source of truth for file-drop detection in one place
  • Minimal surface-area change (7 lines removed from frontend)

Fixes #17522

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (removed redundant frontend logic, backend remains the source of truth)

Changes Made

Frontend (ui-tui/src/app/useSubmission.ts):

  • Removed the /(?:^|\s)(?:file:\/\/|~\/|\.?\.\/|\/)[^\s]+/ regex pre-check
  • Now always calls input.detect_drop for every user submission; short-circuits only for slash commands

Tests (tests/test_tui_gateway_server.py):

  • Added test_input_detect_drop_path_with_spaces — verifies attachment with spaces in filename
  • Added test_input_detect_drop_path_with_spaces_and_remainder — verifies remainder parsing when path has spaces
  • Fixed test_rollback_restore_resolves_number_and_file_path — restored indented calls = {} declaration

How to Test

  1. Manual TUI verification:

    hermes --tui
    • Type/paste a path with spaces: /tmp/Screenshot 2026-04-29.png
    • Submit with optional prompt: /tmp/Screenshot 2026-04-29.png describe this
    • Verify the image attaches and [User attached image: Screenshot 2026-04-29.png] appears
    • The remainder (describe this) should become the prompt text
  2. Automated tests:

    scripts/run_tests.sh tests/test_tui_gateway_server.py::test_input_detect_drop_path_with_spaces tests/test_tui_gateway_server.py::test_input_detect_drop_path_with_spaces_and_remainder tests/test_tui_gateway_server.py::test_input_detect_drop_attaches_image -v

    All three should pass.

  3. Full test suite:

    scripts/run_tests.sh tests/test_tui_gateway_server.py -v

    Confirms no regressions in TUI gateway tests.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run npm test in ui-tui/ and all tests pass (tests updated for ActiveTool object flow are already present in baseline)
  • I've added tests for the new behavior (2 new tests + 1 test fixture fix)
  • I've tested on my platform: Ubuntu 24.04, Python 3.11, Node 20

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A (behavioral fix aligns TUI with existing CLI behavior; docs already describe image attachment)
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact — TUI is cross-platform; change is runtime logic only
  • I've left CHANGELOG.md and AGENTS.md untouched per user preference

Screenshots / Logs

(No visual change; behavior now matches CLI attachment detection. Optional: attach TUI screenshots showing successful image attachment with a filename containing spaces.)

Changed files

  • tests/test_tui_gateway_server.py (modified, +50/-0)
  • ui-tui/src/app/useSubmission.ts (modified, +3/-7)

Code Example

https://paste.rs/W7HS7
https://paste.rs/0PrVL

---
RAW_BUFFERClick to expand / collapse

Bug Description

When attaching images to a message in the Hermes TUI, file paths containing spaces (e.g., "Screenshot 2026-04-29.png") are truncated at the first space. This causes the image attachment to fail because the backend receives an incomplete path and the remainder of the user's message becomes stray text instead of being preserved as the prompt.

The root cause is a restrictive frontend regex in useSubmission.ts that performs a pre-check before calling the backend's input.detect_drop. The regex /(?:^|\s)(?:file:\/\/|~\/|\.?\.\/|\/)[^\s]+/ stops matching at whitespace, so it fails to capture full paths containing spaces, quotes, or Windows drive letters. The backend _detect_file_drop logic (used by the CLI) correctly handles these cases but is bypassed entirely when the frontend pre-check returns a truncated match.

Steps to Reproduce

  1. Start Hermes in TUI mode: hermes --tui
  2. Prepare an image file with a space in its name, e.g. "Screenshot 2026-04-29.png" in your home directory or a known location
  3. In the TUI, type/paste the full path to the image, e.g.: /home/youruser/Screenshot 2026-04-29.png
  4. Optionally add a prompt after the path: /home/youruser/Screenshot 2026-04-29.png describe this
  5. Submit the message

Observed: The path is truncated at the first space; the image is not attached. If a remainder exists, it appears as plain text without the image context.

Expected: The full path is recognized and the image is attached; any remainder after the path becomes the text prompt sent to the model.

Expected Behavior

  • Paths with spaces, quotes, and special characters should be correctly recognized as file attachments
  • The remainder text after the path (if any) should be preserved and passed to the model as the prompt
  • The behavior should match the CLI's _detect_file_drop logic, which robustly handles edge cases

Actual Behavior

  • The frontend regex pre-check truncates paths at the first space
  • The backend input.detect_drop is never called for these paths, so no attachment occurs
  • Users cannot attach files with spaces in their names via the TUI

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

N/A (CLI only)

Debug Report

https://paste.rs/W7HS7
https://paste.rs/0PrVL

Operating System

Ubuntu 24.04

Python Version

3.12.3

Hermes Version

0.11.0

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

extent analysis

TL;DR

Update the frontend regex in useSubmission.ts to correctly handle file paths with spaces and special characters.

Guidance

  • Review the current regex /(?:^|\s)(?:file:\/\/|~\/|\.?\.\/|\/)[^\s]+/ and consider modifying it to match paths with spaces, such as using a character class that includes whitespace.
  • Verify the updated regex using test cases with various file path formats, including those with spaces, quotes, and special characters.
  • Compare the updated frontend behavior with the existing backend _detect_file_drop logic to ensure consistency.
  • Test the fix with different operating systems and file systems to ensure compatibility.

Example

// Updated regex example (may require further refinement)
const updatedRegex = /(?:^|\s)(?:file:\/\/|~\/|\.?\.\/|\/)[\s\S]+/;

Notes

The proposed fix assumes that updating the frontend regex will resolve the issue, but further testing and verification are necessary to ensure the change does not introduce new problems.

Recommendation

Apply workaround: Update the frontend regex to handle file paths with spaces and special characters, as this directly addresses the identified root cause and aligns with the expected behavior of the _detect_file_drop logic.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: Fix TUI image attachment for paths containing spaces [1 pull requests, 1 comments, 1 participants]