Skip to content

Long region preview's "Expand..." button is sent literally to the agent #587

@alberti42

Description

@alberti42

When I send a region longer than 5 lines (e.g. via agent-shell-send-region), the inserted preview is capped and followed by an Expand... button (agent-shell.el:6113-6135, max-preview-lines 5). If I press RET to submit without first clicking the button, the agent receives the truncated preview plus the literal string Expand... — the full text never reaches it.

Cause: the full text is captured only inside the button's action closure. shell-maker-submitcomint-send-input reads the prompt with buffer-substring-no-properties, so the closure is never consulted.

Possible fixes:

  1. Auto-expand any collapsed agent-shell-region-id regions in the input area before submission.
  2. Store the full text on a text property (or invisible overlay) that submission can substitute back in, so the visible preview stays compact but the agent receives the full content.
  3. At minimum, expose max-preview-lines as a defcustom so users can disable the cap.

Repro:

  1. Open a buffer with > 5 lines of text, mark a region spanning all of them.
  2. M-x agent-shell-send-region.
  3. Press RET without clicking Expand....
  4. Observe that the agent sees …\nExpand... instead of the full region.

Checklist

  • I agree to communicate with the author myself (not AI-generated).
  • I've read the README's Filing issues section.
  • I'm running the latest versions (fill in below).
  • Emacs: GNU Emacs 31.0.60
  • agent-shell: 67babec (2026-05-16, merge of Add Hermes Agent Support  #583)
  • acp.el: 03099fa (2026-05-03, merge of Add support for devcontainer #18)
  • ACP package: OpenCode adapter (agent-shell-opencode.el, bundled with agent-shell)
  • Agent CLI: opencode 0.0.0-integrated-202605150926 (personal fork with --attach support; see config below)
  • For requesting new agent support, I'm including a link to the ACP-capable agent or related ACP package.
  • For issues, I'm including ACP traffic (as per README).

-- Thanks a lot for your consideration! Andrea

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions