Skip to content

feat(web): add bounded file and image attachments with safe rendering #344

Description

@sowen1023

Parent

Problem

The Web composer currently accepts only a string prompt. It has no file picker, paste/drop attachment flow, image preview, or multimodal prompt projection. Model output also lacks a reviewed browser policy for rendering image content, so remote image references remain inert.

This prevents common coding workflows such as attaching a screenshot, a log, or a small reference file while preserving the original evidence identity.

Value

  • Support screenshot-driven debugging and multimodal models.
  • Let users attach bounded evidence without copying large content into the text box.
  • Make input provenance, model compatibility, and cleanup explicit.

Approach constraints

  • Reuse Pi message/content-block semantics and provider capability checks.
  • Bind uploaded content to the expected workspace, Session, and prompt command.
  • Enforce explicit count, per-file, aggregate-byte, MIME, and filename bounds before admission.
  • Do not turn a browser-supplied path into unrestricted filesystem authority.
  • Keep canonical bytes separate from bounded model/UI projections and report truncation honestly.
  • Clean temporary artifacts on rejection, cancellation, settlement, and host shutdown.
  • Render untrusted SVG/HTML and remote resources under a reviewed browser security policy.

Acceptance criteria

  • Users can select, paste, or drop supported files and images into the composer.
  • The UI shows name, type, size, removal state, and admission errors before sending.
  • Unsupported models/providers fail clearly without silently dropping attachments.
  • Prompt admission is atomic: text and all accepted attachments target the same expected Session.
  • Count, MIME, filename, per-file, and aggregate size limits are tested.
  • Traversal, symlink, stale-session, cancellation, and cleanup cases fail closed.
  • Supported image output is rendered safely; unsupported content has a usable download/link fallback.
  • Refresh/reconnect does not duplicate an admitted attachment.
  • Protocol, host, runtime, UI, and real-browser tests cover the flow.
  • bun run check and bun run test pass.

Out of scope

  • Cloud attachment storage.
  • Arbitrary large-file transfer.
  • Fetching remote URLs on behalf of the user without a separate permission design.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions