mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
fix(cli): prevent stale image attachment on text paste and voice input
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
95ee453bc0
commit
940237c6fd
2 changed files with 55 additions and 3 deletions
15
cli.py
15
cli.py
|
|
@ -1203,6 +1203,11 @@ def _format_image_attachment_badges(attached_images: list[Path], image_counter:
|
|||
)
|
||||
|
||||
|
||||
def _should_auto_attach_clipboard_image_on_paste(pasted_text: str) -> bool:
|
||||
"""Auto-attach clipboard images only for image-only paste gestures."""
|
||||
return not pasted_text.strip()
|
||||
|
||||
|
||||
def _collect_query_images(query: str | None, image_arg: str | None = None) -> tuple[str, list[Path]]:
|
||||
"""Collect local image attachments for single-query CLI flows."""
|
||||
message = query or ""
|
||||
|
|
@ -6282,6 +6287,9 @@ class HermesCLI:
|
|||
|
||||
if result.get("success") and result.get("transcript", "").strip():
|
||||
transcript = result["transcript"].strip()
|
||||
self._attached_images.clear()
|
||||
if hasattr(self, '_app') and self._app:
|
||||
self._app.invalidate()
|
||||
self._pending_input.put(transcript)
|
||||
submitted = True
|
||||
elif result.get("success"):
|
||||
|
|
@ -8006,8 +8014,9 @@ class HermesCLI:
|
|||
"""Handle terminal paste — detect clipboard images.
|
||||
|
||||
When the terminal supports bracketed paste, Ctrl+V / Cmd+V
|
||||
triggers this with the pasted text. We also check the
|
||||
clipboard for an image on every paste event.
|
||||
triggers this with the pasted text. We only auto-attach a
|
||||
clipboard image for image-only/empty paste gestures so text
|
||||
pastes and dictation do not accidentally attach stale images.
|
||||
|
||||
Large pastes (5+ lines) are collapsed to a file reference
|
||||
placeholder while preserving any existing user text in the
|
||||
|
|
@ -8017,7 +8026,7 @@ class HermesCLI:
|
|||
# Normalise line endings — Windows \r\n and old Mac \r both become \n
|
||||
# so the 5-line collapse threshold and display are consistent.
|
||||
pasted_text = pasted_text.replace('\r\n', '\n').replace('\r', '\n')
|
||||
if self._try_attach_clipboard_image():
|
||||
if _should_auto_attach_clipboard_image_on_paste(pasted_text) and self._try_attach_clipboard_image():
|
||||
event.app.invalidate()
|
||||
if pasted_text:
|
||||
line_count = pasted_text.count('\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue