Skip to content

feat: attach files and screenshots to tasks and messages - #35

Merged
kalaspuff merged 9 commits into
mainfrom
fctl/5-on-the-app-fctl-sh-frontend-it-should-be
Oct 18, 2026
Merged

kalaspuff merged 9 commits into
mainfrom
fctl/5-on-the-app-fctl-sh-frontend-it-should-be

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

People can now attach files to a new session's task and to messages in a session. In the web app, every composer (the floor's, a project page's and a session's) takes files from a paperclip button, a drop anywhere on the page, or a paste, screenshots included. In the CLI, fctl run, send and resume take --attach. The agent finds the files in its sandbox and sees images directly in the message.

What changed

Storage (ADR 0008). A new Durable Object per project, FilesObject, keeps attached files in its SQLite storage in 1 MiB chunks. Durable Objects are already deployed, so instances need no new Cloudflare resources or deploy-token permissions; the class arrives with a v2 Durable Object migration. Uploads that no message claims are deleted after a day. Deleting a project, directly or with an account, queues its files in file_purges, alongside the existing session_purges.

API.

  • Uploads: POST /api/v1/projects/{id}/attachments (to start a session) and POST /api/v1/sessions/{id}/attachments (a message in one, for anyone who may message it, including people the session is shared with). The body is the raw file as application/octet-stream, passed through the Worker unread. It isn't JSON, but browsers can't send it cross-site without a preflight, and it gets the usual origin check.
  • CreateSessionRequest, SendMessageRequest, ResumeSessionRequest and the viewer socket's send take attachments: [id]. Sending claims the uploads for the session: they must be the sender's and not sent in another session. A message may be only files.
  • Downloads: GET /api/v1/sessions/{id}/attachments/{attachment} for the session's viewers, and GET /api/v1/runner/sessions/{id}/attachments/{attachment} for the runner it is assigned to. Files are served with nosniff, Cross-Origin-Resource-Policy: same-origin and a sandboxing CSP. Only PNG, JPEG, GIF and WebP display in place; everything else downloads.

Host and agent.

  • Before forwarding a message, or configuring the agent with the task, the host fetches its files, in message order, and hands them to fctl-agent as new file frames.
  • The agent saves each file as ~/attachments/<id>/<name>, outside the repository, and lists the paths after the message text.
  • Images also go into Claude's message when Claude accepts them as they are: the bytes are checked to be PNG, JPEG, GIF or WebP, at most 2000 px a side, within the API's 5 MiB base64 limit, and within 5 MiB of inline images per message. These limits avoid images that would fail the turn, or the whole conversation once it holds many. Claude reads anything else with its tools, which resize.
  • Stored events now drop base64 image payloads from tool results. Nothing displayed them, and truncated they were useless.

Compatibility. Every protocol change is an optional field or a new frame type.

  • Hosts announce an attachments feature in their uplink hello. With an older host, the transcript says the agent got the message without its files and to run fctl self update.
  • Agents announce the same feature. An agent started by an older host gets the text alone, and the host says so in the transcript.

Web.

  • Chips show upload progress, with retry and remove.
  • Sending waits for uploads still running. New sessions start through the shared useStartSession hook, which now takes the files.
  • Text copied from Word or Excel still pastes as text, not as its picture.
  • In the transcript, images show as thumbnails that open in a lightbox, and other files as download chips.
  • Agent prose and messages now wrap long paths. Before, a long path pushed phone layouts wider than the screen.

Docs: architecture, CLI, getting started, security and development pages, plus ADR 0008. D1 migration: 0005_attachments.sql.

