Skip to content

feat(session): attach local files to composer prompts - #254

Draft
FrankiNarvaez wants to merge 25 commits into
Gentleman-Programming:mainfrom
FrankiNarvaez:feat/composer-file-attachments
Draft

FrankiNarvaez wants to merge 25 commits into
Gentleman-Programming:mainfrom
FrankiNarvaez:feat/composer-file-attachments

Conversation

@FrankiNarvaez

@FrankiNarvaez FrankiNarvaez commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #253

Drop files from the desktop or sidebar, or paste them into the composer. Images keep their existing transport; other files are referenced by path. Both appear as equal-sized tiles within each attachment strip, separate from the sent message text.

File validation runs off the UI thread. If the draft changes while the disk check is pending, the original press does not send or clear the changed draft.

Verification

  • macOS: formatting and workspace Clippy passed; workspace tests: 1,319 passed, 5 ignored.
  • Focused headless tests cover tile bounds, drag feedback, missing files and draft changes during submit.
  • An isolated macOS build launched; visual confirmation is pending because screen capture was unavailable. Windows and Linux were not manually tested.

Video

https://drive.google.com/file/d/1Zqeri8bAJbeVB85bSkxfvFRoKXY3dZQ0/view?usp=sharing

Dropped or picked non-image files now attach as cards (name, size, remove)
and are sent to the agent as paths appended to the prompt message; folders
are still rejected. Images no longer type [Image #N] into the composer: the
numbered thumbnail strip is what gets sent. No gentle-shell protocol change.
- Pasting a copied file that is not an image now attaches it, like
  dropping or picking it (the tooltip already promised paste).
- Messages sent before image tokens left the composer still show
  `[Image #N]` as `🖼 #N` in the conversation.
- README and architecture docs describe file attachments instead of
  image tokens.
Behavior-preserving move (ADR 0003): file block, sizes, paste tokens and
long-paste rules now live in gentle_core::attachments with their tests;
the app keeps image payloads, file loading and the decode cache and
re-exports the rest.
…ttaching

- Files are named as the agent's backend reads them (WSL: C:\... becomes
  /mnt/c/...); local tabs keep today's spelling.
- Attaching the same file or image twice keeps one card.
- Several refused paths give one warning, one line each.
- Sizes reach GB and never read 1024.0 of a unit.
- An unreadable image is refused as unreadable instead of attached as a file.
- A file gone before sending stops the send and names it.
- Paths with a line break or without a UTF-8 spelling are refused, so the
  prompt's file block cannot break.
…s" list

The agent still receives the same message; the app splits the trailing
"Attached files:" block back out when showing it. Sent bubbles show each
file as a card next to the image thumbnails, and copy, the scroll rail,
session titles and up-arrow history show only the typed text (a
files-only prompt reads as its file names).
… drags from the file tree

While a file is dragged over an agent tab, from Finder or from the
sidebar's file tree, the tab shows a veil with an inbox icon, "Drop files
here" and the folder rule. Dropping attaches through the same rules as
before (folders refused, duplicates kept once). File tree rows are now
drag sources; clicking a row still opens it.
…efore

An independent check found three changes nobody asked for: sizes rounded
half-up (1280 B read 1.3 KB), blank user messages weighed one line less,
and session subtitles lost their trim. Restore each, pinned by tests;
the requested GB tier and never-1024.0 rule stay.
…ails

A sent message and the composer now lay out images and files as one even
row: each file is a tile with the image thumbnail's size, showing a file
icon with its extension and the name at the bottom (middle-truncated);
the folder, and in the composer the size, show on hover. The scroll
estimate counts that row once, whatever it holds.
- Paths are judged on the line the prompt carries: every control
  character and Unicode line separator is refused, and a printable file
  inside an oddly named folder attaches.
- Sizes reach TB (1 TiB reads 1.0 TB).
- Duplicates are found by the file's canonical path (symlinks, ./).
- The existence check at send runs off the UI thread, with one send per
  press; the user's own attachment checks now warn even before the agent
  is ready (sending still waits for it).
- The gone-file test drives the real submit path.
- Named tile ids instead of packed ints; clearer names, docs and test
  helpers in the parser, drop veil and file tree.
…tachments

# Conflicts:
#	crates/app/src/features/session/rpc.rs
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.

feat(session): attach local files to composer prompts

1 participant