Skip to content

feat: let agents publish screenshots for pull requests on fctl - #71

Merged
kalaspuff merged 7 commits into
mainfrom
fctl/35-as-github-apps-seemingly-can-t-attach-sc
Oct 18, 2026
Merged

kalaspuff merged 7 commits into
mainfrom
fctl/35-as-github-apps-seemingly-can-t-attach-sc

Conversation

@fctl-sh

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

Copy link
Copy Markdown
Contributor

GitHub takes gh pr create/edit --attach uploads only with a person's token, and sessions have the GitHub App's, so agents couldn't show screenshots in pull requests (#40). They now fall back to publishing them on fctl, at a link that's practically impossible to guess, and put that link in the pull request. Projects opt in, and so must the instance.

What changed

  • fctl publish shot.png works in a session's sandbox. fctl-agent takes the image over the session socket and checks it. The host uploads it with its runner token (POST /api/v1/runner/sessions/{id}/published), and the control plane stores it in the project's FilesObject. fctl prints the link and Markdown to paste, and --json gives the same data.
  • Links: https://app.fctl.sh/api/v1/published/<token>/<name>. The token is 256 random bits, and D1 (published_files) keeps only its SHA-256. Anyone with the link can open the image, including GitHub's image proxy. Responses are nosniff, have the same sandboxing CSP as attachments, Cross-Origin-Resource-Policy: cross-origin and X-Robots-Tag: noindex, and are public, no-cache with an ETag, so a deleted or expired image stops showing (a matching If-None-Match gets 304).
  • Expiry: 30 days by default. Each project chooses 1 to 60 days (screenshot_days), which covers the 24 hours to 60 days asked for. The FilesObject's alarm deletes the bytes, and the hourly cron trigger deletes the rows.
  • Opt-in at two levels, both off by default.
    • Instance admins allow it in Admin → Settings (a new tab), or with fctl admin set --publish-screenshots on. It is stored in D1's settings as InstanceSettings.
    • A project's maintainers turn it on in Settings → Agents, or with fctl projects set --publish-screenshots on --screenshot-days 7.
    • Both are checked when a screenshot is published and whenever a link is opened, so turning either off takes the screenshots offline at once.
  • Limits: PNG, JPEG, GIF and WebP only, identified from the bytes, so no SVG or HTML is ever served. At most 5 MB each (GitHub's image proxy limit) and 100 per session.
  • What the agent is told: ~/AGENTS.md gets a section only where the project publishes and the sandbox's fctl has the command. It says to try --attach first and to publish when GitHub refuses. It also says how long links last, to publish nothing secret, and to say so if it publishes something by mistake.
  • Transcript: each published screenshot appears as a screenshot_published notice carrying the file. The web app shows the image with Copy Markdown and, for people who manage the session, Delete behind a confirmation. Deletion is also available as fctl unpublish <link> and DELETE /api/v1/published/{token}. Viewers and editors can't delete.
  • Audit log: screenshot.published, screenshot.deleted and instance.settings_updated.
  • fake-claude: a new screenshot behavior draws a small PNG and publishes it, so cargo xtask dev exercises the whole path.
  • Docs:

Compatibility

  • Every protocol change is additive:
    • optional fields: ProjectSettings.publish_screenshots and screenshot_days, Notice.published, Features.publish_screenshots,
    • a new agent frame pair (publish / published) and a new session-socket request.
  • A host rebuilds the spec it passes on, so an older host drops the new setting. Its agents never offer fctl publish, and nothing waits on an answer it can't give.
  • Older CLIs show the notice's message, which holds the link. A new event kind would have broken their fctl logs and fctl attach.
  • Migration 0010_published_files.sql is new. The FilesObject creates its table with IF NOT EXISTS.
  • Settings updates from clients that don't know the fields keep the stored values (keep_unsent), so an older CLI can't quietly turn publishing off or lengthen retention.

How I verified it

  • cargo xtask check passes: fmt, gen, Biome and tsc, clippy native and wasm, all Rust and web tests, and the web build. It passes again after merging main (feat: stop idle sessions after ten minutes and resume them for a message #67, build(deps): use @hyperstructure/design v0.4.0 #68, feat: show when a session's runner is away or can't reach its agent #69).
  • New unit tests cover:
    • the domain: limits, expiry, token shape, link names and Markdown,
    • keep_unsent, and the wire formats,
    • the supervisor: the publish round trip, refusals (project off, not an image, no host), the timeout, and a late answer still reaching the transcript,
    • CLI output, and fake-claude's PNG, whose CRC and zlib data I also decoded independently.
  • End to end with cargo xtask dev:
    • With publishing off, fctl publish refuses ("This project doesn't publish screenshots…") and ~/AGENTS.md has no screenshots section.
    • With it on (7 days), the agent's ~/AGENTS.md says 7 days. The link serves the exact bytes with the headers above; HEAD works, If-None-Match gets 304, and a wrong token gets 404.
    • Project off or instance off: 404. On again: 200. fctl unpublish (or Delete in the web app): 404.
    • A non-member gets 404, viewers and editors get 403, and a maintainer can delete. Non-admins get 403 from /admin/settings.
    • An expired link 404s, and the cron trigger deleted its row. The audit entries are there.
    • --screenshot-days 61 is rejected by the CLI, and 0 by the API.
  • A link opened in a tab shows the image on the browser's own image page.
  • UI in Chromium, light and dark and at 390 px: Admin → Settings, the project's Agents section (with the hint and a link when the instance doesn't allow it), the transcript card, the delete dialog and the deleted state.

Screenshots

At 654ec0c, against cargo xtask dev. This session can't attach them: gh pr edit --attach refuses its token, which is what this pull request fixes, and app.fctl.sh won't have fctl publish until it ships. What they show:

  • Admin → Settings: an "Agents" section with a Published screenshots switch and a paragraph that says what it allows, that links work for 24 hours to 60 days as each project chooses, and that off takes every published screenshot offline.
  • Project → Settings → Agents:
    • a Publish screenshots switch under "Credit Claude in commits", described like the switches above it,
    • when it's on, a Screenshot links work for select (24 hours, 3, 7, 14, 30 or 60 days),
    • when the instance doesn't allow it, an amber line, "This instance's admins haven't allowed it yet (Admin → Settings)".
  • Session transcript: a blue notice line, "Published screenshot.png · anyone with the link can open it until Oct 25". Under it are a 144 px high thumbnail linking to the image, its size (160×90 · 43 KB), Copy Markdown and Delete. At 390 px the actions wrap under the image.
  • Delete opens the standard dialog: "Delete screenshot.png? Its link stops working for everyone, in pull requests too. This can't be undone." It has Cancel and a red Delete. Afterwards the line reads "Published screenshot.png · deleted".

After it merges

  1. Release and deploy. Agents get fctl publish with hosts and sandbox images of that release.
  2. On app.fctl.sh, an admin turns on Admin → Settings → Published screenshots. Each project that wants it turns it on in its settings, for example fctl and fctl-site.
  3. Merge docs(legal): say what publishing screenshots shares and keeps fctl-site#11 once this is deployed. It updates the privacy policy and terms, as AGENTS.md asks, and its own screenshots skill.

Refs #40. This covers screenshots and both skills. It doesn't publish short video recordings (.webm/.mp4): GitHub doesn't play videos from other hosts in a description, and Safari needs range requests to play them from a link. Animated GIF and WebP do work.

Session: https://app.fctl.sh/s/ses_01M57K8M7GHV0F7BR9NN41P6WZ

fctl-sh Bot added 5 commits October 18, 2026 13:59
GitHub takes no uploads from a session's GitHub App token, so agents
can't attach screenshots to pull requests (#40). Agents in projects that
opt in now publish them with `fctl publish`: fctl-agent hands the image
to the host, which uploads it with its runner token; the control plane
keeps it in the project's FilesObject and serves it at a link with a
256-bit random token until it expires (30 days by default, 1 to 60 days
per project). Publishing needs the instance's admins to allow it and the
project to turn it on; both are off by default, and turning either off
takes the screenshots offline.

The transcript shows each published screenshot in a notice, people who
manage its session can delete it sooner (`fctl unpublish`), and
`cargo xtask dev` publishes one when fake-claude is asked for a
screenshot.
Admin → Settings gets the instance's switch, the project's agent settings
get theirs with how long links work, and the transcript shows each
screenshot the agent published, with its Markdown to copy and, for
people who manage the session, a way to delete it sooner.
The architecture, an ADR, the CLI and security docs, and the screenshots
skill, which now says how a session shows its screenshots: attach them
where GitHub takes them, and publish them with fctl publish where it
doesn't.
…s-seemingly-can-t-attach-sc

# Conflicts:
#	crates/fctl-domain/src/settings.rs
#	crates/fctl-host/src/session.rs
#	crates/fctl/src/cmd/projects.rs
#	docs/adr/README.md
#	docs/cli.md
#	web/src/components/session/transcript.tsx
#	web/src/routes/session.tsx
@kalaspuff
kalaspuff merged commit b8e9cf0 into main Oct 18, 2026
4 of 5 checks passed
@kalaspuff
kalaspuff deleted the fctl/35-as-github-apps-seemingly-can-t-attach-sc branch October 18, 2026 14:33
kalaspuff pushed a commit that referenced this pull request Oct 25, 2026
…lp (#277)

## Summary

`fctl publish --help` and `fctl review --help` printed parts of their
help far to the right: their texts went on to new lines without a `\`,
so the spaces that indent those lines in the source came out in the
help. `fctl publish --help` printed its second sentence and its examples
22 to 24 spaces in, and `fctl review --help` four of its five examples
30 spaces in. Both now read like the other commands' help. They came in
with #71 and #223.

A new test walks every command's help texts (descriptions, before and
after help, and every argument's help) and fails on a line indented by
more than 8 spaces, which is as far as any help indents on purpose
(`fctl review submit --help`'s JSON example). It fails on main's `fctl
publish` and passes with this change. Found while working on the pull
request below; it's separate so that it gets its own line in the release
notes.

- #276

`fctl review --help`, ending with, before:

```
Examples:
  fctl review                          # the project's reviews, newest first
                              fctl review settings --on --effort high
                              fctl review start acme/web#12
                              fctl review threads                  # a review agent, in its sandbox
                              fctl review submit review.json       # a review agent, in its sandbox
```

After:

```
Examples:
  fctl review                          # the project's reviews, newest first
  fctl review settings --on --effort high
  fctl review start acme/web#12
  fctl review threads                  # a review agent, in its sandbox
  fctl review submit review.json       # a review agent, in its sandbox
```

[fctl session](https://app.fctl.sh/s/ses_01M5SSYJC8AZTVMF34HFYXXB8H)

Co-authored-by: fctl-sh[bot] <fctl-sh[bot]@users.noreply.github.com>
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