Before merging

  • Privacy policy. hyperstructure/fctl-site legal/privacy.md needs a matching change (that repository isn't reachable from this session). app.fctl.sh now stores the files people attach to messages, in Cloudflare Durable Objects, with their project, until the project is deleted; uploads never sent are deleted after a day. They go to the runner host that runs the session and into its sandbox, and Anthropic receives images shown in a message and any file the agent reads.
  • Hosts. Hosts need the next release to pass files to agents. Until then, the transcript says so whenever a message carries files.

How I verified it

  • Unit tests. fctl-domain: names, media types, PNG/JPEG/GIF/WebP sniffing, inline limits, sizes, Content-Disposition, validation, titles, base64 omission. fctl-agent: saving, the file list, the inline budget. Web: paste rules, pasted-image names, sizes.
  • Checks. cargo fmt --check, clippy (workspace and wasm32 control plane), all Rust tests (84), and Biome, tsc and Vitest (20) for the web app.
  • End to end on a local stack: wrangler dev, a process-driver host and fake-claude, driven with the CLI, curl, a WebSocket client and Playwright.
    • A task with three files: each saved in the sandbox with its exact size. Only the 800×600 image went inline; the 2400×1600 one stayed on disk.
    • Follow-ups, a files-only message, a viewer-socket send, and a resume with a file all reached the agent.
    • A 15 MB file had the same SHA-256 in the sandbox and on download.
    • Deleting a project drained file_purges.
    • Refusals: a wrong content type, a file over 20 MB, a cross-site cookie upload (403), reuse in another session, an unknown id, 11 files, someone else's upload.
    • A non-member with an editor share uploaded and sent through the session; as a viewer share they could download but not upload.
    • A fake older host (hello without features) produced the transcript notice; the real host's reconnect then delivered the file.
  • Web UI in Chromium: attach by button, paste and drop; the drop hint; remove; start; transcript thumbnails and chips; the lightbox; both themes; a 390 px phone width.
    • The design package is private, so the UI ran against a local stand-in for its tokens, fonts and WebGL scenes. Colors are approximate; layout and behavior are the real ones.

Not done here

  • fctl account export lists attachments in its transcripts but not their bytes. security.md now says each file downloads from its session; including them could be a follow-up.

Made in fctl session https://app.fctl.sh/s/ses_01M564K7K8ZR6T9W1S8MH43WA9

fctl-sh Bot and others added 9 commits October 18, 2026 00:26
People can send files with a task, a message or a resume, by id from a new
upload endpoint. The bytes live in a new Durable Object per project
(FilesObject), in 1 MiB chunks; uploads no message claims are deleted after
a day, and deleting a project purges its files like its event logs.

Hosts fetch a message's files with the runner token before forwarding it
(in order, one fetcher per session) and hand them to fctl-agent as `file`
frames. The agent saves them under ~/attachments/<id>/<name>, lists the
paths in Claude's turn, and puts images Claude accepts as they are (PNG,
JPEG, GIF, WebP up to 2000 px and the API's size limit) into the message
itself. Older hosts and agents announce no `attachments` feature; the
transcript then says the agent got the message without its files.

The CLI gets --attach on run, send and resume; fake-claude reports the
files it got so runs can be checked.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Both composers (the floor's new-session box and a session's message box)
take files from a paperclip button, a drop anywhere on the page, or a
paste (screenshots included; rich text from Word or Excel still pastes as
text). Files upload as soon as they are added, with progress, retry and
remove; sending waits for uploads still running. The transcript shows a
message's images as thumbnails that open full size, and other files as
chips that download. Messages may be only files.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Agents now quote attachment paths (~/attachments/att_…/name), which have no
break opportunities and pushed the transcript wider than a phone's screen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sessions can be shared with people outside their project; an editor share
can message the agent but could not upload, because uploads were scoped to
the project. Files for a message now go to POST /sessions/{id}/attachments,
which allows exactly who may message the session; the project endpoint
stays for starting sessions. The web composer and fctl send/resume use it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
main moved starting a session into useStartSession and StartButton (one
request per start) and added a start form to project pages. Attachments now
go through that hook, so the floor and project pages both take files; the
agent's prompt test fixture gains task_attachments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
main shipped migration 0004 (session descriptions) and ADR 0007, so the
attachments migration becomes 0005_attachments.sql and its ADR 0008. The
conflicts were neighbours: imports, tests, fake-claude behaviors, the
session columns and docs; both sides are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kalaspuff
kalaspuff merged commit 401c59d into main Oct 18, 2026
4 of 6 checks passed
@kalaspuff
kalaspuff deleted the fctl/5-on-the-app-fctl-sh-frontend-it-should-be branch October 18, 2026 01:16
fctl-sh Bot added a commit that referenced this pull request Oct 18, 2026
Conflicts with attachments (#35):

- The project_repos migration becomes 0006: 0004 and 0005 have shipped.
- The repositories ADR becomes 0009, after attachments' 0008.
- fctl-agent's Paths keeps both ~/repos and ~/attachments; a fresh resume
  sends the task's files and says the other repositories need cloning
  again.
- The project page keeps the attachment imports beside the repository ones.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant